summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-04-12 18:11:12 +0300
committerUoti Urpala <uau@mplayer2.org>2011-04-12 18:11:28 +0300
commit7fe2856fd99fb9211634a3fbf611fb8c04232396 (patch)
treed30e47c92f581460fecb05db352ea88f6e935c89
parent511498818f3372a911ca142ab25f59bbb10d7e3f (diff)
downloadmpv-7fe2856fd99fb9211634a3fbf611fb8c04232396.tar.bz2
mpv-7fe2856fd99fb9211634a3fbf611fb8c04232396.tar.xz
OSD: support displaying fractional part of current position
Add option -osd-fractions which enables display of fractional seconds when showing the current playback time on OSD. Based on a patch from Christian <herr.mitterlehner@gsmpaaiml.com> but with several modifications.
-rw-r--r--DOCS/man/de/mplayer.118
-rw-r--r--DOCS/man/en/mplayer.117
-rw-r--r--cfg-mplayer.h1
-rw-r--r--mplayer.c38
-rw-r--r--options.h1
5 files changed, 70 insertions, 5 deletions
diff --git a/DOCS/man/de/mplayer.1 b/DOCS/man/de/mplayer.1
index de7bef45ca..120c6ce701 100644
--- a/DOCS/man/de/mplayer.1
+++ b/DOCS/man/de/mplayer.1
@@ -2408,6 +2408,24 @@ Deaktiviert das automatische Laden von Untertiteln.
Setzt die Anzeigedauer der OSD-Meldungen in ms (Standard: 1000).
.
.TP
+.B \-osd\-fractions <0\-2>
+Setzt die Art der Anzeige von Nachkommastellen des aktuellen Zeitstempels im
+OSD:
+.PD 0
+.RSs
+.IPs 0
+Keine Anzeige der Nachkommastellen (Standard).
+.IPs 1
+Zeige die ersten beiden Nachkommastellen.
+.IPs 2
+Zeige genäherte Framezahl an.
+Die angezeigte Framezahl ist nicht exakt, sondern nur genähert.
+Für variable FPS ist die Näherung weit von der tatsächlichen Framezahl
+entfernt.
+.RE
+.PD 1
+.
+.TP
.B \-osdlevel <0\-3> (nur bei MPlayer)
Gibt den Modus an, in dem das OSD startet:
.PD 0
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
index 91ae431846..75671c69ec 100644
--- a/DOCS/man/en/mplayer.1
+++ b/DOCS/man/en/mplayer.1
@@ -2298,6 +2298,23 @@ Turns off automatic subtitle file loading.
Set the duration of the OSD messages in ms (default: 1000).
.
.TP
+.B \-osd\-fractions <0\-2>
+Set how fractions of seconds of the current timestamp are printed on the OSD:
+.PD 0
+.RSs
+.IPs 0
+Do not display fractions (default).
+.IPs 1
+Show the first two decimals.
+.IPs 2
+Show approximate frame count within current second.
+This frame count is not accurate but only an approximation.
+For variable fps, the approximation is known to be far off the correct frame
+count.
+.RE
+.PD 1
+.
+.TP
.B \-osdlevel <0\-3>
Specifies which mode the OSD should start in.
.PD 0
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index e2a52ee637..3f30951e12 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -216,6 +216,7 @@ const m_option_t mplayer_opts[]={
#endif
OPT_INTRANGE("osdlevel", osd_level, 0, 0, 3),
OPT_INTRANGE("osd-duration", osd_duration, 0, 0, 3600000),
+ OPT_INTRANGE("osd-fractions", osd_fractions, 0, 0, 2),
#ifdef CONFIG_MENU
{"menu", &use_menu, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"nomenu", &use_menu, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
diff --git a/mplayer.c b/mplayer.c
index 826634f635..7ced98e965 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1639,7 +1639,9 @@ static void update_osd_msg(struct MPContext *mpctx)
int len = get_time_length(mpctx);
int percentage = -1;
char percentage_text[10];
- int pts = get_current_time(mpctx);
+ char fractions_text[4];
+ double fpts = get_current_time(mpctx);
+ int pts = fpts;
if (mpctx->osd_show_percentage_until)
percentage = get_percent_pos(mpctx);
@@ -1649,15 +1651,41 @@ static void update_osd_msg(struct MPContext *mpctx)
else
percentage_text[0] = 0;
+ if (opts->osd_fractions == 1) {
+ //print fractions as sub-second timestamp
+ snprintf(fractions_text, sizeof(fractions_text), ".%02d",
+ (int)((fpts - pts) * 100));
+ } else if (opts->osd_fractions == 2) {
+ /* Print fractions by estimating the frame count within the
+ * second.
+ *
+ * Rounding or cutting off numbers after the decimal point
+ * causes problems because of float's precision and movies
+ * whose first frame is not exactly at timestamp 0. Therefore,
+ * we add 0.2 and cut off at the decimal point, which proved
+ * to be good heuristic.
+ */
+ double fps = mpctx->sh_video->fps;
+ if (fps <= 1 || fps > 99)
+ strcpy(fractions_text, ".??");
+ else
+ snprintf(fractions_text, sizeof(fractions_text), ".%02d",
+ (int) ( (fpts - pts) * fps + 0.2 ) );
+ } else {
+ //do not print fractions
+ fractions_text[0] = 0;
+ }
+
if (opts->osd_level == 3)
snprintf(osd_text_timer, 63,
- "%c %02d:%02d:%02d / %02d:%02d:%02d%s",
+ "%c %02d:%02d:%02d%s / %02d:%02d:%02d%s",
mpctx->osd_function,pts/3600,(pts/60)%60,pts%60,
- len/3600,(len/60)%60,len%60,percentage_text);
+ fractions_text, len/3600, (len/60)%60, len%60,
+ percentage_text);
else
- snprintf(osd_text_timer, 63, "%c %02d:%02d:%02d%s",
+ snprintf(osd_text_timer, 63, "%c %02d:%02d:%02d%s%s",
mpctx->osd_function,pts/3600,(pts/60)%60,
- pts%60,percentage_text);
+ pts%60, fractions_text, percentage_text);
} else
osd_text_timer[0]=0;
diff --git a/options.h b/options.h
index 0fb0a7d809..1e2a125965 100644
--- a/options.h
+++ b/options.h
@@ -31,6 +31,7 @@ typedef struct MPOpts {
int osd_level;
int osd_duration;
+ int osd_fractions;
int auto_quality;
int benchmark;
char *stream_dump_name;