Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CEA-708 Decoder fixes for issue #1807 (Refactoring the PR #8356) #8415

Merged
merged 1 commit into from
Jan 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public final class Cea708Decoder extends CeaDecoder {

private final ParsableByteArray ccData;
private final ParsableBitArray serviceBlockPacket;
private int lastSequenceNo = -1;
// TODO: Use isWideAspectRatio in decoding.
@SuppressWarnings({"unused", "FieldCanBeLocal"})
private final boolean isWideAspectRatio;
Expand Down Expand Up @@ -231,6 +232,13 @@ protected void decode(SubtitleInputBuffer inputBuffer) {
finalizeCurrentPacket();

int sequenceNumber = (ccData1 & 0xC0) >> 6; // first 2 bits
if (lastSequenceNo != -1 && sequenceNumber != (lastSequenceNo + 1) % 4) {
resetCueBuilders();
Log.w(TAG, "discontinuity in sequence number detected : lastSequenceNo = " +
lastSequenceNo + " sequenceNumber = " + sequenceNumber);
}
lastSequenceNo = sequenceNumber;

int packetSize = ccData1 & 0x3F; // last 6 bits
if (packetSize == 0) {
packetSize = 64;
Expand Down Expand Up @@ -270,10 +278,11 @@ private void finalizeCurrentPacket() {
@RequiresNonNull("currentDtvCcPacket")
private void processCurrentPacket() {
if (currentDtvCcPacket.currentIndex != (currentDtvCcPacket.packetSize * 2 - 1)) {
Log.w(TAG, "DtvCcPacket ended prematurely; size is " + (currentDtvCcPacket.packetSize * 2 - 1)
Log.d(TAG, "DtvCcPacket ended prematurely; size is " + (currentDtvCcPacket.packetSize * 2 - 1)
+ ", but current index is " + currentDtvCcPacket.currentIndex + " (sequence number "
+ currentDtvCcPacket.sequenceNumber + "); ignoring packet");
return;
+ currentDtvCcPacket.sequenceNumber + ");");
// This is not invalid packet. As per CEA-708 section 4.4.1.1, the Packect end can happen
// when the reception of cc_type = 0x03 (binary 11).
sneelavara marked this conversation as resolved.
Show resolved Hide resolved
}

serviceBlockPacket.reset(currentDtvCcPacket.packetData, currentDtvCcPacket.currentIndex);
Expand Down