[MPlayer-dev-eng] [PATCH] fix OSD decimal output for dvdnav

Roger Pack rogerdpack2 at gmail.com
Wed Apr 18 16:55:47 CEST 2012


> Applied. I suspect the reason might have been that the stream time
> stamps are actually updated too rarely and thus not precise enough,
> however imprecise is still better than wrong.
> Part of the issue is that the stream time stamps are delayed by the
> cache.
> Ideally pts should be used to fix up the stream time stamps.
> Or rather the opposite way, video pts should be used mostly, but
> with stream value as a base to fix up time stamp wraps and
> resets etc.

Ok finally got back to this.

This patch:
https://github.com/rdp/mplayer-svn/commit/28f52e4cfe27262296a2c60832a341895720607c
is my attempt, and it seems to be working fine in testing here.
Thanks!
-roger-



diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index c0b8682..4e738ed 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -1488,7 +1488,22 @@ double demuxer_get_current_time(demuxer_t *demuxer)
     double get_time_ans = 0;
     sh_video_t *sh_video = demuxer->video->sh;
     if (demuxer->stream_pts != MP_NOPTS_VALUE)
-        get_time_ans = demuxer->stream_pts;
+	{
+       get_time_ans = demuxer->stream_pts;	
+	   if(get_time_ans != last_dvd_update_pos) {
+	     // got a new NAV packet
+         last_dvd_update_pos = get_time_ans;
+         last_stream_pos_at_that_dvd_time = sh_video->pts;
+       } else {
+	     // make return value more precise by adding in time elapsed
since NAV packet
+         double time_since_last_nav_packet = sh_video->pts -
last_stream_pos_at_that_dvd_time;
+         if(time_since_last_nav_packet > 0 &&
time_since_last_nav_packet < 1.5) { // should never exceed 1.5s,
typically <= 0.4
+           get_time_ans += time_since_last_nav_packet;
+         } else {
+           last_stream_pos_at_that_dvd_time = sh_video->pts;
+         }
+       }
+	}
     else if (sh_video)
         get_time_ans = sh_video->pts;
     return get_time_ans;


More information about the MPlayer-dev-eng mailing list