mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Fixed CEA-708 issues
Caption characters weren't being assigned to the correct window and the lack of pen location support was causing multiple lines (and words) to be concatenated. As per the CEA-708-B specification, section 8.10.5, when we encounter a DefineWindow command, we're also supposed to update the current window to the newly defined one. We were not doing this previously, resulting in text that should have been in separate windows being combined into one. Furthermore, some content uses the SetPenLocation command to move the cursor down a line instead of appending a new line. As we don't currently support SetPenLocation, this resulted in multiple lines (and words) being concatenated together, potentially causing the text to extend past the edge of the window/screen. This change implements a workaround (until SetPenLocation is properly supported) for this issue in which setting the pen location to a new row will append a new-line to that window. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=149679613
This commit is contained in:
parent
b84c84cc76
commit
0cb9802e1b
1 changed files with 17 additions and 1 deletions
|
|
@ -470,6 +470,11 @@ public final class Cea708Decoder extends CeaDecoder {
|
|||
case COMMAND_DF7:
|
||||
window = (command - COMMAND_DF0);
|
||||
handleDefineWindow(window);
|
||||
// We also set the current window to the newly defined window.
|
||||
if (currentWindow != window) {
|
||||
currentWindow = window;
|
||||
currentCueBuilder = cueBuilders[window];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Log.w(TAG, "Invalid C1 command: " + command);
|
||||
|
|
@ -871,6 +876,7 @@ public final class Cea708Decoder extends CeaDecoder {
|
|||
private int foregroundColor;
|
||||
private int backgroundColorStartPosition;
|
||||
private int backgroundColor;
|
||||
private int row;
|
||||
|
||||
public CueBuilder() {
|
||||
rolledUpCaptions = new LinkedList<>();
|
||||
|
|
@ -910,6 +916,7 @@ public final class Cea708Decoder extends CeaDecoder {
|
|||
underlineStartPosition = C.POSITION_UNSET;
|
||||
foregroundColorStartPosition = C.POSITION_UNSET;
|
||||
backgroundColorStartPosition = C.POSITION_UNSET;
|
||||
row = 0;
|
||||
}
|
||||
|
||||
public boolean isDefined() {
|
||||
|
|
@ -1044,7 +1051,16 @@ public final class Cea708Decoder extends CeaDecoder {
|
|||
}
|
||||
|
||||
public void setPenLocation(int row, int column) {
|
||||
// TODO: Support moving the pen location with a window.
|
||||
// TODO: Support moving the pen location with a window properly.
|
||||
|
||||
// Until we support proper pen locations, if we encounter a row that's different from the
|
||||
// previous one, we should append a new line. Otherwise, we'll see strings that should be
|
||||
// on new lines concatenated with the previous, resulting in 2 words being combined, as
|
||||
// well as potentially drawing beyond the width of the window/screen.
|
||||
if (this.row != row) {
|
||||
append('\n');
|
||||
}
|
||||
this.row = row;
|
||||
}
|
||||
|
||||
public void backspace() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue