mirror of
https://github.com/samsonjs/media.git
synced 2026-04-09 11:55:46 +00:00
Ignore repeated control characters in EIA608 subtitles.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=117220536
This commit is contained in:
parent
a1c74cb259
commit
16f57e3919
2 changed files with 19 additions and 0 deletions
|
|
@ -94,4 +94,8 @@ package com.google.android.exoplayer.text.eia608;
|
|||
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
|
|||
private int captionRowCount;
|
||||
private String caption;
|
||||
private String lastRenderedCaption;
|
||||
private ClosedCaptionCtrl repeatableControl;
|
||||
|
||||
/**
|
||||
* @param textRenderer The text renderer.
|
||||
|
|
@ -94,6 +95,7 @@ public final class Eia608TrackRenderer extends SampleSourceTrackRenderer impleme
|
|||
@Override
|
||||
protected void onReset(long positionUs) {
|
||||
inputStreamEnded = false;
|
||||
repeatableControl = null;
|
||||
pendingCaptionLists.clear();
|
||||
clearPendingSample();
|
||||
captionRowCount = DEFAULT_CAPTIONS_ROW_COUNT;
|
||||
|
|
@ -193,10 +195,20 @@ public final class Eia608TrackRenderer extends SampleSourceTrackRenderer impleme
|
|||
return;
|
||||
}
|
||||
|
||||
boolean isRepeatableControl = false;
|
||||
for (int i = 0; i < captionBufferSize; i++) {
|
||||
ClosedCaption caption = captionList.captions[i];
|
||||
if (caption.type == ClosedCaption.TYPE_CTRL) {
|
||||
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()) {
|
||||
handleMiscCode(captionCtrl);
|
||||
} else if (captionCtrl.isPreambleAddressCode()) {
|
||||
|
|
@ -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) {
|
||||
caption = getDisplayCaption();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue