summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-17 01:37:59 +0100
committerwm4 <wm4@nowhere>2019-11-17 02:11:45 +0100
commit4e74320320ea78904d94d11ffb35ef8f9f2b431e (patch)
tree4a16c71e6f5ab4531134bcf785c9eb40fbb2bd50 /player
parent42c5867c4e71bdb07fbaf893a8ba56160b0587bb (diff)
downloadmpv-4e74320320ea78904d94d11ffb35ef8f9f2b431e.tar.bz2
mpv-4e74320320ea78904d94d11ffb35ef8f9f2b431e.tar.xz
video: make track switching work for external images
Until now, this didn't work, since the external image had pts 0; so enabling video at a later time did nothing, because the image was discarded. Since hrseek now ends on the last frame (instead of nothing), reusing the hrseek mechanism solves this, and we don't even need to treat the cursed coverart case separately.
Diffstat (limited to 'player')
-rw-r--r--player/video.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/player/video.c b/player/video.c
index 815c5dfe02..337865f1eb 100644
--- a/player/video.c
+++ b/player/video.c
@@ -455,7 +455,18 @@ static bool have_new_frame(struct MPContext *mpctx, bool eof)
static int video_output_image(struct MPContext *mpctx)
{
struct vo_chain *vo_c = mpctx->vo_chain;
- bool hrseek = mpctx->hrseek_active && mpctx->video_status == STATUS_SYNCING;
+ bool hrseek = false;
+ double hrseek_pts = mpctx->hrseek_pts;
+ if (mpctx->video_status == STATUS_SYNCING) {
+ hrseek = mpctx->hrseek_active;
+ // playback_pts is normally only set when audio and video have started
+ // playing normally. If video is in syncing mode, then this must mean
+ // video was just enabled via track switching - skip to current time.
+ if (!hrseek && mpctx->playback_pts != MP_NOPTS_VALUE) {
+ hrseek = true;
+ hrseek_pts = mpctx->playback_pts;
+ }
+ }
if (vo_c->is_coverart) {
if (vo_has_frame(mpctx->video_out))
@@ -494,16 +505,11 @@ static int video_output_image(struct MPContext *mpctx)
mp_pin_out_unread(vo_c->filter->f->pins[1], frame);
img = NULL;
r = VD_EOF;
- } else if (hrseek && (img->pts < mpctx->hrseek_pts - .005 ||
+ } else if (hrseek && (img->pts < hrseek_pts - .005 ||
mpctx->hrseek_lastframe))
{
/* just skip - but save in case it was the last frame */
mp_image_setrefp(&mpctx->saved_frame, img);
- } else if (mpctx->video_status == STATUS_SYNCING &&
- mpctx->playback_pts != MP_NOPTS_VALUE &&
- img->pts < mpctx->playback_pts && !vo_c->is_coverart)
- {
- /* skip after stream-switching */
} else {
if (hrseek && mpctx->hrseek_backstep) {
if (mpctx->saved_frame) {