0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

vo_gpu: d3d11: prevent wraparound in queued frames calc

If expected_sync_pc is greater than submit_count, the unsigned
subtraction will wraparound, which breaks playback. This bug was found
while experimenting with bit-blt model present, but it might be possible
to trigger it with the flip model as well, if there was a dropped frame.
This commit is contained in:
James Ross-Gowan 2019-10-19 00:12:06 +11:00
parent ca0177481b
commit 7384b05433

View File

@ -296,8 +296,9 @@ static void d3d11_get_vsync(struct ra_swapchain *sw, struct vo_vsync_info *info)
// Now guess the timestamp of the last submitted frame based on the
// timestamp of the frame at SyncRefreshCount and the frame rate
int queued_frames = submit_count - expected_sync_pc;
int64_t last_queue_display_time_qpc = stats.SyncQPCTime.QuadPart +
(submit_count - expected_sync_pc) * p->vsync_duration_qpc;
queued_frames * p->vsync_duration_qpc;
// Only set the estimated display time if it's after the last submission
// time. It could be before if mpv skips a lot of frames.