From 0beb0e9d48fb55fe0d5698aeae42ac91410bf513 Mon Sep 17 00:00:00 2001 From: Underground78 Date: Wed, 23 Jul 2014 23:22:56 +0200 Subject: Subtitle queue: Avoid blinking caused by small rounding error. --- src/SubPic/SubPicQueueImpl.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/SubPic') diff --git a/src/SubPic/SubPicQueueImpl.cpp b/src/SubPic/SubPicQueueImpl.cpp index 0951988c9..75f1b5fac 100644 --- a/src/SubPic/SubPicQueueImpl.cpp +++ b/src/SubPic/SubPicQueueImpl.cpp @@ -579,8 +579,14 @@ DWORD CSubPicQueue::ThreadProc() if (bIsAnimated) { REFERENCE_TIME rtEndThis = std::min(rtCurrent + rtTimePerSubFrame, rtStopReal); hr = RenderTo(pStatic, rtCurrent, rtEndThis, fps, bIsAnimated); + // Set the segment start and stop timings pStatic->SetSegmentStart(rtStart); - pStatic->SetSegmentStop(rtStopReal); + // The stop timing can be moved so that the duration from the current start time + // of the subpic to the segment end is always at least one video frame long. This + // avoids missing subtitle frame due to rounding errors in the timings. + // At worst this can cause a segment to be displayed for one more frame than expected + // but it's much less annoying than having the subtitle disappearing for one frame + pStatic->SetSegmentStop(std::max(rtCurrent + rtTimePerFrame, rtStopReal)); rtCurrent = rtEndThis; } else { hr = RenderTo(pStatic, rtStart, rtStopReal, fps, bIsAnimated); -- cgit v1.2.3