diff options
author | James Ross-Gowan <rossy@jrg.systems> | 2019-10-19 00:12:06 +1100 |
---|---|---|
committer | James Ross-Gowan <rossy@jrg.systems> | 2019-10-26 01:14:01 +1100 |
commit | 7384b054335b334d040f11ee22129afc99b77f63 (patch) | |
tree | f97197c08a94f7817b07377e77b1527996a462bf /video/out/d3d11 | |
parent | ca0177481b910c606e482a525d16c698bb340e82 (diff) | |
download | mpv-7384b054335b334d040f11ee22129afc99b77f63.tar.bz2 mpv-7384b054335b334d040f11ee22129afc99b77f63.tar.xz |
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.
Diffstat (limited to 'video/out/d3d11')
-rw-r--r-- | video/out/d3d11/context.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/video/out/d3d11/context.c b/video/out/d3d11/context.c index 62c0f5772f..f03f93df92 100644 --- a/video/out/d3d11/context.c +++ b/video/out/d3d11/context.c @@ -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. |