diff options
author | Underground78 <underground78@users.sourceforge.net> | 2013-05-01 23:13:17 +0400 |
---|---|---|
committer | Underground78 <underground78@users.sourceforge.net> | 2013-05-01 23:20:07 +0400 |
commit | 885c54a405e70ef8250e2f209edfb958adff8c45 (patch) | |
tree | 2ba5e501a76b43c370980998e2e7ebb197aae002 | |
parent | abb252094a0b386ea78a0360815dbcb9bd29c08a (diff) |
PGS and DVB subtitles: Fix missing subtitles after resizing the window.
When using the subpicture queue along with PGS and DVB subtitles, some subtitles were missing after the window was resized.
-rw-r--r-- | docs/Changelog.txt | 2 | ||||
-rw-r--r-- | src/Subtitles/DVBSub.cpp | 31 | ||||
-rw-r--r-- | src/Subtitles/DVBSub.h | 2 | ||||
-rw-r--r-- | src/Subtitles/HdmvSub.cpp | 29 | ||||
-rw-r--r-- | src/Subtitles/HdmvSub.h | 4 |
5 files changed, 46 insertions, 22 deletions
diff --git a/docs/Changelog.txt b/docs/Changelog.txt index f08abddf6..cd7164aab 100644 --- a/docs/Changelog.txt +++ b/docs/Changelog.txt @@ -18,6 +18,8 @@ Legend: - Use percentage for the boost setting since it is easier to understand for most people
- Add a setting to change the max normalization factor and use a max normalization factor
of 4 by default instead of 10
+! PGS and DVB subtitles: Fix missing subtitles after resizing the window when using
+ the subpicture queue.
1.6.7 - 25 April 2013
diff --git a/src/Subtitles/DVBSub.cpp b/src/Subtitles/DVBSub.cpp index c963aa915..917f2ae9e 100644 --- a/src/Subtitles/DVBSub.cpp +++ b/src/Subtitles/DVBSub.cpp @@ -331,6 +331,8 @@ void CDVBSub::EndOfStream() void CDVBSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox)
{
+ RemoveOldPages(rt);
+
DVB_PAGE* pPage = FindPage(rt);
if (pPage != NULL) {
@@ -377,23 +379,17 @@ HRESULT CDVBSub::GetTextureSize(POSITION pos, SIZE& MaxTextureSize, SIZE& VideoS POSITION CDVBSub::GetStartPosition(REFERENCE_TIME rt, double fps)
{
- DVB_PAGE* pPage;
-
- // Cleanup old PG
- while (m_Pages.GetCount() > 0) {
- pPage = m_Pages.GetHead();
+ POSITION pos = m_Pages.GetHeadPosition();
+ while (pos) {
+ DVB_PAGE* pPage = m_Pages.GetAt(pos);
if (pPage->rtStop < rt) {
- if (!pPage->rendered) {
- TRACE_DVB(_T("DVB - remove unrendered object, %s - %s\n"), ReftimeToString(pPage->rtStart), ReftimeToString(pPage->rtStop));
- }
- m_Pages.RemoveHead();
- delete pPage;
+ m_Pages.GetNext(pos);
} else {
break;
}
}
- return m_Pages.GetHeadPosition();
+ return pos;
}
POSITION CDVBSub::GetNext(POSITION pos)
@@ -427,6 +423,19 @@ void CDVBSub::Reset() }
}
+void CDVBSub::RemoveOldPages(REFERENCE_TIME rt)
+{
+ // Cleanup the old pages. We keep a 2 min buffer to play nice with the queue.
+ while (m_Pages.GetCount() > 0 && m_Pages.GetHead()->rtStop + 120 * 10000000i64 < rt) {
+ DVB_PAGE* pPage = m_Pages.GetHead();
+ if (!pPage->rendered) {
+ TRACE_DVB(_T("DVB - remove unrendered object, %s - %s\n"), ReftimeToString(pPage->rtStart), ReftimeToString(pPage->rtStop));
+ }
+ m_Pages.RemoveHead();
+ delete pPage;
+ }
+}
+
HRESULT CDVBSub::ParsePage(CGolombBuffer& gb, WORD wSegLength, CAutoPtr<DVB_PAGE>& pPage)
{
int nEnd = gb.GetPos() + wSegLength;
diff --git a/src/Subtitles/DVBSub.h b/src/Subtitles/DVBSub.h index 204e3105c..cd6ab56e3 100644 --- a/src/Subtitles/DVBSub.h +++ b/src/Subtitles/DVBSub.h @@ -225,4 +225,6 @@ private: HRESULT EnqueuePage(REFERENCE_TIME rtStop);
HRESULT UpdateTimeStamp(REFERENCE_TIME rtStop);
+
+ void RemoveOldPages(REFERENCE_TIME rt);
};
diff --git a/src/Subtitles/HdmvSub.cpp b/src/Subtitles/HdmvSub.cpp index 6ef986ff2..57df6cfd3 100644 --- a/src/Subtitles/HdmvSub.cpp +++ b/src/Subtitles/HdmvSub.cpp @@ -62,22 +62,17 @@ void CHdmvSub::AllocSegment(int nSize) POSITION CHdmvSub::GetStartPosition(REFERENCE_TIME rt, double fps)
{
- HDMV_PRESENTATION_SEGMENT* pPresentationSegment;
-
- // Cleanup old PG
- while (m_pPresentationSegments.GetCount() > 0) {
- pPresentationSegment = m_pPresentationSegments.GetHead();
+ POSITION pos = m_pPresentationSegments.GetHeadPosition();
+ while (pos) {
+ HDMV_PRESENTATION_SEGMENT* pPresentationSegment = m_pPresentationSegments.GetAt(pos);
if (pPresentationSegment->rtStop < rt) {
- TRACE_HDMVSUB(_T("CHdmvSub:HDMV Remove Presentation segment %d %s => %s (rt=%s)\n"), pPresentationSegment->composition_descriptor.nNumber,
- ReftimeToString(pPresentationSegment->rtStart), ReftimeToString(pPresentationSegment->rtStop), ReftimeToString(rt));
- m_pPresentationSegments.RemoveHead();
- delete pPresentationSegment;
+ m_pPresentationSegments.GetNext(pos);
} else {
break;
}
}
- return m_pPresentationSegments.GetHeadPosition();
+ return pos;
}
HRESULT CHdmvSub::ParseSample(IMediaSample* pSample)
@@ -308,6 +303,8 @@ void CHdmvSub::ParseCompositionDescriptor(CGolombBuffer* pGBuffer, COMPOSITION_D void CHdmvSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox)
{
+ RemoveOldSegments(rt);
+
HDMV_PRESENTATION_SEGMENT* pPresentationSegment = FindPresentationSegment(rt);
bbox.left = LONG_MAX;
@@ -370,6 +367,18 @@ void CHdmvSub::Reset() }
}
+void CHdmvSub::RemoveOldSegments(REFERENCE_TIME rt)
+{
+ // Cleanup the old presentation segments. We keep a 2 min buffer to play nice with the queue.
+ while (m_pPresentationSegments.GetCount() > 0 && m_pPresentationSegments.GetHead()->rtStop + 120 * 10000000i64 < rt) {
+ HDMV_PRESENTATION_SEGMENT* pPresentationSegment = m_pPresentationSegments.RemoveHead();
+ TRACE_HDMVSUB(_T("CHdmvSub::RemoveOldSegments Remove presentation segment %d %s => %s (rt=%s)\n"),
+ pPresentationSegment->composition_descriptor.nNumber,
+ ReftimeToString(pPresentationSegment->rtStart), ReftimeToString(pPresentationSegment->rtStop), ReftimeToString(rt));
+ delete pPresentationSegment;
+ }
+}
+
CHdmvSub::HDMV_PRESENTATION_SEGMENT* CHdmvSub::FindPresentationSegment(REFERENCE_TIME rt)
{
POSITION pos = m_pPresentationSegments.GetHeadPosition();
diff --git a/src/Subtitles/HdmvSub.h b/src/Subtitles/HdmvSub.h index 4404bc3b6..3f67d2700 100644 --- a/src/Subtitles/HdmvSub.h +++ b/src/Subtitles/HdmvSub.h @@ -1,5 +1,5 @@ /*
- * (C) 2006-2012 see Authors.txt
+ * (C) 2006-2013 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -149,4 +149,6 @@ private: HDMV_PRESENTATION_SEGMENT* FindPresentationSegment(REFERENCE_TIME rt);
CompositionObject* FindObject(HDMV_PRESENTATION_SEGMENT* pPresentationSegment, short sObjectId);
+
+ void RemoveOldSegments(REFERENCE_TIME rt);
};
|