Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
Collect the subtitles at the same time to prevent overlap. (collect_s…
Browse files Browse the repository at this point in the history
…ubtitles xbmc#4885)
  • Loading branch information
epoke committed Jun 16, 2014
1 parent fc212a4 commit 97b3192
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
13 changes: 13 additions & 0 deletions xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayText.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ class CDVDOverlayText : public CDVDOverlay
}
}

void AddElement(CDVDOverlayText *pOverlay)
{
for (CElement* e = pOverlay->m_pHead; e; e = e->pNext)
{
if (e->IsElementType(ELEMENT_TYPE_TEXT))
AddElement(new CElementText(*static_cast<CElementText*>(e)));
else if (e->IsElementType(ELEMENT_TYPE_PROPERTY))
AddElement(new CElementProperty(*static_cast<CElementProperty*>(e)));
else
AddElement(new CElement(*static_cast<CElement*>(e)));
}
}

CElement* m_pHead;
CElement* m_pEnd;
};
Expand Down
47 changes: 40 additions & 7 deletions xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitleLineCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "DVDSubtitleLineCollection.h"
#include "DVDClock.h"
#include "DVDCodecs/Overlay/DVDOverlayText.h"


CDVDSubtitleLineCollection::CDVDSubtitleLineCollection()
Expand Down Expand Up @@ -81,19 +82,51 @@ CDVDOverlay* CDVDSubtitleLineCollection::Get(double iPts)

if (m_pCurrent)
{
while (m_pCurrent && m_pCurrent->pOverlay->iPTSStopTime < iPts)
if (m_pCurrent->pOverlay->IsOverlayType(DVDOVERLAY_TYPE_TEXT))
{
m_pCurrent = m_pCurrent->pNext;
}
static double iPrevPts = 0.0;

if (iPts == iPrevPts)
return NULL;

if (m_pCurrent)
CDVDOverlayText* pOverlayText = NULL;

for (ListElement* p1 = m_pHead; p1->pNext->pNext != NULL; p1 = p1->pNext)
{
if (p1->pOverlay->iPTSStartTime <= iPts
&& (p1->pOverlay->iPTSStopTime >= iPts || p1->pOverlay->iPTSStopTime == 0LL))
{
if (!pOverlayText)
{
pOverlayText = new CDVDOverlayText(static_cast<CDVDOverlayText&>(*p1->pOverlay));
}
else
{
pOverlayText->AddElement(static_cast<CDVDOverlayText*>(p1->pOverlay));
}
}
}

iPrevPts = iPts;
pOverlay = static_cast<CDVDOverlay*> (pOverlayText);
}
else
{
pOverlay = m_pCurrent->pOverlay;
while (m_pCurrent && m_pCurrent->pOverlay->iPTSStopTime < iPts)
{
m_pCurrent = m_pCurrent->pNext;
}

if (m_pCurrent)
{
pOverlay = m_pCurrent->pOverlay;

// advance to the next overlay
m_pCurrent = m_pCurrent->pNext;
// advance to the next overlay
m_pCurrent = m_pCurrent->pNext;
}
}
}

return pOverlay;
}

Expand Down

0 comments on commit 97b3192

Please sign in to comment.