summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-02-26 00:38:36 +0100
committerwm4 <wm4@nowhere>2013-02-26 02:01:48 +0100
commit72bdc5d3af22735753e1487fd251db09f8a20194 (patch)
tree4a1d47258e767023b2dc09d5db4a8fc386412896 /core
parent70346d3be623bc5edc31a15bd1ca205c33050219 (diff)
downloadmpv-72bdc5d3af22735753e1487fd251db09f8a20194.tar.bz2
mpv-72bdc5d3af22735753e1487fd251db09f8a20194.tar.xz
core: use playback time to determine playback percent position
The percent position is used for the OSD, the status line, and for the OSD bar (shown on seeks). By default, the PTS of the last demuxed packet was used to calculate it. This led to a "jumpy" display when the percentage value (casted to int) was changing. The reasons for this were the presence of video frame reordering (packet PTS is not monotonic), or getting PTS values from different streams (like audio/subs). Since these rely on PTS values and correct file durations anyway, simplify it by calculating it with the current playback position in mplayer.c instead.
Diffstat (limited to 'core')
-rw-r--r--core/mplayer.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index fa12403a82..97ab1e8ab4 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -2970,18 +2970,28 @@ double get_current_time(struct MPContext *mpctx)
return 0;
}
+static double get_start_time(struct MPContext *mpctx)
+{
+ struct demuxer *demuxer = mpctx->demuxer;
+ if (!demuxer)
+ return 0;
+ double time = 0;
+ demux_control(demuxer, DEMUXER_CTRL_GET_START_TIME, &time);
+ return time;
+}
+
int get_percent_pos(struct MPContext *mpctx)
{
struct demuxer *demuxer = mpctx->demuxer;
if (!demuxer)
return 0;
int ans = 0;
- if (mpctx->timeline)
- ans = get_current_time(mpctx) * 100 /
- mpctx->timeline[mpctx->num_timeline_parts].start;
- else if (demux_control(demuxer, DEMUXER_CTRL_GET_PERCENT_POS, &ans) > 0)
- ;
- else {
+ double start = get_start_time(mpctx);
+ double len = get_time_length(mpctx);
+ double pos = get_current_time(mpctx);
+ if (len > 0) {
+ ans = (pos - start) / len * 100;
+ } else {
int len = (demuxer->movi_end - demuxer->movi_start) / 100;
int64_t pos = demuxer->filepos > 0 ?
demuxer->filepos : stream_tell(demuxer->stream);