[MPlayer-cvslog] r34400 - in trunk: libmpdemux/demuxer.c libmpdemux/demuxer.h mplayer.c

reimar subversion at mplayerhq.hu
Mon Dec 5 19:27:40 CET 2011


Author: reimar
Date: Mon Dec  5 19:27:40 2011
New Revision: 34400

Log:
Fix OSD time and e.g. frame number displayed with osd_fractions
getting out of sync by using the same source for both.

Patch by Roger Pack [rogerdpack2 gmail com].

Modified:
   trunk/libmpdemux/demuxer.c
   trunk/libmpdemux/demuxer.h
   trunk/mplayer.c

Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c	Mon Dec  5 19:22:56 2011	(r34399)
+++ trunk/libmpdemux/demuxer.c	Mon Dec  5 19:27:40 2011	(r34400)
@@ -1480,7 +1480,7 @@ double demuxer_get_time_length(demuxer_t
  *        0 otherwise
  * \return the current play time
  */
-int demuxer_get_current_time(demuxer_t *demuxer)
+double demuxer_get_current_time(demuxer_t *demuxer)
 {
     double get_time_ans = 0;
     sh_video_t *sh_video = demuxer->video->sh;
@@ -1488,7 +1488,7 @@ int demuxer_get_current_time(demuxer_t *
         get_time_ans = demuxer->stream_pts;
     else if (sh_video)
         get_time_ans = sh_video->pts;
-    return (int) get_time_ans;
+    return get_time_ans;
 }
 
 int demuxer_get_percent_pos(demuxer_t *demuxer)

Modified: trunk/libmpdemux/demuxer.h
==============================================================================
--- trunk/libmpdemux/demuxer.h	Mon Dec  5 19:22:56 2011	(r34399)
+++ trunk/libmpdemux/demuxer.h	Mon Dec  5 19:27:40 2011	(r34400)
@@ -437,7 +437,7 @@ char* demux_info_get(demuxer_t *demuxer,
 int demux_info_print(demuxer_t *demuxer);
 int demux_control(demuxer_t *demuxer, int cmd, void *arg);
 
-int demuxer_get_current_time(demuxer_t *demuxer);
+double demuxer_get_current_time(demuxer_t *demuxer);
 double demuxer_get_time_length(demuxer_t *demuxer);
 int demuxer_get_percent_pos(demuxer_t *demuxer);
 int demuxer_switch_audio(demuxer_t *demuxer, int index);

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Mon Dec  5 19:22:56 2011	(r34399)
+++ trunk/mplayer.c	Mon Dec  5 19:27:40 2011	(r34400)
@@ -1584,7 +1584,8 @@ static void update_osd_msg(void)
             int percentage = -1;
             char percentage_text[10];
             char fractions_text[4];
-            int pts = demuxer_get_current_time(mpctx->demuxer);
+            double pts = demuxer_get_current_time(mpctx->demuxer);
+            int pts_seconds = pts;
 
             if (mpctx->osd_show_percentage)
                 percentage = demuxer_get_percent_pos(mpctx->demuxer);
@@ -1597,7 +1598,7 @@ static void update_osd_msg(void)
             if (osd_fractions == 1) {
                 // print fractions as sub-second timestamp
                 snprintf(fractions_text, sizeof(fractions_text), ".%02d",
-                         (int)((mpctx->sh_video->pts - pts) * 100) % 100);
+                         (int)((pts - pts_seconds) * 100) % 100);
             } else if (osd_fractions == 2) {
                 // print fractions by estimating the frame count within the
                 // second
@@ -1608,7 +1609,7 @@ static void update_osd_msg(void)
                 // 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) *
+                         (int)((pts - pts_seconds) *
                                mpctx->sh_video->fps + 0.2));
             } else {
                 // do not print fractions
@@ -1618,13 +1619,13 @@ static void update_osd_msg(void)
             if (osd_level == 3)
                 snprintf(osd_text_timer, 63,
                          "%c %02d:%02d:%02d%s / %02d:%02d:%02d%s",
-                         mpctx->osd_function, pts / 3600, (pts / 60) % 60, pts % 60,
+                         mpctx->osd_function, pts_seconds / 3600, (pts_seconds / 60) % 60, pts_seconds % 60,
                          fractions_text, len / 3600, (len / 60) % 60, len % 60,
                          percentage_text);
             else
                 snprintf(osd_text_timer, 63, "%c %02d:%02d:%02d%s%s",
-                         mpctx->osd_function, pts / 3600, (pts / 60) % 60,
-                         pts % 60, fractions_text, percentage_text);
+                         mpctx->osd_function, pts_seconds / 3600, (pts_seconds / 60) % 60,
+                         pts_seconds % 60, fractions_text, percentage_text);
         } else
             osd_text_timer[0] = 0;
 


More information about the MPlayer-cvslog mailing list