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;
165 memcpy(&subtitle, inpos,
sizeof(subtitle));
170 if (subtitle.
row == 0)
176 LOG(VB_VBI, LOG_DEBUG,
"erase displayed memory");
185 unsigned char *end = inpos + subtitle.
len;
189 auto *ccbuf =
new std::vector<CC608Text*>;
191 int replace = linecont;
193 bool scroll_prsv =
false;
195 int scroll_ymax = 15;
205 while ((inpos < end) && *inpos != 0 && (char)*inpos ==
'\b')
212 m_state[streamIdx].m_outputText.remove(
213 m_state[streamIdx].m_outputText.length() - bscnt,
221 m_state[streamIdx].m_outputCol = 0;
222 m_state[streamIdx].m_outputText =
"";
223 while ((inpos < end) && *inpos != 0 && (char)*inpos ==
' ')
226 m_state[streamIdx].m_outputCol++;
230 m_state[streamIdx].m_outputRow = subtitle.
row;
231 unsigned char *cur = inpos;
234 while (cur < end && *cur !=
'\n' && *cur != 0)
238 if (*inpos != 0 || linecont)
242 m_state[streamIdx].m_outputText +=
243 QString::fromUtf8((
const char *)inpos, -1);
247 m_state[streamIdx].m_outputText =
248 QString::fromUtf8((
const char *)inpos, -1);
251 m_state[streamIdx].m_outputText,
252 m_state[streamIdx].m_outputCol,
253 m_state[streamIdx].m_outputRow);
254 ccbuf->push_back(tmpcc);
256 if (ccbuf->size() > 4)
257 LOG(VB_VBI, LOG_DEBUG, QString(
"CC overflow: %1 %2 %3")
258 .arg(
m_state[streamIdx].m_outputCol)
259 .arg(
m_state[streamIdx].m_outputRow)
260 .arg(
m_state[streamIdx].m_outputText));
266 }
while (inpos < end);
274 if (
m_state[streamIdx].m_outputRow > 15)
277 scroll =
m_state[streamIdx].m_outputRow - 15;
282 else if (subtitle.
rowcount == 0 || row > 1)
286 if (
m_state[streamIdx].m_outputRow > 15)
288 for (
auto & ccp : *ccbuf)
291 tmpcc->
m_y -= (
m_state[streamIdx].m_outputRow - 15);
315 scroll_ymax =
m_state[streamIdx].m_outputRow;
320 scroll_prsv, scroll_yoff, scroll_ymax, streamIdx);
337 memcpy(&pagenr, inpos,
sizeof(
int));
338 inpos +=
sizeof(int);
350 std::vector<CC608Text*> *ccbuf,
int replace,
int scroll,
bool scroll_prsv,
351 int scroll_yoff,
int scroll_ymax,
int streamIdx)
360 LOG(VB_VBI, LOG_DEBUG, QString(
"%1:%2 ").arg(__FUNCTION__).arg(__LINE__) +
361 QString(
"replace:%1 ").arg(replace) +
362 QString(
"scroll:%1 ").arg(scroll) +
363 QString(
"scroll_prsv:%1 ").arg(scroll_prsv) +
364 QString(
"scroll_yoff:%1 ").arg(scroll_yoff) +
365 QString(
"scroll_ymax:%1 ").arg(scroll_ymax) +
366 QString(
"streamIdx:%1 ").arg(streamIdx));
368 std::vector<CC608Text*>::iterator i;
371 m_state[streamIdx].m_output.m_lock.lock();
372 if (!
m_state[streamIdx].m_output.m_buffers.empty() && (scroll || replace))
376 i =
m_state[streamIdx].m_output.m_buffers.end() - 1;
382 int ydel = scroll_yoff + scroll;
383 int ykeep = scroll_ymax;
385 if (scroll_prsv && ylast)
387 ymove = ylast - scroll_ymax;
392 i =
m_state[streamIdx].m_output.m_buffers.begin();
393 while (i <
m_state[streamIdx].m_output.m_buffers.end())
398 i =
m_state[streamIdx].m_output.m_buffers.erase(i);
402 if (
cc->m_y > (ylast - replace))
406 i =
m_state[streamIdx].m_output.m_buffers.erase(i);
410 if (
cc->m_y > ydel &&
cc->m_y <= ykeep)
413 cc->m_y -= (scroll + ymove);
419 i =
m_state[streamIdx].m_output.m_buffers.erase(i);
430 visible +=
m_state[streamIdx].m_output.m_buffers.size();
435 for (i = ccbuf->begin(); i != ccbuf->end(); ++i)
440 m_state[streamIdx].m_output.m_buffers.push_back(*i);
444 m_state[streamIdx].m_changed = (visible != 0);
445 m_state[streamIdx].m_output.m_lock.unlock();
464 if (
output && outputStreamIdx < 0)
470 if (
output && outputStreamIdx >= 0)
472 outputStreamIdx = std::min(outputStreamIdx,
MAXOUTBUFFERS - 1);
473 m_state[outputStreamIdx].Clear();
496 std::chrono::milliseconds timecode,
char type)
506 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")