diff options
author | wm4 <wm4@nowhere> | 2014-08-13 21:54:26 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-08-13 22:01:10 +0200 |
commit | b0959488d104fa011ec9a267569d101769e1fb1e (patch) | |
tree | fbd87a4015b3ea8781e0e7f88357f84e9faeecc6 /player/video.c | |
parent | 4a325a8592dcb3da8d00408f4539e14bd48b6039 (diff) | |
download | mpv-b0959488d104fa011ec9a267569d101769e1fb1e.tar.bz2 mpv-b0959488d104fa011ec9a267569d101769e1fb1e.tar.xz |
video: don't run new frame processing on every iteration
This ran adjust_sync() on every playloop iteration, instead of every
newly decoded frame. It seems this was idempotent in the common case,
but the code was originally designed to be run once only, so restore
that.
Diffstat (limited to 'player/video.c')
-rw-r--r-- | player/video.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/player/video.c b/player/video.c index edad2465a3..27cb2bebab 100644 --- a/player/video.c +++ b/player/video.c @@ -518,7 +518,7 @@ static int video_output_image(struct MPContext *mpctx, double endpts) int pos = mpctx->next_frame[0] ? 1 : 0; assert(!mpctx->next_frame[pos]); mpctx->next_frame[pos] = img; - return VD_PROGRESS; + return VD_NEW_FRAME; } return r; // includes the true EOF case @@ -562,12 +562,13 @@ static int update_video(struct MPContext *mpctx, double endpts) { struct vo *vo = mpctx->video_out; bool eof = false; + int r = VD_PROGRESS; // Already enough video buffered? bool vo_framedrop = !!mpctx->video_out->driver->flip_page_timed; int min_frames = vo_framedrop ? 2 : 1; // framedrop needs duration if (!mpctx->next_frame[min_frames - 1]) { - int r = video_output_image(mpctx, endpts); + r = video_output_image(mpctx, endpts); if (r < 0 || r == VD_WAIT) return r; eof = r == VD_EOF; @@ -590,24 +591,26 @@ static int update_video(struct MPContext *mpctx, double endpts) if (!mpctx->next_frame[min_frames - 1]) return eof ? VD_EOF : VD_PROGRESS; - double pts = mpctx->next_frame[0]->pts; - double last_pts = mpctx->video_next_pts; - if (last_pts == MP_NOPTS_VALUE) - last_pts = pts; - double frame_time = pts - last_pts; - if (frame_time < 0 || frame_time >= 60) { - // Assume a PTS difference >= 60 seconds is a discontinuity. - MP_WARN(mpctx, "Jump in video pts: %f -> %f\n", last_pts, pts); - frame_time = 0; - } - mpctx->video_next_pts = pts; - if (mpctx->d_audio) - mpctx->delay -= frame_time; - if (mpctx->video_status >= STATUS_READY) { - mpctx->time_frame += frame_time / mpctx->opts->playback_speed; - adjust_sync(mpctx, pts, frame_time); + if (r == VD_NEW_FRAME) { + double pts = mpctx->next_frame[0]->pts; + double last_pts = mpctx->video_next_pts; + if (last_pts == MP_NOPTS_VALUE) + last_pts = pts; + double frame_time = pts - last_pts; + if (frame_time < 0 || frame_time >= 60) { + // Assume a PTS difference >= 60 seconds is a discontinuity. + MP_WARN(mpctx, "Jump in video pts: %f -> %f\n", last_pts, pts); + frame_time = 0; + } + mpctx->video_next_pts = pts; + if (mpctx->d_audio) + mpctx->delay -= frame_time; + if (mpctx->video_status >= STATUS_READY) { + mpctx->time_frame += frame_time / mpctx->opts->playback_speed; + adjust_sync(mpctx, pts, frame_time); + } + MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time); } - MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time); return VD_NEW_FRAME; } |