summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-22 18:06:59 +0200
committerwm4 <wm4@nowhere>2014-09-22 18:06:59 +0200
commitf605b03f631e770ce6e99893134554603d6fbe40 (patch)
treeb5a13cc82a6bcd8953775302d22fe9e11676e7e6
parent63a2024a8b4786e5f87901658294b93db55a5efc (diff)
downloadmpv-f605b03f631e770ce6e99893134554603d6fbe40.tar.bz2
mpv-f605b03f631e770ce6e99893134554603d6fbe40.tar.xz
video: filter new frames at a better time (2)
We generally want 2 things: 1. minimal wakeups for decoding each frame 2. minimal number of frames decoded on continuous seeking Commit 35810cb8 changed this a bit, and fixed 1. But it broke 2., and now it decodes 2 frames instead of 1 when you keep seeking (arrow key held down or such). This made seeking appear slower. Fix this by making the logic more explicit. In particular, call the filters only if we actually try to get a new frame. When playing with --no-audio and all other distractions disabled (like OSC), it still wakes up 2 times per frame - but the second time is merely because the VO didn't accept the new frame yet.
-rw-r--r--player/video.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/player/video.c b/player/video.c
index 61cbb09713..028132860f 100644
--- a/player/video.c
+++ b/player/video.c
@@ -532,11 +532,6 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
if (have_new_frame(mpctx))
return VD_NEW_FRAME;
- // Filter a new frame.
- int r = video_decode_and_filter(mpctx);
- if (r < 0)
- return r; // error
-
if (!mpctx->next_frame[0] && mpctx->next_frame[1]) {
mpctx->next_frame[0] = mpctx->next_frame[1];
mpctx->next_frame[1] = NULL;
@@ -560,11 +555,18 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
}
mpctx->dropped_frames = 0;
MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time);
- r = VD_PROGRESS;
}
+ if (have_new_frame(mpctx))
+ return VD_NEW_FRAME;
+
// Get a new frame if we need one.
+ int r = VD_PROGRESS;
if (!mpctx->next_frame[1]) {
+ // Filter a new frame.
+ r = video_decode_and_filter(mpctx);
+ if (r < 0)
+ return r; // error
struct mp_image *img = vf_read_output_frame(mpctx->d_video->vfilter);
if (img) {
// Always add these; they make backstepping after seeking faster.
@@ -589,7 +591,7 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
// On EOF, always allow the playloop to use the remaining frame.
if (have_new_frame(mpctx) || (r <= 0 && mpctx->next_frame[0]))
- r = VD_NEW_FRAME;
+ return VD_NEW_FRAME;
return r;
}