summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-03-30 20:08:56 +0100
committerwm4 <wm4@nowhere>2013-03-30 20:23:45 +0100
commitef3c0e6edafd6460d30c24dfd9f5b2f50401f38f (patch)
tree5b6b085430e3f200bfb033ca721c996e1d092c37 /core
parentd39b131bde2f90c1607e1d9292c1a4ce291eb148 (diff)
downloadmpv-ef3c0e6edafd6460d30c24dfd9f5b2f50401f38f.tar.bz2
mpv-ef3c0e6edafd6460d30c24dfd9f5b2f50401f38f.tar.xz
osd: draw the OSD bar with ASS vector drawings
Drawing the bar with vector drawings (instead with characters from the OSD font) offers more flexibility and looks better. This also adds chapter marks to the OSD bar, which are visible as small triangles on the top and bottom inner border of the bar. Change the default position of the OSD bar below the center of the screen. This is less annoying than putting the bar directly into the center of the view, where it obscures the video. The new position is not quite on the bottom of the screen to avoid collisions with subtitles. The old centered position can be forced with ``--osd-bar-align-y=0``. Also make it possible to change the OSD bar width/height with the new --osd-bar-w and --osd-bar-h options. It's possible that the new OSD bar renders much slower than the old one. There are two reasons for this: 1. the character based bar allowed libass to cache each character, while the vector drawing forces it to redraw every time the bar position changes. 2., the bar position is updated at a much higher granularity (the bar position is passed along as float instead of as integer in the range 0-100, so the bar will be updated on every single video frame).
Diffstat (limited to 'core')
-rw-r--r--core/cfg-mplayer.h2
-rw-r--r--core/defaultopts.c3
-rw-r--r--core/mplayer.c26
-rw-r--r--core/options.h2
4 files changed, 31 insertions, 2 deletions
diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h
index 3b164a7346..5bae70ab0e 100644
--- a/core/cfg-mplayer.h
+++ b/core/cfg-mplayer.h
@@ -501,6 +501,8 @@ const m_option_t common_opts[] = {
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),
+ OPT_FLOATRANGE("osd-bar-w", osd_bar_w, 0, 1, 100),
+ OPT_FLOATRANGE("osd-bar-h", osd_bar_h, 0, 0.1, 50),
OPT_SUBSTRUCT("osd", osd_style, osd_style_conf, 0),
OPT_SUBSTRUCT("sub-text", sub_text_style, osd_style_conf, 0),
{NULL, NULL, 0, 0, 0, 0, NULL}
diff --git a/core/defaultopts.c b/core/defaultopts.c
index 9f544d6d55..36170df725 100644
--- a/core/defaultopts.c
+++ b/core/defaultopts.c
@@ -43,6 +43,9 @@ void set_default_mplayer_options(struct MPOpts *opts)
.gamma_hue = 1000,
.osd_level = 1,
.osd_duration = 1000,
+ .osd_bar_align_y = 0.5,
+ .osd_bar_w = 75.0,
+ .osd_bar_h = 3.125,
.loop_times = -1,
.ordered_chapters = 1,
.chapter_merge_threshold = 100,
diff --git a/core/mplayer.c b/core/mplayer.c
index eccb40b7ec..b0563a7c2c 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -1330,7 +1330,8 @@ void set_osd_bar(struct MPContext *mpctx, int type, const char *name,
if (mpctx->sh_video && opts->term_osd != 1) {
mpctx->osd_visible = (GetTimerMS() + opts->osd_duration) | 1;
mpctx->osd->progbar_type = type;
- mpctx->osd->progbar_value = 256 * (val - min) / (max - min);
+ mpctx->osd->progbar_value = (val - min) / (max - min);
+ mpctx->osd->progbar_num_stops = 0;
vo_osd_changed(OSDTYPE_PROGBAR);
return;
}
@@ -1345,7 +1346,7 @@ static void update_osd_bar(struct MPContext *mpctx, int type,
double min, double max, double val)
{
if (mpctx->osd->progbar_type == type) {
- int new_value = 256 * (val - min) / (max - min);
+ float new_value = (val - min) / (max - min);
if (new_value != mpctx->osd->progbar_value) {
mpctx->osd->progbar_value = new_value;
vo_osd_changed(OSDTYPE_PROGBAR);
@@ -1353,6 +1354,26 @@ static void update_osd_bar(struct MPContext *mpctx, int type,
}
}
+static void set_osd_bar_chapters(struct MPContext *mpctx, int type)
+{
+ struct osd_state *osd = mpctx->osd;
+ osd->progbar_num_stops = 0;
+ if (osd->progbar_type == type) {
+ double len = get_time_length(mpctx);
+ if (len > 0) {
+ int num = get_chapter_count(mpctx);
+ for (int n = 0; n < num; n++) {
+ double time = chapter_start_time(mpctx, n);
+ if (time >= 0) {
+ float pos = time / len;
+ MP_TARRAY_APPEND(osd, osd->progbar_stops,
+ osd->progbar_num_stops, pos);
+ }
+ }
+ }
+ }
+}
+
void set_osd_function(struct MPContext *mpctx, int osd_function)
{
struct MPOpts *opts = &mpctx->opts;
@@ -1432,6 +1453,7 @@ static void add_seek_osd_messages(struct MPContext *mpctx)
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_BAR) {
set_osd_bar(mpctx, OSD_BAR_SEEK, "Position", 0, 1,
av_clipf(get_current_pos_ratio(mpctx), 0, 1));
+ set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
}
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) {
mp_osd_msg_t *msg = add_osd_msg(mpctx, OSD_MSG_TEXT, 1,
diff --git a/core/options.h b/core/options.h
index 4483d6bed2..4291f2d872 100644
--- a/core/options.h
+++ b/core/options.h
@@ -161,6 +161,8 @@ typedef struct MPOpts {
int osd_bar_visible;
float osd_bar_align_x;
float osd_bar_align_y;
+ float osd_bar_w;
+ float osd_bar_h;
struct osd_style_opts *osd_style;
struct osd_style_opts *sub_text_style;
float sub_scale;