[MPlayer-dev-eng] [PATCH] fix OSD decimal output for dvdnav
Roger Pack
rogerdpack2 at gmail.com
Wed Apr 18 18:22:29 CEST 2012
> This patch:
> https://github.com/rdp/mplayer-svn/commit/28f52e4cfe27262296a2c60832a341895720607c
> is my attempt, and it seems to be working fine in testing here.
> Thanks!
Oops forgot to declare the variables (I'm not sure exactly where best
to, but anyway...)
https://github.com/rdp/mplayer-svn/compare/e0061...26cf6b
Thanks!
-roger-
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index fbbd5e6..b9bff0d 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -1474,6 +1474,8 @@ double demuxer_get_time_length(demuxer_t *demuxer)
return get_time_ans;
}
+static double last_dvd_update_pos = 0.0;
+static double last_stream_pos_at_that_dvd_time = 0.0;
/**
* \brief demuxer_get_current_time() returns the time of the current
play in three possible ways:
* either when the stream reader satisfies
STREAM_CTRL_GET_CURRENT_TIME (e.g. dvd)
@@ -1486,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