Mercurial > mplayer.hg
changeset 34312:d2a41814c879
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].
author | reimar |
---|---|
date | Mon, 05 Dec 2011 18:27:40 +0000 |
parents | cdee75826a31 |
children | 8f2167abd6e0 |
files | libmpdemux/demuxer.c libmpdemux/demuxer.h mplayer.c |
diffstat | 3 files changed, 10 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demuxer.c Mon Dec 05 18:22:56 2011 +0000 +++ b/libmpdemux/demuxer.c Mon Dec 05 18:27:40 2011 +0000 @@ -1480,7 +1480,7 @@ * 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 @@ 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)
--- a/libmpdemux/demuxer.h Mon Dec 05 18:22:56 2011 +0000 +++ b/libmpdemux/demuxer.h Mon Dec 05 18:27:40 2011 +0000 @@ -437,7 +437,7 @@ 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);
--- a/mplayer.c Mon Dec 05 18:22:56 2011 +0000 +++ b/mplayer.c Mon Dec 05 18:27:40 2011 +0000 @@ -1584,7 +1584,8 @@ 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 @@ 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 @@ // 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 @@ 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;