diff options
author | wm4 <wm4@nowhere> | 2014-09-18 19:20:22 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-09-18 19:34:56 +0200 |
commit | e37ad620aa324939ce15ec4a6898b87e1e23d643 (patch) | |
tree | 843caba626d9f9e5b8c13410b63d326e92817abc /player/video.c | |
parent | 35810cb8b458b7ae80db1bbbae34f41a48050887 (diff) | |
download | mpv-e37ad620aa324939ce15ec4a6898b87e1e23d643.tar.bz2 mpv-e37ad620aa324939ce15ec4a6898b87e1e23d643.tar.xz |
video: check whether there are enough frames after filtering
Move the check to a function. Run the check a second time after
decoding/filtering. This second check is strictly speaking redundant
(which is why it wasn't done until now), but it avoids a useless
playloop iteration.
Diffstat (limited to 'player/video.c')
-rw-r--r-- | player/video.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/player/video.c b/player/video.c index c3834457bd..16bbb172e6 100644 --- a/player/video.c +++ b/player/video.c @@ -495,6 +495,15 @@ static void adjust_sync(struct MPContext *mpctx, double v_pts, double frame_time mpctx->total_avsync_change += change; } +// Enough video filtered already to push one frame to the VO? +static bool have_new_frame(struct MPContext *mpctx) +{ + bool need_2nd = !!(mpctx->opts->frame_dropping & 1) // we need the duration + && mpctx->video_pts != MP_NOPTS_VALUE; // ...except for the 1st frame + + return mpctx->next_frame[0] && (!need_2nd || mpctx->next_frame[1]); +} + // Fill mpctx->next_frame[] with a newly filtered or decoded image. // returns VD_* code static int video_output_image(struct MPContext *mpctx, double endpts) @@ -511,11 +520,7 @@ static int video_output_image(struct MPContext *mpctx, double endpts) return r <= 0 ? VD_EOF : VD_PROGRESS; } - bool need_2nd = !!(mpctx->opts->frame_dropping & 1) // we need the duration - && mpctx->video_pts != MP_NOPTS_VALUE; // ...except for the 1st frame - - // Enough video filtered already? - if (mpctx->next_frame[0] && (!need_2nd || mpctx->next_frame[1])) + if (have_new_frame(mpctx)) return VD_NEW_FRAME; // Filter a new frame. @@ -573,7 +578,7 @@ static int video_output_image(struct MPContext *mpctx, double endpts) } // On EOF, always allow the playloop to use the remaining frame. - if (r <= 0 && mpctx->next_frame[0]) + if (have_new_frame(mpctx) || (r <= 0 && mpctx->next_frame[0])) r = VD_NEW_FRAME; return r; |