36 bool last_changed =
true;
73 m_state[streamIdx].m_changed =
false;
74 return &
m_state[streamIdx].m_output;
99 memcpy(&pagenr, inpos,
sizeof(
int));
100 inpos +=
sizeof(int);
110 memcpy(&st, inpos,
sizeof(st));
118 QString((
const char*) inpos), st.
row, st.
col);
120 m_state[streamIdx].m_output.lock.lock();
121 m_state[streamIdx].m_output.buffers.push_back(
cc);
122 m_state[streamIdx].m_output.lock.unlock();
143 m_state[streamIdx].m_changed =
false;
144 return &
m_state[streamIdx].m_output;
163 memcpy(&subtitle, inpos,
sizeof(subtitle));
168 if (subtitle.
row == 0)
174 LOG(VB_VBI, LOG_DEBUG,
"erase displayed memory");
183 unsigned char *end = inpos + subtitle.
len;
187 auto *ccbuf =
new std::vector<CC608Text*>;
189 int replace = linecont;
191 bool scroll_prsv =
false;
193 int scroll_ymax = 15;
203 while ((inpos < end) && *inpos != 0 && (char)*inpos ==
'\b')
210 m_state[streamIdx].m_outputText.remove(
211 m_state[streamIdx].m_outputText.length() - bscnt,
219 m_state[streamIdx].m_outputCol = 0;
220 m_state[streamIdx].m_outputText =
"";
221 while ((inpos < end) && *inpos != 0 && (char)*inpos ==
' ')
224 m_state[streamIdx].m_outputCol++;
228 m_state[streamIdx].m_outputRow = subtitle.
row;
229 unsigned char *cur = inpos;
232 while (cur < end && *cur !=
'\n' && *cur != 0)
236 if (*inpos != 0 || linecont)
240 m_state[streamIdx].m_outputText +=
241 QString::fromUtf8((
const char *)inpos, -1);
245 m_state[streamIdx].m_outputText =
246 QString::fromUtf8((
const char *)inpos, -1);
249 m_state[streamIdx].m_outputText,
250 m_state[streamIdx].m_outputCol,
251 m_state[streamIdx].m_outputRow);
252 ccbuf->push_back(tmpcc);
254 if (ccbuf->size() > 4)
255 LOG(VB_VBI, LOG_DEBUG, QString(
"CC overflow: %1 %2 %3")
256 .arg(
m_state[streamIdx].m_outputCol)
257 .arg(
m_state[streamIdx].m_outputRow)
258 .arg(
m_state[streamIdx].m_outputText));
264 }
while (inpos < end);
272 if (
m_state[streamIdx].m_outputRow > 15)
275 scroll =
m_state[streamIdx].m_outputRow - 15;
280 else if (subtitle.
rowcount == 0 || row > 1)
284 if (
m_state[streamIdx].m_outputRow > 15)
286 for (
auto & ccp : *ccbuf)
289 tmpcc->
m_y -= (
m_state[streamIdx].m_outputRow - 15);
314 scroll_ymax =
m_state[streamIdx].m_outputRow;
319 scroll_prsv, scroll_yoff, scroll_ymax, streamIdx);
336 memcpy(&pagenr, inpos,
sizeof(
int));
337 inpos +=
sizeof(int);
349 std::vector<CC608Text*> *ccbuf,
int replace,
int scroll,
bool scroll_prsv,
350 int scroll_yoff,
int scroll_ymax,
int streamIdx)
359 LOG(VB_VBI, LOG_DEBUG, QString(
"%1:%2 ").arg(__FUNCTION__).arg(__LINE__) +
360 QString(
"replace:%1 ").arg(replace) +
361 QString(
"scroll:%1 ").arg(scroll) +
362 QString(
"scroll_prsv:%1 ").arg(scroll_prsv) +
363 QString(
"scroll_yoff:%1 ").arg(scroll_yoff) +
364 QString(
"scroll_ymax:%1 ").arg(scroll_ymax) +
365 QString(
"streamIdx:%1 ").arg(streamIdx));
367 std::vector<CC608Text*>::iterator i;
370 m_state[streamIdx].m_output.m_lock.lock();
371 if (!
m_state[streamIdx].m_output.m_buffers.empty() && (scroll || replace))
375 i =
m_state[streamIdx].m_output.m_buffers.end() - 1;
381 int ydel = scroll_yoff + scroll;
382 int ykeep = scroll_ymax;
384 if (scroll_prsv && ylast)
386 ymove = ylast - scroll_ymax;
391 i =
m_state[streamIdx].m_output.m_buffers.begin();
392 while (i <
m_state[streamIdx].m_output.m_buffers.end())
397 i =
m_state[streamIdx].m_output.m_buffers.erase(i);
401 if (
cc->m_y > (ylast - replace))
405 i =
m_state[streamIdx].m_output.m_buffers.erase(i);
409 if (
cc->m_y > ydel &&
cc->m_y <= ykeep)
412 cc->m_y -= (scroll + ymove);
418 i =
m_state[streamIdx].m_output.m_buffers.erase(i);
429 visible +=
m_state[streamIdx].m_output.m_buffers.size();
434 for (i = ccbuf->begin(); i != ccbuf->end(); ++i)
439 m_state[streamIdx].m_output.m_buffers.push_back(*i);
443 m_state[streamIdx].m_changed = (visible != 0);
444 m_state[streamIdx].m_output.m_lock.unlock();
463 if (
output && outputStreamIdx < 0)
469 if (
output && outputStreamIdx >= 0)
471 outputStreamIdx = std::min(outputStreamIdx,
MAXOUTBUFFERS - 1);
472 m_state[outputStreamIdx].Clear();
495 std::chrono::milliseconds timecode,
char type)
505 LOG(VB_VBI, LOG_ERR,
"AddTextData(): Text buffer overflow");
531 LOG(VB_VBI, LOG_INFO,
532 QString(
"Writing caption timecode %1 but waiting on %2")