From 72bdc5d3af22735753e1487fd251db09f8a20194 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 26 Feb 2013 00:38:36 +0100 Subject: 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. --- demux/demux_lavf.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'demux/demux_lavf.c') diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index eaa0cfadf8..23495d0ed5 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -765,15 +765,10 @@ static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg) *((double *)arg) = (double)priv->avfc->duration / AV_TIME_BASE; return DEMUXER_CTRL_OK; - case DEMUXER_CTRL_GET_PERCENT_POS: - if (priv->seek_by_bytes) - return DEMUXER_CTRL_DONTKNOW; // let it use the fallback code - if (priv->avfc->duration == 0 || priv->avfc->duration == AV_NOPTS_VALUE) - return DEMUXER_CTRL_DONTKNOW; - - *((int *)arg) = (int)((priv->last_pts - priv->avfc->start_time) * 100 / - priv->avfc->duration); + case DEMUXER_CTRL_GET_START_TIME: + *((double *)arg) = (double)priv->avfc->start_time / AV_TIME_BASE; return DEMUXER_CTRL_OK; + case DEMUXER_CTRL_SWITCH_AUDIO: case DEMUXER_CTRL_SWITCH_VIDEO: { -- cgit v1.2.3