mirror of
https://github.com/mpv-player/mpv
synced 2024-12-21 22:30:22 +00:00
video: filter new frames at a better time
Move this code below the code that "shifts" the newly filtered frame. This allows us to skip a useless playloop iteration later, because obviously we need to filter a new frame after the previous frame has been "shifted", and not before that.
This commit is contained in:
parent
ea2b19f646
commit
35810cb8b4
@ -523,30 +523,6 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
|
||||
if (r < 0)
|
||||
return r; // error
|
||||
|
||||
// Get a new frame if we need one.
|
||||
if (!mpctx->next_frame[1]) {
|
||||
struct mp_image *img = vf_read_output_frame(mpctx->d_video->vfilter);
|
||||
if (img) {
|
||||
// Always add these; they make backstepping after seeking faster.
|
||||
add_frame_pts(mpctx, img->pts);
|
||||
|
||||
bool drop = false;
|
||||
bool hrseek = mpctx->hrseek_active
|
||||
&& mpctx->video_status == STATUS_SYNCING;
|
||||
if (hrseek && img->pts < mpctx->hrseek_pts - .005)
|
||||
drop = true;
|
||||
if (endpts != MP_NOPTS_VALUE && img->pts >= endpts) {
|
||||
drop = true;
|
||||
r = VD_EOF;
|
||||
}
|
||||
if (drop) {
|
||||
talloc_free(img);
|
||||
} else {
|
||||
mpctx->next_frame[1] = img;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!mpctx->next_frame[0] && mpctx->next_frame[1]) {
|
||||
mpctx->next_frame[0] = mpctx->next_frame[1];
|
||||
mpctx->next_frame[1] = NULL;
|
||||
@ -572,6 +548,30 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
|
||||
r = VD_PROGRESS;
|
||||
}
|
||||
|
||||
// Get a new frame if we need one.
|
||||
if (!mpctx->next_frame[1]) {
|
||||
struct mp_image *img = vf_read_output_frame(mpctx->d_video->vfilter);
|
||||
if (img) {
|
||||
// Always add these; they make backstepping after seeking faster.
|
||||
add_frame_pts(mpctx, img->pts);
|
||||
|
||||
bool drop = false;
|
||||
bool hrseek = mpctx->hrseek_active
|
||||
&& mpctx->video_status == STATUS_SYNCING;
|
||||
if (hrseek && img->pts < mpctx->hrseek_pts - .005)
|
||||
drop = true;
|
||||
if (endpts != MP_NOPTS_VALUE && img->pts >= endpts) {
|
||||
drop = true;
|
||||
r = VD_EOF;
|
||||
}
|
||||
if (drop) {
|
||||
talloc_free(img);
|
||||
} else {
|
||||
mpctx->next_frame[1] = img;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// On EOF, always allow the playloop to use the remaining frame.
|
||||
if (r <= 0 && mpctx->next_frame[0])
|
||||
r = VD_NEW_FRAME;
|
||||
|
Loading…
Reference in New Issue
Block a user