MythTV  master
cc608decoder.cpp
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 // Some of the XDS was inspired by code in TVTime. -- dtk 03/30/2006
4 
5 #include <algorithm>
6 #include <vector>
7 
8 // Qt headers
9 #include <QStringList>
10 #include <QCoreApplication>
11 
12 // MythTV headers
13 #include "libmyth/mythcontext.h"
15 
16 #include "format.h"
17 #include "captions/cc608decoder.h"
18 #include "vbilut.h"
19 
20 #define DEBUG_XDS 0
21 
22 static void init_xds_program_type(CC608ProgramType& xds_program_type);
23 
25  : m_reader(ccr),
26  m_rbuf(new unsigned char[sizeof(ccsubtitle)+255])
27 {
28  // fill translation table
29  for (uint i = 0; i < 128; i++)
30  m_stdChar[i] = QChar(i);
31  m_stdChar[42] = QLatin1Char(0xE1); // á
32  m_stdChar[92] = QLatin1Char(0xE9); // é
33  m_stdChar[94] = QLatin1Char(0xED); // í
34  m_stdChar[95] = QLatin1Char(0xF3); // ó
35  m_stdChar[96] = QLatin1Char(0xFA); // ú
36  m_stdChar[123] = QLatin1Char(0xE7); // ç
37  m_stdChar[124] = QLatin1Char(0xF7); // ÷
38  m_stdChar[125] = QLatin1Char(0xD1); // Ñ
39  m_stdChar[126] = QLatin1Char(0xF1); // ñ
40  m_stdChar[127] = QChar(0x2588); // full block
41 
43 }
44 
46 {
47  delete [] m_rbuf;
48 }
49 
50 void CC608Decoder::FormatCC(std::chrono::milliseconds tc, int code1, int code2)
51 {
52  FormatCCField(tc, 0, code1);
53  FormatCCField(tc, 1, code2);
54 }
55 
56 void CC608Decoder::GetServices(std::chrono::seconds seconds, CC608Seen& seen) const
57 {
58  auto then = SystemClock::now() - seconds;
59  for (uint i = 0; i < 4; i++)
60  seen[i] = (m_lastSeen[i] >= then);
61 }
62 
63 static const std::array<const int,16> rowdata =
64 {
65  11, -1, 1, 2, 3, 4, 12, 13,
66  14, 15, 5, 6, 7, 8, 9, 10
67 };
68 
69 static const std::array<const QChar,16> specialchar =
70 {
71  QLatin1Char(0xAE), QLatin1Char(0xB0), QLatin1Char(0xBD), QLatin1Char(0xBF), // ®°½¿
72  QChar(0x2122), QLatin1Char(0xA2), QLatin1Char(0xA3), QChar(0x266A), // ™¢£♪
73  QLatin1Char(0xE0), QLatin1Char(' '), QLatin1Char(0xE8), QLatin1Char(0xE2), // à èâ
74  QLatin1Char(0xEA), QLatin1Char(0xEE), QLatin1Char(0xF4), QLatin1Char(0xFB) // êîôû
75 };
76 
77 static const std::array<const QChar,32> extendedchar2 =
78 {
79  QLatin1Char(0xC1), QLatin1Char(0xC9), QLatin1Char(0xD3), QLatin1Char(0xDA), // ÁÉÓÚ
80  QLatin1Char(0xDC), QLatin1Char(0xFC), QLatin1Char('`'), QLatin1Char(0xA1), // Üü`¡
81  QLatin1Char('*'), QLatin1Char('\''), QChar(0x2014), QLatin1Char(0xA9), // *'-©
82  QChar(0x2120), QLatin1Char(0xB7), QChar(0x201C), QChar(0x201D), // ℠·“”
83  QLatin1Char(0xC0), QLatin1Char(0xC2), QLatin1Char(0xC7), QLatin1Char(0xC8), // ÀÂÇÈ
84  QLatin1Char(0xCA), QLatin1Char(0xCB), QLatin1Char(0xEB), QLatin1Char(0xCE), // ÊËëÎ
85  QLatin1Char(0xCF), QLatin1Char(0xEF), QLatin1Char(0xD4), QLatin1Char(0xD9), // ÏïÔÙ
86  QLatin1Char(0xF9), QLatin1Char(0xDB), QLatin1Char(0xAB), QLatin1Char(0xBB) // ùÛ«»
87 };
88 
89 static const std::array<const QChar,32> extendedchar3 =
90 {
91  QLatin1Char(0xC3), QLatin1Char(0xE3), QLatin1Char(0xCD), QLatin1Char(0xCC), // ÃãÍÌ
92  QLatin1Char(0xEC), QLatin1Char(0xD2), QLatin1Char(0xF2), QLatin1Char(0xD5), // ìÒòÕ
93  QLatin1Char(0xF5), QLatin1Char('{'), QLatin1Char('}'), QLatin1Char('\\'), // õ{}
94  QLatin1Char('^'), QLatin1Char('_'), QLatin1Char(0xA6), QLatin1Char('~'), // ^_¦~
95  QLatin1Char(0xC4), QLatin1Char(0xE4), QLatin1Char(0xD6), QLatin1Char(0xF6), // ÄäÖö
96  QLatin1Char(0xDF), QLatin1Char(0xA5), QLatin1Char(0xA4), QLatin1Char('|'), // ߥ¤|
97  QLatin1Char(0xC5), QLatin1Char(0xE5), QLatin1Char(0xD8), QLatin1Char(0xF8), // ÅåØø
98  QChar(0x250C), QChar(0x2510), QChar(0x2514), QChar(0x2518) // ┌┐└┘
99 };
100 
101 void CC608Decoder::FormatCCField(std::chrono::milliseconds tc, size_t field, int data)
102 {
103  size_t len = 0;
104  size_t mode = 0;
105 
106  if (data == -1) // invalid data. flush buffers to be safe.
107  {
108  // TODO: flush reader buffer
109  if (m_ccMode[field] != -1)
110  {
111  for (mode = field*4; mode < (field*4 + 4); mode++)
112  ResetCC(mode);
113  m_xds[field] = 0;
114  m_badVbi[field] = 0;
115  m_ccMode[field] = -1;
116  m_txtMode[field*2] = 0;
117  m_txtMode[field*2 + 1] = 0;
118  }
119  return;
120  }
121 
122  if ((m_lastFormatData[field&1] == data) &&
123  (m_lastFormatTc[field&1] == tc))
124  {
125  LOG(VB_VBI, LOG_DEBUG, "Format CC -- Duplicate");
126  return;
127  }
128 
129  m_lastFormatTc[field&1] = tc;
130  m_lastFormatData[field&1] = data;
131 
132  int b1 = data & 0x7f;
133  int b2 = (data >> 8) & 0x7f;
134 #if 1
135  LOG(VB_VBI, LOG_DEBUG,
136  QString("Format CC @%1/%2 = %3 %4, %5/%6 = '%7' '%8'")
137  .arg(tc.count()).arg(field)
138  .arg((data&0xff), 2, 16)
139  .arg((data&0xff00)>>8, 2, 16)
140  .arg(b1, 2, 16, QChar('0'))
141  .arg(b2, 2, 16, QChar('0'))
142  .arg(QChar((b1 & 0x60) ? b1 : '_'))
143  .arg(QChar((b2 & 0x60) ? b2 : '_')));
144 #endif
145  if (m_ccMode[field] >= 0)
146  {
147  mode = field << 2 |
148  (m_txtMode[field*2 + m_ccMode[field]] << 1) |
149  m_ccMode[field];
150  if (mode != std::numeric_limits<std::size_t>::max())
151  len = m_ccBuf[mode].length();
152  else
153  len = 0;
154  }
155  else
156  {
157  mode = std::numeric_limits<std::size_t>::max();
158  len = 0;
159  }
160 
161  if (FalseDup(tc, field, data))
162  {
163  if (m_ignoreTimeCode)
164  return;
165  goto skip;
166  }
167 
168  if (XDSDecode(field, b1, b2))
169  return;
170 
171  if (b1 & 0x60)
172  // 0x20 <= b1 <= 0x7F
173  // text codes
174  {
175  if (mode != std::numeric_limits<std::size_t>::max())
176  {
177  m_lastCodeTc[field] += 33ms;
178  m_timeCode[mode] = tc;
179 
180  // commit row number only when first text code
181  // comes in
182  if (m_newRow[mode])
183  NewRowCC(mode, len);
184 
185  m_ccBuf[mode] += CharCC(b1);
186  m_col[mode]++;
187  if (b2 & 0x60)
188  {
189  m_ccBuf[mode] += CharCC(b2);
190  m_col[mode]++;
191  }
192  }
193  }
194 
195  else if ((b1 & 0x10) && (b2 > 0x1F))
196  // 0x10 <= b1 <= 0x1F
197  // control codes
198  {
199  m_lastCodeTc[field] += 67ms;
200 
201  int newccmode = (b1 >> 3) & 1;
202  int newtxtmode = m_txtMode[field*2 + newccmode];
203  if ((b1 & 0x06) == 0x04)
204  {
205  switch (b2)
206  {
207  case 0x29:
208  case 0x2C:
209  case 0x20:
210  case 0x2F:
211  case 0x25:
212  case 0x26:
213  case 0x27:
214  // CC1,2
215  newtxtmode = 0;
216  break;
217  case 0x2A:
218  case 0x2B:
219  // TXT1,2
220  newtxtmode = 1;
221  break;
222  }
223  }
224  m_ccMode[field] = newccmode;
225  m_txtMode[field*2 + newccmode] = newtxtmode;
226  mode = (field << 2) | (newtxtmode << 1) | m_ccMode[field];
227 
228  m_timeCode[mode] = tc;
229  len = m_ccBuf[mode].length();
230 
231  if (b2 & 0x40) //preamble address code (row & indent)
232  {
233  if (newtxtmode)
234  // no address codes in TXT mode?
235  goto skip;
236 
237  m_newRow[mode] = rowdata[((b1 << 1) & 14) | ((b2 >> 5) & 1)];
238  if (m_newRow[mode] == -1)
239  // bogus code?
240  m_newRow[mode] = m_lastRow[mode] + 1;
241 
242  if (b2 & 0x10) //row contains indent flag
243  {
244  m_newCol[mode] = (b2 & 0x0E) << 1;
245  // Encode as 0x7020 or 0x7021 depending on the
246  // underline flag.
247  m_newAttr[mode] = (b2 & 0x1) + 0x20;
248  LOG(VB_VBI, LOG_INFO,
249  QString("cc608 preamble indent, b2=%1")
250  .arg(b2, 2, 16));
251  }
252  else
253  {
254  m_newCol[mode] = 0;
255  m_newAttr[mode] = (b2 & 0xf) + 0x10;
256  // Encode as 0x7010 through 0x702f for the 16 possible
257  // values of b2.
258  LOG(VB_VBI, LOG_INFO,
259  QString("cc608 preamble color change, b2=%1")
260  .arg(b2, 2, 16));
261  }
262 
263  // row, indent, attribute settings are not final
264  // until text code arrives
265  }
266  else
267  {
268  switch (b1 & 0x07)
269  {
270  case 0x00: //attribute
271 #if 0
272  LOG(VB_VBI, LOG_DEBUG,
273  QString("<ATTRIBUTE %1 %2>").arg(b1).arg(b2));
274 #endif
275  break;
276  case 0x01: //midrow or char
277  if (m_newRow[mode])
278  NewRowCC(mode, len);
279 
280  switch (b2 & 0x70)
281  {
282  case 0x20: //midrow attribute change
283  LOG(VB_VBI, LOG_INFO,
284  QString("cc608 mid-row color change, b2=%1")
285  .arg(b2, 2, 16));
286  // Encode as 0x7000 through 0x700f for the
287  // 16 possible values of b2.
288  m_ccBuf[mode] += ' ';
289  m_ccBuf[mode] += QChar(0x7000 + (b2 & 0xf));
290  m_col[mode]++;
291  break;
292  case 0x30: //special character..
293  m_ccBuf[mode] += specialchar[b2 & 0x0f];
294  m_col[mode]++;
295  break;
296  }
297  break;
298  case 0x02: //extended char
299  // extended char is preceded by alternate char
300  // - if there's no alternate, it could be noise
301  if (!len)
302  break;
303 
304  if (b2 & 0x30)
305  {
306  m_ccBuf[mode].remove(len - 1, 1);
307  m_ccBuf[mode] += extendedchar2[b2 - 0x20];
308  break;
309  }
310  break;
311  case 0x03: //extended char
312  // extended char is preceded by alternate char
313  // - if there's no alternate, it could be noise
314  if (!len)
315  break;
316 
317  if (b2 & 0x30)
318  {
319  m_ccBuf[mode].remove(len - 1, 1);
320  m_ccBuf[mode] += extendedchar3[b2 - 0x20];
321  break;
322  }
323  break;
324  case 0x04: //misc
325  case 0x05: //misc + F
326 #if 0
327  LOG(VB_VBI, LOG_DEBUG,
328  QString("ccmode %1 cmd %2").arg(m_ccMode)
329  .arg(b2, 2, 16, '0'));
330 #endif
331  switch (b2)
332  {
333  case 0x21: //backspace
334  // add backspace if line has been encoded already
335  if (m_newRow[mode])
336  len = NewRowCC(mode, len);
337 
338  if (len == 0 ||
339  m_ccBuf[mode].startsWith("\b"))
340  {
341  m_ccBuf[mode] += '\b';
342  m_col[mode]--;
343  }
344  else
345  {
346  m_ccBuf[mode].remove(len - 1, 1);
347  m_col[mode]--;
348  }
349  break;
350  case 0x25: //2 row caption
351  case 0x26: //3 row caption
352  case 0x27: //4 row caption
353  if (m_style[mode] == CC_STYLE_PAINT && len)
354  {
355  // flush
356  BufferCC(mode, len, 0);
357  m_ccBuf[mode] = "";
358  m_row[mode] = 0;
359  m_col[mode] = 0;
360  }
361  else if (m_style[mode] == CC_STYLE_POPUP)
362  ResetCC(mode);
363 
364  m_rowCount[mode] = b2 - 0x25 + 2;
365  m_style[mode] = CC_STYLE_ROLLUP;
366  break;
367  case 0x2D: //carriage return
368  if (m_style[mode] != CC_STYLE_ROLLUP)
369  break;
370 
371  if (m_newRow[mode])
372  m_row[mode] = m_newRow[mode];
373 
374  // flush if there is text or need to scroll
375  // TODO: decode ITV (WebTV) link in TXT2
376  if (len || (m_row[mode] != 0 && !m_lineCont[mode] &&
377  (!newtxtmode || m_row[mode] >= 16)))
378  {
379  BufferCC(mode, len, 0);
380  }
381 
382  if (newtxtmode)
383  {
384  if (m_row[mode] < 16)
385  m_newRow[mode] = m_row[mode] + 1;
386  else
387  // scroll up previous lines
388  m_newRow[mode] = 16;
389  }
390 
391  m_ccBuf[mode] = "";
392  m_col[mode] = 0;
393  m_lineCont[mode] = 0;
394  break;
395 
396  case 0x29:
397  // resume direct caption (paint-on style)
398  if (m_style[mode] == CC_STYLE_ROLLUP && len)
399  {
400  // flush
401  BufferCC(mode, len, 0);
402  m_ccBuf[mode] = "";
403  m_row[mode] = 0;
404  m_col[mode] = 0;
405  }
406  else if (m_style[mode] == CC_STYLE_POPUP)
407  ResetCC(mode);
408 
409  m_style[mode] = CC_STYLE_PAINT;
410  m_rowCount[mode] = 0;
411  m_lineCont[mode] = 0;
412  break;
413 
414  case 0x2B: //resume text display
415  m_resumeText[mode] = 1;
416  if (m_row[mode] == 0)
417  {
418  m_newRow[mode] = 1;
419  m_newCol[mode] = 0;
420  m_newAttr[mode] = 0;
421  }
422  m_style[mode] = CC_STYLE_ROLLUP;
423  break;
424  case 0x2C: //erase displayed memory
425  if (m_ignoreTimeCode ||
426  (tc - m_lastClr[mode]) > 5s ||
427  m_lastClr[mode] == 0ms)
428  {
429  // don't overflow the frontend with
430  // too many redundant erase codes
431  BufferCC(mode, 0, 1);
432  }
433  if (m_style[mode] != CC_STYLE_POPUP)
434  {
435  m_row[mode] = 0;
436  m_col[mode] = 0;
437  }
438  m_lineCont[mode] = 0;
439  break;
440 
441  case 0x20: //resume caption (pop-up style)
442  if (m_style[mode] != CC_STYLE_POPUP)
443  {
444  if (len)
445  // flush
446  BufferCC(mode, len, 0);
447  m_ccBuf[mode] = "";
448  m_row[mode] = 0;
449  m_col[mode] = 0;
450  }
451  m_style[mode] = CC_STYLE_POPUP;
452  m_rowCount[mode] = 0;
453  m_lineCont[mode] = 0;
454  break;
455  case 0x2F: //end caption + swap memory
456  if (m_style[mode] != CC_STYLE_POPUP)
457  {
458  if (len)
459  // flush
460  BufferCC(mode, len, 0);
461  }
462  else if (m_ignoreTimeCode ||
463  (tc - m_lastClr[mode]) > 5s ||
464  m_lastClr[mode] == 0ms)
465  {
466  // clear and flush
467  BufferCC(mode, len, 1);
468  }
469  else if (len)
470  {
471  // flush
472  BufferCC(mode, len, 0);
473  }
474  m_ccBuf[mode] = "";
475  m_row[mode] = 0;
476  m_col[mode] = 0;
477  m_style[mode] = CC_STYLE_POPUP;
478  m_rowCount[mode] = 0;
479  m_lineCont[mode] = 0;
480  break;
481 
482  case 0x2A: //text restart
483  // clear display
484  BufferCC(mode, 0, 1);
485  ResetCC(mode);
486  // TXT starts at row 1
487  m_newRow[mode] = 1;
488  m_newCol[mode] = 0;
489  m_newAttr[mode] = 0;
490  m_style[mode] = CC_STYLE_ROLLUP;
491  break;
492 
493  case 0x2E: //erase non-displayed memory
494  ResetCC(mode);
495  break;
496  }
497  break;
498  case 0x07: //misc (TAB)
499  if (m_newRow[mode])
500  {
501  m_newCol[mode] += (b2 & 0x03);
502  NewRowCC(mode, len);
503  }
504  else
505  {
506  // illegal?
507  for (int x = 0; x < (b2 & 0x03); x++)
508  {
509  m_ccBuf[mode] += ' ';
510  m_col[mode]++;
511  }
512  }
513  break;
514  }
515  }
516  }
517 
518  skip:
519  for (mode = field*4; mode < (field*4 + 4); mode++)
520  {
521  len = m_ccBuf[mode].length();
522  if ((m_ignoreTimeCode || ((tc - m_timeCode[mode]) > 100ms)) &&
523  (m_style[mode] != CC_STYLE_POPUP) && len)
524  {
525  // flush unfinished line if waiting too long
526  // in paint-on or scroll-up mode
527  m_timeCode[mode] = tc;
528  BufferCC(mode, len, 0);
529  m_ccBuf[mode] = "";
530  m_row[mode] = m_lastRow[mode];
531  m_lineCont[mode] = 1;
532  }
533  }
534 
535  if (data != m_lastCode[field])
536  {
537  m_lastCode[field] = data;
538  m_lastCodeTc[field] = tc;
539  }
540  m_lastTc[field] = tc;
541 }
542 
543 bool CC608Decoder::FalseDup(std::chrono::milliseconds tc, int field, int data)
544 {
545  int b1 = data & 0x7f;
546  int b2 = (data >> 8) & 0x7f;
547 
548  if (m_ignoreTimeCode)
549  {
550  // most digital streams with encoded VBI
551  // have duplicate control codes;
552  // suppress every other repeated control code
553  if ((data == m_lastCode[field]) &&
554  ((b1 & 0x70) == 0x10))
555  {
556  m_lastCode[field] = -1;
557  return true;
558  }
559  return false;
560  }
561 
562  // bttv-0.9 VBI reads are pretty reliable (1 read/33367us).
563  // bttv-0.7 reads don't seem to work as well so if read intervals
564  // vary from this, be more conservative in detecting duplicate
565  // CC codes.
566  std::chrono::milliseconds dup_text_fudge = 0ms;
567  std::chrono::milliseconds dup_ctrl_fudge = 0ms;
568  if (m_badVbi[field] < 100 && b1 != 0 && b2 != 0)
569  {
570  std::chrono::milliseconds d = tc - m_lastTc[field];
571  if (d < 25ms || d > 42ms)
572  m_badVbi[field]++;
573  else if (m_badVbi[field] > 0)
574  m_badVbi[field]--;
575  }
576  if (m_badVbi[field] < 4)
577  {
578  // this should pick up all codes
579  dup_text_fudge = -2ms;
580  // this should pick up 1st, 4th, 6th, 8th, ... codes
581  dup_ctrl_fudge = 33ms - 4ms;
582  }
583  else
584  {
585  dup_text_fudge = 4ms;
586  dup_ctrl_fudge = 33ms - 4ms;
587  }
588 
589  if (data == m_lastCode[field])
590  {
591  if ((b1 & 0x70) == 0x10)
592  {
593  if (tc > (m_lastCodeTc[field] + 67ms + dup_ctrl_fudge))
594  return false;
595  }
596  else if (b1)
597  {
598  // text, XDS
599  if (tc > (m_lastCodeTc[field] + 33ms + dup_text_fudge))
600  return false;
601  }
602 
603  return true;
604  }
605 
606  return false;
607 }
608 
609 void CC608Decoder::ResetCC(size_t mode)
610 {
611 // m_lastRow[mode] = 0;
612 // m_newRow[mode] = 0;
613 // m_newCol[mode] = 0;
614 // m_timeCode[mode] = 0;
615  m_row[mode] = 0;
616  m_col[mode] = 0;
617  m_rowCount[mode] = 0;
618 // m_style[mode] = CC_STYLE_POPUP;
619  m_lineCont[mode] = 0;
620  m_resumeText[mode] = 0;
621  m_lastClr[mode] = 0ms;
622  m_ccBuf[mode] = "";
623 }
624 
625 QString CC608Decoder::ToASCII(const QString &cc608str, bool suppress_unknown)
626 {
627  QString ret = "";
628 
629  for (auto cp : qAsConst(cc608str))
630  {
631  int cpu = cp.unicode();
632  if (cpu == 0)
633  break;
634  switch (cpu)
635  {
636  case 0x2120 : ret += "(SM)"; break;
637  case 0x2122 : ret += "(TM)"; break;
638  case 0x2014 : ret += "(--)"; break;
639  case 0x201C : ret += "``"; break;
640  case 0x201D : ret += "''"; break;
641  case 0x250C : ret += "|-"; break;
642  case 0x2510 : ret += "-|"; break;
643  case 0x2514 : ret += "|_"; break;
644  case 0x2518 : ret += "_|"; break;
645  case 0x2588 : ret += "[]"; break;
646  case 0x266A : ret += "o/~"; break;
647  case '\b' : ret += "\\b"; break;
648  default :
649  if (cpu >= 0x7000 && cpu < 0x7000 + 0x30)
650  {
651  if (!suppress_unknown)
652  ret += QString("[%1]").arg(cpu, 2, 16);
653  }
654  else if (cpu <= 0x80)
655  ret += QString(cp.toLatin1());
656  else if (!suppress_unknown)
657  ret += QString("{%1}").arg(cpu, 2, 16);
658  }
659  }
660 
661  return ret;
662 }
663 
664 void CC608Decoder::BufferCC(size_t mode, int len, int clr)
665 {
666  QByteArray tmpbuf;
667  if (len)
668  {
669  // calculate UTF-8 encoding length
670  tmpbuf = m_ccBuf[mode].toUtf8();
671  len = std::min(static_cast<int>(tmpbuf.length()), 255);
672  }
673 
674  unsigned char *bp = m_rbuf;
675  *(bp++) = m_row[mode];
676  *(bp++) = m_rowCount[mode];
677  *(bp++) = m_style[mode];
678  // overload resumetext field
679  unsigned char f = m_resumeText[mode];
680  f |= mode << 4;
681  if (m_lineCont[mode])
682  f |= CC_LINE_CONT;
683  *(bp++) = f;
684  *(bp++) = clr;
685  *(bp++) = len;
686  if (len)
687  {
688  memcpy(bp,
689  tmpbuf.constData(),
690  len);
691  len += sizeof(ccsubtitle);
692  }
693  else
694  len = sizeof(ccsubtitle);
695 
696  if ((len != 0) && VERBOSE_LEVEL_CHECK(VB_VBI, LOG_INFO))
697  {
698  LOG(VB_VBI, LOG_INFO, QString("### %1 %2 %3 %4 %5 %6 %7 - '%8'")
699  .arg(m_timeCode[mode].count(), 10)
700  .arg(m_row[mode], 2).arg(m_rowCount[mode])
701  .arg(m_style[mode]).arg(f, 2, 16)
702  .arg(clr).arg(len, 3)
703  .arg(ToASCII(QString::fromUtf8(tmpbuf.constData(), len), false)));
704  }
705 
706  m_reader->AddTextData(m_rbuf, len, m_timeCode[mode], 'C');
707  uint8_t ccmode = m_rbuf[3] & CC_MODE_MASK;
708  int stream = -1;
709  switch (ccmode)
710  {
711  case CC_CC1: stream = 0; break;
712  case CC_CC2: stream = 1; break;
713  case CC_CC3: stream = 2; break;
714  case CC_CC4: stream = 3; break;
715  }
716  if (stream >= 0)
717  m_lastSeen[stream] = std::chrono::system_clock::now();
718 
719  m_resumeText[mode] = 0;
720  if (clr && !len)
721  m_lastClr[mode] = m_timeCode[mode];
722  else if (len)
723  m_lastClr[mode] = 0ms;
724 }
725 
726 int CC608Decoder::NewRowCC(size_t mode, int len)
727 {
728  if (m_style[mode] == CC_STYLE_ROLLUP)
729  {
730  // previous line was likely missing a carriage return
731  m_row[mode] = m_newRow[mode];
732  if (len)
733  {
734  BufferCC(mode, len, 0);
735  m_ccBuf[mode] = "";
736  len = 0;
737  }
738  m_col[mode] = 0;
739  m_lineCont[mode] = 0;
740  }
741  else
742  {
743  // popup/paint style
744 
745  if (m_row[mode] == 0)
746  {
747  if (len == 0)
748  m_row[mode] = m_newRow[mode];
749  else
750  {
751  // previous line was missing a row address
752  // - assume it was one row up
753  m_ccBuf[mode] += '\n';
754  len++;
755  if (m_row[mode] == 0)
756  m_row[mode] = m_newRow[mode] - 1;
757  else
758  m_row[mode]--;
759  }
760  }
761  else if (m_newRow[mode] > m_lastRow[mode])
762  {
763  // next line can be more than one row away
764  for (int i = 0; i < (m_newRow[mode] - m_lastRow[mode]); i++)
765  {
766  m_ccBuf[mode] += '\n';
767  len++;
768  }
769  m_col[mode] = 0;
770  }
771  else if (m_newRow[mode] == m_lastRow[mode])
772  {
773  // same row
774  if (m_newCol[mode] >= m_col[mode])
775  {
776  // new line appends to current line
777  m_newCol[mode] -= m_col[mode];
778  }
779  else
780  {
781  // new line overwrites current line;
782  // could be legal (overwrite spaces?) but
783  // more likely we have bad address codes
784  // - just move to next line; may exceed row 15
785  // but frontend will adjust
786  m_ccBuf[mode] += '\n';
787  len++;
788  m_col[mode] = 0;
789  }
790  }
791  else
792  {
793  // next line goes upwards (not legal?)
794  // - flush
795  BufferCC(mode, len, 0);
796  m_ccBuf[mode] = "";
797  m_row[mode] = m_newRow[mode];
798  m_col[mode] = 0;
799  m_lineCont[mode] = 0;
800  len = 0;
801  }
802  }
803 
804  m_lastRow[mode] = m_newRow[mode];
805  m_newRow[mode] = 0;
806 
807  int limit = m_newCol[mode];
808  for (int x = 0; x < limit; x++)
809  {
810  m_ccBuf[mode] += ' ';
811  len++;
812  m_col[mode]++;
813  }
814 
815  if (m_newAttr[mode])
816  {
817  m_ccBuf[mode] += QChar(m_newAttr[mode] + 0x7000);
818  len++;
819  }
820 
821  m_newCol[mode] = 0;
822  m_newAttr[mode] = 0;
823 
824  return len;
825 }
826 
827 
828 static bool IsPrintable(char c)
829 {
830  return !(((c) & 0x7F) < 0x20 || ((c) & 0x7F) > 0x7E);
831 }
832 
833 static char Printable(char c)
834 {
835  return IsPrintable(c) ? ((c) & 0x7F) : '.';
836 }
837 
838 #if 0
839 static int OddParity(unsigned char c)
840 {
841  c ^= (c >> 4); c ^= (c >> 2); c ^= (c >> 1);
842  return c & 1;
843 }
844 #endif
845 
846 // // // // // // // // // // // // // // // // // // // // // // // //
847 // // // // // // // // // // // VPS // // // // // // // // // // //
848 // // // // // // // // // // // // // // // // // // // // // // // //
849 
850 static constexpr int PIL_TIME(int day, int mon, int hour, int min)
851 { return (day << 15) + (mon << 11) + (hour << 6) + min; }
852 
853 static void DumpPIL(int pil)
854 {
855  int day = (pil >> 15);
856  int mon = (pil >> 11) & 0xF;
857  int hour = (pil >> 6 ) & 0x1F;
858  int min = (pil ) & 0x3F;
859 
860  if (pil == PIL_TIME(0, 15, 31, 63))
861  LOG(VB_VBI, LOG_INFO, " PDC: Timer-control (no PDC)");
862  else if (pil == PIL_TIME(0, 15, 30, 63))
863  LOG(VB_VBI, LOG_INFO, " PDC: Recording inhibit/terminate");
864  else if (pil == PIL_TIME(0, 15, 29, 63))
865  LOG(VB_VBI, LOG_INFO, " PDC: Interruption");
866  else if (pil == PIL_TIME(0, 15, 28, 63))
867  LOG(VB_VBI, LOG_INFO, " PDC: Continue");
868  else if (pil == PIL_TIME(31, 15, 31, 63))
869  LOG(VB_VBI, LOG_INFO, " PDC: No time");
870  else
871  LOG(VB_VBI, LOG_INFO, QString(" PDC: %1, 200X-%2-%3 %4:%5")
872  .arg(pil).arg(mon).arg(day).arg(hour).arg(min));
873 #undef PIL_TIME
874 }
875 
876 void CC608Decoder::DecodeVPS(const unsigned char *buf)
877 {
878  int c = vbi_bit_reverse[buf[1]];
879 
880  if ((int8_t) c < 0)
881  {
882  m_vpsLabel[m_vpsL] = 0;
884  m_vpsL = 0;
885  }
886  c &= 0x7F;
888  m_vpsL = (m_vpsL + 1) % 16;
889 
890  LOG(VB_VBI, LOG_INFO, QString("VPS: 3-10: %1 %2 %3 %4 %5 %6 %7 %8 (\"%9\")")
891  .arg(buf[0]).arg(buf[1]).arg(buf[2]).arg(buf[3]).arg(buf[4])
892  .arg(buf[5]).arg(buf[6]).arg(buf[7]).arg(m_vpsPrLabel.data()));
893 
894  int pcs = buf[2] >> 6;
895  int cni = + ((buf[10] & 3) << 10)
896  + ((buf[11] & 0xC0) << 2)
897  + ((buf[8] & 0xC0) << 0)
898  + (buf[11] & 0x3F);
899  int pil = ((buf[8] & 0x3F) << 14) + (buf[9] << 6) + (buf[10] >> 2);
900  int pty = buf[12];
901 
902  LOG(VB_VBI, LOG_INFO, QString("CNI: %1 PCS: %2 PTY: %3 ")
903  .arg(cni).arg(pcs).arg(pty));
904 
905  DumpPIL(pil);
906 
907  // c & 0xf0;
908 }
909 
910 // // // // // // // // // // // // // // // // // // // // // // // //
911 // // // // // // // // // // // WSS // // // // // // // // // // //
912 // // // // // // // // // // // // // // // // // // // // // // // //
913 
914 void CC608Decoder::DecodeWSS(const unsigned char *buf)
915 {
916  static const std::array<const int,8> kWssBits { 0, 0, 0, 1, 0, 1, 1, 1 };
917  uint wss = 0;
918 
919  for (uint i = 0; i < 16; i++)
920  {
921  uint b1 = kWssBits[buf[i] & 7];
922  uint b2 = kWssBits[(buf[i] >> 3) & 7];
923 
924  if (b1 == b2)
925  return;
926  wss |= b2 << i;
927  }
928  unsigned char parity = wss & 0xf;
929  parity ^= parity >> 2;
930  parity ^= parity >> 1;
931 
932  LOG(VB_VBI, LOG_INFO,
933  QString("WSS: %1; %2 mode; %3 color coding;\n\t\t\t"
934  " %4 helper; reserved b7=%5; %6\n\t\t\t"
935  " open subtitles: %7; %scopyright %8; copying %9")
936  .arg(QString::fromStdString(formats[wss & 7]),
937  (wss & 0x0010) ? "film" : "camera",
938  (wss & 0x0020) ? "MA/CP" : "standard",
939  (wss & 0x0040) ? "modulated" : "no",
940  (wss & 0x0080) ? "1" : "0",
941  (wss & 0x0100) ? "have TTX subtitles; " : "",
942  QString::fromStdString(subtitles[(wss >> 9) & 3]),
943  (wss & 0x0800) ? "surround sound; " : "",
944  (wss & 0x1000) ? "asserted" : "unknown")
945  // Qt < 5.14 only allows a max of nin string arguments in a single call
946  .arg((wss & 0x2000) ? "restricted" : "not restricted")); // clazy:exclude=qstring-arg
947 
948  if (parity & 1)
949  {
950  m_wssFlags = wss;
951  m_wssValid = true;
952  }
953 }
954 
955 QString CC608Decoder::XDSDecodeString(const std::vector<unsigned char> &buf,
956  uint start, uint end) const
957 {
958 #if DEBUG_XDS
959  for (uint i = start; (i < buf.size()) && (i < end); i++)
960  {
961  LOG(VB_VBI, LOG_INFO, QString("%1: 0x%2 -> 0x%3 %4")
962  .arg(i,2)
963  .arg(buf[i],2,16,QChar('0'))
964  .arg(CharCC(buf[i]).unicode(),2,16,QChar('0'))
965  .arg(CharCC(buf[i])));
966  }
967 #endif // DEBUG_XDS
968 
969  QString tmp = "";
970  for (uint i = start; (i < buf.size()) && (i < end); i++)
971  {
972  if (buf[i] > 0x0)
973  tmp += CharCC(buf[i]);
974  }
975 
976 #if DEBUG_XDS
977  LOG(VB_VBI, LOG_INFO, QString("XDSDecodeString: '%1'").arg(tmp));
978 #endif // DEBUG_XDS
979 
980  return tmp.trimmed();
981 }
982 
983 static bool is_better(const QString &newStr, const QString &oldStr)
984 {
985  if (!newStr.isEmpty() && newStr != oldStr &&
986  (newStr != oldStr.left(newStr.length())))
987  {
988  if (oldStr.isEmpty())
989  return true;
990 
991  // check if the string contains any bogus characters
992  return std::all_of(newStr.cbegin(), newStr.cend(),
993  [](auto ch){ return ch.toLatin1() >= 0x20; } );
994  }
995  return false;
996 }
997 
999 {
1000  QMutexLocker locker(&m_xdsLock);
1001  return m_xdsRatingSystems[(future) ? 1 : 0];
1002 }
1003 
1004 uint CC608Decoder::GetRating(uint i, bool future) const
1005 {
1006  QMutexLocker locker(&m_xdsLock);
1007  return m_xdsRating[(future) ? 1 : 0][i & 0x3] & 0x7;
1008 }
1009 
1010 QString CC608Decoder::GetRatingString(uint i, bool future) const
1011 {
1012  QMutexLocker locker(&m_xdsLock);
1013 
1014  const std::array<const QString,4> prefix { "MPAA-", "TV-", "CE-", "CF-" };
1015  const std::array<const std::array<const QString,8>,4> mainStr
1016  {{
1017  { "NR", "G", "PG", "PG-13", "R", "NC-17", "X", "NR" },
1018  { "NR", "Y", "Y7", "G", "PG", "14", "MA", "NR" },
1019  { "E", "C", "C8+", "G", "PG", "14+", "18+", "NR" },
1020  { "E", "G", "8+", "13+", "16+", "18+", "NR", "NR" },
1021  }};
1022 
1023  QString main = prefix[i] + mainStr[i][GetRating(i, future)];
1024 
1025  if (kRatingTPG == i)
1026  {
1027  uint cf = (future) ? 1 : 0;
1028  if (!(m_xdsRating[cf][i]&0xF0))
1029  return main;
1030 
1031  main += " ";
1032  // TPG flags
1033  if (m_xdsRating[cf][i] & 0x80)
1034  main += "D"; // Dialog
1035  if (m_xdsRating[cf][i] & 0x40)
1036  main += "V"; // Violence
1037  if (m_xdsRating[cf][i] & 0x20)
1038  main += "S"; // Sex
1039  if (m_xdsRating[cf][i] & 0x10)
1040  main += "L"; // Language
1041  }
1042 
1043  return main;
1044 }
1045 
1046 QString CC608Decoder::GetProgramName(bool future) const
1047 {
1048  QMutexLocker locker(&m_xdsLock);
1049  return m_xdsProgramName[(future) ? 1 : 0];
1050 }
1051 
1052 QString CC608Decoder::GetProgramType(bool future) const
1053 {
1054  QMutexLocker locker(&m_xdsLock);
1055  const std::vector<uint> &program_type = m_xdsProgramType[(future) ? 1 : 0];
1056  QString tmp = "";
1057 
1058  for (size_t i = 0; i < program_type.size(); i++)
1059  {
1060  if (i != 0)
1061  tmp += ", ";
1062  tmp += m_xdsProgramTypeString[program_type[i]];
1063  }
1064 
1065  return tmp;
1066 }
1067 
1068 QString CC608Decoder::GetXDS(const QString &key) const
1069 {
1070  QMutexLocker locker(&m_xdsLock);
1071 
1072  if (key == "ratings")
1073  return QString::number(GetRatingSystems(false));
1074  if (key.startsWith("has_rating_"))
1075  return ((1<<key.right(1).toUInt()) & GetRatingSystems(false))?"1":"0";
1076  if (key.startsWith("rating_"))
1077  return GetRatingString(key.right(1).toUInt(), false);
1078 
1079  if (key == "future_ratings")
1080  return QString::number(GetRatingSystems(true));
1081  if (key.startsWith("has_future_rating_"))
1082  return ((1<<key.right(1).toUInt()) & GetRatingSystems(true))?"1":"0";
1083  if (key.startsWith("future_rating_"))
1084  return GetRatingString(key.right(1).toUInt(), true);
1085 
1086  if (key == "programname")
1087  return GetProgramName(false);
1088  if (key == "future_programname")
1089  return GetProgramName(true);
1090 
1091  if (key == "programtype")
1092  return GetProgramType(false);
1093  if (key == "future_programtype")
1094  return GetProgramType(true);
1095 
1096  if (key == "callsign")
1097  return m_xdsNetCall;
1098  if (key == "channame")
1099  return m_xdsNetName;
1100  if (key == "tsid")
1101  return QString::number(m_xdsTsid);
1102 
1103  return {};
1104 }
1105 
1106 static std::array<const int,16> b1_to_service
1107 { -1, // 0x0
1108  0, 0, //0x1,0x2 -- Current
1109  1, 1, //0x3,0x4 -- Future
1110  2, 2, //0x5,0x6 -- Channel
1111  3, 3, //0x7,0x8 -- Misc
1112  4, 4, //0x9,0xA -- Public Service
1113  5, 5, //0xB,0xC -- Reserved
1114  6, 6, //0xD,0xE -- Private Data
1115  -1, // 0xF
1116 };
1117 
1118 bool CC608Decoder::XDSDecode(int field, int b1, int b2)
1119 {
1120  if (field == 0)
1121  return false; // XDS is only on second field
1122 
1123 #if DEBUG_XDS
1124  LOG(VB_VBI, LOG_INFO,
1125  QString("XDSDecode: 0x%1 0x%2 '%3%4' xds[%5]=%6 in XDS %7")
1126  .arg(b1,2,16,QChar('0')).arg(b2,2,16,QChar('0'))
1127  .arg((CharCC(b1).unicode()>0x20) ? CharCC(b1) : QChar(' '))
1128  .arg((CharCC(b2).unicode()>0x20) ? CharCC(b2) : QChar(' '))
1129  .arg(field).arg(m_xds[field])
1130  .arg(m_xdsCurService));
1131 #else
1132  (void) field;
1133 #endif // DEBUG_XDS
1134 
1135  if (m_xdsCurService < 0)
1136  {
1137  if (b1 > 0x0f)
1138  return false;
1139 
1141 
1142  if (m_xdsCurService < 0)
1143  return false;
1144 
1145  if (b1 & 1)
1146  {
1147  m_xdsBuf[m_xdsCurService].clear(); // if start of service clear buffer
1148 #if DEBUG_XDS
1149  LOG(VB_VBI, LOG_INFO, QString("XDSDecode: Starting XDS %1").arg(m_xdsCurService));
1150 #endif // DEBUG_XDS
1151  }
1152  }
1153  else if ((0x0 < b1) && (b1 < 0x0f))
1154  { // switch to different service
1156 #if DEBUG_XDS
1157  LOG(VB_VBI, LOG_INFO, QString("XDSDecode: Resuming XDS %1").arg(m_xdsCurService));
1158 #endif // DEBUG_XDS
1159  }
1160 
1161  if (m_xdsCurService < 0)
1162  return false;
1163 
1164  m_xdsBuf[m_xdsCurService].push_back(b1);
1165  m_xdsBuf[m_xdsCurService].push_back(b2);
1166 
1167  if (b1 == 0x0f) // end of packet
1168  {
1169 #if DEBUG_XDS
1170  LOG(VB_VBI, LOG_INFO, QString("XDSDecode: Ending XDS %1").arg(m_xdsCurService));
1171 #endif // DEBUG_XDS
1174  m_xdsBuf[m_xdsCurService].clear();
1175  m_xdsCurService = -1;
1176  }
1177  else if ((0x10 <= b1) && (b1 <= 0x1f)) // suspension of XDS packet
1178  {
1179 #if DEBUG_XDS
1180  LOG(VB_VBI, LOG_INFO, QString("XDSDecode: Suspending XDS %1 on 0x%2")
1181  .arg(m_xdsCurService).arg(b1,2,16,QChar('0')));
1182 #endif // DEBUG_XDS
1183  m_xdsCurService = -1;
1184  }
1185 
1186  return true;
1187 }
1188 
1189 void CC608Decoder::XDSPacketParse(const std::vector<unsigned char> &xds_buf)
1190 {
1191  QMutexLocker locker(&m_xdsLock);
1192 
1193  bool handled = false;
1194  int xds_class = xds_buf[0];
1195 
1196  if (!xds_class)
1197  return;
1198 
1199  if ((xds_class == 0x01) || (xds_class == 0x03)) // cont code 2 and 4, resp.
1200  handled = XDSPacketParseProgram(xds_buf, (xds_class == 0x03));
1201  else if (xds_class == 0x05) // cont code: 0x06
1202  handled = XDSPacketParseChannel(xds_buf);
1203  else if ((xds_class == 0x07) || // cont code: 0x08 // misc.
1204  (xds_class == 0x09) || // cont code: 0x0a // public (aka weather)
1205  (xds_class == 0x0b)) // cont code: 0x0c // reserved
1206  ;
1207  else if (xds_class == 0x0d) // cont code: 0x0e
1208  handled = true; // undefined
1209 
1210  if (!handled)
1211  {
1212 #if DEBUG_XDS
1213  LOG(VB_VBI, LOG_INFO, QString("XDS: ") +
1214  QString("Unhandled packet (0x%1 0x%2) sz(%3) '%4'")
1215  .arg(xds_buf[0],0,16).arg(xds_buf[1],0,16)
1216  .arg(xds_buf.size())
1217  .arg(XDSDecodeString(xds_buf, 2, xds_buf.size() - 2)));
1218 #endif
1219  }
1220 }
1221 
1222 bool CC608Decoder::XDSPacketCRC(const std::vector<unsigned char> &xds_buf)
1223 {
1224  /* Check the checksum for validity of the packet. */
1225  int sum = 0;
1226  for (size_t i = 0; i < xds_buf.size() - 1; i++)
1227  sum += xds_buf[i];
1228 
1229  if ((((~sum) & 0x7f) + 1) != xds_buf[xds_buf.size() - 1])
1230  {
1231  m_xdsCrcFailed++;
1232 
1233  LOG(VB_VBI, LOG_ERR, QString("XDS: failed CRC %1 of %2")
1235 
1236  return false;
1237  }
1238 
1239  m_xdsCrcPassed++;
1240  return true;
1241 }
1242 
1244  const std::vector<unsigned char> &xds_buf, bool future)
1245 {
1246  bool handled = true;
1247  int b2 = xds_buf[1];
1248  int cf = (future) ? 1 : 0;
1249  QString loc = (future) ? "XDS: Future " : "XDS: Current ";
1250 
1251  if ((b2 == 0x01) && (xds_buf.size() >= 6))
1252  {
1253  uint min = xds_buf[2] & 0x3f;
1254  uint hour = xds_buf[3] & 0x0f;
1255  uint day = xds_buf[4] & 0x1f;
1256  uint month = xds_buf[5] & 0x0f;
1257  month = (month < 1 || month > 12) ? 0 : month;
1258 
1259  LOG(VB_VBI, LOG_INFO, loc +
1260  QString("Start Time %1/%2 %3:%4%5")
1261  .arg(month).arg(day).arg(hour).arg(min / 10).arg(min % 10));
1262  }
1263  else if ((b2 == 0x02) && (xds_buf.size() >= 4))
1264  {
1265  uint length_min = xds_buf[2] & 0x3f;
1266  uint length_hour = xds_buf[3] & 0x3f;
1267  uint length_elapsed_min = 0;
1268  uint length_elapsed_hour = 0;
1269  uint length_elapsed_secs = 0;
1270  if (xds_buf.size() > 6)
1271  {
1272  length_elapsed_min = xds_buf[4] & 0x3f;
1273  length_elapsed_hour = xds_buf[5] & 0x3f;
1274  }
1275  if (xds_buf.size() > 8 && xds_buf[7] == 0x40)
1276  length_elapsed_secs = xds_buf[6] & 0x3f;
1277 
1278  QString msg = QString("Program Length %1:%2%3 "
1279  "Time in Show %4:%5%6.%7%8")
1280  .arg(length_hour).arg(length_min / 10).arg(length_min % 10)
1281  .arg(length_elapsed_hour)
1282  .arg(length_elapsed_min / 10).arg(length_elapsed_min % 10)
1283  .arg(length_elapsed_secs / 10).arg(length_elapsed_secs % 10);
1284 
1285  LOG(VB_VBI, LOG_INFO, loc + msg);
1286  }
1287  else if ((b2 == 0x03) && (xds_buf.size() >= 6))
1288  {
1289  QString tmp = XDSDecodeString(xds_buf, 2, xds_buf.size() - 2);
1290  if (is_better(tmp, m_xdsProgramName[cf]))
1291  {
1292  m_xdsProgramName[cf] = tmp;
1293  LOG(VB_VBI, LOG_INFO, loc + QString("Program Name: '%1'")
1294  .arg(GetProgramName(future)));
1295  }
1296  }
1297  else if ((b2 == 0x04) && (xds_buf.size() >= 6))
1298  {
1299  std::vector<uint> program_type;
1300  for (size_t i = 2; i < xds_buf.size() - 2; i++)
1301  {
1302  int cur = xds_buf[i] - 0x20;
1303  if (cur >= 0 && cur < 96)
1304  program_type.push_back(cur);
1305  }
1306 
1307  bool unchanged = m_xdsProgramType[cf].size() == program_type.size();
1308  for (uint i = 0; (i < program_type.size()) && unchanged; i++)
1309  unchanged = m_xdsProgramType[cf][i] == program_type[i];
1310 
1311  if (!unchanged)
1312  {
1313  m_xdsProgramType[cf] = program_type;
1314  LOG(VB_VBI, LOG_INFO, loc + QString("Program Type '%1'")
1315  .arg(GetProgramType(future)));
1316  }
1317  }
1318  else if ((b2 == 0x05) && (xds_buf.size() >= 4))
1319  {
1320  uint movie_rating = xds_buf[2] & 0x7;
1321  uint rating_system = (xds_buf[2] >> 3) & 0x7;
1322  uint tv_rating = xds_buf[3] & 0x7;
1323  uint VSL = xds_buf[3] & (0x7 << 3);
1324  uint sel = VSL | rating_system;
1325  if (sel == 3)
1326  {
1327  if (!(kHasCanEnglish & m_xdsRatingSystems[cf]) ||
1328  (tv_rating != GetRating(kRatingCanEnglish, future)))
1329  {
1331  m_xdsRating[cf][kRatingCanEnglish] = tv_rating;
1332  LOG(VB_VBI, LOG_INFO, loc + QString("VChip %1")
1333  .arg(GetRatingString(kRatingCanEnglish, future)));
1334  }
1335  }
1336  else if (sel == 7)
1337  {
1338  if (!(kHasCanFrench & m_xdsRatingSystems[cf]) ||
1339  (tv_rating != GetRating(kRatingCanFrench, future)))
1340  {
1342  m_xdsRating[cf][kRatingCanFrench] = tv_rating;
1343  LOG(VB_VBI, LOG_INFO, loc + QString("VChip %1")
1344  .arg(GetRatingString(kRatingCanFrench, future)));
1345  }
1346  }
1347  else if (sel == 0x13 || sel == 0x1f)
1348  ; // Reserved according to TVTime code
1349  else if ((rating_system & 0x3) == 1)
1350  {
1351  if (!(kHasTPG & m_xdsRatingSystems[cf]) ||
1352  (tv_rating != GetRating(kRatingTPG, future)))
1353  {
1354  uint f = ((xds_buf[0]<<3) & 0x80) | ((xds_buf[1]<<1) & 0x70);
1355  m_xdsRatingSystems[cf] |= kHasTPG;
1356  m_xdsRating[cf][kRatingTPG] = tv_rating | f;
1357  LOG(VB_VBI, LOG_INFO, loc + QString("VChip %1")
1358  .arg(GetRatingString(kRatingTPG, future)));
1359  }
1360  }
1361  else if (rating_system == 0)
1362  {
1363  if (!(kHasMPAA & m_xdsRatingSystems[cf]) ||
1364  (movie_rating != GetRating(kRatingMPAA, future)))
1365  {
1367  m_xdsRating[cf][kRatingMPAA] = movie_rating;
1368  LOG(VB_VBI, LOG_INFO, loc + QString("VChip %1")
1369  .arg(GetRatingString(kRatingMPAA, future)));
1370  }
1371  }
1372  else
1373  {
1374  LOG(VB_VBI, LOG_ERR, loc +
1375  QString("VChip Unhandled -- rs(%1) rating(%2:%3)")
1376  .arg(rating_system).arg(tv_rating).arg(movie_rating));
1377  }
1378  }
1379 #if 0
1380  else if (b2 == 0x07)
1381  ; // caption
1382  else if (b2 == 0x08)
1383  ; // cgms
1384  else if (b2 == 0x09)
1385  ; // unknown
1386  else if (b2 == 0x0c)
1387  ; // misc
1388  else if (b2 == 0x10 || b2 == 0x13 || b2 == 0x15 || b2 == 0x16 ||
1389  b2 == 0x91 || b2 == 0x92 || b2 == 0x94 || b2 == 0x97)
1390  ; // program description
1391  else if (b2 == 0x86)
1392  ; // audio
1393  else if (b2 == 0x89)
1394  ; // aspect
1395  else if (b2 == 0x8c)
1396  ; // program data
1397 #endif
1398  else
1399  handled = false;
1400 
1401  return handled;
1402 }
1403 
1404 bool CC608Decoder::XDSPacketParseChannel(const std::vector<unsigned char> &xds_buf)
1405 {
1406  bool handled = true;
1407 
1408  int b2 = xds_buf[1];
1409  if ((b2 == 0x01) && (xds_buf.size() >= 6))
1410  {
1411  QString tmp = XDSDecodeString(xds_buf, 2, xds_buf.size() - 2);
1412  if (is_better(tmp, m_xdsNetName))
1413  {
1414  LOG(VB_VBI, LOG_INFO, QString("XDS: Network Name '%1'").arg(tmp));
1415  m_xdsNetName = tmp;
1416  }
1417  }
1418  else if ((b2 == 0x02) && (xds_buf.size() >= 6))
1419  {
1420  QString tmp = XDSDecodeString(xds_buf, 2, xds_buf.size() - 2);
1421  if (is_better(tmp, m_xdsNetCall) && (tmp.indexOf(" ") < 0))
1422  {
1423  LOG(VB_VBI, LOG_INFO, QString("XDS: Network Call '%1'").arg(tmp));
1424  m_xdsNetCall = tmp;
1425  }
1426  }
1427  else if ((b2 == 0x04) && (xds_buf.size() >= 6))
1428  {
1429  uint tsid = (xds_buf[2] << 24 | xds_buf[3] << 16 |
1430  xds_buf[4] << 8 | xds_buf[5]);
1431  if (tsid != m_xdsTsid)
1432  {
1433  LOG(VB_VBI, LOG_INFO, QString("XDS: TSID 0x%1").arg(tsid,0,16));
1434  m_xdsTsid = tsid;
1435  }
1436  }
1437  else
1438  handled = false;
1439 
1440  return handled;
1441 }
1442 
1443 static void init_xds_program_type(CC608ProgramType& xds_program_type)
1444 {
1445  xds_program_type[0] = QCoreApplication::translate("(Categories)",
1446  "Education");
1447  xds_program_type[1] = QCoreApplication::translate("(Categories)",
1448  "Entertainment");
1449  xds_program_type[2] = QCoreApplication::translate("(Categories)",
1450  "Movie");
1451  xds_program_type[3] = QCoreApplication::translate("(Categories)",
1452  "News");
1453  xds_program_type[4] = QCoreApplication::translate("(Categories)",
1454  "Religious");
1455  xds_program_type[5] = QCoreApplication::translate("(Categories)",
1456  "Sports");
1457  xds_program_type[6] = QCoreApplication::translate("(Categories)",
1458  "Other");
1459  xds_program_type[7] = QCoreApplication::translate("(Categories)",
1460  "Action");
1461  xds_program_type[8] = QCoreApplication::translate("(Categories)",
1462  "Advertisement");
1463  xds_program_type[9] = QCoreApplication::translate("(Categories)",
1464  "Animated");
1465  xds_program_type[10] = QCoreApplication::translate("(Categories)",
1466  "Anthology");
1467  xds_program_type[11] = QCoreApplication::translate("(Categories)",
1468  "Automobile");
1469  xds_program_type[12] = QCoreApplication::translate("(Categories)",
1470  "Awards");
1471  xds_program_type[13] = QCoreApplication::translate("(Categories)",
1472  "Baseball");
1473  xds_program_type[14] = QCoreApplication::translate("(Categories)",
1474  "Basketball");
1475  xds_program_type[15] = QCoreApplication::translate("(Categories)",
1476  "Bulletin");
1477  xds_program_type[16] = QCoreApplication::translate("(Categories)",
1478  "Business");
1479  xds_program_type[17] = QCoreApplication::translate("(Categories)",
1480  "Classical");
1481  xds_program_type[18] = QCoreApplication::translate("(Categories)",
1482  "College");
1483  xds_program_type[19] = QCoreApplication::translate("(Categories)",
1484  "Combat");
1485  xds_program_type[20] = QCoreApplication::translate("(Categories)",
1486  "Comedy");
1487  xds_program_type[21] = QCoreApplication::translate("(Categories)",
1488  "Commentary");
1489  xds_program_type[22] = QCoreApplication::translate("(Categories)",
1490  "Concert");
1491  xds_program_type[23] = QCoreApplication::translate("(Categories)",
1492  "Consumer");
1493  xds_program_type[24] = QCoreApplication::translate("(Categories)",
1494  "Contemporary");
1495  xds_program_type[25] = QCoreApplication::translate("(Categories)",
1496  "Crime");
1497  xds_program_type[26] = QCoreApplication::translate("(Categories)",
1498  "Dance");
1499  xds_program_type[27] = QCoreApplication::translate("(Categories)",
1500  "Documentary");
1501  xds_program_type[28] = QCoreApplication::translate("(Categories)",
1502  "Drama");
1503  xds_program_type[29] = QCoreApplication::translate("(Categories)",
1504  "Elementary");
1505  xds_program_type[30] = QCoreApplication::translate("(Categories)",
1506  "Erotica");
1507  xds_program_type[31] = QCoreApplication::translate("(Categories)",
1508  "Exercise");
1509  xds_program_type[32] = QCoreApplication::translate("(Categories)",
1510  "Fantasy");
1511  xds_program_type[33] = QCoreApplication::translate("(Categories)",
1512  "Farm");
1513  xds_program_type[34] = QCoreApplication::translate("(Categories)",
1514  "Fashion");
1515  xds_program_type[35] = QCoreApplication::translate("(Categories)",
1516  "Fiction");
1517  xds_program_type[36] = QCoreApplication::translate("(Categories)",
1518  "Food");
1519  xds_program_type[37] = QCoreApplication::translate("(Categories)",
1520  "Football");
1521  xds_program_type[38] = QCoreApplication::translate("(Categories)",
1522  "Foreign");
1523  xds_program_type[39] = QCoreApplication::translate("(Categories)",
1524  "Fundraiser");
1525  xds_program_type[40] = QCoreApplication::translate("(Categories)",
1526  "Game/Quiz");
1527  xds_program_type[41] = QCoreApplication::translate("(Categories)",
1528  "Garden");
1529  xds_program_type[42] = QCoreApplication::translate("(Categories)",
1530  "Golf");
1531  xds_program_type[43] = QCoreApplication::translate("(Categories)",
1532  "Government");
1533  xds_program_type[44] = QCoreApplication::translate("(Categories)",
1534  "Health");
1535  xds_program_type[45] = QCoreApplication::translate("(Categories)",
1536  "High School");
1537  xds_program_type[46] = QCoreApplication::translate("(Categories)",
1538  "History");
1539  xds_program_type[47] = QCoreApplication::translate("(Categories)",
1540  "Hobby");
1541  xds_program_type[48] = QCoreApplication::translate("(Categories)",
1542  "Hockey");
1543  xds_program_type[49] = QCoreApplication::translate("(Categories)",
1544  "Home");
1545  xds_program_type[50] = QCoreApplication::translate("(Categories)",
1546  "Horror");
1547  xds_program_type[51] = QCoreApplication::translate("(Categories)",
1548  "Information");
1549  xds_program_type[52] = QCoreApplication::translate("(Categories)",
1550  "Instruction");
1551  xds_program_type[53] = QCoreApplication::translate("(Categories)",
1552  "International");
1553  xds_program_type[54] = QCoreApplication::translate("(Categories)",
1554  "Interview");
1555  xds_program_type[55] = QCoreApplication::translate("(Categories)",
1556  "Language");
1557  xds_program_type[56] = QCoreApplication::translate("(Categories)",
1558  "Legal");
1559  xds_program_type[57] = QCoreApplication::translate("(Categories)",
1560  "Live");
1561  xds_program_type[58] = QCoreApplication::translate("(Categories)",
1562  "Local");
1563  xds_program_type[59] = QCoreApplication::translate("(Categories)",
1564  "Math");
1565  xds_program_type[60] = QCoreApplication::translate("(Categories)",
1566  "Medical");
1567  xds_program_type[61] = QCoreApplication::translate("(Categories)",
1568  "Meeting");
1569  xds_program_type[62] = QCoreApplication::translate("(Categories)",
1570  "Military");
1571  xds_program_type[63] = QCoreApplication::translate("(Categories)",
1572  "Miniseries");
1573  xds_program_type[64] = QCoreApplication::translate("(Categories)",
1574  "Music");
1575  xds_program_type[65] = QCoreApplication::translate("(Categories)",
1576  "Mystery");
1577  xds_program_type[66] = QCoreApplication::translate("(Categories)",
1578  "National");
1579  xds_program_type[67] = QCoreApplication::translate("(Categories)",
1580  "Nature");
1581  xds_program_type[68] = QCoreApplication::translate("(Categories)",
1582  "Police");
1583  xds_program_type[69] = QCoreApplication::translate("(Categories)",
1584  "Politics");
1585  xds_program_type[70] = QCoreApplication::translate("(Categories)",
1586  "Premiere");
1587  xds_program_type[71] = QCoreApplication::translate("(Categories)",
1588  "Prerecorded");
1589  xds_program_type[72] = QCoreApplication::translate("(Categories)",
1590  "Product");
1591  xds_program_type[73] = QCoreApplication::translate("(Categories)",
1592  "Professional");
1593  xds_program_type[74] = QCoreApplication::translate("(Categories)",
1594  "Public");
1595  xds_program_type[75] = QCoreApplication::translate("(Categories)",
1596  "Racing");
1597  xds_program_type[76] = QCoreApplication::translate("(Categories)",
1598  "Reading");
1599  xds_program_type[77] = QCoreApplication::translate("(Categories)",
1600  "Repair");
1601  xds_program_type[78] = QCoreApplication::translate("(Categories)",
1602  "Repeat");
1603  xds_program_type[79] = QCoreApplication::translate("(Categories)",
1604  "Review");
1605  xds_program_type[80] = QCoreApplication::translate("(Categories)",
1606  "Romance");
1607  xds_program_type[81] = QCoreApplication::translate("(Categories)",
1608  "Science");
1609  xds_program_type[82] = QCoreApplication::translate("(Categories)",
1610  "Series");
1611  xds_program_type[83] = QCoreApplication::translate("(Categories)",
1612  "Service");
1613  xds_program_type[84] = QCoreApplication::translate("(Categories)",
1614  "Shopping");
1615  xds_program_type[85] = QCoreApplication::translate("(Categories)",
1616  "Soap Opera");
1617  xds_program_type[86] = QCoreApplication::translate("(Categories)",
1618  "Special");
1619  xds_program_type[87] = QCoreApplication::translate("(Categories)",
1620  "Suspense");
1621  xds_program_type[88] = QCoreApplication::translate("(Categories)",
1622  "Talk");
1623  xds_program_type[89] = QCoreApplication::translate("(Categories)",
1624  "Technical");
1625  xds_program_type[90] = QCoreApplication::translate("(Categories)",
1626  "Tennis");
1627  xds_program_type[91] = QCoreApplication::translate("(Categories)",
1628  "Travel");
1629  xds_program_type[92] = QCoreApplication::translate("(Categories)",
1630  "Variety");
1631  xds_program_type[93] = QCoreApplication::translate("(Categories)",
1632  "Video");
1633  xds_program_type[94] = QCoreApplication::translate("(Categories)",
1634  "Weather");
1635  xds_program_type[95] = QCoreApplication::translate("(Categories)",
1636  "Western");
1637 }
CC608Decoder::m_rbuf
unsigned char * m_rbuf
Definition: cc608decoder.h:131
cc::code2
int code2
Definition: cc.h:14
CC608Decoder::m_lastClr
CC608PerModeTc m_lastClr
Definition: cc608decoder.h:124
rowdata
static const std::array< const int, 16 > rowdata
Definition: cc608decoder.cpp:63
bbciplayer.main
main
Definition: bbciplayer.py:259
CC608Decoder::m_lastCodeTc
CC608PerFieldTc m_lastCodeTc
Definition: cc608decoder.h:107
Printable
static char Printable(char c)
Definition: cc608decoder.cpp:833
is_better
static bool is_better(const QString &newStr, const QString &oldStr)
Definition: cc608decoder.cpp:983
CC608Decoder::m_newCol
CC608PerMode m_newCol
Definition: cc608decoder.h:115
CC608Decoder::m_xdsRatingSystems
std::array< uint, 2 > m_xdsRatingSystems
Definition: cc608decoder.h:154
CC608Decoder::m_ccMode
CC608PerField m_ccMode
Definition: cc608decoder.h:108
CC608Decoder::m_xdsCurService
int m_xdsCurService
Definition: cc608decoder.h:144
CC608Decoder::GetRating
uint GetRating(uint i, bool future) const
Definition: cc608decoder.cpp:1004
CC608Decoder::FormatCC
void FormatCC(std::chrono::milliseconds tc, int code1, int code2)
Definition: cc608decoder.cpp:50
CC608Decoder::m_vpsLabel
std::array< char, 20 > m_vpsLabel
Definition: cc608decoder.h:137
kRatingTPG
@ kRatingTPG
Definition: cc608decoder.h:48
CC_CC3
@ CC_CC3
Definition: format.h:209
format.h
CC_STYLE_PAINT
@ CC_STYLE_PAINT
Definition: format.h:196
CC608Decoder::m_xdsNetName
QString m_xdsNetName
Definition: cc608decoder.h:160
VERBOSE_LEVEL_CHECK
static bool VERBOSE_LEVEL_CHECK(uint64_t mask, LogLevel_t level)
Definition: mythlogging.h:29
CC608Decoder::m_vpsL
int m_vpsL
Definition: cc608decoder.h:138
x0
static int x0
Definition: mythsocket.cpp:49
x3
static int x3
Definition: mythsocket.cpp:52
CC608Decoder::m_badVbi
CC608PerField m_badVbi
Definition: cc608decoder.h:104
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
kRatingCanFrench
@ kRatingCanFrench
Definition: cc608decoder.h:50
b1_to_service
static std::array< const int, 16 > b1_to_service
Definition: cc608decoder.cpp:1107
CC608Input
Definition: cc608decoder.h:30
IsPrintable
static bool IsPrintable(char c)
Definition: cc608decoder.cpp:828
CC608Decoder::m_xdsProgramTypeString
CC608ProgramType m_xdsProgramTypeString
Definition: cc608decoder.h:163
CC608Decoder::m_rowCount
CC608PerMode m_rowCount
Definition: cc608decoder.h:120
CC608Decoder::GetProgramName
QString GetProgramName(bool future) const
Definition: cc608decoder.cpp:1046
CC608Decoder::BufferCC
void BufferCC(size_t mode, int len, int clr)
Definition: cc608decoder.cpp:664
CC_MODE_MASK
static constexpr uint8_t CC_MODE_MASK
Definition: format.h:202
CC_STYLE_ROLLUP
@ CC_STYLE_ROLLUP
Definition: format.h:197
CC608Seen
std::array< bool, 4 > CC608Seen
Definition: cc608decoder.h:23
hardwareprofile.distros.mythtv_data.data_mythtv.prefix
string prefix
Definition: data_mythtv.py:40
vbi_bit_reverse
const std::array< const uint8_t, 256 > vbi_bit_reverse
Definition: vbilut.cpp:153
CC608Decoder::m_wssValid
bool m_wssValid
Definition: cc608decoder.h:142
CC608Decoder::XDSDecode
bool XDSDecode(int field, int b1, int b2)
Definition: cc608decoder.cpp:1118
tmp
static guint32 * tmp
Definition: goom_core.cpp:26
CC608Decoder::m_ignoreTimeCode
bool m_ignoreTimeCode
Definition: cc608decoder.h:99
CC608Decoder::m_newAttr
CC608PerMode m_newAttr
Definition: cc608decoder.h:116
CC608Decoder::ToASCII
static QString ToASCII(const QString &cc608, bool suppress_unknown)
Definition: cc608decoder.cpp:625
CC608Decoder::m_col
CC608PerMode m_col
Definition: cc608decoder.h:119
CC608Decoder::FalseDup
bool FalseDup(std::chrono::milliseconds tc, int field, int data)
Definition: cc608decoder.cpp:543
CC608Decoder::m_lastTc
CC608PerFieldTc m_lastTc
Definition: cc608decoder.h:105
CC_CC4
@ CC_CC4
Definition: format.h:210
CC608Decoder::m_vpsPrLabel
std::array< char, 20 > m_vpsPrLabel
Definition: cc608decoder.h:136
CC608Decoder::m_txtMode
std::array< int, 4 > m_txtMode
Definition: cc608decoder.h:110
CC608Decoder::m_newRow
CC608PerMode m_newRow
Definition: cc608decoder.h:114
CC608Decoder::m_style
CC608PerMode m_style
Definition: cc608decoder.h:121
cc608decoder.h
mythlogging.h
CC608Decoder::m_xdsCrcPassed
uint m_xdsCrcPassed
Definition: cc608decoder.h:146
vbilut.h
CC608Decoder::DecodeWSS
void DecodeWSS(const unsigned char *buf)
Definition: cc608decoder.cpp:914
kRatingMPAA
@ kRatingMPAA
Definition: cc608decoder.h:47
CC608ProgramType
std::array< QString, 96 > CC608ProgramType
Definition: cc608decoder.h:24
CC608Decoder::m_xdsProgramName
std::array< QString, 2 > m_xdsProgramName
Definition: cc608decoder.h:156
CC608Decoder::~CC608Decoder
~CC608Decoder()
Definition: cc608decoder.cpp:45
CC608Decoder::GetRatingString
QString GetRatingString(uint i, bool future) const
Definition: cc608decoder.cpp:1010
CC608Decoder::m_resumeText
CC608PerMode m_resumeText
Definition: cc608decoder.h:123
kRatingCanEnglish
@ kRatingCanEnglish
Definition: cc608decoder.h:49
CC608Decoder::m_timeCode
CC608PerModeTc m_timeCode
Definition: cc608decoder.h:117
formats
const std::array< const std::string, 8 > formats
Definition: vbilut.cpp:189
DumpPIL
static void DumpPIL(int pil)
Definition: cc608decoder.cpp:853
CC608Decoder::m_lastFormatTc
CC608PerFieldTc m_lastFormatTc
Definition: cc608decoder.h:132
PIL_TIME
static constexpr int PIL_TIME(int day, int mon, int hour, int min)
Definition: cc608decoder.cpp:850
CC_CC1
@ CC_CC1
Definition: format.h:205
kHasTPG
@ kHasTPG
Definition: cc608decoder.h:41
CC_CC2
@ CC_CC2
Definition: format.h:206
CC608Decoder::GetRatingSystems
uint GetRatingSystems(bool future) const
Definition: cc608decoder.cpp:998
CC608Decoder::m_row
CC608PerMode m_row
Definition: cc608decoder.h:118
CC608Decoder::m_xds
CC608PerField m_xds
Definition: cc608decoder.h:109
CC608Decoder::m_xdsNetCall
QString m_xdsNetCall
Definition: cc608decoder.h:159
CC608Decoder::NewRowCC
int NewRowCC(size_t mode, int len)
Definition: cc608decoder.cpp:726
CC608Decoder::m_reader
CC608Input * m_reader
Definition: cc608decoder.h:97
extendedchar3
static const std::array< const QChar, 32 > extendedchar3
Definition: cc608decoder.cpp:89
uint
unsigned int uint
Definition: compat.h:79
CC608Decoder::m_lineCont
CC608PerMode m_lineCont
Definition: cc608decoder.h:122
CC608Input::AddTextData
virtual void AddTextData(unsigned char *buf, int len, std::chrono::milliseconds timecode, char type)=0
CC608Decoder::m_ccBuf
std::array< QString, 8 > m_ccBuf
Definition: cc608decoder.h:125
CC608Decoder::m_lastRow
CC608PerMode m_lastRow
Definition: cc608decoder.h:113
CC608Decoder::CharCC
QChar CharCC(int code) const
Definition: cc608decoder.h:82
CC608Decoder::FormatCCField
void FormatCCField(std::chrono::milliseconds tc, size_t field, int data)
Definition: cc608decoder.cpp:101
CC608Decoder::m_xdsCrcFailed
uint m_xdsCrcFailed
Definition: cc608decoder.h:147
CC608Decoder::m_lastFormatData
CC608PerField m_lastFormatData
Definition: cc608decoder.h:133
musicbrainzngs.compat.unicode
unicode
Definition: compat.py:50
CC608Decoder::m_xdsRating
std::array< std::array< uint, 4 >, 2 > m_xdsRating
Definition: cc608decoder.h:155
CC608Decoder::m_xdsTsid
uint m_xdsTsid
Definition: cc608decoder.h:161
CC608Decoder::m_xdsLock
QRecursiveMutex m_xdsLock
Definition: cc608decoder.h:152
kHasCanEnglish
@ kHasCanEnglish
Definition: cc608decoder.h:42
CC608Decoder::ResetCC
void ResetCC(size_t mode)
Definition: cc608decoder.cpp:609
mythcontext.h
CC_LINE_CONT
static constexpr uint8_t CC_LINE_CONT
Definition: format.h:201
subtitles
const std::array< const std::string, 4 > subtitles
Definition: vbilut.cpp:201
CC608Decoder::XDSPacketCRC
bool XDSPacketCRC(const std::vector< unsigned char > &xds_buf)
Definition: cc608decoder.cpp:1222
cc::code1
int code1
Definition: cc.h:13
kHasCanFrench
@ kHasCanFrench
Definition: cc608decoder.h:43
CC608Decoder::DecodeVPS
void DecodeVPS(const unsigned char *buf)
Definition: cc608decoder.cpp:876
CC608Decoder::GetXDS
QString GetXDS(const QString &key) const
Definition: cc608decoder.cpp:1068
CC608Decoder::XDSPacketParse
void XDSPacketParse(const std::vector< unsigned char > &xds_buf)
Definition: cc608decoder.cpp:1189
CC608Decoder::m_stdChar
std::array< QChar, 128 > m_stdChar
Definition: cc608decoder.h:128
d
static const iso6937table * d
Definition: iso6937tables.cpp:1025
CC608Decoder::XDSPacketParseChannel
bool XDSPacketParseChannel(const std::vector< unsigned char > &xds_buf)
Definition: cc608decoder.cpp:1404
CC608Decoder::m_lastSeen
std::array< SystemTime, 4 > m_lastSeen
Definition: cc608decoder.h:101
CC608Decoder::XDSDecodeString
QString XDSDecodeString(const std::vector< unsigned char > &buf, uint start, uint end) const
Definition: cc608decoder.cpp:955
ccsubtitle
Definition: format.h:183
CC608Decoder::GetServices
void GetServices(std::chrono::seconds seconds, CC608Seen &seen) const
Definition: cc608decoder.cpp:56
CC608Decoder::m_xdsBuf
std::array< std::vector< unsigned char >, 7 > m_xdsBuf
Definition: cc608decoder.h:145
init_xds_program_type
static void init_xds_program_type(CC608ProgramType &xds_program_type)
Definition: cc608decoder.cpp:1443
CC608Decoder::XDSPacketParseProgram
bool XDSPacketParseProgram(const std::vector< unsigned char > &xds_buf, bool future)
Definition: cc608decoder.cpp:1243
CC_STYLE_POPUP
@ CC_STYLE_POPUP
Definition: format.h:195
CC608Decoder::m_xdsProgramType
std::array< std::vector< uint >, 2 > m_xdsProgramType
Definition: cc608decoder.h:157
CC608Decoder::m_wssFlags
uint m_wssFlags
Definition: cc608decoder.h:141
CC608Decoder::CC608Decoder
CC608Decoder(CC608Input *ccr)
Definition: cc608decoder.cpp:24
specialchar
static const std::array< const QChar, 16 > specialchar
Definition: cc608decoder.cpp:69
kHasMPAA
@ kHasMPAA
Definition: cc608decoder.h:40
CC608Decoder::GetProgramType
QString GetProgramType(bool future) const
Definition: cc608decoder.cpp:1052
CC608Decoder::m_lastCode
CC608PerField m_lastCode
Definition: cc608decoder.h:106
extendedchar2
static const std::array< const QChar, 32 > extendedchar2
Definition: cc608decoder.cpp:77