diff options
author | wm4 <wm4@nowhere> | 2015-11-16 22:47:17 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-11-16 22:47:17 +0100 |
commit | 70df1608d6f74f3eba9a5e593822984194f63951 (patch) | |
tree | e6f332aa72d8fd8020d4ba9a214a4826ed6e711f /player/misc.c | |
parent | e24e0ccd6828ff8a50fb290bed45a0f6d81eb00b (diff) | |
download | mpv-70df1608d6f74f3eba9a5e593822984194f63951.tar.bz2 mpv-70df1608d6f74f3eba9a5e593822984194f63951.tar.xz |
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.)
Diffstat (limited to 'player/misc.c')
-rw-r--r-- | player/misc.c | 19 |
1 files changed, 5 insertions, 14 deletions
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; } |