summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-18 19:17:38 +0200
committerwm4 <wm4@nowhere>2014-09-18 19:32:25 +0200
commit35810cb8b458b7ae80db1bbbae34f41a48050887 (patch)
tree71086e1a1b1f6622923aa92015cb9cf4b7bb2cef
parentea2b19f64673a975a6bafe3292d26eab51142a5f (diff)
downloadmpv-35810cb8b458b7ae80db1bbbae34f41a48050887.tar.bz2
mpv-35810cb8b458b7ae80db1bbbae34f41a48050887.tar.xz
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.
-rw-r--r--player/video.c48
1 files 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;