mirror of https://github.com/mpv-player/mpv
player: fix recent speed change regression
Commit 5afc025c
broke this. The reason is that mpctx->delay is updated
when a new video frame is added. This value is also needed to resync
audio, but it will be for the wrong PTS. They must be consistent with
each other, and if they aren't, initial sync will be off by N video
frames, which results at least in worse user experience.
This can be reproduced by for example heavily switching between normal
and 2x speed, or similar.
Fix by readding the video_next_pts field (keeping its use minimal,
instead of reverting the commit that removed it).
This commit is contained in:
parent
75005ec06d
commit
4c25b000b5
|
@ -329,8 +329,8 @@ static bool get_sync_samples(struct MPContext *mpctx, int *skip)
|
||||||
|
|
||||||
double sync_pts = MP_NOPTS_VALUE;
|
double sync_pts = MP_NOPTS_VALUE;
|
||||||
if (sync_to_video) {
|
if (sync_to_video) {
|
||||||
if (mpctx->video_pts != MP_NOPTS_VALUE) {
|
if (mpctx->video_next_pts != MP_NOPTS_VALUE) {
|
||||||
sync_pts = mpctx->video_pts;
|
sync_pts = mpctx->video_next_pts;
|
||||||
} else if (mpctx->video_status < STATUS_READY) {
|
} else if (mpctx->video_status < STATUS_READY) {
|
||||||
return false; // wait until we know a video PTS
|
return false; // wait until we know a video PTS
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,6 +275,8 @@ typedef struct MPContext {
|
||||||
* (or at least queued to be flipped by VO) */
|
* (or at least queued to be flipped by VO) */
|
||||||
double video_pts;
|
double video_pts;
|
||||||
double last_seek_pts;
|
double last_seek_pts;
|
||||||
|
// Mostly unused; for proper audio resync on speed changes.
|
||||||
|
double video_next_pts;
|
||||||
// As video_pts, but is not reset when seeking away. (For the very short
|
// As video_pts, but is not reset when seeking away. (For the very short
|
||||||
// period of time until a new frame is decoded and shown.)
|
// period of time until a new frame is decoded and shown.)
|
||||||
double last_vo_pts;
|
double last_vo_pts;
|
||||||
|
|
|
@ -215,6 +215,7 @@ void reset_video_state(struct MPContext *mpctx)
|
||||||
mpctx->delay = 0;
|
mpctx->delay = 0;
|
||||||
mpctx->time_frame = 0;
|
mpctx->time_frame = 0;
|
||||||
mpctx->video_pts = MP_NOPTS_VALUE;
|
mpctx->video_pts = MP_NOPTS_VALUE;
|
||||||
|
mpctx->video_next_pts = MP_NOPTS_VALUE;
|
||||||
mpctx->total_avsync_change = 0;
|
mpctx->total_avsync_change = 0;
|
||||||
mpctx->drop_frame_cnt = 0;
|
mpctx->drop_frame_cnt = 0;
|
||||||
mpctx->dropped_frames = 0;
|
mpctx->dropped_frames = 0;
|
||||||
|
@ -552,6 +553,7 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
|
||||||
MP_WARN(mpctx, "Jump in video pts: %f -> %f\n", last_pts, pts);
|
MP_WARN(mpctx, "Jump in video pts: %f -> %f\n", last_pts, pts);
|
||||||
frame_time = 0;
|
frame_time = 0;
|
||||||
}
|
}
|
||||||
|
mpctx->video_next_pts = pts;
|
||||||
if (mpctx->d_audio)
|
if (mpctx->d_audio)
|
||||||
mpctx->delay -= frame_time;
|
mpctx->delay -= frame_time;
|
||||||
if (mpctx->video_status >= STATUS_READY) {
|
if (mpctx->video_status >= STATUS_READY) {
|
||||||
|
|
Loading…
Reference in New Issue