From 70df1608d6f74f3eba9a5e593822984194f63951 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 16 Nov 2015 22:47:17 +0100 Subject: player: handle rebasing start time differently Most of this is explained in the DOCS additions. This gives us slightly more sanity, because there is less interaction between the various parts. The goal is getting rid of the video_offset entirely. The simplification extends to the user API. In particular, we don't need to fix missing parts in the API, such as the lack for a seek command that seeks relatively to the start time. All these things are now transparent. (If someone really wants to know the real timestamps/start time, new properties would have to be added.) --- player/misc.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'player/misc.c') diff --git a/player/misc.c b/player/misc.c index 1e67adbe32..0a3479590d 100644 --- a/player/misc.c +++ b/player/misc.c @@ -56,21 +56,20 @@ double get_relative_time(struct MPContext *mpctx) double rel_time_to_abs(struct MPContext *mpctx, struct m_rel_time t) { double length = get_time_length(mpctx); - double start = get_start_time(mpctx); switch (t.type) { case REL_TIME_ABSOLUTE: return t.pos; case REL_TIME_RELATIVE: if (t.pos >= 0) { - return start + t.pos; + return t.pos; } else { if (length >= 0) - return MPMAX(start + length + t.pos, 0.0); + return MPMAX(length + t.pos, 0.0); } break; case REL_TIME_PERCENT: if (length >= 0) - return start + length * (t.pos / 100.0); + return length * (t.pos / 100.0); break; case REL_TIME_CHAPTER: if (chapter_start_time(mpctx, t.pos) != MP_NOPTS_VALUE) @@ -87,12 +86,11 @@ double get_play_end_pts(struct MPContext *mpctx) if (opts->play_end.type) { end = rel_time_to_abs(mpctx, opts->play_end); } else if (opts->play_length.type) { - double startpts = get_start_time(mpctx); double start = rel_time_to_abs(mpctx, opts->play_start); if (start == MP_NOPTS_VALUE) - start = startpts; + start = 0; double length = rel_time_to_abs(mpctx, opts->play_length); - if (start != MP_NOPTS_VALUE && length != MP_NOPTS_VALUE) + if (length != MP_NOPTS_VALUE) end = start + length; } if (opts->chapterrange[1] > 0) { @@ -117,18 +115,11 @@ double get_main_demux_pts(struct MPContext *mpctx) return main_new_pos; } -double get_start_time(struct MPContext *mpctx) -{ - return mpctx->demuxer ? mpctx->demuxer->start_time : 0; -} - // Get the offset from the given track to the video. double get_track_video_offset(struct MPContext *mpctx, struct track *track) { if (track && track->under_timeline) return mpctx->video_offset; - if (track && track->is_external) - return get_start_time(mpctx); return 0; } -- cgit v1.2.3