Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2015-03-25 01:38:57 +0300
committerHendrik Leppkes <h.leppkes@gmail.com>2015-03-25 01:38:57 +0300
commit56ceb369b7f20c33bcbf7000a32a618e26c9ccd3 (patch)
treeb554a206cd9b761ffc5e635484784a99c0c73cfe /decoder
parentc374e1faf0791169a6d71cb80c4ced0a3868ee53 (diff)
Use current time as subtitle timestamp if no other timestamp is available.
This fixes timeout of subtitles on some discs.
Diffstat (limited to 'decoder')
-rw-r--r--decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp12
-rw-r--r--decoder/LAVVideo/subtitles/LAVSubtitleProvider.h1
2 files changed, 12 insertions, 1 deletions
diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp
index 1a01b9f1..7596fa7c 100644
--- a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp
+++ b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp
@@ -128,6 +128,8 @@ STDMETHODIMP CLAVSubtitleProvider::RequestFrame(REFERENCE_TIME start, REFERENCE_
subtitleFrame->AddBitmap(pRect);
}
}
+
+ m_rtLastFrame = start;
}
if (subtitleFrame->Empty()) {
@@ -197,6 +199,7 @@ STDMETHODIMP CLAVSubtitleProvider::Flush()
ClearSubtitleRects();
SAFE_DELETE(m_pHLI);
+ m_rtLastFrame = 0;
m_pLAVVideo->SetInDVDMenu(false);
return S_OK;
@@ -308,16 +311,23 @@ void CLAVSubtitleProvider::ProcessSubtitleFrame(AVSubtitle *sub, REFERENCE_TIME
DbgLog((LOG_TRACE, 10, L"Decoded Sub: rtStart: %I64d, start_display_time: %d, end_display_time: %d, num_rects: %u, num_dvd_palette: %d", rtStart, sub->start_display_time, sub->end_display_time, sub->num_rects, sub->num_dvd_palette));
if (sub->num_rects > 0) {
if (m_pAVCtx->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {
+ CAutoLock lock(this);
+
// DVD subs have the limitation that only one subtitle can be shown at a given time,
// so we need to timeout unlimited subs when a new one appears, as well as limit the duration of timed subs
// to prevent overlapping subtitles
REFERENCE_TIME rtSubTimeout = (rtStart != AV_NOPTS_VALUE) ? rtStart - 1 : SUBTITLE_PTS_TIMEOUT;
- CAutoLock lock(this);
for (auto it = m_SubFrames.begin(); it != m_SubFrames.end(); it++) {
if ((*it)->rtStop == AV_NOPTS_VALUE || rtStart == AV_NOPTS_VALUE || (*it)->rtStop > rtStart) {
(*it)->rtStop = rtSubTimeout;
}
}
+
+ // Override subtitle timestamps if we have a timeout, and are not in a menu
+ if (rtStart == AV_NOPTS_VALUE && sub->end_display_time > 0 && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED)) {
+ DbgLog((LOG_TRACE, 10, L" -> Overriding subtitle timestamp to %I64d", m_rtLastFrame));
+ rtStart = m_rtLastFrame;
+ }
}
REFERENCE_TIME rtStop = AV_NOPTS_VALUE;
diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h
index f8e17b24..cf8b044a 100644
--- a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h
+++ b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.h
@@ -78,6 +78,7 @@ private:
AVCodecContext *m_pAVCtx = nullptr;
AVCodecParserContext *m_pParser = nullptr;
+ REFERENCE_TIME m_rtLastFrame = 0;
REFERENCE_TIME m_rtStartCache = AV_NOPTS_VALUE;
ULONGLONG m_SubPicId = 0;
BOOL m_bComposit = TRUE;