Commit 16f57e39 by olly Committed by Oliver Woodman

Ignore repeated control characters in EIA608 subtitles.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=117220536
parent a1c74cb2
...@@ -94,4 +94,8 @@ package com.google.android.exoplayer.text.eia608; ...@@ -94,4 +94,8 @@ package com.google.android.exoplayer.text.eia608;
return (cc1 >= 0x10 && cc1 <= 0x1F) && (cc2 >= 0x40 && cc2 <= 0x7F); return (cc1 >= 0x10 && cc1 <= 0x1F) && (cc2 >= 0x40 && cc2 <= 0x7F);
} }
public boolean isRepeatable() {
return cc1 >= 0x10 && cc1 <= 0x1F;
}
} }
...@@ -66,6 +66,7 @@ public final class Eia608TrackRenderer extends SampleSourceTrackRenderer impleme ...@@ -66,6 +66,7 @@ public final class Eia608TrackRenderer extends SampleSourceTrackRenderer impleme
private int captionRowCount; private int captionRowCount;
private String caption; private String caption;
private String lastRenderedCaption; private String lastRenderedCaption;
private ClosedCaptionCtrl repeatableControl;
/** /**
* @param textRenderer The text renderer. * @param textRenderer The text renderer.
...@@ -94,6 +95,7 @@ public final class Eia608TrackRenderer extends SampleSourceTrackRenderer impleme ...@@ -94,6 +95,7 @@ public final class Eia608TrackRenderer extends SampleSourceTrackRenderer impleme
@Override @Override
protected void onReset(long positionUs) { protected void onReset(long positionUs) {
inputStreamEnded = false; inputStreamEnded = false;
repeatableControl = null;
pendingCaptionLists.clear(); pendingCaptionLists.clear();
clearPendingSample(); clearPendingSample();
captionRowCount = DEFAULT_CAPTIONS_ROW_COUNT; captionRowCount = DEFAULT_CAPTIONS_ROW_COUNT;
...@@ -193,10 +195,20 @@ public final class Eia608TrackRenderer extends SampleSourceTrackRenderer impleme ...@@ -193,10 +195,20 @@ public final class Eia608TrackRenderer extends SampleSourceTrackRenderer impleme
return; return;
} }
boolean isRepeatableControl = false;
for (int i = 0; i < captionBufferSize; i++) { for (int i = 0; i < captionBufferSize; i++) {
ClosedCaption caption = captionList.captions[i]; ClosedCaption caption = captionList.captions[i];
if (caption.type == ClosedCaption.TYPE_CTRL) { if (caption.type == ClosedCaption.TYPE_CTRL) {
ClosedCaptionCtrl captionCtrl = (ClosedCaptionCtrl) caption; ClosedCaptionCtrl captionCtrl = (ClosedCaptionCtrl) caption;
isRepeatableControl = captionBufferSize == 1 && captionCtrl.isRepeatable();
if (isRepeatableControl && repeatableControl != null
&& repeatableControl.cc1 == captionCtrl.cc1
&& repeatableControl.cc2 == captionCtrl.cc2) {
repeatableControl = null;
continue;
} else if (isRepeatableControl) {
repeatableControl = captionCtrl;
}
if (captionCtrl.isMiscCode()) { if (captionCtrl.isMiscCode()) {
handleMiscCode(captionCtrl); handleMiscCode(captionCtrl);
} else if (captionCtrl.isPreambleAddressCode()) { } else if (captionCtrl.isPreambleAddressCode()) {
...@@ -207,6 +219,9 @@ public final class Eia608TrackRenderer extends SampleSourceTrackRenderer impleme ...@@ -207,6 +219,9 @@ public final class Eia608TrackRenderer extends SampleSourceTrackRenderer impleme
} }
} }
if (!isRepeatableControl) {
repeatableControl = null;
}
if (captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_PAINT_ON) { if (captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_PAINT_ON) {
caption = getDisplayCaption(); caption = getDisplayCaption();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment