[MPlayer-dev-eng] [PATCH] Fractional part of time stamp in OSD

Christian herr.mitterlehner at gsmpaaiml.com
Sun Jan 30 08:43:02 CET 2011


Hello,

Attached, you'll find the 2nd revision of the patch.

On Sat, Jan 29, 2011 at 11:28:16PM +0100, Diego Biurrun wrote:
> On Sat, Jan 29, 2011 at 07:22:46AM +0100, Christian wrote:
> > 
> > Attached, you'll find the revised version of the patch.
> > 
> > [ Section of DOCS/man/en/mplayer.1 ]
> 
> Capitalize these sentences and end in a period.

Fixed,

> > [ DOCS/man/de/mplayer.1 ]
> 
> same

Fixed.

> tabs and trailing whitespace

Fixed.

Kind regards,
Christian
-------------- next part --------------
Index: DOCS/man/en/mplayer.1
===================================================================
--- DOCS/man/en/mplayer.1	(Revision 32825)
+++ DOCS/man/en/mplayer.1	(Arbeitskopie)
@@ -2426,6 +2426,23 @@
 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 approximated 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> (MPlayer only)
 Specifies which mode the OSD should start in.
 .PD 0
Index: DOCS/man/de/mplayer.1
===================================================================
--- DOCS/man/de/mplayer.1	(Revision 32825)
+++ DOCS/man/de/mplayer.1	(Arbeitskopie)
@@ -2416,6 +2416,24 @@
 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?rte Framezahl an.
+Die angezeigte Framezahl ist nicht exakt, sondern nur gen?rt.
+F?iable FPS ist die N?rung weit von der tats?lichen Framezahl
+entfernt.
+.RE
+.PD 1
+.
+.TP
 .B \-osdlevel <0\-3> (nur bei MPlayer)
 Gibt den Modus an, in dem das OSD startet:
 .PD 0
Index: mplayer.c
===================================================================
--- mplayer.c	(Revision 32825)
+++ mplayer.c	(Arbeitskopie)
@@ -212,6 +212,8 @@
 // if nonzero, hide current OSD contents when GetTimerMS() reaches this
 unsigned int osd_visible;
 int osd_duration = 1000;
+int osd_fractions = 0; // determines how fractions of seconds are displayed
+                       // on OSD
 
 int term_osd = 1;
 static char* term_osd_esc = "\x1b[A\r\x1b[K";
@@ -1569,6 +1571,7 @@
             int len = demuxer_get_time_length(mpctx->demuxer);
             int percentage = -1;
             char percentage_text[10];
+            char fractions_text[4];
             int pts = demuxer_get_current_time(mpctx->demuxer);
 
             if (mpctx->osd_show_percentage)
@@ -1579,15 +1582,38 @@
             else
                 percentage_text[0] = 0;
 
+            if (osd_fractions==1) {
+                //print fractions as sub-second timestamp
+                snprintf(fractions_text, sizeof(fractions_text), ".%02d",
+                         (int)( (mpctx->sh_video->pts - pts)* 100 + 0.5)
+                         % 100);
+            } else if (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
+                //as good heuristic
+                snprintf(fractions_text, sizeof(fractions_text), ".%02d",
+                         (int) ( ( mpctx->sh_video->pts - pts ) *
+                         mpctx->sh_video->fps + 0.2 ) );
+            } else {
+                //do not print fractions
+                fractions_text[0] = 0;
+            }
+
             if (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;
 
Index: cfg-mplayer.h
===================================================================
--- cfg-mplayer.h	(Revision 32825)
+++ cfg-mplayer.h	(Arbeitskopie)
@@ -235,6 +235,7 @@
 #endif
     {"osdlevel", &osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
     {"osd-duration", &osd_duration, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
+    {"osd-fractions", &osd_fractions, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL},
 #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},


More information about the MPlayer-dev-eng mailing list