Skip to content

Commit 3e14ce1

Browse files
committed
Code changes suggested by tonihei
1 parent 2f356ba commit 3e14ce1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ public final class Cea608Decoder extends CeaDecoder {
8383

8484
private static final byte CTRL_BACKSPACE = 0x21;
8585

86-
@SuppressWarnings("unused")
87-
private static final byte CTRL_ALARM_OFF= 0x22; // not supported any more
88-
89-
@SuppressWarnings("unused")
90-
private static final byte CTRL_ALARM_ON= 0x23; // not supported any more
91-
9286
private static final byte CTRL_DELETE_TO_END_OF_ROW = 0x24;
9387

9488
/**
@@ -258,7 +252,7 @@ public final class Cea608Decoder extends CeaDecoder {
258252
// The incoming characters may belong to 3 different services based on the last received control
259253
// codes. The 3 services are Captioning, Text and XDS. In this decoder we only intend to process
260254
// bytes belonging to the Captioning service.
261-
private boolean isInCaptionMode = true;
255+
private boolean isInCaptionMode;
262256

263257
public Cea608Decoder(String mimeType, int accessibilityChannel) {
264258
ccData = new ParsableByteArray();
@@ -291,6 +285,7 @@ public Cea608Decoder(String mimeType, int accessibilityChannel) {
291285

292286
setCaptionMode(CC_MODE_UNKNOWN);
293287
resetCueBuilders();
288+
isInCaptionMode = true;
294289
}
295290

296291
@Override
@@ -330,23 +325,28 @@ protected Subtitle createSubtitle() {
330325
return new CeaSubtitle(cues);
331326
}
332327

333-
private boolean isCodeForUnsupportedMode(byte cc1, byte cc2) {
328+
private static boolean isCodeForUnsupportedMode(byte cc1, byte cc2) {
334329
// Control codes from 0x01 to 0x0F indicate the beginning of XDS Data
335330
if (0x01 <= cc1 && cc1 <= 0x0F) {
336331
return true;
337332
}
338333

339334
// 2 commands switch to TEXT mode.
340-
if (((cc1 & 0xF7) == 0x14) // first byte must be 0x14 or 0x1C based on channel
335+
if ((isModeSwitchCommand(cc1))
341336
&& (cc2 == CTRL_TEXT_RESTART || cc2 == CTRL_RESUME_TEXT_DISPLAY)) {
342337
return true;
343338
}
344339

345340
return false;
346341
}
347342

343+
// first byte of these commands must be 0x14 or 0x1C based on channel
344+
private static boolean isModeSwitchCommand(byte cc1) {
345+
return (cc1 & 0xF7) == 0x14;
346+
}
347+
348348
private static boolean isControlCodeSwitchingToCaptionMode(byte cc1, byte cc2) {
349-
if ((cc1 & 0xF7) != 0x14) { // Matching commands must have the CC1 value: 0|0|0|1|CH|1|0|0 where CH is the channel bit
349+
if (!isModeSwitchCommand(cc1)) {
350350
return false;
351351
}
352352

0 commit comments

Comments
 (0)