Merge pull request #5355 from zsmatyas:dev-v2

PiperOrigin-RevId: 229364147
This commit is contained in:
Oliver Woodman 2019-01-15 15:03:22 +00:00
commit 3b5e8ada31
2 changed files with 20 additions and 26 deletions

View File

@ -31,6 +31,8 @@
([#5378](https://github.com/google/ExoPlayer/issues/5378)). ([#5378](https://github.com/google/ExoPlayer/issues/5378)).
* Add support for SHOUTcast ICY metadata * Add support for SHOUTcast ICY metadata
([#3735](https://github.com/google/ExoPlayer/issues/3735)). ([#3735](https://github.com/google/ExoPlayer/issues/3735)).
* CEA-608: Improved conformance to the specification
([#3860](https://github.com/google/ExoPlayer/issues/3860)).
* IMA extension: * IMA extension:
* Clear ads loader listeners on release * Clear ads loader listeners on release
([#4114](https://github.com/google/ExoPlayer/issues/4114)). ([#4114](https://github.com/google/ExoPlayer/issues/4114)).
@ -1182,7 +1184,7 @@
[here](https://medium.com/google-exoplayer/customizing-exoplayers-ui-components-728cf55ee07a#.9ewjg7avi). [here](https://medium.com/google-exoplayer/customizing-exoplayers-ui-components-728cf55ee07a#.9ewjg7avi).
* Robustness improvements when handling MediaSource timeline changes and * Robustness improvements when handling MediaSource timeline changes and
MediaPeriod transitions. MediaPeriod transitions.
* EIA608: Support for caption styling and positioning. * CEA-608: Support for caption styling and positioning.
* MPEG-TS: Improved support: * MPEG-TS: Improved support:
* Support injection of custom TS payload readers. * Support injection of custom TS payload readers.
* Support injection of custom section payload readers. * Support injection of custom section payload readers.
@ -1426,8 +1428,8 @@ V2 release.
(#801). (#801).
* MP3: Fix playback of some streams when stream length is unknown. * MP3: Fix playback of some streams when stream length is unknown.
* ID3: Support multiple frames of the same type in a single tag. * ID3: Support multiple frames of the same type in a single tag.
* EIA608: Correctly handle repeated control characters, fixing an issue in which * CEA-608: Correctly handle repeated control characters, fixing an issue in
captions would immediately disappear. which captions would immediately disappear.
* AVC3: Fix decoder failures on some MediaTek devices in the case where the * AVC3: Fix decoder failures on some MediaTek devices in the case where the
first buffer fed to the decoder does not start with SPS/PPS NAL units. first buffer fed to the decoder does not start with SPS/PPS NAL units.
* Misc bug fixes. * Misc bug fixes.

View File

@ -292,7 +292,6 @@ public final class Cea608Decoder extends CeaDecoder {
protected void decode(SubtitleInputBuffer inputBuffer) { protected void decode(SubtitleInputBuffer inputBuffer) {
ccData.reset(inputBuffer.data.array(), inputBuffer.data.limit()); ccData.reset(inputBuffer.data.array(), inputBuffer.data.limit());
boolean captionDataProcessed = false; boolean captionDataProcessed = false;
boolean isRepeatableControl = false;
while (ccData.bytesLeft() >= packetLength) { while (ccData.bytesLeft() >= packetLength) {
byte ccHeader = packetLength == 2 ? CC_IMPLICIT_DATA_HEADER byte ccHeader = packetLength == 2 ? CC_IMPLICIT_DATA_HEADER
: (byte) ccData.readUnsignedByte(); : (byte) ccData.readUnsignedByte();
@ -323,6 +322,9 @@ public final class Cea608Decoder extends CeaDecoder {
continue; continue;
} }
boolean repeatedControlPossible = repeatableControlSet;
repeatableControlSet = false;
boolean previousCaptionValid = captionValid; boolean previousCaptionValid = captionValid;
captionValid = (ccHeader & CC_VALID_FLAG) == CC_VALID_FLAG; captionValid = (ccHeader & CC_VALID_FLAG) == CC_VALID_FLAG;
if (!captionValid) { if (!captionValid) {
@ -372,7 +374,7 @@ public final class Cea608Decoder extends CeaDecoder {
// Control character. // Control character.
// ccData1 - 0|0|0|X|X|X|X|X // ccData1 - 0|0|0|X|X|X|X|X
if ((ccData1 & 0xE0) == 0x00) { if ((ccData1 & 0xE0) == 0x00) {
isRepeatableControl = handleCtrl(ccData1, ccData2); handleCtrl(ccData1, ccData2, repeatedControlPossible);
continue; continue;
} }
@ -384,32 +386,24 @@ public final class Cea608Decoder extends CeaDecoder {
} }
if (captionDataProcessed) { if (captionDataProcessed) {
if (!isRepeatableControl) {
repeatableControlSet = false;
}
if (captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_PAINT_ON) { if (captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_PAINT_ON) {
cues = getDisplayCues(); cues = getDisplayCues();
} }
} }
} }
private boolean handleCtrl(byte cc1, byte cc2) { private void handleCtrl(byte cc1, byte cc2, boolean repeatedControlPossible) {
boolean isRepeatableControl = isRepeatable(cc1); // Most control commands are sent twice in succession to ensure they are received properly. We
// don't want to process duplicate commands, so if we see the same repeatable command twice in a
// Most control commands are sent twice in succession to ensure they are received properly. // row then we ignore the second one.
// We don't want to process duplicate commands, so if we see the same repeatable command twice if (isRepeatable(cc1)) {
// in a row, ignore the second one. if (repeatedControlPossible && repeatableControlCc1 == cc1 && repeatableControlCc2 == cc2) {
if (isRepeatableControl) { // This is a repeated command, so we ignore it.
if (repeatableControlSet return;
&& repeatableControlCc1 == cc1
&& repeatableControlCc2 == cc2) {
// This is a duplicate. Clear the repeatable control flag and return.
repeatableControlSet = false;
return true;
} else { } else {
// This is a repeatable command, but we haven't see it yet, so set the repeatable control // This is the first occurrence of a repeatable command. Set the repeatable control
// flag (to ensure we ignore the next one should it be a duplicate) and continue processing // variables so that we can recognize and ignore a duplicate (if there is one), and then
// the command. // continue to process the command below.
repeatableControlSet = true; repeatableControlSet = true;
repeatableControlCc1 = cc1; repeatableControlCc1 = cc1;
repeatableControlCc2 = cc2; repeatableControlCc2 = cc2;
@ -425,8 +419,6 @@ public final class Cea608Decoder extends CeaDecoder {
} else if (isMiscCode(cc1, cc2)) { } else if (isMiscCode(cc1, cc2)) {
handleMiscCode(cc2); handleMiscCode(cc2);
} }
return isRepeatableControl;
} }
private void handleMidrowCtrl(byte cc2) { private void handleMidrowCtrl(byte cc2) {