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).
This commit is contained in:
wm4 2020-02-28 01:26:08 +01:00
parent 3ae4094ec0
commit 009d1ffda6
1 changed files with 5 additions and 2 deletions

View File

@ -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;
}