38 bool last_changed =
true;
75 m_state[streamIdx].m_changed =
false;
76 return &
m_state[streamIdx].m_output;
101 memcpy(&pagenr, inpos,
sizeof(
int));
102 inpos +=
sizeof(int);
112 memcpy(&st, inpos,
sizeof(st));
120 QString((
const char*) inpos), st.
row, st.
col);
122 m_state[streamIdx].m_output.lock.lock();
123 m_state[streamIdx].m_output.buffers.push_back(cc);
124 m_state[streamIdx].m_output.lock.unlock();
145 m_state[streamIdx].m_changed =
false;
146 return &
m_state[streamIdx].m_output;
167 memcpy(&subtitle, inpos,
sizeof(subtitle));
172 if (subtitle.
row == 0)
178 LOG(VB_VBI, LOG_DEBUG,
"erase displayed memory");
187 unsigned char *end = inpos + subtitle.
len;
191 auto *ccbuf =
new std::vector<CC608Text*>;
193 int replace = linecont;
195 bool scroll_prsv =
false;
197 int scroll_ymax = 15;
207 while ((inpos < end) && *inpos != 0 && (char)*inpos ==
'\b')
214 m_state[streamIdx].m_outputText.remove(
215 m_state[streamIdx].m_outputText.length() - bscnt,
223 m_state[streamIdx].m_outputCol = 0;
224 m_state[streamIdx].m_outputText =
"";
225 while ((inpos < end) && *inpos != 0 && (char)*inpos ==
' ')
228 m_state[streamIdx].m_outputCol++;
232 m_state[streamIdx].m_outputRow = subtitle.
row;
233 unsigned char *cur = inpos;
236 while (cur < end && *cur !=
'\n' && *cur != 0)
240 if (*inpos != 0 || linecont)
244 m_state[streamIdx].m_outputText +=
245 QString::fromUtf8((
const char *)inpos, -1);
249 m_state[streamIdx].m_outputText =
250 QString::fromUtf8((
const char *)inpos, -1);
253 m_state[streamIdx].m_outputText,
254 m_state[streamIdx].m_outputCol,
255 m_state[streamIdx].m_outputRow);
256 ccbuf->push_back(tmpcc);
258 if (ccbuf->size() > 4)
259 LOG(VB_VBI, LOG_DEBUG, QString(
"CC overflow: %1 %2 %3")
260 .arg(
m_state[streamIdx].m_outputCol)
261 .arg(
m_state[streamIdx].m_outputRow)
262 .arg(
m_state[streamIdx].m_outputText));
268 }
while (inpos < end);
276 if (
m_state[streamIdx].m_outputRow > 15)
279 scroll =
m_state[streamIdx].m_outputRow - 15;
284 else if (subtitle.
rowcount == 0 || row > 1)
288 if (
m_state[streamIdx].m_outputRow > 15)
290 for (
auto & ccp : *ccbuf)
293 tmpcc->
m_y -= (
m_state[streamIdx].m_outputRow - 15);
317 scroll_ymax =
m_state[streamIdx].m_outputRow;
322 scroll_prsv, scroll_yoff, scroll_ymax, streamIdx);
339 memcpy(&pagenr, inpos,
sizeof(
int));
340 inpos +=
sizeof(int);
352 std::vector<CC608Text*> *ccbuf,
int replace,
int scroll,
bool scroll_prsv,
353 int scroll_yoff,
int scroll_ymax,
int streamIdx)
362 LOG(VB_VBI, LOG_DEBUG, QString(
"%1:%2 ").arg(__FUNCTION__).arg(__LINE__) +
363 QString(
"replace:%1 ").arg(replace) +
364 QString(
"scroll:%1 ").arg(scroll) +
365 QString(
"scroll_prsv:%1 ").arg(scroll_prsv) +
366 QString(
"scroll_yoff:%1 ").arg(scroll_yoff) +
367 QString(
"scroll_ymax:%1 ").arg(scroll_ymax) +
368 QString(
"streamIdx:%1 ").arg(streamIdx));
370 std::vector<CC608Text*>::iterator i;
373 m_state[streamIdx].m_output.m_lock.lock();
374 if (!
m_state[streamIdx].m_output.m_buffers.empty() && (scroll || replace))
378 i =
m_state[streamIdx].m_output.m_buffers.end() - 1;
384 int ydel = scroll_yoff + scroll;
385 int ykeep = scroll_ymax;
387 if (scroll_prsv && ylast)
389 ymove = ylast - scroll_ymax;
394 i =
m_state[streamIdx].m_output.m_buffers.begin();
395 while (i <
m_state[streamIdx].m_output.m_buffers.end())
400 i =
m_state[streamIdx].m_output.m_buffers.erase(i);
404 if (cc->
m_y > (ylast - replace))
408 i =
m_state[streamIdx].m_output.m_buffers.erase(i);
412 if (cc->
m_y > ydel && cc->
m_y <= ykeep)
415 cc->
m_y -= (scroll + ymove);
421 i =
m_state[streamIdx].m_output.m_buffers.erase(i);
432 visible +=
m_state[streamIdx].m_output.m_buffers.size();
437 for (i = ccbuf->begin(); i != ccbuf->end(); ++i)
442 m_state[streamIdx].m_output.m_buffers.push_back(*i);
446 m_state[streamIdx].m_changed = (visible != 0);
447 m_state[streamIdx].m_output.m_lock.unlock();
466 if (
output && outputStreamIdx < 0)
472 if (
output && outputStreamIdx >= 0)
474 outputStreamIdx = std::min(outputStreamIdx,
MAXOUTBUFFERS - 1);
475 m_state[outputStreamIdx].Clear();
498 std::chrono::milliseconds timecode,
char type)
508 LOG(VB_VBI, LOG_ERR,
"AddTextData(): Text buffer overflow");
533 LOG(VB_VBI, LOG_INFO,
534 QString(
"Writing caption timecode %1 but waiting on %2")