Mercurial > mplayer.hg
diff mplayer.c @ 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 | aa8061d708b9 |
children | f05c75392897 |
line wrap: on
line diff
--- 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;