diff options
Diffstat (limited to 'player/playloop.c')
-rw-r--r-- | player/playloop.c | 59 |
1 files changed, 15 insertions, 44 deletions
diff --git a/player/playloop.c b/player/playloop.c index f5463e2622..5efb048cb2 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -205,7 +205,7 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek, case MPSEEK_FACTOR: ; double len = get_time_length(mpctx); if (len >= 0) - target_time = seek.amount * len + get_start_time(mpctx); + target_time = seek.amount * len; break; } @@ -228,16 +228,11 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek, hr_seek &= seek.type == MPSEEK_ABSOLUTE; // otherwise, no target PTS known double demuxer_amount = seek.amount; - if (mpctx->timeline) { - bool need_reset = false; - demuxer_amount = timeline_set_from_time(mpctx, seek.amount, - &need_reset); - if (need_reset) { - reinit_video_chain(mpctx); - reinit_audio_chain(mpctx); - reinit_subs(mpctx, 0); - reinit_subs(mpctx, 1); - } + if (timeline_switch_to_time(mpctx, seek.amount)) { + reinit_video_chain(mpctx); + reinit_audio_chain(mpctx); + reinit_subs(mpctx, 0); + reinit_subs(mpctx, 1); } int demuxer_style = 0; @@ -268,7 +263,6 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek, double main_new_pos = seek.amount; if (seek.type != MPSEEK_ABSOLUTE) main_new_pos = get_main_demux_pts(mpctx); - main_new_pos -= get_track_video_offset(mpctx, track); demux_seek(track->demuxer, main_new_pos, SEEK_ABSOLUTE | SEEK_BACKWARD); } } @@ -405,15 +399,14 @@ double get_playback_time(struct MPContext *mpctx) double cur = get_current_time(mpctx); if (cur == MP_NOPTS_VALUE) return cur; - double start = get_start_time(mpctx); // During seeking, the time corresponds to the last seek time - apply some // cosmetics to it. if (mpctx->playback_pts == MP_NOPTS_VALUE) { double length = get_time_length(mpctx); if (length >= 0) - cur = MPCLAMP(cur, start, start + length); + cur = MPCLAMP(cur, 0, length); } - return cur >= start ? cur - start : cur; + return cur; } // Return playback position in 0.0-1.0 ratio, or -1 if unknown. @@ -423,15 +416,15 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range) if (!demuxer) return -1; double ans = -1; - double start = get_start_time(mpctx); + double start = 0; double len = get_time_length(mpctx); if (use_range) { double startpos = rel_time_to_abs(mpctx, mpctx->opts->play_start); double endpos = get_play_end_pts(mpctx); - if (endpos == MP_NOPTS_VALUE || endpos > start + MPMAX(0, len)) - endpos = start + MPMAX(0, len); - if (startpos == MP_NOPTS_VALUE || startpos < start) - startpos = start; + if (endpos == MP_NOPTS_VALUE || endpos > MPMAX(0, len)) + endpos = MPMAX(0, len); + if (startpos == MP_NOPTS_VALUE || startpos < 0) + startpos = 0; if (endpos < startpos) endpos = startpos; start = startpos; @@ -506,7 +499,7 @@ char *chapter_name(struct MPContext *mpctx, int chapter) double chapter_start_time(struct MPContext *mpctx, int chapter) { if (chapter == -1) - return get_start_time(mpctx); + return 0; if (chapter >= 0 && chapter < mpctx->num_chapters) return mpctx->chapters[chapter].pts; return MP_NOPTS_VALUE; @@ -693,27 +686,6 @@ void add_frame_pts(struct MPContext *mpctx, double pts) mpctx->vo_pts_history_pts[0] = pts; } -// Return the last (at most num) frame duration in fd[]. Return the number of -// entries written to fd[] (range [0, num]). fd[0] is the most recent frame. -int get_past_frame_durations(struct MPContext *mpctx, double *fd, int num) -{ - double next_pts = mpctx->vo_pts_history_pts[0]; - if (mpctx->vo_pts_history_seek[0] != mpctx->vo_pts_history_seek_ts || - next_pts == MP_NOPTS_VALUE) - return 0; - int num_ret = 0; - for (int n = 1; n < MAX_NUM_VO_PTS && num_ret < num; n++) { - double frame_pts = mpctx->vo_pts_history_pts[n]; - // Discontinuity -> refuse to return a value. - if (mpctx->vo_pts_history_seek[n] != mpctx->vo_pts_history_seek_ts || - next_pts <= frame_pts || frame_pts == MP_NOPTS_VALUE) - break; - fd[num_ret++] = next_pts - frame_pts; - next_pts = frame_pts; - } - return num_ret; -} - static double find_previous_pts(struct MPContext *mpctx, double pts) { for (int n = 0; n < MAX_NUM_VO_PTS - 1; n++) { @@ -806,8 +778,7 @@ static void handle_loop_file(struct MPContext *mpctx) if (opts->loop_file && mpctx->stop_play == AT_END_OF_FILE) { mpctx->stop_play = KEEP_PLAYING; set_osd_function(mpctx, OSD_FFW); - queue_seek(mpctx, MPSEEK_ABSOLUTE, get_start_time(mpctx), - MPSEEK_DEFAULT, true); + queue_seek(mpctx, MPSEEK_ABSOLUTE, 0, MPSEEK_DEFAULT, true); if (opts->loop_file > 0) opts->loop_file--; } |