@svta/cml-608 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +18 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +76 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ValueOf } from "@svta/cml-utils";
|
|
|
5
5
|
/**
|
|
6
6
|
* The different caption modes that can be used.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @public
|
|
9
9
|
*/
|
|
10
10
|
type CaptionModes = "MODE_ROLL-UP" | "MODE_POP-ON" | "MODE_PAINT-ON" | "MODE_TEXT" | null;
|
|
11
11
|
//#endregion
|
|
@@ -16,7 +16,7 @@ type CaptionModes = "MODE_ROLL-UP" | "MODE_POP-ON" | "MODE_PAINT-ON" | "MODE_TEX
|
|
|
16
16
|
*
|
|
17
17
|
* @enum
|
|
18
18
|
*
|
|
19
|
-
* @
|
|
19
|
+
* @public
|
|
20
20
|
*/
|
|
21
21
|
declare const VerboseLevel: {
|
|
22
22
|
readonly ERROR: 0;
|
|
@@ -27,7 +27,7 @@ declare const VerboseLevel: {
|
|
|
27
27
|
readonly DATA: 3;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* @
|
|
30
|
+
* @public
|
|
31
31
|
*/
|
|
32
32
|
type VerboseLevel = ValueOf<typeof VerboseLevel>;
|
|
33
33
|
//#endregion
|
|
@@ -36,7 +36,7 @@ type VerboseLevel = ValueOf<typeof VerboseLevel>;
|
|
|
36
36
|
/**
|
|
37
37
|
* CaptionsLogger. To be removed in the future.
|
|
38
38
|
*
|
|
39
|
-
* @
|
|
39
|
+
* @public
|
|
40
40
|
*/
|
|
41
41
|
declare class CaptionsLogger {
|
|
42
42
|
time: number | null;
|
|
@@ -48,7 +48,7 @@ declare class CaptionsLogger {
|
|
|
48
48
|
/**
|
|
49
49
|
* Represents a single PAC (Preamble Address Code) data.
|
|
50
50
|
*
|
|
51
|
-
* @
|
|
51
|
+
* @public
|
|
52
52
|
*/
|
|
53
53
|
type PACData = {
|
|
54
54
|
row: number;
|
|
@@ -62,7 +62,7 @@ type PACData = {
|
|
|
62
62
|
/**
|
|
63
63
|
* PenStyles
|
|
64
64
|
*
|
|
65
|
-
* @
|
|
65
|
+
* @public
|
|
66
66
|
*/
|
|
67
67
|
type PenStyles = {
|
|
68
68
|
foreground: string | null;
|
|
@@ -77,7 +77,7 @@ type PenStyles = {
|
|
|
77
77
|
/**
|
|
78
78
|
* Pen state.
|
|
79
79
|
*
|
|
80
|
-
* @
|
|
80
|
+
* @public
|
|
81
81
|
*/
|
|
82
82
|
declare class PenState {
|
|
83
83
|
foreground: string;
|
|
@@ -97,7 +97,7 @@ declare class PenState {
|
|
|
97
97
|
/**
|
|
98
98
|
* Unicode character with styling and background.
|
|
99
99
|
*
|
|
100
|
-
* @
|
|
100
|
+
* @public
|
|
101
101
|
*/
|
|
102
102
|
declare class StyledUnicodeChar {
|
|
103
103
|
uchar: string;
|
|
@@ -114,7 +114,7 @@ declare class StyledUnicodeChar {
|
|
|
114
114
|
/**
|
|
115
115
|
* CTA-608 row consisting of NR_COLS instances of StyledUnicodeChar.
|
|
116
116
|
*
|
|
117
|
-
* @
|
|
117
|
+
* @public
|
|
118
118
|
*/
|
|
119
119
|
declare class Row {
|
|
120
120
|
chars: StyledUnicodeChar[];
|
|
@@ -150,7 +150,7 @@ declare class Row {
|
|
|
150
150
|
/**
|
|
151
151
|
* Keep a CTA-608 screen of 32x15 styled characters
|
|
152
152
|
*
|
|
153
|
-
* @
|
|
153
|
+
* @public
|
|
154
154
|
*/
|
|
155
155
|
declare class CaptionScreen {
|
|
156
156
|
rows: Row[];
|
|
@@ -190,7 +190,7 @@ declare class CaptionScreen {
|
|
|
190
190
|
/**
|
|
191
191
|
* A handler for CTA-608 cues.
|
|
192
192
|
*
|
|
193
|
-
* @
|
|
193
|
+
* @public
|
|
194
194
|
*/
|
|
195
195
|
type CueHandler = {
|
|
196
196
|
newCue(startTime: number, endTime: number, screen: CaptionScreen): void;
|
|
@@ -202,7 +202,7 @@ type CueHandler = {
|
|
|
202
202
|
/**
|
|
203
203
|
* CTA-608 Channel
|
|
204
204
|
*
|
|
205
|
-
* @
|
|
205
|
+
* @public
|
|
206
206
|
*/
|
|
207
207
|
declare class Cta608Channel {
|
|
208
208
|
chNr: number;
|
|
@@ -247,7 +247,7 @@ declare class Cta608Channel {
|
|
|
247
247
|
/**
|
|
248
248
|
* SupportedField
|
|
249
249
|
*
|
|
250
|
-
* @
|
|
250
|
+
* @public
|
|
251
251
|
*/
|
|
252
252
|
type SupportedField = 1 | 3;
|
|
253
253
|
//#endregion
|
|
@@ -255,7 +255,7 @@ type SupportedField = 1 | 3;
|
|
|
255
255
|
/**
|
|
256
256
|
* CEA-608 caption parser.
|
|
257
257
|
*
|
|
258
|
-
* @
|
|
258
|
+
* @public
|
|
259
259
|
*/
|
|
260
260
|
declare class Cta608Parser {
|
|
261
261
|
private channels;
|
|
@@ -337,7 +337,7 @@ declare class Cta608Parser {
|
|
|
337
337
|
* @param cta608Range - The range of the CTA-608 data
|
|
338
338
|
* @returns The extracted CTA-608 data
|
|
339
339
|
*
|
|
340
|
-
* @
|
|
340
|
+
* @public
|
|
341
341
|
*/
|
|
342
342
|
declare function extractCta608Data(raw: DataView, cta608Range: number[]): number[][];
|
|
343
343
|
//#endregion
|
|
@@ -350,7 +350,7 @@ declare function extractCta608Data(raw: DataView, cta608Range: number[]): number
|
|
|
350
350
|
* @param sampleSize - The size of the sample in bytes
|
|
351
351
|
* @returns fieldData array containing field 1 and field 2 data arrays
|
|
352
352
|
*
|
|
353
|
-
* @
|
|
353
|
+
* @public
|
|
354
354
|
*/
|
|
355
355
|
declare function extractCta608DataFromSample(raw: DataView, startPos: number, sampleSize: number): number[][];
|
|
356
356
|
//#endregion
|
|
@@ -363,7 +363,7 @@ declare function extractCta608DataFromSample(raw: DataView, startPos: number, sa
|
|
|
363
363
|
* @param size - The size of the data
|
|
364
364
|
* @returns The extracted CTA-608 NAL units
|
|
365
365
|
*
|
|
366
|
-
* @
|
|
366
|
+
* @public
|
|
367
367
|
*/
|
|
368
368
|
declare function findCta608Nalus(raw: DataView, startPos: number, size: number): number[][];
|
|
369
369
|
//#endregion
|
|
@@ -401,7 +401,7 @@ declare function findCta608Nalus(raw: DataView, startPos: number, size: number):
|
|
|
401
401
|
/**
|
|
402
402
|
* SCC Parser
|
|
403
403
|
*
|
|
404
|
-
* @
|
|
404
|
+
* @public
|
|
405
405
|
*/
|
|
406
406
|
declare class SccParser {
|
|
407
407
|
hasHeader: boolean;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/CaptionModes.ts","../src/VerboseLevel.ts","../src/CaptionsLogger.ts","../src/PACData.ts","../src/PenStyles.ts","../src/PenState.ts","../src/StyledUnicodeChar.ts","../src/Row.ts","../src/CaptionScreen.ts","../src/CueHandler.ts","../src/Cta608Channel.ts","../src/SupportedField.ts","../src/Cta608Parser.ts","../src/extractCta608Data.ts","../src/extractCta608DataFromSample.ts","../src/findCta608Nalus.ts","../src/SccParser.ts"],"sourcesContent":[],"mappings":";;;;;;;AAKA;;KAAY,YAAA;;;;;AAAZ;;;;ACKA;AAYA;cAZa;;;ECmCb,SAAa,OAAA,EAAA,CAAA;;;;ACxCb,CAAA;;;;ACAY,KHiBA,YAAA,GAAe,OGjBf,CAAA,OHiB8B,YGjB9B,CAAA;;;;;;;;;AG8CC,cLNA,cAAA,CKMA;EACE,IAAA,EAAA,MAAA,GAAA,IAAA;EAOM,YAAA,ELZC,YKYD;EAON,GAAA,CAAA,QAAA,ELjBA,YKiBA,EAAA,GAAA,EAAA,MAAA,GAAA,CAAA,GAAA,GAAA,MAAA,CAAA,CAAA,EAAA,IAAA;;;;;;;AP7Df;;KGAY,OAAA;;EFK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;;;ECR1B,QAAa,QAAA;EACE;;;;;;;;;;ACFf;;;;;EAmEwB,QAAA,UAAA;EAAR;;;;;;;;;AC9GhB;;;;AC8CA;;EAGO,cAAA,CAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;;;;AVnDP;;;;ACKA;AAYA;iBYbgB,iBAAA,MAAuB;;;;;;AbJvC;;;;ACKA;AAYA;;iBaNgB,2BAAA,MAAiC;;;;;;AdXjD;;;;ACKA;AAYA;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/CaptionModes.ts","../src/VerboseLevel.ts","../src/CaptionsLogger.ts","../src/PACData.ts","../src/PenStyles.ts","../src/PenState.ts","../src/StyledUnicodeChar.ts","../src/Row.ts","../src/CaptionScreen.ts","../src/CueHandler.ts","../src/Cta608Channel.ts","../src/SupportedField.ts","../src/Cta608Parser.ts","../src/extractCta608Data.ts","../src/extractCta608DataFromSample.ts","../src/findCta608Nalus.ts","../src/SccParser.ts"],"sourcesContent":[],"mappings":";;;;;;;AAKA;;KAAY,YAAA;;;;;AAAZ;;;;ACKA;AAYA;cAZa;;;ECmCb,SAAa,OAAA,EAAA,CAAA;;;;ACxCb,CAAA;;;;ACAY,KHiBA,YAAA,GAAe,OGjBf,CAAA,OHiB8B,YGjB9B,CAAA;;;;;;;;;AG8CC,cLNA,cAAA,CKMA;EACE,IAAA,EAAA,MAAA,GAAA,IAAA;EAOM,YAAA,ELZC,YKYD;EAON,GAAA,CAAA,QAAA,ELjBA,YKiBA,EAAA,GAAA,EAAA,MAAA,GAAA,CAAA,GAAA,GAAA,MAAA,CAAA,CAAA,EAAA,IAAA;;;;;;;AP7Df;;KGAY,OAAA;;EFKZ,MAAa,EAAA,MAAA,GAAA,IAAA;EAYb,KAAY,EAAA,MAAA,GAAA,IAAA;;;;;;;;;ADjBZ;;KIAY,SAAA;;EHKZ,SAAa,EAAA,OAAA;EAYb,OAAY,EAAA,OAAA;;;;;;;;;;;;AM6BC,cFNA,QAAA,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AAYA;iBYbgB,iBAAA,MAAuB;;;;;;AbJvC;;;;ACKA;AAYA;;iBaNgB,2BAAA,MAAiC;;;;;;AdXjD;;;;ACKA;AAYA;;iBcVgB,eAAA,MAAqB;;;;;;AfPrC;;;;ACKA;AAYA;;;;ACuBA;;;;ACxCA;;;;ACAA;;;;ACwCA;;;;;;;;;ACAA;;AASqC,cUlBxB,SAAA,CVkBwB;EAKX,SAAA,EAAA,OAAA;EAIX,aAAA,EAAA,MAAA;EAIA,SAAA,EAAA,GAAA;EAAA,KAAA,EAAA,MAAA,GAAA,GAAA;;;;EChBf,aAAa,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,MAAA;EACE,eAAA,CAAA,CAAA,EAAA,OAAA;EAOM,QAAA,CAAA,CAAA,EAAA,MAAA,GAAA,GAAA;EAON,cAAA,CAAA,CAAA,EAAA,MAAA"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @enum
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @public
|
|
9
9
|
*/
|
|
10
10
|
const VerboseLevel = {
|
|
11
11
|
ERROR: 0,
|
|
@@ -21,7 +21,7 @@ const VerboseLevel = {
|
|
|
21
21
|
/**
|
|
22
22
|
* CaptionsLogger. To be removed in the future.
|
|
23
23
|
*
|
|
24
|
-
* @
|
|
24
|
+
* @public
|
|
25
25
|
*/
|
|
26
26
|
var CaptionsLogger = class {
|
|
27
27
|
constructor() {
|
|
@@ -41,7 +41,7 @@ var CaptionsLogger = class {
|
|
|
41
41
|
/**
|
|
42
42
|
* Pen state.
|
|
43
43
|
*
|
|
44
|
-
* @
|
|
44
|
+
* @public
|
|
45
45
|
*/
|
|
46
46
|
var PenState = class {
|
|
47
47
|
constructor() {
|
|
@@ -87,7 +87,7 @@ var PenState = class {
|
|
|
87
87
|
/**
|
|
88
88
|
* Unicode character with styling and background.
|
|
89
89
|
*
|
|
90
|
-
* @
|
|
90
|
+
* @public
|
|
91
91
|
*/
|
|
92
92
|
var StyledUnicodeChar = class {
|
|
93
93
|
constructor() {
|
|
@@ -230,7 +230,7 @@ function getCharForByte(byte) {
|
|
|
230
230
|
/**
|
|
231
231
|
* CTA-608 row consisting of NR_COLS instances of StyledUnicodeChar.
|
|
232
232
|
*
|
|
233
|
-
* @
|
|
233
|
+
* @public
|
|
234
234
|
*/
|
|
235
235
|
var Row = class {
|
|
236
236
|
constructor(logger = new CaptionsLogger()) {
|
|
@@ -332,7 +332,7 @@ const NR_ROWS = 15;
|
|
|
332
332
|
/**
|
|
333
333
|
* Keep a CTA-608 screen of 32x15 styled characters
|
|
334
334
|
*
|
|
335
|
-
* @
|
|
335
|
+
* @public
|
|
336
336
|
*/
|
|
337
337
|
var CaptionScreen = class {
|
|
338
338
|
constructor(logger = new CaptionsLogger()) {
|
|
@@ -473,7 +473,7 @@ var CaptionScreen = class {
|
|
|
473
473
|
/**
|
|
474
474
|
* CTA-608 Channel
|
|
475
475
|
*
|
|
476
|
-
* @
|
|
476
|
+
* @public
|
|
477
477
|
*/
|
|
478
478
|
var Cta608Channel = class {
|
|
479
479
|
constructor(channelNumber, outputFilter, logger = new CaptionsLogger()) {
|
|
@@ -744,7 +744,7 @@ function setLastCmd(a, b, cmdHistory) {
|
|
|
744
744
|
/**
|
|
745
745
|
* CEA-608 caption parser.
|
|
746
746
|
*
|
|
747
|
-
* @
|
|
747
|
+
* @public
|
|
748
748
|
*/
|
|
749
749
|
var Cta608Parser = class {
|
|
750
750
|
constructor(field, out1, out2) {
|
|
@@ -992,7 +992,7 @@ var Cta608Parser = class {
|
|
|
992
992
|
* @param cta608Range - The range of the CTA-608 data
|
|
993
993
|
* @returns The extracted CTA-608 data
|
|
994
994
|
*
|
|
995
|
-
* @
|
|
995
|
+
* @public
|
|
996
996
|
*/
|
|
997
997
|
function extractCta608Data(raw, cta608Range) {
|
|
998
998
|
let pos = cta608Range[0];
|
|
@@ -1047,12 +1047,62 @@ function isCCType(type) {
|
|
|
1047
1047
|
function isNonEmptyCCData(ccData1, ccData2) {
|
|
1048
1048
|
return (ccData1 & 127) > 0 || (ccData2 & 127) > 0;
|
|
1049
1049
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1050
|
+
/**
|
|
1051
|
+
* H.264 SEI NAL unit type
|
|
1052
|
+
*/
|
|
1053
|
+
const H264_SEI_TYPE = 6;
|
|
1054
|
+
/**
|
|
1055
|
+
* H.265 prefix SEI NAL unit type
|
|
1056
|
+
*/
|
|
1057
|
+
const H265_PREFIX_SEI_TYPE = 39;
|
|
1058
|
+
/**
|
|
1059
|
+
* H.265 suffix SEI NAL unit type
|
|
1060
|
+
*/
|
|
1061
|
+
const H265_SUFFIX_SEI_TYPE = 40;
|
|
1062
|
+
/**
|
|
1063
|
+
* H.266 prefix SEI NAL unit type
|
|
1064
|
+
*/
|
|
1065
|
+
const H266_PREFIX_SEI_TYPE = 23;
|
|
1066
|
+
/**
|
|
1067
|
+
* H.266 suffix SEI NAL unit type
|
|
1068
|
+
*/
|
|
1069
|
+
const H266_SUFFIX_SEI_TYPE = 24;
|
|
1070
|
+
/**
|
|
1071
|
+
* Detects whether a NAL unit is an SEI (Supplemental Enhancement Information) unit
|
|
1072
|
+
* and returns its type and header size.
|
|
1073
|
+
*
|
|
1074
|
+
* This function supports auto-detection across H.264, H.265, and H.266 codecs:
|
|
1075
|
+
* - H.264: 1-byte NAL header, type in bits 0-4
|
|
1076
|
+
* - H.265: 2-byte NAL header, type in bits 1-6 of byte 0
|
|
1077
|
+
* - H.266: 2-byte NAL header, type in bits 3-7 of byte 1
|
|
1078
|
+
*
|
|
1079
|
+
* @param raw - The DataView containing the NAL unit data
|
|
1080
|
+
* @param pos - The position of the first NAL header byte
|
|
1081
|
+
* @returns An object containing the NAL unit type and header size, or null if not an SEI NAL unit
|
|
1082
|
+
*/
|
|
1083
|
+
function extractNalUnitType(raw, pos) {
|
|
1084
|
+
const byte0 = raw.getUint8(pos);
|
|
1085
|
+
const h264Type = byte0 & 31;
|
|
1086
|
+
if (h264Type === H264_SEI_TYPE) return {
|
|
1087
|
+
nalType: h264Type,
|
|
1088
|
+
headerSize: 1
|
|
1089
|
+
};
|
|
1090
|
+
const h265Type = byte0 >> 1 & 63;
|
|
1091
|
+
if (h265Type === H265_PREFIX_SEI_TYPE || h265Type === H265_SUFFIX_SEI_TYPE) return {
|
|
1092
|
+
nalType: h265Type,
|
|
1093
|
+
headerSize: 2
|
|
1094
|
+
};
|
|
1095
|
+
if (pos + 1 >= raw.byteLength) return null;
|
|
1096
|
+
const h266Type = raw.getUint8(pos + 1) >> 3 & 31;
|
|
1097
|
+
if (h266Type === H266_PREFIX_SEI_TYPE || h266Type === H266_SUFFIX_SEI_TYPE) return {
|
|
1098
|
+
nalType: h266Type,
|
|
1099
|
+
headerSize: 2
|
|
1100
|
+
};
|
|
1101
|
+
return null;
|
|
1052
1102
|
}
|
|
1053
1103
|
function parseCta608DataFromSei(sei, fieldData) {
|
|
1054
1104
|
let cursor = 0;
|
|
1055
|
-
while (cursor < sei.byteLength) {
|
|
1105
|
+
while (cursor < sei.byteLength - 1) {
|
|
1056
1106
|
let payloadType = 0;
|
|
1057
1107
|
let payloadSize = 0;
|
|
1058
1108
|
let now;
|
|
@@ -1091,18 +1141,19 @@ function parseCta608DataFromSei(sei, fieldData) {
|
|
|
1091
1141
|
* @param sampleSize - The size of the sample in bytes
|
|
1092
1142
|
* @returns fieldData array containing field 1 and field 2 data arrays
|
|
1093
1143
|
*
|
|
1094
|
-
* @
|
|
1144
|
+
* @public
|
|
1095
1145
|
*/
|
|
1096
1146
|
function extractCta608DataFromSample(raw, startPos, sampleSize) {
|
|
1097
1147
|
let nalSize = 0;
|
|
1098
|
-
let nalType = 0;
|
|
1099
1148
|
const fieldData = [[], []];
|
|
1100
|
-
for (let cursor = startPos; cursor < startPos + sampleSize -
|
|
1149
|
+
for (let cursor = startPos; cursor < startPos + sampleSize - 6; cursor++) {
|
|
1101
1150
|
nalSize = raw.getUint32(cursor);
|
|
1102
|
-
|
|
1103
|
-
if (
|
|
1104
|
-
|
|
1105
|
-
|
|
1151
|
+
const nalEnd = cursor + 4 + nalSize;
|
|
1152
|
+
if (nalEnd > startPos + sampleSize) break;
|
|
1153
|
+
const seiInfo = extractNalUnitType(raw, cursor + 4);
|
|
1154
|
+
if (seiInfo) {
|
|
1155
|
+
const seiStart = cursor + 4 + seiInfo.headerSize;
|
|
1156
|
+
if (nalEnd <= raw.byteLength) parseCta608DataFromSei(getSeiData(raw, seiStart, nalEnd), fieldData);
|
|
1106
1157
|
}
|
|
1107
1158
|
cursor += nalSize + 3;
|
|
1108
1159
|
}
|
|
@@ -1119,10 +1170,10 @@ function extractCta608DataFromSample(raw, startPos, sampleSize) {
|
|
|
1119
1170
|
* @param size - The size of the data
|
|
1120
1171
|
* @returns The extracted CTA-608 NAL units
|
|
1121
1172
|
*
|
|
1122
|
-
* @
|
|
1173
|
+
* @public
|
|
1123
1174
|
*/
|
|
1124
1175
|
function findCta608Nalus(raw, startPos, size) {
|
|
1125
|
-
let nalSize = 0, cursor = startPos
|
|
1176
|
+
let nalSize = 0, cursor = startPos;
|
|
1126
1177
|
const cta608NaluRanges = [];
|
|
1127
1178
|
const isCTA608SEI = (payloadType, payloadSize, raw$1, pos) => {
|
|
1128
1179
|
if (payloadType !== 4 || payloadSize < 8) return null;
|
|
@@ -1134,9 +1185,9 @@ function findCta608Nalus(raw, startPos, size) {
|
|
|
1134
1185
|
};
|
|
1135
1186
|
while (cursor < startPos + size) {
|
|
1136
1187
|
nalSize = raw.getUint32(cursor);
|
|
1137
|
-
|
|
1138
|
-
if (
|
|
1139
|
-
let pos = cursor +
|
|
1188
|
+
const seiInfo = extractNalUnitType(raw, cursor + 4);
|
|
1189
|
+
if (seiInfo) {
|
|
1190
|
+
let pos = cursor + 4 + seiInfo.headerSize;
|
|
1140
1191
|
let payloadType = -1;
|
|
1141
1192
|
while (pos < cursor + 4 + nalSize - 1) {
|
|
1142
1193
|
payloadType = 0;
|
|
@@ -1197,7 +1248,7 @@ function findCta608Nalus(raw, startPos, size) {
|
|
|
1197
1248
|
/**
|
|
1198
1249
|
* SCC Parser
|
|
1199
1250
|
*
|
|
1200
|
-
* @
|
|
1251
|
+
* @public
|
|
1201
1252
|
*/
|
|
1202
1253
|
var SccParser = class {
|
|
1203
1254
|
constructor(processor, field = 1) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["m: string","specialCea608CharsCodes: Record<number, number>","i: number","chars: string[]","styles: PenStyles","displayText: string[]","styles: Partial<PenStyles>","backgroundColors: string[]","hexArray: string[]","rowsHighCh1: Record<number, number>","rowsHighCh2: Record<number, number>","rowsLowCh1: Record<number, number>","rowsLowCh2: Record<number, number>","cmdFound: boolean","charsFound: number[] | null","chNr: number","row: number","chNr: Channels","pacData: PACData","channelNr: Channels","charCodes: number[]","charCode1: number | null","oneCode: number","index: number","bkgData: Partial<PenStyles>","fieldData: number[][]","ccData1: number","ccData2: number","data: number[]","nalSize: number","nalType: number","fieldData: number[][]","raw","ceaData: number[]"],"sources":["../src/VerboseLevel.ts","../src/CaptionsLogger.ts","../src/PenState.ts","../src/StyledUnicodeChar.ts","../src/utils/NR_COLS.ts","../src/utils/specialCea608CharsCodes.ts","../src/utils/getCharForByte.ts","../src/Row.ts","../src/utils/NR_ROWS.ts","../src/CaptionScreen.ts","../src/Cta608Channel.ts","../src/utils/backgroundColors.ts","../src/utils/createCmdHistory.ts","../src/utils/hasCmdRepeated.ts","../src/utils/numArrayToHexArray.ts","../src/utils/rowsHighCh1.ts","../src/utils/rowsHighCh2.ts","../src/utils/rowsLowCh1.ts","../src/utils/rowsLowCh2.ts","../src/utils/setLastCmd.ts","../src/Cta608Parser.ts","../src/extractCta608Data.ts","../src/utils/seiHelpers.ts","../src/extractCta608DataFromSample.ts","../src/findCta608Nalus.ts","../src/SccParser.ts"],"sourcesContent":["import type { ValueOf } from '@svta/cml-utils'\n\n/**\n * Logging levels for the CTA-608 parser.\n *\n *\n * @enum\n *\n * @beta\n */\nexport const VerboseLevel = {\n\tERROR: 0,\n\tTEXT: 1,\n\tWARNING: 2,\n\tINFO: 2,\n\tDEBUG: 3,\n\tDATA: 3,\n} as const\n\n/**\n * @beta\n */\nexport type VerboseLevel = ValueOf<typeof VerboseLevel>;\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport { VerboseLevel } from './VerboseLevel.ts'\n\n/**\n * CaptionsLogger. To be removed in the future.\n *\n * @beta\n */\nexport class CaptionsLogger {\n\tpublic time: number | null = null\n\tpublic verboseLevel: VerboseLevel = VerboseLevel.ERROR\n\n\tlog(severity: VerboseLevel, msg: string | (() => string)): void {\n\t\tif (this.verboseLevel >= severity) {\n\t\t\tconst m: string = typeof msg === 'function' ? msg() : msg\n\t\t\tconsole.log(`${this.time} [${severity}] ${m}`)\n\t\t}\n\t}\n}\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { PenStyles } from './PenStyles.ts'\n\n/**\n * Pen state.\n *\n * @beta\n */\nexport class PenState {\n\tpublic foreground: string = 'white'\n\tpublic underline: boolean = false\n\tpublic italics: boolean = false\n\tpublic background: string = 'black'\n\tpublic flash: boolean = false\n\n\treset(): void {\n\t\tthis.foreground = 'white'\n\t\tthis.underline = false\n\t\tthis.italics = false\n\t\tthis.background = 'black'\n\t\tthis.flash = false\n\t}\n\n\tsetStyles(styles: Partial<PenStyles>): void {\n\t\tconst attribs = [\n\t\t\t'foreground',\n\t\t\t'underline',\n\t\t\t'italics',\n\t\t\t'background',\n\t\t\t'flash',\n\t\t]\n\t\tfor (const style of attribs) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(styles, style)) {\n\t\t\t\t(this as any)[style] = (styles as any)[style]\n\t\t\t}\n\t\t}\n\t}\n\n\tisDefault(): boolean {\n\t\treturn (\n\t\t\tthis.foreground === 'white' &&\n\t\t\t!this.underline &&\n\t\t\t!this.italics &&\n\t\t\tthis.background === 'black' &&\n\t\t\t!this.flash\n\t\t)\n\t}\n\n\tequals(other: PenState): boolean {\n\t\treturn (\n\t\t\tthis.foreground === other.foreground &&\n\t\t\tthis.underline === other.underline &&\n\t\t\tthis.italics === other.italics &&\n\t\t\tthis.background === other.background &&\n\t\t\tthis.flash === other.flash\n\t\t)\n\t}\n\n\tcopy(newPenState: PenState): void {\n\t\tthis.foreground = newPenState.foreground\n\t\tthis.underline = newPenState.underline\n\t\tthis.italics = newPenState.italics\n\t\tthis.background = newPenState.background\n\t\tthis.flash = newPenState.flash\n\t}\n}\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport { PenState } from './PenState.ts'\n\n/**\n * Unicode character with styling and background.\n *\n * @beta\n */\nexport class StyledUnicodeChar {\n\tuchar: string = ' '\n\tpenState: PenState = new PenState()\n\n\treset(): void {\n\t\tthis.uchar = ' '\n\t\tthis.penState.reset()\n\t}\n\n\tsetChar(uchar: string, newPenState: PenState): void {\n\t\tthis.uchar = uchar\n\t\tthis.penState.copy(newPenState)\n\t}\n\n\tsetPenState(newPenState: PenState): void {\n\t\tthis.penState.copy(newPenState)\n\t}\n\n\tequals(other: StyledUnicodeChar): boolean {\n\t\treturn this.uchar === other.uchar && this.penState.equals(other.penState)\n\t}\n\n\tcopy(newChar: StyledUnicodeChar): void {\n\t\tthis.uchar = newChar.uchar\n\t\tthis.penState.copy(newChar.penState)\n\t}\n\n\tisEmpty(): boolean {\n\t\treturn this.uchar === ' ' && this.penState.isDefault()\n\t}\n}\n","export const NR_COLS = 100\n","/**\n * Exceptions from regular ASCII. CodePoints are mapped to UTF-16 codes\n */\nexport const specialCea608CharsCodes: Record<number, number> = {\n\t42: 225, // lowercase a, acute accent\n\t92: 233, // lowercase e, acute accent\n\t94: 237, // lowercase i, acute accent\n\t95: 243, // lowercase o, acute accent\n\t96: 250, // lowercase u, acute accent\n\t123: 231, // lowercase c with cedilla\n\t124: 247, // division symbol\n\t125: 209, // uppercase N tilde\n\t126: 241, // lowercase n tilde\n\t127: 9608, // Full block\n\n\n\n\t// THIS BLOCK INCLUDES THE 16 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS\n\t// THAT COME FROM HI BYTE=0x11 AND LOW BETWEEN 0x30 AND 0x3F\n\t// THIS MEANS THAT \\x50 MUST BE ADDED TO THE VALUES\n\t128: 174, // Registered symbol (R)\n\t129: 176, // degree sign\n\t130: 189, // 1/2 symbolOutputFilter\n\t131: 191, // Inverted (open) question mark\n\t132: 8482, // Trademark symbol (TM)\n\t133: 162, // Cents symbol\n\t134: 163, // Pounds sterling\n\t135: 9834, // Music 8'th note\n\t136: 224, // lowercase a, grave accent\n\t137: 32, // transparent space (regular)\n\t138: 232, // lowercase e, grave accent\n\t139: 226, // lowercase a, circumflex accent\n\t140: 234, // lowercase e, circumflex accent\n\t141: 238, // lowercase i, circumflex accent\n\t142: 244, // lowercase o, circumflex accent\n\t143: 251, // lowercase u, circumflex accent\n\n\n\t// THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS\n\t// THAT COME FROM HI BYTE=0x12 AND LOW BETWEEN 0x20 AND 0x3F\n\t144: 193, // capital letter A with acute\n\t145: 201, // capital letter E with acute\n\t146: 211, // capital letter O with acute\n\t147: 218, // capital letter U with acute\n\t148: 220, // capital letter U with diaresis\n\t149: 252, // lowercase letter U with diaeresis\n\t150: 8216, // opening single quote\n\t151: 161, // inverted exclamation mark\n\t152: 42, // asterisk\n\t153: 8217, // closing single quote\n\t154: 9473, // box drawings heavy horizontal\n\t155: 169, // copyright sign\n\t156: 8480, // Service mark\n\t157: 8226, // (round) bullet\n\t158: 8220, // Left double quotation mark\n\t159: 8221, // Right double quotation mark\n\t160: 192, // uppercase A, grave accent\n\t161: 194, // uppercase A, circumflex\n\t162: 199, // uppercase C with cedilla\n\t163: 200, // uppercase E, grave accent\n\t164: 202, // uppercase E, circumflex\n\t165: 203, // capital letter E with diaresis\n\t166: 235, // lowercase letter e with diaresis\n\t167: 206, // uppercase I, circumflex\n\t168: 207, // uppercase I, with diaresis\n\t169: 239, // lowercase i, with diaresis\n\t170: 212, // uppercase O, circumflex\n\t171: 217, // uppercase U, grave accent\n\t172: 249, // lowercase u, grave accent\n\t173: 219, // uppercase U, circumflex\n\t174: 171, // left-pointing double angle quotation mark\n\t175: 187, // right-pointing double angle quotation mark\n\n\n\t// THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS\n\t// THAT COME FROM HI BYTE=0x13 AND LOW BETWEEN 0x20 AND 0x3F\n\t176: 195, // Uppercase A, tilde\n\t177: 227, // Lowercase a, tilde\n\t178: 205, // Uppercase I, acute accent\n\t179: 204, // Uppercase I, grave accent\n\t180: 236, // Lowercase i, grave accent\n\t181: 210, // Uppercase O, grave accent\n\t182: 242, // Lowercase o, grave accent\n\t183: 213, // Uppercase O, tilde\n\t184: 245, // Lowercase o, tilde\n\t185: 123, // Open curly brace\n\t186: 125, // Closing curly brace\n\t187: 92, // Backslash\n\t188: 94, // Caret\n\t189: 95, // Underscore\n\t190: 124, // Pipe (vertical line)\n\t191: 8764, // Tilde operator\n\t192: 196, // Uppercase A, umlaut\n\t193: 228, // Lowercase A, umlaut\n\t194: 214, // Uppercase O, umlaut\n\t195: 246, // Lowercase o, umlaut\n\t196: 223, // Esszett (sharp S)\n\t197: 165, // Yen symbolOutputFilter\n\t198: 164, // Generic currency sign\n\t199: 9475, // Box drawings heavy vertical\n\t200: 197, // Uppercase A, ring\n\t201: 229, // Lowercase A, ring\n\t202: 216, // Uppercase O, stroke\n\t203: 248, // Lowercase o, strok\n\t204: 9487, // Box drawings heavy down and right\n\t205: 9491, // Box drawings heavy down and left\n\t206: 9495, // Box drawings heavy up and right\n\t207: 9499, // Box drawings heavy up and left\n}\n","import { specialCea608CharsCodes } from './specialCea608CharsCodes.ts'\n\nexport function getCharForByte(byte: number): string {\n\treturn String.fromCharCode(specialCea608CharsCodes[byte] || byte)\n};\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport { CaptionsLogger } from './CaptionsLogger.ts'\nimport { PenState } from './PenState.ts'\nimport type { PenStyles } from './PenStyles.ts'\nimport { StyledUnicodeChar } from './StyledUnicodeChar.ts'\nimport { VerboseLevel } from './VerboseLevel.ts'\nimport { NR_COLS } from './utils/NR_COLS.ts'\nimport { getCharForByte } from './utils/getCharForByte.ts'\n\n/**\n * CTA-608 row consisting of NR_COLS instances of StyledUnicodeChar.\n *\n * @beta\n */\nexport class Row {\n\tpublic chars: StyledUnicodeChar[] = []\n\tpublic cueStartTime: number | null = null\n\n\tprivate pos: number = 0\n\tprivate currPenState: PenState = new PenState()\n\tprivate logger: CaptionsLogger\n\n\tconstructor(logger: CaptionsLogger = new CaptionsLogger()) {\n\t\tfor (let i = 0; i < NR_COLS; i++) {\n\t\t\tthis.chars.push(new StyledUnicodeChar())\n\t\t}\n\t\tthis.logger = logger\n\t}\n\n\tequals(other: Row): boolean {\n\t\tfor (let i = 0; i < NR_COLS; i++) {\n\t\t\tif (!this.chars[i].equals(other.chars[i])) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\n\tcopy(other: Row): void {\n\t\tfor (let i = 0; i < NR_COLS; i++) {\n\t\t\tthis.chars[i].copy(other.chars[i])\n\t\t}\n\t}\n\n\tisEmpty(): boolean {\n\t\tlet empty = true\n\t\tfor (let i = 0; i < NR_COLS; i++) {\n\t\t\tif (!this.chars[i].isEmpty()) {\n\t\t\t\tempty = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn empty\n\t}\n\n\t/**\n\t * Set the cursor to a valid column.\n\t */\n\tsetCursor(absPos: number): void {\n\t\tif (this.pos !== absPos) {\n\t\t\tthis.pos = absPos\n\t\t}\n\n\t\tif (this.pos < 0) {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t'Negative cursor position ' + this.pos,\n\t\t\t)\n\t\t\tthis.pos = 0\n\t\t}\n\t\telse if (this.pos > NR_COLS) {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t'Too large cursor position ' + this.pos,\n\t\t\t)\n\t\t\tthis.pos = NR_COLS\n\t\t}\n\t}\n\n\t/**\n\t * Move the cursor relative to current position.\n\t */\n\tmoveCursor(relPos: number): void {\n\t\tconst newPos = this.pos + relPos\n\t\tif (relPos > 1) {\n\t\t\tfor (let i = this.pos + 1; i < newPos + 1; i++) {\n\t\t\t\tthis.chars[i].setPenState(this.currPenState)\n\t\t\t}\n\t\t}\n\t\tthis.setCursor(newPos)\n\t}\n\n\t/**\n\t * Backspace, move one step back and clear character.\n\t */\n\tbackSpace(): void {\n\t\tthis.moveCursor(-1)\n\t\tthis.chars[this.pos].setChar(' ', this.currPenState)\n\t}\n\n\tinsertChar(byte: number): void {\n\t\tif (byte >= 0x90) {\n\t\t\t// Extended char\n\t\t\tthis.backSpace()\n\t\t}\n\t\tconst char = getCharForByte(byte)\n\t\tif (this.pos >= NR_COLS) {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.ERROR,\n\t\t\t\t() =>\n\t\t\t\t\t'Cannot insert ' +\n\t\t\t\t\tbyte.toString(16) +\n\t\t\t\t\t' (' +\n\t\t\t\t\tchar +\n\t\t\t\t\t') at position ' +\n\t\t\t\t\tthis.pos +\n\t\t\t\t\t'. Skipping it!',\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tthis.chars[this.pos].setChar(char, this.currPenState)\n\t\tthis.moveCursor(1)\n\t}\n\n\tclearFromPos(startPos: number): void {\n\t\tlet i: number\n\t\tfor (i = startPos; i < NR_COLS; i++) {\n\t\t\tthis.chars[i].reset()\n\t\t}\n\t}\n\n\tclear(): void {\n\t\tthis.clearFromPos(0)\n\t\tthis.pos = 0\n\t\tthis.currPenState.reset()\n\t}\n\n\tclearToEndOfRow(): void {\n\t\tthis.clearFromPos(this.pos)\n\t}\n\n\tgetTextString(): string {\n\t\tconst chars: string[] = []\n\t\tlet empty = true\n\t\tfor (let i = 0; i < NR_COLS; i++) {\n\t\t\tconst char = this.chars[i].uchar\n\t\t\tif (char !== ' ') {\n\t\t\t\tempty = false\n\t\t\t}\n\n\t\t\tchars.push(char)\n\t\t}\n\t\tif (empty) {\n\t\t\treturn ''\n\t\t}\n\t\telse {\n\t\t\treturn chars.join('')\n\t\t}\n\t}\n\n\tsetPenStyles(styles: Partial<PenStyles>): void {\n\t\tthis.currPenState.setStyles(styles)\n\t\tconst currChar = this.chars[this.pos]\n\t\tcurrChar.setPenState(this.currPenState)\n\t}\n}\n","export const NR_ROWS = 15\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport { CaptionsLogger } from './CaptionsLogger.ts'\nimport type { PACData } from './PACData.ts'\nimport type { PenStyles } from './PenStyles.ts'\nimport { Row } from './Row.ts'\nimport { NR_ROWS } from './utils/NR_ROWS.ts'\nimport { VerboseLevel } from './VerboseLevel.ts'\n\n/**\n * Keep a CTA-608 screen of 32x15 styled characters\n *\n * @beta\n */\nexport class CaptionScreen {\n\trows: Row[] = []\n\tprivate currRow: number = NR_ROWS - 1\n\tprivate nrRollUpRows: number | null = null\n\tprivate lastOutputScreen: CaptionScreen | null = null\n\tprivate logger: CaptionsLogger\n\n\tconstructor(logger: CaptionsLogger = new CaptionsLogger()) {\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tthis.rows.push(new Row(logger))\n\t\t}\n\t\tthis.logger = logger\n\t}\n\n\treset(): void {\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tthis.rows[i].clear()\n\t\t}\n\t\tthis.currRow = NR_ROWS - 1\n\t}\n\n\tequals(other: CaptionScreen): boolean {\n\t\tlet equal = true\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tif (!this.rows[i].equals(other.rows[i])) {\n\t\t\t\tequal = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn equal\n\t}\n\n\tcopy(other: CaptionScreen): void {\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tthis.rows[i].copy(other.rows[i])\n\t\t}\n\t}\n\n\tisEmpty(): boolean {\n\t\tlet empty = true\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tif (!this.rows[i].isEmpty()) {\n\t\t\t\tempty = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn empty\n\t}\n\n\tbackSpace(): void {\n\t\tconst row = this.rows[this.currRow]\n\t\trow.backSpace()\n\t}\n\n\tclearToEndOfRow(): void {\n\t\tconst row = this.rows[this.currRow]\n\t\trow.clearToEndOfRow()\n\t}\n\n\t/**\n\t * Insert a character (without styling) in the current row.\n\t */\n\tinsertChar(char: number): void {\n\t\tconst row = this.rows[this.currRow]\n\t\trow.insertChar(char)\n\t}\n\n\tsetPen(styles: Partial<PenStyles>): void {\n\t\tconst row = this.rows[this.currRow]\n\t\trow.setPenStyles(styles)\n\t}\n\n\tmoveCursor(relPos: number): void {\n\t\tconst row = this.rows[this.currRow]\n\t\trow.moveCursor(relPos)\n\t}\n\n\tsetCursor(absPos: number): void {\n\t\tthis.logger.log(VerboseLevel.INFO, 'setCursor: ' + absPos)\n\t\tconst row = this.rows[this.currRow]\n\t\trow.setCursor(absPos)\n\t}\n\n\tsetPAC(pacData: PACData): void {\n\t\tthis.logger.log(\n\t\t\tVerboseLevel.INFO,\n\t\t\t() => 'pacData = ' + JSON.stringify(pacData),\n\t\t)\n\t\tlet newRow = pacData.row - 1\n\t\tif (this.nrRollUpRows && newRow < this.nrRollUpRows - 1) {\n\t\t\tnewRow = this.nrRollUpRows - 1\n\t\t}\n\n\t\t// Make sure this only affects Roll-up Captions by checking this.nrRollUpRows\n\t\tif (this.nrRollUpRows && this.currRow !== newRow) {\n\t\t\t// clear all rows first\n\t\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\t\tthis.rows[i].clear()\n\t\t\t}\n\n\t\t\t// Copy this.nrRollUpRows rows from lastOutputScreen and place it in the newRow location\n\t\t\t// topRowIndex - the start of rows to copy (inclusive index)\n\t\t\tconst topRowIndex = this.currRow + 1 - this.nrRollUpRows\n\t\t\t// We only copy if the last position was already shown.\n\t\t\t// We use the cueStartTime value to check this.\n\t\t\tconst lastOutputScreen = this.lastOutputScreen\n\t\t\tif (lastOutputScreen) {\n\t\t\t\tconst prevLineTime = lastOutputScreen.rows[topRowIndex].cueStartTime\n\t\t\t\tconst time = this.logger.time\n\t\t\t\tif (prevLineTime !== null && time !== null && prevLineTime < time) {\n\t\t\t\t\tfor (let i = 0; i < this.nrRollUpRows; i++) {\n\t\t\t\t\t\tthis.rows[newRow - this.nrRollUpRows + i + 1].copy(\n\t\t\t\t\t\t\tlastOutputScreen.rows[topRowIndex + i],\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.currRow = newRow\n\t\tconst row = this.rows[this.currRow]\n\t\tif (pacData.indent !== null) {\n\t\t\tconst indent = pacData.indent\n\t\t\tconst prevPos = Math.max(indent - 1, 0)\n\t\t\trow.setCursor(pacData.indent)\n\t\t\tpacData.color = row.chars[prevPos].penState.foreground\n\t\t}\n\t\tconst styles: PenStyles = {\n\t\t\tforeground: pacData.color,\n\t\t\tunderline: pacData.underline,\n\t\t\titalics: pacData.italics,\n\t\t\tbackground: 'black',\n\t\t\tflash: false,\n\t\t}\n\t\tthis.setPen(styles)\n\t}\n\n\t/**\n\t * Set background/extra foreground, but first do back_space, and then insert space (backwards compatibility).\n\t */\n\tsetBkgData(bkgData: Partial<PenStyles>): void {\n\t\tthis.logger.log(\n\t\t\tVerboseLevel.INFO,\n\t\t\t() => 'bkgData = ' + JSON.stringify(bkgData),\n\t\t)\n\t\tthis.backSpace()\n\t\tthis.setPen(bkgData)\n\t\tthis.insertChar(0x20) // Space\n\t}\n\n\tsetRollUpRows(nrRows: number | null): void {\n\t\tthis.nrRollUpRows = nrRows\n\t}\n\n\trollUp(): void {\n\t\tif (this.nrRollUpRows === null) {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t'roll_up but nrRollUpRows not set yet',\n\t\t\t)\n\t\t\treturn // Not properly setup\n\t\t}\n\t\tthis.logger.log(VerboseLevel.TEXT, () => this.getDisplayText())\n\t\tconst topRowIndex = this.currRow + 1 - this.nrRollUpRows\n\t\tconst topRow = this.rows.splice(topRowIndex, 1)[0]\n\t\ttopRow.clear()\n\t\tthis.rows.splice(this.currRow, 0, topRow)\n\t\tthis.logger.log(VerboseLevel.INFO, 'Rolling up')\n\t}\n\n\t/**\n\t * Get all non-empty rows with as unicode text.\n\t */\n\tgetDisplayText(asOneRow?: boolean): string {\n\t\tasOneRow = asOneRow || false\n\t\tconst displayText: string[] = []\n\t\tlet text = ''\n\t\tlet rowNr = -1\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tconst rowText = this.rows[i].getTextString()\n\t\t\tif (rowText) {\n\t\t\t\trowNr = i + 1\n\t\t\t\tif (asOneRow) {\n\t\t\t\t\tdisplayText.push('Row ' + rowNr + \": '\" + rowText + \"'\")\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdisplayText.push(rowText.trim())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (displayText.length > 0) {\n\t\t\tif (asOneRow) {\n\t\t\t\ttext = '[' + displayText.join(' | ') + ']'\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttext = displayText.join('\\n')\n\t\t\t}\n\t\t}\n\t\treturn text\n\t}\n\n\tgetTextAndFormat(): Row[] {\n\t\treturn this.rows\n\t}\n}\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { CaptionModes } from './CaptionModes.ts'\nimport { CaptionScreen } from './CaptionScreen.ts'\nimport { CaptionsLogger } from './CaptionsLogger.ts'\nimport type { CueHandler } from './CueHandler.ts'\nimport type { PACData } from './PACData.ts'\nimport type { PenStyles } from './PenStyles.ts'\nimport type { Row } from './Row.ts'\nimport { VerboseLevel } from './VerboseLevel.ts'\nimport { NR_ROWS } from './utils/NR_ROWS.ts'\n\n/**\n * CTA-608 Channel\n *\n * @beta\n */\nexport class Cta608Channel {\n\tchNr: number\n\toutputFilter: CueHandler\n\tmode: CaptionModes\n\tdisplayedMemory: CaptionScreen\n\tnonDisplayedMemory: CaptionScreen\n\tlastOutputScreen: CaptionScreen\n\tcurrRollUpRow: Row\n\twriteScreen: CaptionScreen\n\tcueStartTime: number | null\n\n\tprivate logger: CaptionsLogger\n\n\tconstructor(\n\t\tchannelNumber: number,\n\t\toutputFilter: CueHandler,\n\t\tlogger: CaptionsLogger = new CaptionsLogger(),\n\t) {\n\t\tthis.chNr = channelNumber\n\t\tthis.outputFilter = outputFilter\n\t\tthis.mode = null\n\t\tthis.displayedMemory = new CaptionScreen(logger)\n\t\tthis.nonDisplayedMemory = new CaptionScreen(logger)\n\t\tthis.lastOutputScreen = new CaptionScreen(logger)\n\t\tthis.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1]\n\t\tthis.writeScreen = this.displayedMemory\n\t\tthis.mode = null\n\t\tthis.cueStartTime = null // Keeps track of where a cue started.\n\t\tthis.logger = logger\n\n\t\tthis.logger.log(VerboseLevel.INFO, 'new Cea608Channel(' + this.chNr + ')')\n\t}\n\n\treset(): void {\n\t\tthis.mode = null\n\t\tthis.displayedMemory.reset()\n\t\tthis.nonDisplayedMemory.reset()\n\t\tthis.lastOutputScreen.reset()\n\t\tthis.outputFilter?.reset?.()\n\t\tthis.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1]\n\t\tthis.writeScreen = this.displayedMemory\n\t\tthis.mode = null\n\t\tthis.cueStartTime = null\n\t}\n\n\tgetHandler(): CueHandler {\n\t\treturn this.outputFilter\n\t}\n\n\tsetHandler(outputFilter: CueHandler): void {\n\t\tthis.outputFilter = outputFilter\n\t}\n\n\tsetPAC(pacData: PACData): void {\n\t\tthis.writeScreen.setPAC(pacData)\n\t}\n\n\tsetBkgData(bkgData: Partial<PenStyles>): void {\n\t\tthis.writeScreen.setBkgData(bkgData)\n\t}\n\n\tsetMode(newMode: CaptionModes): void {\n\t\tif (newMode === this.mode) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.mode = newMode\n\t\tthis.logger.log(VerboseLevel.INFO, () => 'MODE=' + newMode)\n\t\tif (this.mode === 'MODE_POP-ON') {\n\t\t\tthis.writeScreen = this.nonDisplayedMemory\n\t\t}\n\t\telse {\n\t\t\tthis.writeScreen = this.displayedMemory\n\t\t\tthis.writeScreen.reset()\n\t\t}\n\t\tif (this.mode !== 'MODE_ROLL-UP') {\n\t\t\tthis.displayedMemory.setRollUpRows(null)\n\t\t\tthis.nonDisplayedMemory.setRollUpRows(null)\n\t\t}\n\t\tthis.mode = newMode\n\t}\n\n\tinsertChars(chars: number[]): void {\n\t\tfor (const char of chars) {\n\t\t\tthis.writeScreen.insertChar(char)\n\t\t}\n\n\t\tconst screen =\n\t\t\tthis.writeScreen === this.displayedMemory ? 'DISP' : 'NON_DISP'\n\t\tthis.logger.log(\n\t\t\tVerboseLevel.INFO,\n\t\t\t() => screen + ': ' + this.writeScreen.getDisplayText(true),\n\t\t)\n\t\tif (this.mode === 'MODE_PAINT-ON' || this.mode === 'MODE_ROLL-UP') {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.TEXT,\n\t\t\t\t() => 'DISPLAYED: ' + this.displayedMemory.getDisplayText(true),\n\t\t\t)\n\t\t\tthis.outputDataUpdate()\n\t\t}\n\t}\n\n\tccRCL(): void {\n\t\t// Resume Caption Loading (switch mode to Pop On)\n\t\tthis.logger.log(VerboseLevel.INFO, 'RCL - Resume Caption Loading')\n\t\tthis.setMode('MODE_POP-ON')\n\t}\n\n\tccBS(): void {\n\t\t// BackSpace\n\t\tthis.logger.log(VerboseLevel.INFO, 'BS - BackSpace')\n\t\tif (this.mode === 'MODE_TEXT') {\n\t\t\treturn\n\t\t}\n\n\t\tthis.writeScreen.backSpace()\n\t\tif (this.writeScreen === this.displayedMemory) {\n\t\t\tthis.outputDataUpdate()\n\t\t}\n\t}\n\n\tccAOF(): void {\n\t\t// Reserved (formerly Alarm Off)\n\t}\n\n\tccAON(): void {\n\t\t// Reserved (formerly Alarm On)\n\t}\n\n\tccDER(): void {\n\t\t// Delete to End of Row\n\t\tthis.logger.log(VerboseLevel.INFO, 'DER- Delete to End of Row')\n\t\tthis.writeScreen.clearToEndOfRow()\n\t\tthis.outputDataUpdate()\n\t}\n\n\tccRU(nrRows: number | null): void {\n\t\t// Roll-Up Captions-2,3,or 4 Rows\n\t\tthis.logger.log(VerboseLevel.INFO, 'RU(' + nrRows + ') - Roll Up')\n\t\tthis.writeScreen = this.displayedMemory\n\t\tthis.setMode('MODE_ROLL-UP')\n\t\tthis.writeScreen.setRollUpRows(nrRows)\n\t}\n\n\tccFON(): void {\n\t\t// Flash On\n\t\tthis.logger.log(VerboseLevel.INFO, 'FON - Flash On')\n\t\tthis.writeScreen.setPen({ flash: true })\n\t}\n\n\tccRDC(): void {\n\t\t// Resume Direct Captioning (switch mode to PaintOn)\n\t\tthis.logger.log(VerboseLevel.INFO, 'RDC - Resume Direct Captioning')\n\t\tthis.setMode('MODE_PAINT-ON')\n\t}\n\n\tccTR(): void {\n\t\t// Text Restart in text mode (not supported, however)\n\t\tthis.logger.log(VerboseLevel.INFO, 'TR')\n\t\tthis.setMode('MODE_TEXT')\n\t}\n\n\tccRTD(): void {\n\t\t// Resume Text Display in Text mode (not supported, however)\n\t\tthis.logger.log(VerboseLevel.INFO, 'RTD')\n\t\tthis.setMode('MODE_TEXT')\n\t}\n\n\tccEDM(): void {\n\t\t// Erase Displayed Memory\n\t\tthis.logger.log(VerboseLevel.INFO, 'EDM - Erase Displayed Memory')\n\t\tthis.displayedMemory.reset()\n\t\tthis.outputDataUpdate(true)\n\t}\n\n\tccCR(): void {\n\t\t// Carriage Return\n\t\tthis.logger.log(VerboseLevel.INFO, 'CR - Carriage Return')\n\t\tthis.writeScreen.rollUp()\n\t\tthis.outputDataUpdate(true)\n\t}\n\n\tccENM(): void {\n\t\t// Erase Non-Displayed Memory\n\t\tthis.logger.log(VerboseLevel.INFO, 'ENM - Erase Non-displayed Memory')\n\t\tthis.nonDisplayedMemory.reset()\n\t}\n\n\tccEOC(): void {\n\t\t// End of Caption (Flip Memories)\n\t\tthis.logger.log(VerboseLevel.INFO, 'EOC - End Of Caption')\n\t\tif (this.mode === 'MODE_POP-ON') {\n\t\t\tconst tmp = this.displayedMemory\n\t\t\tthis.displayedMemory = this.nonDisplayedMemory\n\t\t\tthis.nonDisplayedMemory = tmp\n\t\t\tthis.writeScreen = this.nonDisplayedMemory\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.TEXT,\n\t\t\t\t() => 'DISP: ' + this.displayedMemory.getDisplayText(),\n\t\t\t)\n\t\t}\n\t\tthis.outputDataUpdate(true)\n\t}\n\n\tccTO(nrCols: number): void {\n\t\t// Tab Offset 1,2, or 3 columns\n\t\tthis.logger.log(VerboseLevel.INFO, 'TO(' + nrCols + ') - Tab Offset')\n\t\tthis.writeScreen.moveCursor(nrCols)\n\t}\n\n\tccMIDROW(secondByte: number): void {\n\t\t// Parse MIDROW command\n\t\tconst styles: Partial<PenStyles> = { flash: false }\n\t\tstyles.underline = secondByte % 2 === 1\n\t\tstyles.italics = secondByte >= 0x2e\n\t\tif (!styles.italics) {\n\t\t\tconst colorIndex = Math.floor(secondByte / 2) - 0x10\n\t\t\tconst colors = [\n\t\t\t\t'white',\n\t\t\t\t'green',\n\t\t\t\t'blue',\n\t\t\t\t'cyan',\n\t\t\t\t'red',\n\t\t\t\t'yellow',\n\t\t\t\t'magenta',\n\t\t\t]\n\t\t\tstyles.foreground = colors[colorIndex]\n\t\t}\n\t\telse {\n\t\t\tstyles.foreground = 'white'\n\t\t}\n\t\tthis.logger.log(VerboseLevel.INFO, 'MIDROW: ' + JSON.stringify(styles))\n\t\tthis.writeScreen.setPen(styles)\n\t}\n\n\toutputDataUpdate(dispatch: boolean = false): void {\n\t\tconst time = this.logger.time\n\t\tif (time === null) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.outputFilter) {\n\t\t\tif (this.cueStartTime === null && !this.displayedMemory.isEmpty()) {\n\t\t\t\t// Start of a new cue\n\t\t\t\tthis.cueStartTime = time\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (!this.displayedMemory.equals(this.lastOutputScreen)) {\n\t\t\t\t\tthis.outputFilter.newCue(\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tthis.cueStartTime!,\n\t\t\t\t\t\ttime,\n\t\t\t\t\t\tthis.lastOutputScreen,\n\t\t\t\t\t)\n\t\t\t\t\tif (dispatch && this.outputFilter.dispatchCue) {\n\t\t\t\t\t\tthis.outputFilter.dispatchCue()\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.cueStartTime = this.displayedMemory.isEmpty() ? null : time\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.lastOutputScreen.copy(this.displayedMemory)\n\t\t}\n\t}\n\n\tcueSplitAtTime(t: number): void {\n\t\tif (this.outputFilter) {\n\t\t\tif (!this.displayedMemory.isEmpty()) {\n\t\t\t\tif (this.outputFilter.newCue) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tthis.outputFilter.newCue(this.cueStartTime!, t, this.displayedMemory)\n\t\t\t\t}\n\n\t\t\t\tthis.cueStartTime = t\n\t\t\t}\n\t\t}\n\t}\n}\n","export const backgroundColors: string[] = [\n\t'white',\n\t'green',\n\t'blue',\n\t'cyan',\n\t'red',\n\t'yellow',\n\t'magenta',\n\t'black',\n\t'transparent',\n]\n","import type { CmdHistory } from '../CmdHistory.ts'\n\nexport function createCmdHistory(): CmdHistory {\n\treturn {\n\t\ta: null,\n\t\tb: null,\n\t}\n}\n","import type { CmdHistory } from '../CmdHistory.ts'\n\nexport function hasCmdRepeated(a: number, b: number, cmdHistory: CmdHistory): boolean {\n\treturn cmdHistory.a === a && cmdHistory.b === b\n}\n","export function numArrayToHexArray(numArray: number[]): string[] {\n\tconst hexArray: string[] = []\n\tfor (const num of numArray) {\n\t\thexArray.push(num.toString(16))\n\t}\n\n\treturn hexArray\n};\n","export const rowsHighCh1: Record<number, number> = {\n\t17: 2,\n\t18: 4,\n\t21: 6,\n\t22: 8,\n\t23: 10,\n\t19: 13,\n\t20: 15,\n}\n","export const rowsHighCh2: Record<number, number> = {\n\t25: 2,\n\t26: 4,\n\t29: 6,\n\t30: 8,\n\t31: 10,\n\t27: 13,\n\t28: 15,\n}\n","// Tables to look up row from PAC data\n\nexport const rowsLowCh1: Record<number, number> = {\n\t17: 1,\n\t18: 3,\n\t21: 5,\n\t22: 7,\n\t23: 9,\n\t16: 11,\n\t19: 12,\n\t20: 14,\n}\n","export const rowsLowCh2: Record<number, number> = {\n\t25: 1,\n\t26: 3,\n\t29: 5,\n\t30: 7,\n\t31: 9,\n\t24: 11,\n\t27: 12,\n\t28: 14,\n}\n","import type { CmdHistory } from '../CmdHistory.ts'\n\nexport function setLastCmd(\n\ta: number | null,\n\tb: number | null,\n\tcmdHistory: CmdHistory,\n): void {\n\tcmdHistory.a = a\n\tcmdHistory.b = b\n}\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport { CaptionsLogger } from './CaptionsLogger.ts'\nimport type { Channels } from './Channels.ts'\nimport type { CmdHistory } from './CmdHistory.ts'\nimport { Cta608Channel } from './Cta608Channel.ts'\nimport type { PACData } from './PACData.ts'\nimport type { PenStyles } from './PenStyles.ts'\nimport type { SupportedField } from './SupportedField.ts'\nimport { VerboseLevel } from './VerboseLevel.ts'\nimport { backgroundColors } from './utils/backgroundColors.ts'\nimport { createCmdHistory } from './utils/createCmdHistory.ts'\nimport { getCharForByte } from './utils/getCharForByte.ts'\nimport { hasCmdRepeated } from './utils/hasCmdRepeated.ts'\nimport { numArrayToHexArray } from './utils/numArrayToHexArray.ts'\nimport { rowsHighCh1 } from './utils/rowsHighCh1.ts'\nimport { rowsHighCh2 } from './utils/rowsHighCh2.ts'\nimport { rowsLowCh1 } from './utils/rowsLowCh1.ts'\nimport { rowsLowCh2 } from './utils/rowsLowCh2.ts'\nimport { setLastCmd } from './utils/setLastCmd.ts'\n\n/**\n * CEA-608 caption parser.\n *\n * @beta\n */\nexport class Cta608Parser {\n\tprivate channels: (Cta608Channel | null)[]\n\tprivate currentChannel: Channels = 0\n\tprivate cmdHistory: CmdHistory = createCmdHistory()\n\tprivate logger: CaptionsLogger\n\tprivate lastTime: number | null = null\n\n\tconstructor(field: SupportedField, out1: any, out2: any) {\n\t\tconst logger = (this.logger = new CaptionsLogger())\n\t\tthis.channels = [\n\t\t\tnull,\n\t\t\tnew Cta608Channel(field, out1, logger),\n\t\t\tnew Cta608Channel(field + 1, out2, logger),\n\t\t]\n\t}\n\n\t/**\n\t * Add data for time t in forms of list of bytes (unsigned ints). The bytes are treated as pairs.\n\t *\n\t * @param time - The time in milliseconds\n\t * @param byteList - The list of bytes\n\t */\n\taddData(time: number | null, byteList: number[]): void {\n\t\tthis.lastTime = time\n\t\tthis.logger.time = time\n\n\t\tfor (let i = 0; i < byteList.length; i += 2) {\n\t\t\tconst a = byteList[i] & 0x7f\n\t\t\tconst b = byteList[i + 1] & 0x7f\n\t\t\tlet cmdFound: boolean = false\n\t\t\tlet charsFound: number[] | null = null\n\n\t\t\tif (this.lastTime !== null) {\n\t\t\t\ttime = this.lastTime + 0.5 * i * 1001 / 30000\n\t\t\t\tthis.logger.time = time\n\t\t\t}\n\n\t\t\tif (a === 0 && b === 0) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.logger.log(\n\t\t\t\t\tVerboseLevel.DATA,\n\t\t\t\t\t() =>\n\t\t\t\t\t\t'[' +\n\t\t\t\t\t\tnumArrayToHexArray([byteList[i], byteList[i + 1]]) +\n\t\t\t\t\t\t'] -> (' +\n\t\t\t\t\t\tnumArrayToHexArray([a, b]) +\n\t\t\t\t\t\t')',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tconst cmdHistory = this.cmdHistory\n\t\t\tconst isControlCode = a >= 0x10 && a <= 0x1f\n\t\t\tif (isControlCode) {\n\t\t\t\t// Skip redundant control codes\n\t\t\t\tif (hasCmdRepeated(a, b, cmdHistory)) {\n\t\t\t\t\tsetLastCmd(null, null, cmdHistory)\n\t\t\t\t\tthis.logger.log(\n\t\t\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t'Repeated command (' +\n\t\t\t\t\t\t\tnumArrayToHexArray([a, b]) +\n\t\t\t\t\t\t\t') is dropped',\n\t\t\t\t\t)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tsetLastCmd(a, b, this.cmdHistory)\n\n\t\t\t\tcmdFound = this.parseCmd(a, b)\n\n\t\t\t\tif (!cmdFound) {\n\t\t\t\t\tcmdFound = this.parseMidrow(a, b)\n\t\t\t\t}\n\n\t\t\t\tif (!cmdFound) {\n\t\t\t\t\tcmdFound = this.parsePAC(a, b)\n\t\t\t\t}\n\n\t\t\t\tif (!cmdFound) {\n\t\t\t\t\tcmdFound = this.parseBackgroundAttributes(a, b)\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsetLastCmd(null, null, cmdHistory)\n\t\t\t}\n\n\t\t\tif (!cmdFound) {\n\t\t\t\tcharsFound = this.parseChars(a, b)\n\t\t\t\tif (charsFound.length) {\n\t\t\t\t\tconst currChNr = this.currentChannel\n\t\t\t\t\tif (currChNr && currChNr > 0) {\n\t\t\t\t\t\tconst channel = this.channels[currChNr] as Cta608Channel\n\t\t\t\t\t\tchannel.insertChars(charsFound)\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.logger.log(\n\t\t\t\t\t\t\tVerboseLevel.WARNING,\n\t\t\t\t\t\t\t'No channel found yet. TEXT-MODE?',\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!cmdFound && !charsFound) {\n\t\t\t\tthis.logger.log(\n\t\t\t\t\tVerboseLevel.WARNING,\n\t\t\t\t\t() =>\n\t\t\t\t\t\t\"Couldn't parse cleaned data \" +\n\t\t\t\t\t\tnumArrayToHexArray([a, b]) +\n\t\t\t\t\t\t' orig: ' +\n\t\t\t\t\t\tnumArrayToHexArray([byteList[i], byteList[i + 1]]),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Parse Command.\n\t *\n\t * @param a - The first byte\n\t * @param b - The second byte\n\t * @returns True if a command was found\n\t */\n\tprivate parseCmd(a: number, b: number): boolean {\n\n\t\tconst cond1 =\n\t\t\t(a === 0x14 || a === 0x1c || a === 0x15 || a === 0x1d) &&\n\t\t\tb >= 0x20 &&\n\t\t\tb <= 0x2f\n\t\tconst cond2 = (a === 0x17 || a === 0x1f) && b >= 0x21 && b <= 0x23\n\t\tif (!(cond1 || cond2)) {\n\t\t\treturn false\n\t\t}\n\n\t\tconst chNr = a === 0x14 || a === 0x15 || a === 0x17 ? 1 : 2\n\t\tconst channel = this.channels[chNr] as Cta608Channel\n\n\t\tif (a === 0x14 || a === 0x15 || a === 0x1c || a === 0x1d) {\n\t\t\tif (b === 0x20) {\n\t\t\t\tchannel.ccRCL()\n\t\t\t}\n\t\t\telse if (b === 0x21) {\n\t\t\t\tchannel.ccBS()\n\t\t\t}\n\t\t\telse if (b === 0x22) {\n\t\t\t\tchannel.ccAOF()\n\t\t\t}\n\t\t\telse if (b === 0x23) {\n\t\t\t\tchannel.ccAON()\n\t\t\t}\n\t\t\telse if (b === 0x24) {\n\t\t\t\tchannel.ccDER()\n\t\t\t}\n\t\t\telse if (b === 0x25) {\n\t\t\t\tchannel.ccRU(2)\n\t\t\t}\n\t\t\telse if (b === 0x26) {\n\t\t\t\tchannel.ccRU(3)\n\t\t\t}\n\t\t\telse if (b === 0x27) {\n\t\t\t\tchannel.ccRU(4)\n\t\t\t}\n\t\t\telse if (b === 0x28) {\n\t\t\t\tchannel.ccFON()\n\t\t\t}\n\t\t\telse if (b === 0x29) {\n\t\t\t\tchannel.ccRDC()\n\t\t\t}\n\t\t\telse if (b === 0x2a) {\n\t\t\t\tchannel.ccTR()\n\t\t\t}\n\t\t\telse if (b === 0x2b) {\n\t\t\t\tchannel.ccRTD()\n\t\t\t}\n\t\t\telse if (b === 0x2c) {\n\t\t\t\tchannel.ccEDM()\n\t\t\t}\n\t\t\telse if (b === 0x2d) {\n\t\t\t\tchannel.ccCR()\n\t\t\t}\n\t\t\telse if (b === 0x2e) {\n\t\t\t\tchannel.ccENM()\n\t\t\t}\n\t\t\telse if (b === 0x2f) {\n\t\t\t\tchannel.ccEOC()\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t// a == 0x17 || a == 0x1F\n\t\t\tchannel.ccTO(b - 0x20)\n\t\t}\n\n\t\tthis.currentChannel = chNr\n\t\treturn true\n\t}\n\n\t/**\n\t * Parse midrow styling command\n\t *\n\t * @param a - The first byte\n\t * @param b - The second byte\n\t * @returns `true` if midrow styling command was found\n\t */\n\tprivate parseMidrow(a: number, b: number): boolean {\n\t\tlet chNr: number = 0\n\n\t\tif ((a === 0x11 || a === 0x19) && b >= 0x20 && b <= 0x2f) {\n\t\t\tif (a === 0x11) {\n\t\t\t\tchNr = 1\n\t\t\t}\n\t\t\telse {\n\t\t\t\tchNr = 2\n\t\t\t}\n\n\t\t\tif (chNr !== this.currentChannel) {\n\t\t\t\tthis.logger.log(\n\t\t\t\t\tVerboseLevel.ERROR,\n\t\t\t\t\t'Mismatch channel in midrow parsing',\n\t\t\t\t)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tconst channel = this.channels[chNr]\n\t\t\tif (!channel) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tchannel.ccMIDROW(b)\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t() => 'MIDROW (' + numArrayToHexArray([a, b]) + ')',\n\t\t\t)\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\t/**\n\t * Parse Preable Access Codes (Table 53).\n\t *\n\t * @param a - The first byte\n\t * @param b - The second byte\n\t * @returns A Boolean that tells if PAC found\n\t */\n\tprivate parsePAC(a: number, b: number): boolean {\n\t\tlet row: number\n\n\t\tconst case1 =\n\t\t\t((a >= 0x11 && a <= 0x17) || (a >= 0x19 && a <= 0x1f)) &&\n\t\t\tb >= 0x40 &&\n\t\t\tb <= 0x7f\n\t\tconst case2 = (a === 0x10 || a === 0x18) && b >= 0x40 && b <= 0x5f\n\t\tif (!(case1 || case2)) {\n\t\t\treturn false\n\t\t}\n\n\t\tconst chNr: Channels = a <= 0x17 ? 1 : 2\n\n\t\tif (b >= 0x40 && b <= 0x5f) {\n\t\t\trow = chNr === 1 ? rowsLowCh1[a] : rowsLowCh2[a]\n\t\t}\n\t\telse {\n\t\t\t// 0x60 <= b <= 0x7F\n\t\t\trow = chNr === 1 ? rowsHighCh1[a] : rowsHighCh2[a]\n\t\t}\n\t\tconst channel = this.channels[chNr]\n\t\tif (!channel) {\n\t\t\treturn false\n\t\t}\n\t\tchannel.setPAC(this.interpretPAC(row, b))\n\t\tthis.currentChannel = chNr\n\t\treturn true\n\t}\n\n\t/**\n\t * Interpret the second byte of the pac, and return the information.\n\t *\n\t * @param row - The row number\n\t * @param byte - The second byte\n\t * @returns pacData with style parameters\n\t */\n\tprivate interpretPAC(row: number, byte: number): PACData {\n\t\tlet pacIndex\n\t\tconst pacData: PACData = {\n\t\t\tcolor: null,\n\t\t\titalics: false,\n\t\t\tindent: null,\n\t\t\tunderline: false,\n\t\t\trow: row,\n\t\t}\n\n\t\tif (byte > 0x5f) {\n\t\t\tpacIndex = byte - 0x60\n\t\t}\n\t\telse {\n\t\t\tpacIndex = byte - 0x40\n\t\t}\n\n\t\tpacData.underline = (pacIndex & 1) === 1\n\t\tif (pacIndex <= 0xd) {\n\t\t\tpacData.color = [\n\t\t\t\t'white',\n\t\t\t\t'green',\n\t\t\t\t'blue',\n\t\t\t\t'cyan',\n\t\t\t\t'red',\n\t\t\t\t'yellow',\n\t\t\t\t'magenta',\n\t\t\t\t'white',\n\t\t\t][Math.floor(pacIndex / 2)]\n\t\t}\n\t\telse if (pacIndex <= 0xf) {\n\t\t\tpacData.italics = true\n\t\t\tpacData.color = 'white'\n\t\t}\n\t\telse {\n\t\t\tpacData.indent = Math.floor((pacIndex - 0x10) / 2) * 4\n\t\t}\n\t\treturn pacData // Note that row has zero offset. The spec uses 1.\n\t}\n\n\t/**\n\t * Parse characters.\n\t *\n\t * @param a - The first byte\n\t * @param b - The second byte\n\t * @returns An array with 1 to 2 codes corresponding to chars, if found. null otherwise.\n\t */\n\tprivate parseChars(a: number, b: number): number[] {\n\t\tlet channelNr: Channels\n\t\tlet charCodes: number[] = []\n\t\tlet charCode1: number | null = null\n\n\t\tif (a >= 0x19) {\n\t\t\tchannelNr = 2\n\t\t\tcharCode1 = a - 8\n\t\t}\n\t\telse {\n\t\t\tchannelNr = 1\n\t\t\tcharCode1 = a\n\t\t}\n\t\tif (charCode1 >= 0x11 && charCode1 <= 0x13) {\n\t\t\t// Special character\n\t\t\tlet oneCode: number\n\t\t\tif (charCode1 === 0x11) {\n\t\t\t\toneCode = b + 0x50\n\t\t\t}\n\t\t\telse if (charCode1 === 0x12) {\n\t\t\t\toneCode = b + 0x70\n\t\t\t}\n\t\t\telse {\n\t\t\t\toneCode = b + 0x90\n\t\t\t}\n\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.INFO,\n\t\t\t\t() =>\n\t\t\t\t\t\"Special char '\" +\n\t\t\t\t\tgetCharForByte(oneCode) +\n\t\t\t\t\t\"' in channel \" +\n\t\t\t\t\tchannelNr,\n\t\t\t)\n\t\t\tcharCodes = [oneCode]\n\t\t}\n\t\telse if (a >= 0x20 && a <= 0x7f) {\n\t\t\tcharCodes = b === 0 ? [a] : [a, b]\n\t\t}\n\t\tif (charCodes) {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t() => 'Char codes = ' + numArrayToHexArray(charCodes).join(','),\n\t\t\t)\n\t\t}\n\t\treturn charCodes\n\t}\n\n\t/**\n\t * Parse extended background attributes as well as new foreground color black.\n\t *\n\t * @param a - The first byte\n\t * @param b - The second byte\n\t * @returns True if background attributes are found\n\t */\n\tprivate parseBackgroundAttributes(a: number, b: number): boolean {\n\t\tconst case1 = (a === 0x10 || a === 0x18) && b >= 0x20 && b <= 0x2f\n\t\tconst case2 = (a === 0x17 || a === 0x1f) && b >= 0x2d && b <= 0x2f\n\t\tif (!(case1 || case2)) {\n\t\t\treturn false\n\t\t}\n\t\tlet index: number\n\t\tconst bkgData: Partial<PenStyles> = {}\n\t\tif (a === 0x10 || a === 0x18) {\n\t\t\tindex = Math.floor((b - 0x20) / 2)\n\t\t\tbkgData.background = backgroundColors[index]\n\t\t\tif (b % 2 === 1) {\n\t\t\t\tbkgData.background = bkgData.background + '_semi'\n\t\t\t}\n\t\t}\n\t\telse if (b === 0x2d) {\n\t\t\tbkgData.background = 'transparent'\n\t\t}\n\t\telse {\n\t\t\tbkgData.foreground = 'black'\n\t\t\tif (b === 0x2f) {\n\t\t\t\tbkgData.underline = true\n\t\t\t}\n\t\t}\n\t\tconst chNr: Channels = a <= 0x17 ? 1 : 2\n\t\tconst channel: Cta608Channel = this.channels[chNr] as Cta608Channel\n\t\tchannel.setBkgData(bkgData)\n\t\treturn true\n\t}\n\n\t/**\n\t * Reset state of parser and its channels.\n\t */\n\treset(): void {\n\t\tfor (let i = 0; i < Object.keys(this.channels).length; i++) {\n\t\t\tconst channel = this.channels[i]\n\t\t\tif (channel) {\n\t\t\t\tchannel.reset()\n\t\t\t}\n\t\t}\n\t\tsetLastCmd(null, null, this.cmdHistory)\n\t}\n\n\t/**\n\t * Trigger the generation of a cue, and the start of a new one if displayScreens are not empty.\n\t */\n\tcueSplitAtTime(t: number): void {\n\t\tfor (const channel of this.channels) {\n\t\t\tif (channel) {\n\t\t\t\tchannel.cueSplitAtTime(t)\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * Extract CTA-608 data from a DataView\n *\n * @param raw - The DataView to extract the data from\n * @param cta608Range - The range of the CTA-608 data\n * @returns The extracted CTA-608 data\n *\n * @beta\n */\nexport function extractCta608Data(raw: DataView, cta608Range: number[]): number[][] {\n\tlet pos = cta608Range[0]\n\tconst fieldData: number[][] = [[], []]\n\n\tpos += 8 // Skip the identifier up to userDataTypeCode\n\tconst ccCount = raw.getUint8(pos) & 31\n\tpos += 2 // Advance 1 and skip reserved byte\n\n\tfor (let i = 0; i < ccCount; i++) {\n\t\tconst byte = raw.getUint8(pos)\n\t\tconst ccValid = byte & 4\n\t\tconst ccType = byte & 3\n\t\tpos++\n\t\tconst ccData1: number = raw.getUint8(pos) // Keep parity bit\n\t\tpos++\n\t\tconst ccData2: number = raw.getUint8(pos) // Keep parity bit\n\t\tpos++\n\t\tif (ccValid && ((ccData1 & 127) + (ccData2 & 127) !== 0)) { //Check validity and non-empty data\n\t\t\tif (ccType === 0) {\n\t\t\t\tfieldData[0].push(ccData1)\n\t\t\t\tfieldData[0].push(ccData2)\n\t\t\t}\n\t\t\telse if (ccType === 1) {\n\t\t\t\tfieldData[1].push(ccData1)\n\t\t\t\tfieldData[1].push(ccData2)\n\t\t\t}\n\t\t}\n\t}\n\treturn fieldData\n}\n","export function getSeiData(raw: DataView, startPos: number, endPos: number): DataView {\n\tconst data: number[] = []\n\n\tfor (let cursor = startPos; cursor < endPos; cursor++) {\n\t\tif (cursor + 2 < endPos && raw.getUint8(cursor) === 0x00 && raw.getUint8(cursor + 1) === 0x00 && raw.getUint8(cursor + 2) === 0x03) {\n\t\t\tdata.push(0x00)\n\t\t\tdata.push(0x00)\n\t\t\tcursor += 2\n\t\t} \n\t\telse {\n\t\t\tdata.push(raw.getUint8(cursor))\n\t\t}\n\t}\n\n\treturn new DataView(new Uint8Array(data).buffer)\n}\n\nexport function isCea608Sei(payloadType: number, payloadSize: number, sei: DataView, pos: number): boolean {\n\tif (payloadType !== 4 || payloadSize < 8) {\n\t\treturn false\n\t}\n\n\tconst countryCode = sei.getUint8(pos)\n\tif (countryCode !== 0xB5) {\n\t\treturn false\n\t}\n\n\tconst providerCode = sei.getUint16(pos + 1)\n\tif (providerCode !== 0x0031) {\n\t\treturn false\n\t}\n\n\tconst userIdentifier = sei.getUint32(pos + 3)\n\tif (userIdentifier !== 0x47413934) {\n\t\treturn false\n\t}\n\n\tconst userDataTypeCode = sei.getUint8(pos + 7)\n\tif (userDataTypeCode !== 0x03) {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nexport function isCCType(type: number): boolean {\n\treturn type === 0 || type === 1\n}\n\nexport function isNonEmptyCCData(ccData1: number, ccData2: number): boolean {\n\treturn (ccData1 & 0x7F) > 0 || (ccData2 & 0x7F) > 0\n}\n\nexport function isSeiNalUnitType(unitType: number): boolean {\n\treturn unitType === 0x06\n}\n\nexport function parseCta608DataFromSei(sei: DataView, fieldData: number[][]): void {\n\tlet cursor = 0\n\twhile (cursor < sei.byteLength) {\n\t\tlet payloadType = 0\n\t\tlet payloadSize = 0\n\t\tlet now\n\n\t\tdo {\n\t\t\tpayloadType += now = sei.getUint8(cursor++)\n\t\t} while (now === 0xFF)\n\t\tdo {\n\t\t\tpayloadSize += now = sei.getUint8(cursor++)\n\t\t} while (now === 0xFF)\n\n\t\tif (isCea608Sei(payloadType, payloadSize, sei, cursor)) {\n\t\t\tconst pos = cursor + 10\n\t\t\tconst ccCount = pos + (sei.getUint8(pos - 2) & 0x1F) * 3\n\t\t\tfor (let i = pos; i < ccCount; i += 3) {\n\t\t\t\tconst byte = sei.getUint8(i)\n\t\t\t\tif (byte & 0x04) {\n\t\t\t\t\tconst ccType = byte & 0x03\n\t\t\t\t\tif (isCCType(ccType)) {\n\t\t\t\t\t\tconst ccData1 = sei.getUint8(i + 1)\n\t\t\t\t\t\tconst ccData2 = sei.getUint8(i + 2)\n\t\t\t\t\t\tif (isNonEmptyCCData(ccData1, ccData2)) {\n\t\t\t\t\t\t\tfieldData[ccType].push(ccData1, ccData2)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcursor += payloadSize\n\t}\n}\n","import {\n\tgetSeiData,\n\tisSeiNalUnitType,\n\tparseCta608DataFromSei,\n} from './utils/seiHelpers.ts'\n\n/**\n * Extracts CEA-608 data from a given sample.\n *\n * @param raw - The DataView with media data\n * @param startPos - The start position within the DataView\n * @param sampleSize - The size of the sample in bytes\n * @returns fieldData array containing field 1 and field 2 data arrays\n *\n * @beta\n */\nexport function extractCta608DataFromSample(raw: DataView, startPos: number, sampleSize: number): number[][] {\n\tlet nalSize: number = 0\n\tlet nalType: number = 0\n\tconst fieldData: number[][] = [[], []]\n\n\tfor (let cursor = startPos; cursor < startPos + sampleSize - 5; cursor++) {\n\t\tnalSize = raw.getUint32(cursor)\n\t\tnalType = raw.getUint8(cursor + 4) & 0x1F\n\n\t\t// Make sure that we don't go out of bounds\n\t\tif (cursor + 5 + nalSize > startPos + sampleSize) {\n\t\t\tbreak\n\t\t}\n\n\t\t// Only process Supplemental Enhancement Information (SEI) NAL units\n\t\tif (isSeiNalUnitType(nalType)) {\n\t\t\tif (cursor + 5 + nalSize <= raw.byteLength) {\n\t\t\t\tconst seiData = getSeiData(raw, cursor + 5, cursor + 5 + nalSize)\n\t\t\t\tparseCta608DataFromSei(seiData, fieldData)\n\t\t\t}\n\t\t}\n\n\t\t// Jump to the next NAL unit\n\t\tcursor += nalSize + 3\n\t}\n\treturn fieldData\n}\n","/**\n * Find CTA-608 NAL units in a video stream\n *\n * @param raw - The DataView to extract the data from\n * @param startPos - The start position of the data\n * @param size - The size of the data\n * @returns The extracted CTA-608 NAL units\n *\n * @beta\n */\nexport function findCta608Nalus(raw: DataView, startPos: number, size: number): number[][] {\n\tlet nalSize = 0, cursor = startPos, nalType = 0\n\tconst cta608NaluRanges = []\n\n\t// Check SEI data according to ANSI-SCTE 128\n\tconst isCTA608SEI = (payloadType: number, payloadSize: number, raw: DataView, pos: number) => {\n\t\tif (payloadType !== 4 || payloadSize < 8) {\n\t\t\treturn null\n\t\t}\n\t\tconst countryCode = raw.getUint8(pos)\n\t\tconst providerCode = raw.getUint16(pos + 1)\n\t\tconst userIdentifier = raw.getUint32(pos + 3)\n\t\tconst userDataTypeCode = raw.getUint8(pos + 7)\n\t\treturn countryCode == 181 && providerCode == 49 && userIdentifier == 1195456820 && userDataTypeCode == 3\n\t}\n\n\twhile (cursor < startPos + size) {\n\t\tnalSize = raw.getUint32(cursor)\n\t\tnalType = raw.getUint8(cursor + 4) & 31\n\t\t//console.log(time + \" NAL \" + nalType);\n\t\tif (nalType === 6) {\n\t\t\t// SEI NAL Unit. The NAL header is the first byte\n\t\t\t//console.log(\"SEI NALU of size \" + nalSize + \" at time \" + time);\n\t\t\tlet pos = cursor + 5\n\t\t\tlet payloadType = -1\n\t\t\twhile (pos < cursor + 4 + nalSize - 1) { // The last byte should be rbsp_trailing_bits\n\t\t\t\tpayloadType = 0\n\t\t\t\tlet b = 255\n\t\t\t\twhile (b === 255) {\n\t\t\t\t\tb = raw.getUint8(pos)\n\t\t\t\t\tpayloadType += b\n\t\t\t\t\tpos++\n\t\t\t\t}\n\t\t\t\tlet payloadSize = 0\n\t\t\t\tb = 255\n\t\t\t\twhile (b === 255) {\n\t\t\t\t\tb = raw.getUint8(pos)\n\t\t\t\t\tpayloadSize += b\n\t\t\t\t\tpos++\n\t\t\t\t}\n\t\t\t\tif (isCTA608SEI(payloadType, payloadSize, raw, pos)) {\n\t\t\t\t\t//console.log(\"CTA608 SEI \" + time + \" \" + payloadSize);\n\t\t\t\t\tcta608NaluRanges.push([pos, payloadSize])\n\t\t\t\t}\n\t\t\t\tpos += payloadSize\n\t\t\t}\n\t\t}\n\t\tcursor += nalSize + 4\n\t}\n\treturn cta608NaluRanges\n}\n","/**\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\n/**\n * SCC Parser\n *\n * @beta\n */\nexport class SccParser {\n\thasHeader: boolean = false\n\tnrLinesParsed: number = 0\n\tprocessor: any\n\tfield: number | any\n\n\tconstructor(processor: any, field: number | any = 1) {\n\t\tthis.processor = processor\n\t\tthis.field = field\n\t}\n\n\tparse(text: string): void {\n\t\tconst lines = text.split(/\\r?\\n/)\n\t\tthis.nrLinesParsed = 0\n\n\t\tif (lines[0] === 'Scenarist_SCC V1.0') {\n\t\t\tthis.hasHeader = true\n\t\t\tthis.nrLinesParsed++\n\t\t}\n\n\t\tfor (let l = 1; l < lines.length; l += 2) {\n\t\t\tif (lines[l] !== '') {\n\t\t\t\tbreak // Every second line should be empty\n\t\t\t}\n\t\t\tthis.nrLinesParsed++\n\t\t\tconst lineData = this.parseDataLine(lines[l + 1])\n\t\t\tif (lineData === null) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tthis.nrLinesParsed++\n\t\t\tthis.processor.addData(lineData[0], lineData[1])\n\t\t}\n\t}\n\n\tparseDataLine(line: string): [number, number[]] | null {\n\t\tif (!line) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst lineParts = line.split(/\\s+/)\n\t\tconst timeData = lineParts[0]\n\t\tconst ceaData: number[] = []\n\n\t\tfor (let i = 1; i < lineParts.length; i++) {\n\t\t\tconst fourHexChars = lineParts[i]\n\t\t\tconst a = parseInt(fourHexChars.substring(0, 2), 16)\n\t\t\tconst b = parseInt(fourHexChars.substring(2, 4), 16)\n\t\t\tceaData.push(a, b)\n\t\t}\n\n\t\tconst time = this.timeConverter(timeData)\n\t\treturn [time, ceaData]\n\t}\n\n\ttimeConverter(smpteTs: string): number {\n\t\tconst parts = smpteTs.split(':')\n\t\tif (parts.length === 3) {\n\t\t\tconst lastParts = parts[2].split(';')\n\t\t\tparts[2] = lastParts[0]\n\t\t\tconst frames = parseInt(lastParts[1], 10)\n\t\t\treturn (30 * (60 * (60 * parseInt(parts[0], 10) + parseInt(parts[1], 10)) + parseInt(parts[2], 10)) + frames) * 1001 / 30000\n\t\t}\n\t\treturn 0 // in case if format is incorrect\n\t}\n\n\tgetHeaderStatus(): boolean {\n\t\treturn this.hasHeader\n\t}\n\n\tgetField(): number | any {\n\t\treturn this.field\n\t}\n\n\tgetLinesParsed(): number {\n\t\treturn this.nrLinesParsed\n\t}\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,eAAe;CAC3B,OAAO;CACP,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,MAAM;CACN;;;;;;;;;AC4BD,IAAa,iBAAb,MAA4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ACvB,MAAM,YAAY,MAAM,GAAG,MAAM,IAAI;AACrC,SAAM,KAAK,UAAU;GACrB,MAAM,SAAS,SAAS,UAAU,IAAI,GAAG;AACzC,WAAQ,MAAM,MAAM,KAAK,SAAS,MAAM,IAAI,GAAG,GAAG,SAAS,MAAM,IAAI,GAAG,IAAI,SAAS,MAAM,IAAI,GAAG,IAAI,UAAU,OAAO;;AAExH,SAAO;;CAGR,kBAA2B;AAC1B,SAAO,KAAK;;CAGb,WAAyB;AACxB,SAAO,KAAK;;CAGb,iBAAyB;AACxB,SAAO,KAAK"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["m: string","specialCea608CharsCodes: Record<number, number>","i: number","chars: string[]","styles: PenStyles","displayText: string[]","styles: Partial<PenStyles>","backgroundColors: string[]","hexArray: string[]","rowsHighCh1: Record<number, number>","rowsHighCh2: Record<number, number>","rowsLowCh1: Record<number, number>","rowsLowCh2: Record<number, number>","cmdFound: boolean","charsFound: number[] | null","chNr: number","row: number","chNr: Channels","pacData: PACData","channelNr: Channels","charCodes: number[]","charCode1: number | null","oneCode: number","index: number","bkgData: Partial<PenStyles>","fieldData: number[][]","ccData1: number","ccData2: number","data: number[]","nalSize: number","fieldData: number[][]","raw","ceaData: number[]"],"sources":["../src/VerboseLevel.ts","../src/CaptionsLogger.ts","../src/PenState.ts","../src/StyledUnicodeChar.ts","../src/utils/NR_COLS.ts","../src/utils/specialCea608CharsCodes.ts","../src/utils/getCharForByte.ts","../src/Row.ts","../src/utils/NR_ROWS.ts","../src/CaptionScreen.ts","../src/Cta608Channel.ts","../src/utils/backgroundColors.ts","../src/utils/createCmdHistory.ts","../src/utils/hasCmdRepeated.ts","../src/utils/numArrayToHexArray.ts","../src/utils/rowsHighCh1.ts","../src/utils/rowsHighCh2.ts","../src/utils/rowsLowCh1.ts","../src/utils/rowsLowCh2.ts","../src/utils/setLastCmd.ts","../src/Cta608Parser.ts","../src/extractCta608Data.ts","../src/utils/seiHelpers.ts","../src/extractCta608DataFromSample.ts","../src/findCta608Nalus.ts","../src/SccParser.ts"],"sourcesContent":["import type { ValueOf } from '@svta/cml-utils'\n\n/**\n * Logging levels for the CTA-608 parser.\n *\n *\n * @enum\n *\n * @public\n */\nexport const VerboseLevel = {\n\tERROR: 0,\n\tTEXT: 1,\n\tWARNING: 2,\n\tINFO: 2,\n\tDEBUG: 3,\n\tDATA: 3,\n} as const\n\n/**\n * @public\n */\nexport type VerboseLevel = ValueOf<typeof VerboseLevel>;\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport { VerboseLevel } from './VerboseLevel.ts'\n\n/**\n * CaptionsLogger. To be removed in the future.\n *\n * @public\n */\nexport class CaptionsLogger {\n\tpublic time: number | null = null\n\tpublic verboseLevel: VerboseLevel = VerboseLevel.ERROR\n\n\tlog(severity: VerboseLevel, msg: string | (() => string)): void {\n\t\tif (this.verboseLevel >= severity) {\n\t\t\tconst m: string = typeof msg === 'function' ? msg() : msg\n\t\t\tconsole.log(`${this.time} [${severity}] ${m}`)\n\t\t}\n\t}\n}\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { PenStyles } from './PenStyles.ts'\n\n/**\n * Pen state.\n *\n * @public\n */\nexport class PenState {\n\tpublic foreground: string = 'white'\n\tpublic underline: boolean = false\n\tpublic italics: boolean = false\n\tpublic background: string = 'black'\n\tpublic flash: boolean = false\n\n\treset(): void {\n\t\tthis.foreground = 'white'\n\t\tthis.underline = false\n\t\tthis.italics = false\n\t\tthis.background = 'black'\n\t\tthis.flash = false\n\t}\n\n\tsetStyles(styles: Partial<PenStyles>): void {\n\t\tconst attribs = [\n\t\t\t'foreground',\n\t\t\t'underline',\n\t\t\t'italics',\n\t\t\t'background',\n\t\t\t'flash',\n\t\t]\n\t\tfor (const style of attribs) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(styles, style)) {\n\t\t\t\t(this as any)[style] = (styles as any)[style]\n\t\t\t}\n\t\t}\n\t}\n\n\tisDefault(): boolean {\n\t\treturn (\n\t\t\tthis.foreground === 'white' &&\n\t\t\t!this.underline &&\n\t\t\t!this.italics &&\n\t\t\tthis.background === 'black' &&\n\t\t\t!this.flash\n\t\t)\n\t}\n\n\tequals(other: PenState): boolean {\n\t\treturn (\n\t\t\tthis.foreground === other.foreground &&\n\t\t\tthis.underline === other.underline &&\n\t\t\tthis.italics === other.italics &&\n\t\t\tthis.background === other.background &&\n\t\t\tthis.flash === other.flash\n\t\t)\n\t}\n\n\tcopy(newPenState: PenState): void {\n\t\tthis.foreground = newPenState.foreground\n\t\tthis.underline = newPenState.underline\n\t\tthis.italics = newPenState.italics\n\t\tthis.background = newPenState.background\n\t\tthis.flash = newPenState.flash\n\t}\n}\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport { PenState } from './PenState.ts'\n\n/**\n * Unicode character with styling and background.\n *\n * @public\n */\nexport class StyledUnicodeChar {\n\tuchar: string = ' '\n\tpenState: PenState = new PenState()\n\n\treset(): void {\n\t\tthis.uchar = ' '\n\t\tthis.penState.reset()\n\t}\n\n\tsetChar(uchar: string, newPenState: PenState): void {\n\t\tthis.uchar = uchar\n\t\tthis.penState.copy(newPenState)\n\t}\n\n\tsetPenState(newPenState: PenState): void {\n\t\tthis.penState.copy(newPenState)\n\t}\n\n\tequals(other: StyledUnicodeChar): boolean {\n\t\treturn this.uchar === other.uchar && this.penState.equals(other.penState)\n\t}\n\n\tcopy(newChar: StyledUnicodeChar): void {\n\t\tthis.uchar = newChar.uchar\n\t\tthis.penState.copy(newChar.penState)\n\t}\n\n\tisEmpty(): boolean {\n\t\treturn this.uchar === ' ' && this.penState.isDefault()\n\t}\n}\n","export const NR_COLS = 100\n","/**\n * Exceptions from regular ASCII. CodePoints are mapped to UTF-16 codes\n */\nexport const specialCea608CharsCodes: Record<number, number> = {\n\t42: 225, // lowercase a, acute accent\n\t92: 233, // lowercase e, acute accent\n\t94: 237, // lowercase i, acute accent\n\t95: 243, // lowercase o, acute accent\n\t96: 250, // lowercase u, acute accent\n\t123: 231, // lowercase c with cedilla\n\t124: 247, // division symbol\n\t125: 209, // uppercase N tilde\n\t126: 241, // lowercase n tilde\n\t127: 9608, // Full block\n\n\n\n\t// THIS BLOCK INCLUDES THE 16 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS\n\t// THAT COME FROM HI BYTE=0x11 AND LOW BETWEEN 0x30 AND 0x3F\n\t// THIS MEANS THAT \\x50 MUST BE ADDED TO THE VALUES\n\t128: 174, // Registered symbol (R)\n\t129: 176, // degree sign\n\t130: 189, // 1/2 symbolOutputFilter\n\t131: 191, // Inverted (open) question mark\n\t132: 8482, // Trademark symbol (TM)\n\t133: 162, // Cents symbol\n\t134: 163, // Pounds sterling\n\t135: 9834, // Music 8'th note\n\t136: 224, // lowercase a, grave accent\n\t137: 32, // transparent space (regular)\n\t138: 232, // lowercase e, grave accent\n\t139: 226, // lowercase a, circumflex accent\n\t140: 234, // lowercase e, circumflex accent\n\t141: 238, // lowercase i, circumflex accent\n\t142: 244, // lowercase o, circumflex accent\n\t143: 251, // lowercase u, circumflex accent\n\n\n\t// THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS\n\t// THAT COME FROM HI BYTE=0x12 AND LOW BETWEEN 0x20 AND 0x3F\n\t144: 193, // capital letter A with acute\n\t145: 201, // capital letter E with acute\n\t146: 211, // capital letter O with acute\n\t147: 218, // capital letter U with acute\n\t148: 220, // capital letter U with diaresis\n\t149: 252, // lowercase letter U with diaeresis\n\t150: 8216, // opening single quote\n\t151: 161, // inverted exclamation mark\n\t152: 42, // asterisk\n\t153: 8217, // closing single quote\n\t154: 9473, // box drawings heavy horizontal\n\t155: 169, // copyright sign\n\t156: 8480, // Service mark\n\t157: 8226, // (round) bullet\n\t158: 8220, // Left double quotation mark\n\t159: 8221, // Right double quotation mark\n\t160: 192, // uppercase A, grave accent\n\t161: 194, // uppercase A, circumflex\n\t162: 199, // uppercase C with cedilla\n\t163: 200, // uppercase E, grave accent\n\t164: 202, // uppercase E, circumflex\n\t165: 203, // capital letter E with diaresis\n\t166: 235, // lowercase letter e with diaresis\n\t167: 206, // uppercase I, circumflex\n\t168: 207, // uppercase I, with diaresis\n\t169: 239, // lowercase i, with diaresis\n\t170: 212, // uppercase O, circumflex\n\t171: 217, // uppercase U, grave accent\n\t172: 249, // lowercase u, grave accent\n\t173: 219, // uppercase U, circumflex\n\t174: 171, // left-pointing double angle quotation mark\n\t175: 187, // right-pointing double angle quotation mark\n\n\n\t// THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS\n\t// THAT COME FROM HI BYTE=0x13 AND LOW BETWEEN 0x20 AND 0x3F\n\t176: 195, // Uppercase A, tilde\n\t177: 227, // Lowercase a, tilde\n\t178: 205, // Uppercase I, acute accent\n\t179: 204, // Uppercase I, grave accent\n\t180: 236, // Lowercase i, grave accent\n\t181: 210, // Uppercase O, grave accent\n\t182: 242, // Lowercase o, grave accent\n\t183: 213, // Uppercase O, tilde\n\t184: 245, // Lowercase o, tilde\n\t185: 123, // Open curly brace\n\t186: 125, // Closing curly brace\n\t187: 92, // Backslash\n\t188: 94, // Caret\n\t189: 95, // Underscore\n\t190: 124, // Pipe (vertical line)\n\t191: 8764, // Tilde operator\n\t192: 196, // Uppercase A, umlaut\n\t193: 228, // Lowercase A, umlaut\n\t194: 214, // Uppercase O, umlaut\n\t195: 246, // Lowercase o, umlaut\n\t196: 223, // Esszett (sharp S)\n\t197: 165, // Yen symbolOutputFilter\n\t198: 164, // Generic currency sign\n\t199: 9475, // Box drawings heavy vertical\n\t200: 197, // Uppercase A, ring\n\t201: 229, // Lowercase A, ring\n\t202: 216, // Uppercase O, stroke\n\t203: 248, // Lowercase o, strok\n\t204: 9487, // Box drawings heavy down and right\n\t205: 9491, // Box drawings heavy down and left\n\t206: 9495, // Box drawings heavy up and right\n\t207: 9499, // Box drawings heavy up and left\n}\n","import { specialCea608CharsCodes } from './specialCea608CharsCodes.ts'\n\nexport function getCharForByte(byte: number): string {\n\treturn String.fromCharCode(specialCea608CharsCodes[byte] || byte)\n};\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport { CaptionsLogger } from './CaptionsLogger.ts'\nimport { PenState } from './PenState.ts'\nimport type { PenStyles } from './PenStyles.ts'\nimport { StyledUnicodeChar } from './StyledUnicodeChar.ts'\nimport { VerboseLevel } from './VerboseLevel.ts'\nimport { NR_COLS } from './utils/NR_COLS.ts'\nimport { getCharForByte } from './utils/getCharForByte.ts'\n\n/**\n * CTA-608 row consisting of NR_COLS instances of StyledUnicodeChar.\n *\n * @public\n */\nexport class Row {\n\tpublic chars: StyledUnicodeChar[] = []\n\tpublic cueStartTime: number | null = null\n\n\tprivate pos: number = 0\n\tprivate currPenState: PenState = new PenState()\n\tprivate logger: CaptionsLogger\n\n\tconstructor(logger: CaptionsLogger = new CaptionsLogger()) {\n\t\tfor (let i = 0; i < NR_COLS; i++) {\n\t\t\tthis.chars.push(new StyledUnicodeChar())\n\t\t}\n\t\tthis.logger = logger\n\t}\n\n\tequals(other: Row): boolean {\n\t\tfor (let i = 0; i < NR_COLS; i++) {\n\t\t\tif (!this.chars[i].equals(other.chars[i])) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\n\tcopy(other: Row): void {\n\t\tfor (let i = 0; i < NR_COLS; i++) {\n\t\t\tthis.chars[i].copy(other.chars[i])\n\t\t}\n\t}\n\n\tisEmpty(): boolean {\n\t\tlet empty = true\n\t\tfor (let i = 0; i < NR_COLS; i++) {\n\t\t\tif (!this.chars[i].isEmpty()) {\n\t\t\t\tempty = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn empty\n\t}\n\n\t/**\n\t * Set the cursor to a valid column.\n\t */\n\tsetCursor(absPos: number): void {\n\t\tif (this.pos !== absPos) {\n\t\t\tthis.pos = absPos\n\t\t}\n\n\t\tif (this.pos < 0) {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t'Negative cursor position ' + this.pos,\n\t\t\t)\n\t\t\tthis.pos = 0\n\t\t}\n\t\telse if (this.pos > NR_COLS) {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t'Too large cursor position ' + this.pos,\n\t\t\t)\n\t\t\tthis.pos = NR_COLS\n\t\t}\n\t}\n\n\t/**\n\t * Move the cursor relative to current position.\n\t */\n\tmoveCursor(relPos: number): void {\n\t\tconst newPos = this.pos + relPos\n\t\tif (relPos > 1) {\n\t\t\tfor (let i = this.pos + 1; i < newPos + 1; i++) {\n\t\t\t\tthis.chars[i].setPenState(this.currPenState)\n\t\t\t}\n\t\t}\n\t\tthis.setCursor(newPos)\n\t}\n\n\t/**\n\t * Backspace, move one step back and clear character.\n\t */\n\tbackSpace(): void {\n\t\tthis.moveCursor(-1)\n\t\tthis.chars[this.pos].setChar(' ', this.currPenState)\n\t}\n\n\tinsertChar(byte: number): void {\n\t\tif (byte >= 0x90) {\n\t\t\t// Extended char\n\t\t\tthis.backSpace()\n\t\t}\n\t\tconst char = getCharForByte(byte)\n\t\tif (this.pos >= NR_COLS) {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.ERROR,\n\t\t\t\t() =>\n\t\t\t\t\t'Cannot insert ' +\n\t\t\t\t\tbyte.toString(16) +\n\t\t\t\t\t' (' +\n\t\t\t\t\tchar +\n\t\t\t\t\t') at position ' +\n\t\t\t\t\tthis.pos +\n\t\t\t\t\t'. Skipping it!',\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tthis.chars[this.pos].setChar(char, this.currPenState)\n\t\tthis.moveCursor(1)\n\t}\n\n\tclearFromPos(startPos: number): void {\n\t\tlet i: number\n\t\tfor (i = startPos; i < NR_COLS; i++) {\n\t\t\tthis.chars[i].reset()\n\t\t}\n\t}\n\n\tclear(): void {\n\t\tthis.clearFromPos(0)\n\t\tthis.pos = 0\n\t\tthis.currPenState.reset()\n\t}\n\n\tclearToEndOfRow(): void {\n\t\tthis.clearFromPos(this.pos)\n\t}\n\n\tgetTextString(): string {\n\t\tconst chars: string[] = []\n\t\tlet empty = true\n\t\tfor (let i = 0; i < NR_COLS; i++) {\n\t\t\tconst char = this.chars[i].uchar\n\t\t\tif (char !== ' ') {\n\t\t\t\tempty = false\n\t\t\t}\n\n\t\t\tchars.push(char)\n\t\t}\n\t\tif (empty) {\n\t\t\treturn ''\n\t\t}\n\t\telse {\n\t\t\treturn chars.join('')\n\t\t}\n\t}\n\n\tsetPenStyles(styles: Partial<PenStyles>): void {\n\t\tthis.currPenState.setStyles(styles)\n\t\tconst currChar = this.chars[this.pos]\n\t\tcurrChar.setPenState(this.currPenState)\n\t}\n}\n","export const NR_ROWS = 15\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport { CaptionsLogger } from './CaptionsLogger.ts'\nimport type { PACData } from './PACData.ts'\nimport type { PenStyles } from './PenStyles.ts'\nimport { Row } from './Row.ts'\nimport { NR_ROWS } from './utils/NR_ROWS.ts'\nimport { VerboseLevel } from './VerboseLevel.ts'\n\n/**\n * Keep a CTA-608 screen of 32x15 styled characters\n *\n * @public\n */\nexport class CaptionScreen {\n\trows: Row[] = []\n\tprivate currRow: number = NR_ROWS - 1\n\tprivate nrRollUpRows: number | null = null\n\tprivate lastOutputScreen: CaptionScreen | null = null\n\tprivate logger: CaptionsLogger\n\n\tconstructor(logger: CaptionsLogger = new CaptionsLogger()) {\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tthis.rows.push(new Row(logger))\n\t\t}\n\t\tthis.logger = logger\n\t}\n\n\treset(): void {\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tthis.rows[i].clear()\n\t\t}\n\t\tthis.currRow = NR_ROWS - 1\n\t}\n\n\tequals(other: CaptionScreen): boolean {\n\t\tlet equal = true\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tif (!this.rows[i].equals(other.rows[i])) {\n\t\t\t\tequal = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn equal\n\t}\n\n\tcopy(other: CaptionScreen): void {\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tthis.rows[i].copy(other.rows[i])\n\t\t}\n\t}\n\n\tisEmpty(): boolean {\n\t\tlet empty = true\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tif (!this.rows[i].isEmpty()) {\n\t\t\t\tempty = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn empty\n\t}\n\n\tbackSpace(): void {\n\t\tconst row = this.rows[this.currRow]\n\t\trow.backSpace()\n\t}\n\n\tclearToEndOfRow(): void {\n\t\tconst row = this.rows[this.currRow]\n\t\trow.clearToEndOfRow()\n\t}\n\n\t/**\n\t * Insert a character (without styling) in the current row.\n\t */\n\tinsertChar(char: number): void {\n\t\tconst row = this.rows[this.currRow]\n\t\trow.insertChar(char)\n\t}\n\n\tsetPen(styles: Partial<PenStyles>): void {\n\t\tconst row = this.rows[this.currRow]\n\t\trow.setPenStyles(styles)\n\t}\n\n\tmoveCursor(relPos: number): void {\n\t\tconst row = this.rows[this.currRow]\n\t\trow.moveCursor(relPos)\n\t}\n\n\tsetCursor(absPos: number): void {\n\t\tthis.logger.log(VerboseLevel.INFO, 'setCursor: ' + absPos)\n\t\tconst row = this.rows[this.currRow]\n\t\trow.setCursor(absPos)\n\t}\n\n\tsetPAC(pacData: PACData): void {\n\t\tthis.logger.log(\n\t\t\tVerboseLevel.INFO,\n\t\t\t() => 'pacData = ' + JSON.stringify(pacData),\n\t\t)\n\t\tlet newRow = pacData.row - 1\n\t\tif (this.nrRollUpRows && newRow < this.nrRollUpRows - 1) {\n\t\t\tnewRow = this.nrRollUpRows - 1\n\t\t}\n\n\t\t// Make sure this only affects Roll-up Captions by checking this.nrRollUpRows\n\t\tif (this.nrRollUpRows && this.currRow !== newRow) {\n\t\t\t// clear all rows first\n\t\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\t\tthis.rows[i].clear()\n\t\t\t}\n\n\t\t\t// Copy this.nrRollUpRows rows from lastOutputScreen and place it in the newRow location\n\t\t\t// topRowIndex - the start of rows to copy (inclusive index)\n\t\t\tconst topRowIndex = this.currRow + 1 - this.nrRollUpRows\n\t\t\t// We only copy if the last position was already shown.\n\t\t\t// We use the cueStartTime value to check this.\n\t\t\tconst lastOutputScreen = this.lastOutputScreen\n\t\t\tif (lastOutputScreen) {\n\t\t\t\tconst prevLineTime = lastOutputScreen.rows[topRowIndex].cueStartTime\n\t\t\t\tconst time = this.logger.time\n\t\t\t\tif (prevLineTime !== null && time !== null && prevLineTime < time) {\n\t\t\t\t\tfor (let i = 0; i < this.nrRollUpRows; i++) {\n\t\t\t\t\t\tthis.rows[newRow - this.nrRollUpRows + i + 1].copy(\n\t\t\t\t\t\t\tlastOutputScreen.rows[topRowIndex + i],\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.currRow = newRow\n\t\tconst row = this.rows[this.currRow]\n\t\tif (pacData.indent !== null) {\n\t\t\tconst indent = pacData.indent\n\t\t\tconst prevPos = Math.max(indent - 1, 0)\n\t\t\trow.setCursor(pacData.indent)\n\t\t\tpacData.color = row.chars[prevPos].penState.foreground\n\t\t}\n\t\tconst styles: PenStyles = {\n\t\t\tforeground: pacData.color,\n\t\t\tunderline: pacData.underline,\n\t\t\titalics: pacData.italics,\n\t\t\tbackground: 'black',\n\t\t\tflash: false,\n\t\t}\n\t\tthis.setPen(styles)\n\t}\n\n\t/**\n\t * Set background/extra foreground, but first do back_space, and then insert space (backwards compatibility).\n\t */\n\tsetBkgData(bkgData: Partial<PenStyles>): void {\n\t\tthis.logger.log(\n\t\t\tVerboseLevel.INFO,\n\t\t\t() => 'bkgData = ' + JSON.stringify(bkgData),\n\t\t)\n\t\tthis.backSpace()\n\t\tthis.setPen(bkgData)\n\t\tthis.insertChar(0x20) // Space\n\t}\n\n\tsetRollUpRows(nrRows: number | null): void {\n\t\tthis.nrRollUpRows = nrRows\n\t}\n\n\trollUp(): void {\n\t\tif (this.nrRollUpRows === null) {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t'roll_up but nrRollUpRows not set yet',\n\t\t\t)\n\t\t\treturn // Not properly setup\n\t\t}\n\t\tthis.logger.log(VerboseLevel.TEXT, () => this.getDisplayText())\n\t\tconst topRowIndex = this.currRow + 1 - this.nrRollUpRows\n\t\tconst topRow = this.rows.splice(topRowIndex, 1)[0]\n\t\ttopRow.clear()\n\t\tthis.rows.splice(this.currRow, 0, topRow)\n\t\tthis.logger.log(VerboseLevel.INFO, 'Rolling up')\n\t}\n\n\t/**\n\t * Get all non-empty rows with as unicode text.\n\t */\n\tgetDisplayText(asOneRow?: boolean): string {\n\t\tasOneRow = asOneRow || false\n\t\tconst displayText: string[] = []\n\t\tlet text = ''\n\t\tlet rowNr = -1\n\t\tfor (let i = 0; i < NR_ROWS; i++) {\n\t\t\tconst rowText = this.rows[i].getTextString()\n\t\t\tif (rowText) {\n\t\t\t\trowNr = i + 1\n\t\t\t\tif (asOneRow) {\n\t\t\t\t\tdisplayText.push('Row ' + rowNr + \": '\" + rowText + \"'\")\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdisplayText.push(rowText.trim())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (displayText.length > 0) {\n\t\t\tif (asOneRow) {\n\t\t\t\ttext = '[' + displayText.join(' | ') + ']'\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttext = displayText.join('\\n')\n\t\t\t}\n\t\t}\n\t\treturn text\n\t}\n\n\tgetTextAndFormat(): Row[] {\n\t\treturn this.rows\n\t}\n}\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { CaptionModes } from './CaptionModes.ts'\nimport { CaptionScreen } from './CaptionScreen.ts'\nimport { CaptionsLogger } from './CaptionsLogger.ts'\nimport type { CueHandler } from './CueHandler.ts'\nimport type { PACData } from './PACData.ts'\nimport type { PenStyles } from './PenStyles.ts'\nimport type { Row } from './Row.ts'\nimport { VerboseLevel } from './VerboseLevel.ts'\nimport { NR_ROWS } from './utils/NR_ROWS.ts'\n\n/**\n * CTA-608 Channel\n *\n * @public\n */\nexport class Cta608Channel {\n\tchNr: number\n\toutputFilter: CueHandler\n\tmode: CaptionModes\n\tdisplayedMemory: CaptionScreen\n\tnonDisplayedMemory: CaptionScreen\n\tlastOutputScreen: CaptionScreen\n\tcurrRollUpRow: Row\n\twriteScreen: CaptionScreen\n\tcueStartTime: number | null\n\n\tprivate logger: CaptionsLogger\n\n\tconstructor(\n\t\tchannelNumber: number,\n\t\toutputFilter: CueHandler,\n\t\tlogger: CaptionsLogger = new CaptionsLogger(),\n\t) {\n\t\tthis.chNr = channelNumber\n\t\tthis.outputFilter = outputFilter\n\t\tthis.mode = null\n\t\tthis.displayedMemory = new CaptionScreen(logger)\n\t\tthis.nonDisplayedMemory = new CaptionScreen(logger)\n\t\tthis.lastOutputScreen = new CaptionScreen(logger)\n\t\tthis.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1]\n\t\tthis.writeScreen = this.displayedMemory\n\t\tthis.mode = null\n\t\tthis.cueStartTime = null // Keeps track of where a cue started.\n\t\tthis.logger = logger\n\n\t\tthis.logger.log(VerboseLevel.INFO, 'new Cea608Channel(' + this.chNr + ')')\n\t}\n\n\treset(): void {\n\t\tthis.mode = null\n\t\tthis.displayedMemory.reset()\n\t\tthis.nonDisplayedMemory.reset()\n\t\tthis.lastOutputScreen.reset()\n\t\tthis.outputFilter?.reset?.()\n\t\tthis.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1]\n\t\tthis.writeScreen = this.displayedMemory\n\t\tthis.mode = null\n\t\tthis.cueStartTime = null\n\t}\n\n\tgetHandler(): CueHandler {\n\t\treturn this.outputFilter\n\t}\n\n\tsetHandler(outputFilter: CueHandler): void {\n\t\tthis.outputFilter = outputFilter\n\t}\n\n\tsetPAC(pacData: PACData): void {\n\t\tthis.writeScreen.setPAC(pacData)\n\t}\n\n\tsetBkgData(bkgData: Partial<PenStyles>): void {\n\t\tthis.writeScreen.setBkgData(bkgData)\n\t}\n\n\tsetMode(newMode: CaptionModes): void {\n\t\tif (newMode === this.mode) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.mode = newMode\n\t\tthis.logger.log(VerboseLevel.INFO, () => 'MODE=' + newMode)\n\t\tif (this.mode === 'MODE_POP-ON') {\n\t\t\tthis.writeScreen = this.nonDisplayedMemory\n\t\t}\n\t\telse {\n\t\t\tthis.writeScreen = this.displayedMemory\n\t\t\tthis.writeScreen.reset()\n\t\t}\n\t\tif (this.mode !== 'MODE_ROLL-UP') {\n\t\t\tthis.displayedMemory.setRollUpRows(null)\n\t\t\tthis.nonDisplayedMemory.setRollUpRows(null)\n\t\t}\n\t\tthis.mode = newMode\n\t}\n\n\tinsertChars(chars: number[]): void {\n\t\tfor (const char of chars) {\n\t\t\tthis.writeScreen.insertChar(char)\n\t\t}\n\n\t\tconst screen =\n\t\t\tthis.writeScreen === this.displayedMemory ? 'DISP' : 'NON_DISP'\n\t\tthis.logger.log(\n\t\t\tVerboseLevel.INFO,\n\t\t\t() => screen + ': ' + this.writeScreen.getDisplayText(true),\n\t\t)\n\t\tif (this.mode === 'MODE_PAINT-ON' || this.mode === 'MODE_ROLL-UP') {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.TEXT,\n\t\t\t\t() => 'DISPLAYED: ' + this.displayedMemory.getDisplayText(true),\n\t\t\t)\n\t\t\tthis.outputDataUpdate()\n\t\t}\n\t}\n\n\tccRCL(): void {\n\t\t// Resume Caption Loading (switch mode to Pop On)\n\t\tthis.logger.log(VerboseLevel.INFO, 'RCL - Resume Caption Loading')\n\t\tthis.setMode('MODE_POP-ON')\n\t}\n\n\tccBS(): void {\n\t\t// BackSpace\n\t\tthis.logger.log(VerboseLevel.INFO, 'BS - BackSpace')\n\t\tif (this.mode === 'MODE_TEXT') {\n\t\t\treturn\n\t\t}\n\n\t\tthis.writeScreen.backSpace()\n\t\tif (this.writeScreen === this.displayedMemory) {\n\t\t\tthis.outputDataUpdate()\n\t\t}\n\t}\n\n\tccAOF(): void {\n\t\t// Reserved (formerly Alarm Off)\n\t}\n\n\tccAON(): void {\n\t\t// Reserved (formerly Alarm On)\n\t}\n\n\tccDER(): void {\n\t\t// Delete to End of Row\n\t\tthis.logger.log(VerboseLevel.INFO, 'DER- Delete to End of Row')\n\t\tthis.writeScreen.clearToEndOfRow()\n\t\tthis.outputDataUpdate()\n\t}\n\n\tccRU(nrRows: number | null): void {\n\t\t// Roll-Up Captions-2,3,or 4 Rows\n\t\tthis.logger.log(VerboseLevel.INFO, 'RU(' + nrRows + ') - Roll Up')\n\t\tthis.writeScreen = this.displayedMemory\n\t\tthis.setMode('MODE_ROLL-UP')\n\t\tthis.writeScreen.setRollUpRows(nrRows)\n\t}\n\n\tccFON(): void {\n\t\t// Flash On\n\t\tthis.logger.log(VerboseLevel.INFO, 'FON - Flash On')\n\t\tthis.writeScreen.setPen({ flash: true })\n\t}\n\n\tccRDC(): void {\n\t\t// Resume Direct Captioning (switch mode to PaintOn)\n\t\tthis.logger.log(VerboseLevel.INFO, 'RDC - Resume Direct Captioning')\n\t\tthis.setMode('MODE_PAINT-ON')\n\t}\n\n\tccTR(): void {\n\t\t// Text Restart in text mode (not supported, however)\n\t\tthis.logger.log(VerboseLevel.INFO, 'TR')\n\t\tthis.setMode('MODE_TEXT')\n\t}\n\n\tccRTD(): void {\n\t\t// Resume Text Display in Text mode (not supported, however)\n\t\tthis.logger.log(VerboseLevel.INFO, 'RTD')\n\t\tthis.setMode('MODE_TEXT')\n\t}\n\n\tccEDM(): void {\n\t\t// Erase Displayed Memory\n\t\tthis.logger.log(VerboseLevel.INFO, 'EDM - Erase Displayed Memory')\n\t\tthis.displayedMemory.reset()\n\t\tthis.outputDataUpdate(true)\n\t}\n\n\tccCR(): void {\n\t\t// Carriage Return\n\t\tthis.logger.log(VerboseLevel.INFO, 'CR - Carriage Return')\n\t\tthis.writeScreen.rollUp()\n\t\tthis.outputDataUpdate(true)\n\t}\n\n\tccENM(): void {\n\t\t// Erase Non-Displayed Memory\n\t\tthis.logger.log(VerboseLevel.INFO, 'ENM - Erase Non-displayed Memory')\n\t\tthis.nonDisplayedMemory.reset()\n\t}\n\n\tccEOC(): void {\n\t\t// End of Caption (Flip Memories)\n\t\tthis.logger.log(VerboseLevel.INFO, 'EOC - End Of Caption')\n\t\tif (this.mode === 'MODE_POP-ON') {\n\t\t\tconst tmp = this.displayedMemory\n\t\t\tthis.displayedMemory = this.nonDisplayedMemory\n\t\t\tthis.nonDisplayedMemory = tmp\n\t\t\tthis.writeScreen = this.nonDisplayedMemory\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.TEXT,\n\t\t\t\t() => 'DISP: ' + this.displayedMemory.getDisplayText(),\n\t\t\t)\n\t\t}\n\t\tthis.outputDataUpdate(true)\n\t}\n\n\tccTO(nrCols: number): void {\n\t\t// Tab Offset 1,2, or 3 columns\n\t\tthis.logger.log(VerboseLevel.INFO, 'TO(' + nrCols + ') - Tab Offset')\n\t\tthis.writeScreen.moveCursor(nrCols)\n\t}\n\n\tccMIDROW(secondByte: number): void {\n\t\t// Parse MIDROW command\n\t\tconst styles: Partial<PenStyles> = { flash: false }\n\t\tstyles.underline = secondByte % 2 === 1\n\t\tstyles.italics = secondByte >= 0x2e\n\t\tif (!styles.italics) {\n\t\t\tconst colorIndex = Math.floor(secondByte / 2) - 0x10\n\t\t\tconst colors = [\n\t\t\t\t'white',\n\t\t\t\t'green',\n\t\t\t\t'blue',\n\t\t\t\t'cyan',\n\t\t\t\t'red',\n\t\t\t\t'yellow',\n\t\t\t\t'magenta',\n\t\t\t]\n\t\t\tstyles.foreground = colors[colorIndex]\n\t\t}\n\t\telse {\n\t\t\tstyles.foreground = 'white'\n\t\t}\n\t\tthis.logger.log(VerboseLevel.INFO, 'MIDROW: ' + JSON.stringify(styles))\n\t\tthis.writeScreen.setPen(styles)\n\t}\n\n\toutputDataUpdate(dispatch: boolean = false): void {\n\t\tconst time = this.logger.time\n\t\tif (time === null) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.outputFilter) {\n\t\t\tif (this.cueStartTime === null && !this.displayedMemory.isEmpty()) {\n\t\t\t\t// Start of a new cue\n\t\t\t\tthis.cueStartTime = time\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (!this.displayedMemory.equals(this.lastOutputScreen)) {\n\t\t\t\t\tthis.outputFilter.newCue(\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tthis.cueStartTime!,\n\t\t\t\t\t\ttime,\n\t\t\t\t\t\tthis.lastOutputScreen,\n\t\t\t\t\t)\n\t\t\t\t\tif (dispatch && this.outputFilter.dispatchCue) {\n\t\t\t\t\t\tthis.outputFilter.dispatchCue()\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.cueStartTime = this.displayedMemory.isEmpty() ? null : time\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.lastOutputScreen.copy(this.displayedMemory)\n\t\t}\n\t}\n\n\tcueSplitAtTime(t: number): void {\n\t\tif (this.outputFilter) {\n\t\t\tif (!this.displayedMemory.isEmpty()) {\n\t\t\t\tif (this.outputFilter.newCue) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tthis.outputFilter.newCue(this.cueStartTime!, t, this.displayedMemory)\n\t\t\t\t}\n\n\t\t\t\tthis.cueStartTime = t\n\t\t\t}\n\t\t}\n\t}\n}\n","export const backgroundColors: string[] = [\n\t'white',\n\t'green',\n\t'blue',\n\t'cyan',\n\t'red',\n\t'yellow',\n\t'magenta',\n\t'black',\n\t'transparent',\n]\n","import type { CmdHistory } from '../CmdHistory.ts'\n\nexport function createCmdHistory(): CmdHistory {\n\treturn {\n\t\ta: null,\n\t\tb: null,\n\t}\n}\n","import type { CmdHistory } from '../CmdHistory.ts'\n\nexport function hasCmdRepeated(a: number, b: number, cmdHistory: CmdHistory): boolean {\n\treturn cmdHistory.a === a && cmdHistory.b === b\n}\n","export function numArrayToHexArray(numArray: number[]): string[] {\n\tconst hexArray: string[] = []\n\tfor (const num of numArray) {\n\t\thexArray.push(num.toString(16))\n\t}\n\n\treturn hexArray\n};\n","export const rowsHighCh1: Record<number, number> = {\n\t17: 2,\n\t18: 4,\n\t21: 6,\n\t22: 8,\n\t23: 10,\n\t19: 13,\n\t20: 15,\n}\n","export const rowsHighCh2: Record<number, number> = {\n\t25: 2,\n\t26: 4,\n\t29: 6,\n\t30: 8,\n\t31: 10,\n\t27: 13,\n\t28: 15,\n}\n","// Tables to look up row from PAC data\n\nexport const rowsLowCh1: Record<number, number> = {\n\t17: 1,\n\t18: 3,\n\t21: 5,\n\t22: 7,\n\t23: 9,\n\t16: 11,\n\t19: 12,\n\t20: 14,\n}\n","export const rowsLowCh2: Record<number, number> = {\n\t25: 1,\n\t26: 3,\n\t29: 5,\n\t30: 7,\n\t31: 9,\n\t24: 11,\n\t27: 12,\n\t28: 14,\n}\n","import type { CmdHistory } from '../CmdHistory.ts'\n\nexport function setLastCmd(\n\ta: number | null,\n\tb: number | null,\n\tcmdHistory: CmdHistory,\n): void {\n\tcmdHistory.a = a\n\tcmdHistory.b = b\n}\n","/**\n *\n * This code was ported from the dash.js project at:\n * https://github.com/Dash-Industry-Forum/dash.js/blob/development/externals/cea608-parser.js\n * https://github.com/Dash-Industry-Forum/dash.js/commit/8269b26a761e0853bb21d78780ed945144ecdd4d#diff-71bc295a2d6b6b7093a1d3290d53a4b2\n *\n * The original copyright appears below:\n *\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport { CaptionsLogger } from './CaptionsLogger.ts'\nimport type { Channels } from './Channels.ts'\nimport type { CmdHistory } from './CmdHistory.ts'\nimport { Cta608Channel } from './Cta608Channel.ts'\nimport type { PACData } from './PACData.ts'\nimport type { PenStyles } from './PenStyles.ts'\nimport type { SupportedField } from './SupportedField.ts'\nimport { VerboseLevel } from './VerboseLevel.ts'\nimport { backgroundColors } from './utils/backgroundColors.ts'\nimport { createCmdHistory } from './utils/createCmdHistory.ts'\nimport { getCharForByte } from './utils/getCharForByte.ts'\nimport { hasCmdRepeated } from './utils/hasCmdRepeated.ts'\nimport { numArrayToHexArray } from './utils/numArrayToHexArray.ts'\nimport { rowsHighCh1 } from './utils/rowsHighCh1.ts'\nimport { rowsHighCh2 } from './utils/rowsHighCh2.ts'\nimport { rowsLowCh1 } from './utils/rowsLowCh1.ts'\nimport { rowsLowCh2 } from './utils/rowsLowCh2.ts'\nimport { setLastCmd } from './utils/setLastCmd.ts'\n\n/**\n * CEA-608 caption parser.\n *\n * @public\n */\nexport class Cta608Parser {\n\tprivate channels: (Cta608Channel | null)[]\n\tprivate currentChannel: Channels = 0\n\tprivate cmdHistory: CmdHistory = createCmdHistory()\n\tprivate logger: CaptionsLogger\n\tprivate lastTime: number | null = null\n\n\tconstructor(field: SupportedField, out1: any, out2: any) {\n\t\tconst logger = (this.logger = new CaptionsLogger())\n\t\tthis.channels = [\n\t\t\tnull,\n\t\t\tnew Cta608Channel(field, out1, logger),\n\t\t\tnew Cta608Channel(field + 1, out2, logger),\n\t\t]\n\t}\n\n\t/**\n\t * Add data for time t in forms of list of bytes (unsigned ints). The bytes are treated as pairs.\n\t *\n\t * @param time - The time in milliseconds\n\t * @param byteList - The list of bytes\n\t */\n\taddData(time: number | null, byteList: number[]): void {\n\t\tthis.lastTime = time\n\t\tthis.logger.time = time\n\n\t\tfor (let i = 0; i < byteList.length; i += 2) {\n\t\t\tconst a = byteList[i] & 0x7f\n\t\t\tconst b = byteList[i + 1] & 0x7f\n\t\t\tlet cmdFound: boolean = false\n\t\t\tlet charsFound: number[] | null = null\n\n\t\t\tif (this.lastTime !== null) {\n\t\t\t\ttime = this.lastTime + 0.5 * i * 1001 / 30000\n\t\t\t\tthis.logger.time = time\n\t\t\t}\n\n\t\t\tif (a === 0 && b === 0) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.logger.log(\n\t\t\t\t\tVerboseLevel.DATA,\n\t\t\t\t\t() =>\n\t\t\t\t\t\t'[' +\n\t\t\t\t\t\tnumArrayToHexArray([byteList[i], byteList[i + 1]]) +\n\t\t\t\t\t\t'] -> (' +\n\t\t\t\t\t\tnumArrayToHexArray([a, b]) +\n\t\t\t\t\t\t')',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tconst cmdHistory = this.cmdHistory\n\t\t\tconst isControlCode = a >= 0x10 && a <= 0x1f\n\t\t\tif (isControlCode) {\n\t\t\t\t// Skip redundant control codes\n\t\t\t\tif (hasCmdRepeated(a, b, cmdHistory)) {\n\t\t\t\t\tsetLastCmd(null, null, cmdHistory)\n\t\t\t\t\tthis.logger.log(\n\t\t\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t'Repeated command (' +\n\t\t\t\t\t\t\tnumArrayToHexArray([a, b]) +\n\t\t\t\t\t\t\t') is dropped',\n\t\t\t\t\t)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tsetLastCmd(a, b, this.cmdHistory)\n\n\t\t\t\tcmdFound = this.parseCmd(a, b)\n\n\t\t\t\tif (!cmdFound) {\n\t\t\t\t\tcmdFound = this.parseMidrow(a, b)\n\t\t\t\t}\n\n\t\t\t\tif (!cmdFound) {\n\t\t\t\t\tcmdFound = this.parsePAC(a, b)\n\t\t\t\t}\n\n\t\t\t\tif (!cmdFound) {\n\t\t\t\t\tcmdFound = this.parseBackgroundAttributes(a, b)\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsetLastCmd(null, null, cmdHistory)\n\t\t\t}\n\n\t\t\tif (!cmdFound) {\n\t\t\t\tcharsFound = this.parseChars(a, b)\n\t\t\t\tif (charsFound.length) {\n\t\t\t\t\tconst currChNr = this.currentChannel\n\t\t\t\t\tif (currChNr && currChNr > 0) {\n\t\t\t\t\t\tconst channel = this.channels[currChNr] as Cta608Channel\n\t\t\t\t\t\tchannel.insertChars(charsFound)\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.logger.log(\n\t\t\t\t\t\t\tVerboseLevel.WARNING,\n\t\t\t\t\t\t\t'No channel found yet. TEXT-MODE?',\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!cmdFound && !charsFound) {\n\t\t\t\tthis.logger.log(\n\t\t\t\t\tVerboseLevel.WARNING,\n\t\t\t\t\t() =>\n\t\t\t\t\t\t\"Couldn't parse cleaned data \" +\n\t\t\t\t\t\tnumArrayToHexArray([a, b]) +\n\t\t\t\t\t\t' orig: ' +\n\t\t\t\t\t\tnumArrayToHexArray([byteList[i], byteList[i + 1]]),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Parse Command.\n\t *\n\t * @param a - The first byte\n\t * @param b - The second byte\n\t * @returns True if a command was found\n\t */\n\tprivate parseCmd(a: number, b: number): boolean {\n\n\t\tconst cond1 =\n\t\t\t(a === 0x14 || a === 0x1c || a === 0x15 || a === 0x1d) &&\n\t\t\tb >= 0x20 &&\n\t\t\tb <= 0x2f\n\t\tconst cond2 = (a === 0x17 || a === 0x1f) && b >= 0x21 && b <= 0x23\n\t\tif (!(cond1 || cond2)) {\n\t\t\treturn false\n\t\t}\n\n\t\tconst chNr = a === 0x14 || a === 0x15 || a === 0x17 ? 1 : 2\n\t\tconst channel = this.channels[chNr] as Cta608Channel\n\n\t\tif (a === 0x14 || a === 0x15 || a === 0x1c || a === 0x1d) {\n\t\t\tif (b === 0x20) {\n\t\t\t\tchannel.ccRCL()\n\t\t\t}\n\t\t\telse if (b === 0x21) {\n\t\t\t\tchannel.ccBS()\n\t\t\t}\n\t\t\telse if (b === 0x22) {\n\t\t\t\tchannel.ccAOF()\n\t\t\t}\n\t\t\telse if (b === 0x23) {\n\t\t\t\tchannel.ccAON()\n\t\t\t}\n\t\t\telse if (b === 0x24) {\n\t\t\t\tchannel.ccDER()\n\t\t\t}\n\t\t\telse if (b === 0x25) {\n\t\t\t\tchannel.ccRU(2)\n\t\t\t}\n\t\t\telse if (b === 0x26) {\n\t\t\t\tchannel.ccRU(3)\n\t\t\t}\n\t\t\telse if (b === 0x27) {\n\t\t\t\tchannel.ccRU(4)\n\t\t\t}\n\t\t\telse if (b === 0x28) {\n\t\t\t\tchannel.ccFON()\n\t\t\t}\n\t\t\telse if (b === 0x29) {\n\t\t\t\tchannel.ccRDC()\n\t\t\t}\n\t\t\telse if (b === 0x2a) {\n\t\t\t\tchannel.ccTR()\n\t\t\t}\n\t\t\telse if (b === 0x2b) {\n\t\t\t\tchannel.ccRTD()\n\t\t\t}\n\t\t\telse if (b === 0x2c) {\n\t\t\t\tchannel.ccEDM()\n\t\t\t}\n\t\t\telse if (b === 0x2d) {\n\t\t\t\tchannel.ccCR()\n\t\t\t}\n\t\t\telse if (b === 0x2e) {\n\t\t\t\tchannel.ccENM()\n\t\t\t}\n\t\t\telse if (b === 0x2f) {\n\t\t\t\tchannel.ccEOC()\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t// a == 0x17 || a == 0x1F\n\t\t\tchannel.ccTO(b - 0x20)\n\t\t}\n\n\t\tthis.currentChannel = chNr\n\t\treturn true\n\t}\n\n\t/**\n\t * Parse midrow styling command\n\t *\n\t * @param a - The first byte\n\t * @param b - The second byte\n\t * @returns `true` if midrow styling command was found\n\t */\n\tprivate parseMidrow(a: number, b: number): boolean {\n\t\tlet chNr: number = 0\n\n\t\tif ((a === 0x11 || a === 0x19) && b >= 0x20 && b <= 0x2f) {\n\t\t\tif (a === 0x11) {\n\t\t\t\tchNr = 1\n\t\t\t}\n\t\t\telse {\n\t\t\t\tchNr = 2\n\t\t\t}\n\n\t\t\tif (chNr !== this.currentChannel) {\n\t\t\t\tthis.logger.log(\n\t\t\t\t\tVerboseLevel.ERROR,\n\t\t\t\t\t'Mismatch channel in midrow parsing',\n\t\t\t\t)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tconst channel = this.channels[chNr]\n\t\t\tif (!channel) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tchannel.ccMIDROW(b)\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t() => 'MIDROW (' + numArrayToHexArray([a, b]) + ')',\n\t\t\t)\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\t/**\n\t * Parse Preable Access Codes (Table 53).\n\t *\n\t * @param a - The first byte\n\t * @param b - The second byte\n\t * @returns A Boolean that tells if PAC found\n\t */\n\tprivate parsePAC(a: number, b: number): boolean {\n\t\tlet row: number\n\n\t\tconst case1 =\n\t\t\t((a >= 0x11 && a <= 0x17) || (a >= 0x19 && a <= 0x1f)) &&\n\t\t\tb >= 0x40 &&\n\t\t\tb <= 0x7f\n\t\tconst case2 = (a === 0x10 || a === 0x18) && b >= 0x40 && b <= 0x5f\n\t\tif (!(case1 || case2)) {\n\t\t\treturn false\n\t\t}\n\n\t\tconst chNr: Channels = a <= 0x17 ? 1 : 2\n\n\t\tif (b >= 0x40 && b <= 0x5f) {\n\t\t\trow = chNr === 1 ? rowsLowCh1[a] : rowsLowCh2[a]\n\t\t}\n\t\telse {\n\t\t\t// 0x60 <= b <= 0x7F\n\t\t\trow = chNr === 1 ? rowsHighCh1[a] : rowsHighCh2[a]\n\t\t}\n\t\tconst channel = this.channels[chNr]\n\t\tif (!channel) {\n\t\t\treturn false\n\t\t}\n\t\tchannel.setPAC(this.interpretPAC(row, b))\n\t\tthis.currentChannel = chNr\n\t\treturn true\n\t}\n\n\t/**\n\t * Interpret the second byte of the pac, and return the information.\n\t *\n\t * @param row - The row number\n\t * @param byte - The second byte\n\t * @returns pacData with style parameters\n\t */\n\tprivate interpretPAC(row: number, byte: number): PACData {\n\t\tlet pacIndex\n\t\tconst pacData: PACData = {\n\t\t\tcolor: null,\n\t\t\titalics: false,\n\t\t\tindent: null,\n\t\t\tunderline: false,\n\t\t\trow: row,\n\t\t}\n\n\t\tif (byte > 0x5f) {\n\t\t\tpacIndex = byte - 0x60\n\t\t}\n\t\telse {\n\t\t\tpacIndex = byte - 0x40\n\t\t}\n\n\t\tpacData.underline = (pacIndex & 1) === 1\n\t\tif (pacIndex <= 0xd) {\n\t\t\tpacData.color = [\n\t\t\t\t'white',\n\t\t\t\t'green',\n\t\t\t\t'blue',\n\t\t\t\t'cyan',\n\t\t\t\t'red',\n\t\t\t\t'yellow',\n\t\t\t\t'magenta',\n\t\t\t\t'white',\n\t\t\t][Math.floor(pacIndex / 2)]\n\t\t}\n\t\telse if (pacIndex <= 0xf) {\n\t\t\tpacData.italics = true\n\t\t\tpacData.color = 'white'\n\t\t}\n\t\telse {\n\t\t\tpacData.indent = Math.floor((pacIndex - 0x10) / 2) * 4\n\t\t}\n\t\treturn pacData // Note that row has zero offset. The spec uses 1.\n\t}\n\n\t/**\n\t * Parse characters.\n\t *\n\t * @param a - The first byte\n\t * @param b - The second byte\n\t * @returns An array with 1 to 2 codes corresponding to chars, if found. null otherwise.\n\t */\n\tprivate parseChars(a: number, b: number): number[] {\n\t\tlet channelNr: Channels\n\t\tlet charCodes: number[] = []\n\t\tlet charCode1: number | null = null\n\n\t\tif (a >= 0x19) {\n\t\t\tchannelNr = 2\n\t\t\tcharCode1 = a - 8\n\t\t}\n\t\telse {\n\t\t\tchannelNr = 1\n\t\t\tcharCode1 = a\n\t\t}\n\t\tif (charCode1 >= 0x11 && charCode1 <= 0x13) {\n\t\t\t// Special character\n\t\t\tlet oneCode: number\n\t\t\tif (charCode1 === 0x11) {\n\t\t\t\toneCode = b + 0x50\n\t\t\t}\n\t\t\telse if (charCode1 === 0x12) {\n\t\t\t\toneCode = b + 0x70\n\t\t\t}\n\t\t\telse {\n\t\t\t\toneCode = b + 0x90\n\t\t\t}\n\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.INFO,\n\t\t\t\t() =>\n\t\t\t\t\t\"Special char '\" +\n\t\t\t\t\tgetCharForByte(oneCode) +\n\t\t\t\t\t\"' in channel \" +\n\t\t\t\t\tchannelNr,\n\t\t\t)\n\t\t\tcharCodes = [oneCode]\n\t\t}\n\t\telse if (a >= 0x20 && a <= 0x7f) {\n\t\t\tcharCodes = b === 0 ? [a] : [a, b]\n\t\t}\n\t\tif (charCodes) {\n\t\t\tthis.logger.log(\n\t\t\t\tVerboseLevel.DEBUG,\n\t\t\t\t() => 'Char codes = ' + numArrayToHexArray(charCodes).join(','),\n\t\t\t)\n\t\t}\n\t\treturn charCodes\n\t}\n\n\t/**\n\t * Parse extended background attributes as well as new foreground color black.\n\t *\n\t * @param a - The first byte\n\t * @param b - The second byte\n\t * @returns True if background attributes are found\n\t */\n\tprivate parseBackgroundAttributes(a: number, b: number): boolean {\n\t\tconst case1 = (a === 0x10 || a === 0x18) && b >= 0x20 && b <= 0x2f\n\t\tconst case2 = (a === 0x17 || a === 0x1f) && b >= 0x2d && b <= 0x2f\n\t\tif (!(case1 || case2)) {\n\t\t\treturn false\n\t\t}\n\t\tlet index: number\n\t\tconst bkgData: Partial<PenStyles> = {}\n\t\tif (a === 0x10 || a === 0x18) {\n\t\t\tindex = Math.floor((b - 0x20) / 2)\n\t\t\tbkgData.background = backgroundColors[index]\n\t\t\tif (b % 2 === 1) {\n\t\t\t\tbkgData.background = bkgData.background + '_semi'\n\t\t\t}\n\t\t}\n\t\telse if (b === 0x2d) {\n\t\t\tbkgData.background = 'transparent'\n\t\t}\n\t\telse {\n\t\t\tbkgData.foreground = 'black'\n\t\t\tif (b === 0x2f) {\n\t\t\t\tbkgData.underline = true\n\t\t\t}\n\t\t}\n\t\tconst chNr: Channels = a <= 0x17 ? 1 : 2\n\t\tconst channel: Cta608Channel = this.channels[chNr] as Cta608Channel\n\t\tchannel.setBkgData(bkgData)\n\t\treturn true\n\t}\n\n\t/**\n\t * Reset state of parser and its channels.\n\t */\n\treset(): void {\n\t\tfor (let i = 0; i < Object.keys(this.channels).length; i++) {\n\t\t\tconst channel = this.channels[i]\n\t\t\tif (channel) {\n\t\t\t\tchannel.reset()\n\t\t\t}\n\t\t}\n\t\tsetLastCmd(null, null, this.cmdHistory)\n\t}\n\n\t/**\n\t * Trigger the generation of a cue, and the start of a new one if displayScreens are not empty.\n\t */\n\tcueSplitAtTime(t: number): void {\n\t\tfor (const channel of this.channels) {\n\t\t\tif (channel) {\n\t\t\t\tchannel.cueSplitAtTime(t)\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * Extract CTA-608 data from a DataView\n *\n * @param raw - The DataView to extract the data from\n * @param cta608Range - The range of the CTA-608 data\n * @returns The extracted CTA-608 data\n *\n * @public\n */\nexport function extractCta608Data(raw: DataView, cta608Range: number[]): number[][] {\n\tlet pos = cta608Range[0]\n\tconst fieldData: number[][] = [[], []]\n\n\tpos += 8 // Skip the identifier up to userDataTypeCode\n\tconst ccCount = raw.getUint8(pos) & 31\n\tpos += 2 // Advance 1 and skip reserved byte\n\n\tfor (let i = 0; i < ccCount; i++) {\n\t\tconst byte = raw.getUint8(pos)\n\t\tconst ccValid = byte & 4\n\t\tconst ccType = byte & 3\n\t\tpos++\n\t\tconst ccData1: number = raw.getUint8(pos) // Keep parity bit\n\t\tpos++\n\t\tconst ccData2: number = raw.getUint8(pos) // Keep parity bit\n\t\tpos++\n\t\tif (ccValid && ((ccData1 & 127) + (ccData2 & 127) !== 0)) { //Check validity and non-empty data\n\t\t\tif (ccType === 0) {\n\t\t\t\tfieldData[0].push(ccData1)\n\t\t\t\tfieldData[0].push(ccData2)\n\t\t\t}\n\t\t\telse if (ccType === 1) {\n\t\t\t\tfieldData[1].push(ccData1)\n\t\t\t\tfieldData[1].push(ccData2)\n\t\t\t}\n\t\t}\n\t}\n\treturn fieldData\n}\n","export function getSeiData(raw: DataView, startPos: number, endPos: number): DataView {\n\tconst data: number[] = []\n\n\tfor (let cursor = startPos; cursor < endPos; cursor++) {\n\t\tif (cursor + 2 < endPos && raw.getUint8(cursor) === 0x00 && raw.getUint8(cursor + 1) === 0x00 && raw.getUint8(cursor + 2) === 0x03) {\n\t\t\tdata.push(0x00)\n\t\t\tdata.push(0x00)\n\t\t\tcursor += 2\n\t\t} \n\t\telse {\n\t\t\tdata.push(raw.getUint8(cursor))\n\t\t}\n\t}\n\n\treturn new DataView(new Uint8Array(data).buffer)\n}\n\nexport function isCea608Sei(payloadType: number, payloadSize: number, sei: DataView, pos: number): boolean {\n\tif (payloadType !== 4 || payloadSize < 8) {\n\t\treturn false\n\t}\n\n\tconst countryCode = sei.getUint8(pos)\n\tif (countryCode !== 0xB5) {\n\t\treturn false\n\t}\n\n\tconst providerCode = sei.getUint16(pos + 1)\n\tif (providerCode !== 0x0031) {\n\t\treturn false\n\t}\n\n\tconst userIdentifier = sei.getUint32(pos + 3)\n\tif (userIdentifier !== 0x47413934) {\n\t\treturn false\n\t}\n\n\tconst userDataTypeCode = sei.getUint8(pos + 7)\n\tif (userDataTypeCode !== 0x03) {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nexport function isCCType(type: number): boolean {\n\treturn type === 0 || type === 1\n}\n\nexport function isNonEmptyCCData(ccData1: number, ccData2: number): boolean {\n\treturn (ccData1 & 0x7F) > 0 || (ccData2 & 0x7F) > 0\n}\n\n/**\n * H.264 SEI NAL unit type\n */\nconst H264_SEI_TYPE = 0x06\n\n/**\n * H.265 prefix SEI NAL unit type\n */\nconst H265_PREFIX_SEI_TYPE = 39\n\n/**\n * H.265 suffix SEI NAL unit type\n */\nconst H265_SUFFIX_SEI_TYPE = 40\n\n/**\n * H.266 prefix SEI NAL unit type\n */\nconst H266_PREFIX_SEI_TYPE = 23\n\n/**\n * H.266 suffix SEI NAL unit type\n */\nconst H266_SUFFIX_SEI_TYPE = 24\n\n/**\n * Check if a NAL unit type is an SEI (Supplemental Enhancement Information) unit\n * for H.264, H.265, or H.266 codecs.\n *\n * @param unitType - The NAL unit type to check\n * @returns true if the unit type is an SEI NAL unit type for any supported codec\n */\nexport function isSeiNalUnitType(unitType: number): boolean {\n\treturn unitType === H264_SEI_TYPE ||\n\t\tunitType === H265_PREFIX_SEI_TYPE ||\n\t\tunitType === H265_SUFFIX_SEI_TYPE ||\n\t\tunitType === H266_PREFIX_SEI_TYPE ||\n\t\tunitType === H266_SUFFIX_SEI_TYPE\n}\n\n/**\n * Detects whether a NAL unit is an SEI (Supplemental Enhancement Information) unit\n * and returns its type and header size.\n *\n * This function supports auto-detection across H.264, H.265, and H.266 codecs:\n * - H.264: 1-byte NAL header, type in bits 0-4\n * - H.265: 2-byte NAL header, type in bits 1-6 of byte 0\n * - H.266: 2-byte NAL header, type in bits 3-7 of byte 1\n *\n * @param raw - The DataView containing the NAL unit data\n * @param pos - The position of the first NAL header byte\n * @returns An object containing the NAL unit type and header size, or null if not an SEI NAL unit\n */\nexport function extractNalUnitType(raw: DataView, pos: number): { nalType: number; headerSize: number } | null {\n\tconst byte0 = raw.getUint8(pos)\n\n\t// H.264: 1-byte header, type in bits 0-4\n\tconst h264Type = byte0 & 0x1F\n\tif (h264Type === H264_SEI_TYPE) {\n\t\treturn { nalType: h264Type, headerSize: 1 }\n\t}\n\n\t// H.265: 2-byte header, type in bits 1-6 of byte 0\n\tconst h265Type = (byte0 >> 1) & 0x3F\n\tif (h265Type === H265_PREFIX_SEI_TYPE || h265Type === H265_SUFFIX_SEI_TYPE) {\n\t\treturn { nalType: h265Type, headerSize: 2 }\n\t}\n\n\t// H.266: 2-byte header, type in bits 3-7 of byte 1\n\tif (pos + 1 >= raw.byteLength) {\n\t\treturn null\n\t}\n\tconst byte1 = raw.getUint8(pos + 1)\n\tconst h266Type = (byte1 >> 3) & 0x1F\n\tif (h266Type === H266_PREFIX_SEI_TYPE || h266Type === H266_SUFFIX_SEI_TYPE) {\n\t\treturn { nalType: h266Type, headerSize: 2 }\n\t}\n\n\treturn null\n}\n\nexport function parseCta608DataFromSei(sei: DataView, fieldData: number[][]): void {\n\tlet cursor = 0\n\t// The last byte is rbsp_trailing_bits, so stop before it\n\twhile (cursor < sei.byteLength - 1) {\n\t\tlet payloadType = 0\n\t\tlet payloadSize = 0\n\t\tlet now\n\n\t\tdo {\n\t\t\tpayloadType += now = sei.getUint8(cursor++)\n\t\t} while (now === 0xFF)\n\t\tdo {\n\t\t\tpayloadSize += now = sei.getUint8(cursor++)\n\t\t} while (now === 0xFF)\n\n\t\tif (isCea608Sei(payloadType, payloadSize, sei, cursor)) {\n\t\t\tconst pos = cursor + 10\n\t\t\tconst ccCount = pos + (sei.getUint8(pos - 2) & 0x1F) * 3\n\t\t\tfor (let i = pos; i < ccCount; i += 3) {\n\t\t\t\tconst byte = sei.getUint8(i)\n\t\t\t\tif (byte & 0x04) {\n\t\t\t\t\tconst ccType = byte & 0x03\n\t\t\t\t\tif (isCCType(ccType)) {\n\t\t\t\t\t\tconst ccData1 = sei.getUint8(i + 1)\n\t\t\t\t\t\tconst ccData2 = sei.getUint8(i + 2)\n\t\t\t\t\t\tif (isNonEmptyCCData(ccData1, ccData2)) {\n\t\t\t\t\t\t\tfieldData[ccType].push(ccData1, ccData2)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcursor += payloadSize\n\t}\n}\n","import {\n\textractNalUnitType,\n\tgetSeiData,\n\tparseCta608DataFromSei,\n} from './utils/seiHelpers.ts'\n\n/**\n * Extracts CEA-608 data from a given sample.\n *\n * @param raw - The DataView with media data\n * @param startPos - The start position within the DataView\n * @param sampleSize - The size of the sample in bytes\n * @returns fieldData array containing field 1 and field 2 data arrays\n *\n * @public\n */\nexport function extractCta608DataFromSample(raw: DataView, startPos: number, sampleSize: number): number[][] {\n\tlet nalSize: number = 0\n\tconst fieldData: number[][] = [[], []]\n\n\t// Loop needs to account for maximum NALU header size (H.265/H.266 = 6 bytes: 4-byte size + 2-byte header)\n\tfor (let cursor = startPos; cursor < startPos + sampleSize - 6; cursor++) {\n\t\tnalSize = raw.getUint32(cursor)\n\n\t\t// The NAL unit data (nalSize bytes) starts after the 4-byte length prefix\n\t\tconst nalEnd = cursor + 4 + nalSize\n\n\t\t// Make sure that we don't go out of bounds\n\t\tif (nalEnd > startPos + sampleSize) {\n\t\t\tbreak\n\t\t}\n\n\t\t// Only process Supplemental Enhancement Information (SEI) NAL units\n\t\tconst seiInfo = extractNalUnitType(raw, cursor + 4)\n\t\tif (seiInfo) {\n\t\t\tconst seiStart = cursor + 4 + seiInfo.headerSize\n\t\t\tif (nalEnd <= raw.byteLength) {\n\t\t\t\tconst seiData = getSeiData(raw, seiStart, nalEnd)\n\t\t\t\tparseCta608DataFromSei(seiData, fieldData)\n\t\t\t}\n\t\t}\n\n\t\t// Jump to the next NAL unit\n\t\tcursor += nalSize + 3\n\t}\n\treturn fieldData\n}\n","import { extractNalUnitType } from './utils/seiHelpers.ts'\n\n/**\n * Find CTA-608 NAL units in a video stream\n *\n * @param raw - The DataView to extract the data from\n * @param startPos - The start position of the data\n * @param size - The size of the data\n * @returns The extracted CTA-608 NAL units\n *\n * @public\n */\nexport function findCta608Nalus(raw: DataView, startPos: number, size: number): number[][] {\n\tlet nalSize = 0, cursor = startPos\n\tconst cta608NaluRanges = []\n\n\t// Check SEI data according to ANSI-SCTE 128\n\tconst isCTA608SEI = (payloadType: number, payloadSize: number, raw: DataView, pos: number) => {\n\t\tif (payloadType !== 4 || payloadSize < 8) {\n\t\t\treturn null\n\t\t}\n\t\tconst countryCode = raw.getUint8(pos)\n\t\tconst providerCode = raw.getUint16(pos + 1)\n\t\tconst userIdentifier = raw.getUint32(pos + 3)\n\t\tconst userDataTypeCode = raw.getUint8(pos + 7)\n\t\treturn countryCode == 181 && providerCode == 49 && userIdentifier == 1195456820 && userDataTypeCode == 3\n\t}\n\n\twhile (cursor < startPos + size) {\n\t\tnalSize = raw.getUint32(cursor)\n\n\t\tconst seiInfo = extractNalUnitType(raw, cursor + 4)\n\t\tif (seiInfo) {\n\t\t\t// SEI NAL Unit. The NAL header is 1 byte (H.264) or 2 bytes (H.265/H.266)\n\t\t\tlet pos = cursor + 4 + seiInfo.headerSize\n\t\t\tlet payloadType = -1\n\t\t\twhile (pos < cursor + 4 + nalSize - 1) { // The last byte should be rbsp_trailing_bits\n\t\t\t\tpayloadType = 0\n\t\t\t\tlet b = 255\n\t\t\t\twhile (b === 255) {\n\t\t\t\t\tb = raw.getUint8(pos)\n\t\t\t\t\tpayloadType += b\n\t\t\t\t\tpos++\n\t\t\t\t}\n\t\t\t\tlet payloadSize = 0\n\t\t\t\tb = 255\n\t\t\t\twhile (b === 255) {\n\t\t\t\t\tb = raw.getUint8(pos)\n\t\t\t\t\tpayloadSize += b\n\t\t\t\t\tpos++\n\t\t\t\t}\n\t\t\t\tif (isCTA608SEI(payloadType, payloadSize, raw, pos)) {\n\t\t\t\t\tcta608NaluRanges.push([pos, payloadSize])\n\t\t\t\t}\n\t\t\t\tpos += payloadSize\n\t\t\t}\n\t\t}\n\t\tcursor += nalSize + 4\n\t}\n\treturn cta608NaluRanges\n}\n","/**\n * The copyright in this software is being made available under the BSD License,\n * included below. This software may be subject to other third party and contributor\n * rights, including patent rights, and no such rights are granted under this license.\n *\n * Copyright (c) 2015-2016, DASH Industry Forum.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification,\n * are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation and/or\n * other materials provided with the distribution.\n * 2. Neither the name of Dash Industry Forum nor the names of its\n * contributors may be used to endorse or promote products derived from this software\n * without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\n/**\n * SCC Parser\n *\n * @public\n */\nexport class SccParser {\n\thasHeader: boolean = false\n\tnrLinesParsed: number = 0\n\tprocessor: any\n\tfield: number | any\n\n\tconstructor(processor: any, field: number | any = 1) {\n\t\tthis.processor = processor\n\t\tthis.field = field\n\t}\n\n\tparse(text: string): void {\n\t\tconst lines = text.split(/\\r?\\n/)\n\t\tthis.nrLinesParsed = 0\n\n\t\tif (lines[0] === 'Scenarist_SCC V1.0') {\n\t\t\tthis.hasHeader = true\n\t\t\tthis.nrLinesParsed++\n\t\t}\n\n\t\tfor (let l = 1; l < lines.length; l += 2) {\n\t\t\tif (lines[l] !== '') {\n\t\t\t\tbreak // Every second line should be empty\n\t\t\t}\n\t\t\tthis.nrLinesParsed++\n\t\t\tconst lineData = this.parseDataLine(lines[l + 1])\n\t\t\tif (lineData === null) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tthis.nrLinesParsed++\n\t\t\tthis.processor.addData(lineData[0], lineData[1])\n\t\t}\n\t}\n\n\tparseDataLine(line: string): [number, number[]] | null {\n\t\tif (!line) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst lineParts = line.split(/\\s+/)\n\t\tconst timeData = lineParts[0]\n\t\tconst ceaData: number[] = []\n\n\t\tfor (let i = 1; i < lineParts.length; i++) {\n\t\t\tconst fourHexChars = lineParts[i]\n\t\t\tconst a = parseInt(fourHexChars.substring(0, 2), 16)\n\t\t\tconst b = parseInt(fourHexChars.substring(2, 4), 16)\n\t\t\tceaData.push(a, b)\n\t\t}\n\n\t\tconst time = this.timeConverter(timeData)\n\t\treturn [time, ceaData]\n\t}\n\n\ttimeConverter(smpteTs: string): number {\n\t\tconst parts = smpteTs.split(':')\n\t\tif (parts.length === 3) {\n\t\t\tconst lastParts = parts[2].split(';')\n\t\t\tparts[2] = lastParts[0]\n\t\t\tconst frames = parseInt(lastParts[1], 10)\n\t\t\treturn (30 * (60 * (60 * parseInt(parts[0], 10) + parseInt(parts[1], 10)) + parseInt(parts[2], 10)) + frames) * 1001 / 30000\n\t\t}\n\t\treturn 0 // in case if format is incorrect\n\t}\n\n\tgetHeaderStatus(): boolean {\n\t\treturn this.hasHeader\n\t}\n\n\tgetField(): number | any {\n\t\treturn this.field\n\t}\n\n\tgetLinesParsed(): number {\n\t\treturn this.nrLinesParsed\n\t}\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,eAAe;CAC3B,OAAO;CACP,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,MAAM;CACN;;;;;;;;;AC4BD,IAAa,iBAAb,MAA4B;;cACE;sBACO,aAAa;;CAEjD,IAAI,UAAwB,KAAoC;AAC/D,MAAI,KAAK,gBAAgB,UAAU;GAClC,MAAMA,IAAY,OAAO,QAAQ,aAAa,KAAK,GAAG;AACtD,WAAQ,IAAI,GAAG,KAAK,KAAK,IAAI,SAAS,IAAI,IAAI;;;;;;;;;;;;ACPjD,IAAa,WAAb,MAAsB;;oBACO;mBACA;iBACF;oBACE;eACJ;;CAExB,QAAc;AACb,OAAK,aAAa;AAClB,OAAK,YAAY;AACjB,OAAK,UAAU;AACf,OAAK,aAAa;AAClB,OAAK,QAAQ;;CAGd,UAAU,QAAkC;AAQ3C,OAAK,MAAM,SAPK;GACf;GACA;GACA;GACA;GACA;GACA,CAEA,KAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,MAAM,CACtD,CAAC,KAAa,SAAU,OAAe;;CAK1C,YAAqB;AACpB,SACC,KAAK,eAAe,WACpB,CAAC,KAAK,aACN,CAAC,KAAK,WACN,KAAK,eAAe,WACpB,CAAC,KAAK;;CAIR,OAAO,OAA0B;AAChC,SACC,KAAK,eAAe,MAAM,cAC1B,KAAK,cAAc,MAAM,aACzB,KAAK,YAAY,MAAM,WACvB,KAAK,eAA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