Commit 0cb9802e by cdrolle Committed by Oliver Woodman

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
parent b84c84cc
...@@ -470,6 +470,11 @@ public final class Cea708Decoder extends CeaDecoder { ...@@ -470,6 +470,11 @@ public final class Cea708Decoder extends CeaDecoder {
case COMMAND_DF7: case COMMAND_DF7:
window = (command - COMMAND_DF0); window = (command - COMMAND_DF0);
handleDefineWindow(window); handleDefineWindow(window);
// We also set the current window to the newly defined window.
if (currentWindow != window) {
currentWindow = window;
currentCueBuilder = cueBuilders[window];
}
break; break;
default: default:
Log.w(TAG, "Invalid C1 command: " + command); Log.w(TAG, "Invalid C1 command: " + command);
...@@ -871,6 +876,7 @@ public final class Cea708Decoder extends CeaDecoder { ...@@ -871,6 +876,7 @@ public final class Cea708Decoder extends CeaDecoder {
private int foregroundColor; private int foregroundColor;
private int backgroundColorStartPosition; private int backgroundColorStartPosition;
private int backgroundColor; private int backgroundColor;
private int row;
public CueBuilder() { public CueBuilder() {
rolledUpCaptions = new LinkedList<>(); rolledUpCaptions = new LinkedList<>();
...@@ -910,6 +916,7 @@ public final class Cea708Decoder extends CeaDecoder { ...@@ -910,6 +916,7 @@ public final class Cea708Decoder extends CeaDecoder {
underlineStartPosition = C.POSITION_UNSET; underlineStartPosition = C.POSITION_UNSET;
foregroundColorStartPosition = C.POSITION_UNSET; foregroundColorStartPosition = C.POSITION_UNSET;
backgroundColorStartPosition = C.POSITION_UNSET; backgroundColorStartPosition = C.POSITION_UNSET;
row = 0;
} }
public boolean isDefined() { public boolean isDefined() {
...@@ -1044,7 +1051,16 @@ public final class Cea708Decoder extends CeaDecoder { ...@@ -1044,7 +1051,16 @@ public final class Cea708Decoder extends CeaDecoder {
} }
public void setPenLocation(int row, int column) { 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() { public void backspace() {
......
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