Skip to content

Commit

Permalink
Fixes #10172. Cleanup duration calculations.
Browse files Browse the repository at this point in the history
We just set the 708 duration on clears as if we were getting a regular caption update + we introduce some sanity checking so if length is not initialized or initialized with a 0 ms duration we leave the caption on screen for 750 ms.

Jim, please open new tickets for any additonal problems you notice.
  • Loading branch information
daniel-kristjansson committed Nov 23, 2011
1 parent fb53394 commit 35750c4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
25 changes: 15 additions & 10 deletions mythtv/libs/libmythtv/mythccextractorplayer.cpp
Expand Up @@ -30,6 +30,9 @@ using namespace std;
#include "avformatdecoder.h"
#include "srtwriter.h"


const int OneSubtitle::kDefaultLength = 750; /* ms */

SRTStuff::~SRTStuff()
{
while (!srtwriters.empty())
Expand Down Expand Up @@ -374,6 +377,9 @@ void MythCCExtractorPlayer::Process608Captions(uint flags)

while ((*it).size() > ((kProcessFinalize & flags) ? 0 : 1))
{
if ((*it).front().length <= 0)
(*it).front().length = OneSubtitle::kDefaultLength;

(*cc608it).srtwriters[idx]->AddSubtitle(
(*it).front(), ++(*cc608it).subs_num[idx]);
(*it).pop_front();
Expand Down Expand Up @@ -437,16 +443,6 @@ void MythCCExtractorPlayer::Ingest708Caption(
cc708win[windowIdx].column = start_column;
cc708win[windowIdx].text = winContent;

if (empty)
{
if (!m_cc708_info[streamId].subs[serviceIdx].empty())
{
OneSubtitle &back = m_cc708_info[streamId].subs[serviceIdx].back();
back.length = m_curTime - back.start_time;
}
return;
}

QMap<uint, QStringList> orderedContent;
QMap<int, Window>::const_iterator ccIt = cc708win.begin();
for (; ccIt != cc708win.end() ; ++ccIt)
Expand Down Expand Up @@ -518,6 +514,9 @@ void MythCCExtractorPlayer::Process708Captions(uint flags)

while ((*it).size() > ((kProcessFinalize & flags) ? 0 : 1))
{
if ((*it).front().length <= 0)
(*it).front().length = OneSubtitle::kDefaultLength;

(*cc708it).srtwriters[idx]->AddSubtitle(
(*it).front(), ++(*cc708it).subs_num[idx]);
(*it).pop_front();
Expand Down Expand Up @@ -603,6 +602,9 @@ void MythCCExtractorPlayer::ProcessTeletext(void)

while (!(*it).empty())
{
if ((*it).front().length <= 0)
(*it).front().length = OneSubtitle::kDefaultLength;

(*ttxit).srtwriters[page]->AddSubtitle(
(*it).front(), ++(*ttxit).subs_num[page]);
(*it).pop_front();
Expand Down Expand Up @@ -735,6 +737,9 @@ void MythCCExtractorPlayer::ProcessDVBSubtitles(uint flags)
QDir stream_dir(m_workingDir.filePath(dir_name));
while (subs.size() > ((kProcessFinalize & flags) ? 0 : 1))
{
if (subs.front().length <= 0)
subs.front().length = OneSubtitle::kDefaultLength;

const OneSubtitle &sub = subs.front();
int64_t end_time = sub.start_time + sub.length;
const QString file_name =
Expand Down
6 changes: 4 additions & 2 deletions mythtv/libs/libmythtv/mythccextractorplayer.h
Expand Up @@ -31,7 +31,7 @@ class MTV_PUBLIC OneSubtitle
/// Time we have to start showing subtitle, msec.
int64_t start_time;
/// Time we have to show subtitle, msec.
int64_t length;
int length;
/// Is this a text subtitle.
bool is_text;
/// Lines of text of subtitles.
Expand All @@ -43,11 +43,13 @@ class MTV_PUBLIC OneSubtitle

OneSubtitle() :
start_time(),
length(500), /* default to 500 milliseconds */
length(-1),
is_text(true),
text(),
img_shift(0, 0)
{}

static const int kDefaultLength;
};

/// Key is a CC number (1-4), values are the subtitles in chrono order.
Expand Down

0 comments on commit 35750c4

Please sign in to comment.