@@ -123,19 +123,26 @@ shaka.cea.Cea608DataChannel = class {
123
123
controlPac_ ( b1 , b2 ) {
124
124
const row = this . pacToRow_ ( b1 , b2 ) ;
125
125
126
- // Get attribute bits (4 bits)
127
- const attr = ( b2 & 0x1E ) >> 1 ;
128
-
129
126
// Set up the defaults.
130
127
let textColor = shaka . cea . CeaUtils . DEFAULT_TXT_COLOR ;
131
128
let italics = false ;
129
+ let indent = null ;
130
+
131
+ // Get PAC index;
132
+ let pacIndex ;
133
+ if ( b2 > 0x5f ) {
134
+ pacIndex = b2 - 0x60 ;
135
+ } else {
136
+ pacIndex = b2 - 0x40 ;
137
+ }
132
138
133
-
134
- // Attributes < 7 are colors, = 7 is white w/ italics, and >7 are indents
135
- if ( attr < 7 ) {
136
- textColor = shaka . cea . Cea608DataChannel . TEXT_COLORS [ attr ] ;
137
- } else if ( attr === 7 ) {
139
+ if ( pacIndex <= 0xd ) {
140
+ const colorIndex = Math . floor ( pacIndex / 2 ) ;
141
+ textColor = shaka . cea . Cea608DataChannel . TEXT_COLORS [ colorIndex ] ;
142
+ } else if ( pacIndex <= 0xf ) {
138
143
italics = true ; // color stays white
144
+ } else {
145
+ indent = Math . floor ( ( pacIndex - 0x10 ) / 2 ) ;
139
146
}
140
147
141
148
// PACs toggle underline on the last bit of b2.
@@ -168,6 +175,7 @@ shaka.cea.Cea608DataChannel = class {
168
175
buf . setUnderline ( underline ) ;
169
176
buf . setItalics ( italics ) ;
170
177
buf . setTextColor ( textColor ) ;
178
+ buf . setIndent ( indent ) ;
171
179
172
180
// Clear the background color, since new row (PAC) should reset ALL styles.
173
181
buf . setBackgroundColor ( shaka . cea . CeaUtils . DEFAULT_BG_COLOR ) ;
@@ -507,6 +515,16 @@ shaka.cea.Cea608DataChannel = class {
507
515
this . curbuf_ . addChar ( charSet , b2 ) ;
508
516
}
509
517
518
+ /**
519
+ * Handles a tab offset.
520
+ *
521
+ * @param {number } offset
522
+ * @private
523
+ */
524
+ handleOffset_ ( offset ) {
525
+ this . curbuf_ . setOffset ( offset ) ;
526
+ }
527
+
510
528
/**
511
529
* Decodes control code.
512
530
* Three types of control codes:
@@ -543,6 +561,9 @@ shaka.cea.Cea608DataChannel = class {
543
561
this . handleExtendedWesternEuropeanChar_ ( b1 , b2 ) ;
544
562
} else if ( this . isMiscellaneous_ ( b1 , b2 ) ) {
545
563
return this . controlMiscellaneous_ ( ccPacket ) ;
564
+ } else if ( this . isOffset_ ( b1 , b2 ) ) {
565
+ const offset = b2 - 0x20 ;
566
+ this . handleOffset_ ( offset ) ;
546
567
}
547
568
return null ;
548
569
}
@@ -561,6 +582,17 @@ shaka.cea.Cea608DataChannel = class {
561
582
return ( ( b1 & 0xf6 ) === 0x14 ) && ( ( b2 & 0xf0 ) === 0x20 ) ;
562
583
}
563
584
585
+ /**
586
+ * Checks if this is a offset control code.
587
+ * @param {number } b1 Byte 1.
588
+ * @param {number } b2 Byte 2.
589
+ * @return {boolean }
590
+ * @private
591
+ */
592
+ isOffset_ ( b1 , b2 ) {
593
+ return ( b1 == 0x17 || b1 == 0x1f ) && b2 >= 0x21 && b2 <= 0x23 ;
594
+ }
595
+
564
596
/**
565
597
* Checks if this is a PAC control code.
566
598
* @param {number } b1 Byte 1.
0 commit comments