summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/options.rst6
-rw-r--r--core/cfg-mplayer.h2
-rw-r--r--core/options.h2
-rw-r--r--sub/osd_libass.c21
4 files changed, 29 insertions, 2 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 12dccdc8c4..ab3dee4616 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1288,6 +1288,12 @@
search for video segments from other files, and will also ignore any
chapter order specified for the main file.
+--osd-bar-align-x=<-1..1>
+ Position of the OSD bar. -1 is far left, 0 is centered, 1 is far right.
+
+--osd-bar-align-y=<-1..1>
+ Position of the OSD bar. -1 is top, 0 is centered, 1 is bottom.
+
--osd-back-color=<#RRGGBB>, --sub-text-back-color=<#RRGGBB>
See ``--osd-color``. Color used for OSD/sub text background.
diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h
index 1c0f269e90..1bc01f5230 100644
--- a/core/cfg-mplayer.h
+++ b/core/cfg-mplayer.h
@@ -499,6 +499,8 @@ const m_option_t common_opts[] = {
OPT_INTRANGE("ass-hinting", ass_hinting, 0, 0, 7),
OPT_CHOICE("ass-style-override", ass_style_override, 0,
({"no", 0}, {"yes", 1})),
+ 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),
OPT_GENERAL("osd", osd_style, M_OPT_PREFIXED,
.type = &m_option_type_subconfig_struct,
.priv = (void*)&osd_style_conf),
diff --git a/core/options.h b/core/options.h
index 87d6711977..f5e350f076 100644
--- a/core/options.h
+++ b/core/options.h
@@ -117,6 +117,8 @@ typedef struct MPOpts {
char **sub_name;
char **sub_paths;
int sub_auto;
+ float osd_bar_align_x;
+ float osd_bar_align_y;
struct osd_style_opts *osd_style;
struct osd_style_opts *sub_text_style;
float sub_scale;
diff --git a/sub/osd_libass.c b/sub/osd_libass.c
index b34292ce16..4b695e62a2 100644
--- a/sub/osd_libass.c
+++ b/sub/osd_libass.c
@@ -155,10 +155,23 @@ static void update_osd(struct osd_state *osd, struct osd_object *obj)
talloc_free(text);
}
+static int get_align(float val, int res, int *out_margin)
+{
+ *out_margin = FFMAX(0, (1.0 - fabs(val)) * res / 2);
+ if (fabs(val) < 0.1)
+ return 1; // centered
+ return val > 0 ? 2 : 0; // bottom / top (or right / left)
+}
+
+static const int ass_align_x[3] = {1, 2, 3};
+static const int ass_align_y[3] = {4, 8, 0};
+
#define OSDBAR_ELEMS 46
static void update_progbar(struct osd_state *osd, struct osd_object *obj)
{
+ struct MPOpts *opts = osd->opts;
+
if (osd->progbar_type < 0) {
clear_obj(obj);
return;
@@ -169,8 +182,12 @@ static void update_progbar(struct osd_state *osd, struct osd_object *obj)
ASS_Style *style = obj->osd_track->styles + obj->osd_track->default_style;
- style->Alignment = 10; // all centered
- style->MarginL = style->MarginR = style->MarginV = 0;
+ int ax = get_align(opts->osd_bar_align_x, obj->osd_track->PlayResX,
+ &style->MarginR);
+ int ay = get_align(opts->osd_bar_align_y, obj->osd_track->PlayResY,
+ &style->MarginV);
+ style->Alignment = ass_align_x[ax] + ass_align_y[ay];
+ style->MarginL = style->MarginR;
// We need a fixed font size with respect to the OSD width.
// Assume the OSD bar takes 2/3 of the OSD width at PlayResY=288 and