From 35810cb8b458b7ae80db1bbbae34f41a48050887 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 18 Sep 2014 19:17:38 +0200 Subject: 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. --- player/video.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/player/video.c b/player/video.c index f36a41b8f7..c3834457bd 100644 --- a/player/video.c +++ b/player/video.c @@ -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; -- cgit v1.2.3