From 009d1ffda6cc5438d7287b2971d17e866ebc86c0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 28 Feb 2020 01:26:08 +0100 Subject: player: remove stale last frame references The seeking logic saves the last video frame it has seen (for example for being able to seek to the last frame, or backstepping). Unfortunately, the frame was fed back to the filtering pipeline in situations when it shouldn't have. Then it's an out of order frame, because it really saves the last _discarded_ frame. For example, seeking to the end of a file with --keep-open, shift+up, shift+down => invalid video pts warning due to saved_frame being fed back. Explicitly discard saved_frame when it's obviously not needed anymore. The removed accesses to "r" are strictly speaking unrelated (just const-propagating them). --- player/video.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'player/video.c') diff --git a/player/video.c b/player/video.c index d8b7728fe8..3f5919a25f 100644 --- a/player/video.c +++ b/player/video.c @@ -522,6 +522,7 @@ static int video_output_image(struct MPContext *mpctx, bool *logical_eof) } mpctx->hrseek_backstep = false; } + mp_image_unrefp(&mpctx->saved_frame); add_new_frame(mpctx, img); img = NULL; } @@ -529,11 +530,13 @@ static int video_output_image(struct MPContext *mpctx, bool *logical_eof) } } + if (!hrseek) + mp_image_unrefp(&mpctx->saved_frame); + // If hr-seek went past EOF, use the last frame. - if (r <= 0 && hrseek && mpctx->saved_frame && r == VD_EOF) { + if (mpctx->saved_frame && r == VD_EOF) { add_new_frame(mpctx, mpctx->saved_frame); mpctx->saved_frame = NULL; - r = VD_EOF; *logical_eof = true; } -- cgit v1.2.3