mirror of
https://github.com/mpv-player/mpv
synced 2025-02-13 02:16:54 +00:00
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.
This commit is contained in:
parent
63a2024a8b
commit
f605b03f63
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user