Commit 26ea43d2 by kim-vde

Merge pull request #8415 from TiVo:p-fix-cea708anchor

PiperOrigin-RevId: 352783091
parents 2d3e6d4d b534097d
...@@ -217,6 +217,10 @@ ...@@ -217,6 +217,10 @@
containers. containers.
* Fix CEA-708 anchor positioning * Fix CEA-708 anchor positioning
([#1807](https://github.com/google/ExoPlayer/issues/1807)). ([#1807](https://github.com/google/ExoPlayer/issues/1807)).
* Fix CEA-708 sequence number discontinuity handling
([#1807](https://github.com/google/ExoPlayer/issues/1807)).
* Fix CEA-708 handling of unexpectedly small packets
([#1807](https://github.com/google/ExoPlayer/issues/1807)).
* Data sources: * Data sources:
* Use the user agent of the underlying network stack by default. * Use the user agent of the underlying network stack by default.
* Metadata retriever: * Metadata retriever:
......
...@@ -145,6 +145,7 @@ public final class Cea708Decoder extends CeaDecoder { ...@@ -145,6 +145,7 @@ public final class Cea708Decoder extends CeaDecoder {
private final ParsableByteArray ccData; private final ParsableByteArray ccData;
private final ParsableBitArray serviceBlockPacket; private final ParsableBitArray serviceBlockPacket;
private int previousSequenceNumber;
// TODO: Use isWideAspectRatio in decoding. // TODO: Use isWideAspectRatio in decoding.
@SuppressWarnings({"unused", "FieldCanBeLocal"}) @SuppressWarnings({"unused", "FieldCanBeLocal"})
private final boolean isWideAspectRatio; private final boolean isWideAspectRatio;
...@@ -162,6 +163,7 @@ public final class Cea708Decoder extends CeaDecoder { ...@@ -162,6 +163,7 @@ public final class Cea708Decoder extends CeaDecoder {
public Cea708Decoder(int accessibilityChannel, @Nullable List<byte[]> initializationData) { public Cea708Decoder(int accessibilityChannel, @Nullable List<byte[]> initializationData) {
ccData = new ParsableByteArray(); ccData = new ParsableByteArray();
serviceBlockPacket = new ParsableBitArray(); serviceBlockPacket = new ParsableBitArray();
previousSequenceNumber = C.INDEX_UNSET;
selectedServiceNumber = accessibilityChannel == Format.NO_VALUE ? 1 : accessibilityChannel; selectedServiceNumber = accessibilityChannel == Format.NO_VALUE ? 1 : accessibilityChannel;
isWideAspectRatio = isWideAspectRatio =
initializationData != null initializationData != null
...@@ -231,6 +233,18 @@ public final class Cea708Decoder extends CeaDecoder { ...@@ -231,6 +233,18 @@ public final class Cea708Decoder extends CeaDecoder {
finalizeCurrentPacket(); finalizeCurrentPacket();
int sequenceNumber = (ccData1 & 0xC0) >> 6; // first 2 bits int sequenceNumber = (ccData1 & 0xC0) >> 6; // first 2 bits
if (previousSequenceNumber != C.INDEX_UNSET
&& sequenceNumber != (previousSequenceNumber + 1) % 4) {
resetCueBuilders();
Log.w(
TAG,
"Sequence number discontinuity. previous="
+ previousSequenceNumber
+ " current="
+ sequenceNumber);
}
previousSequenceNumber = sequenceNumber;
int packetSize = ccData1 & 0x3F; // last 6 bits int packetSize = ccData1 & 0x3F; // last 6 bits
if (packetSize == 0) { if (packetSize == 0) {
packetSize = 64; packetSize = 64;
...@@ -270,10 +284,18 @@ public final class Cea708Decoder extends CeaDecoder { ...@@ -270,10 +284,18 @@ public final class Cea708Decoder extends CeaDecoder {
@RequiresNonNull("currentDtvCcPacket") @RequiresNonNull("currentDtvCcPacket")
private void processCurrentPacket() { private void processCurrentPacket() {
if (currentDtvCcPacket.currentIndex != (currentDtvCcPacket.packetSize * 2 - 1)) { if (currentDtvCcPacket.currentIndex != (currentDtvCcPacket.packetSize * 2 - 1)) {
Log.w(TAG, "DtvCcPacket ended prematurely; size is " + (currentDtvCcPacket.packetSize * 2 - 1) Log.d(
+ ", but current index is " + currentDtvCcPacket.currentIndex + " (sequence number " TAG,
+ currentDtvCcPacket.sequenceNumber + "); ignoring packet"); "DtvCcPacket ended prematurely; size is "
return; + (currentDtvCcPacket.packetSize * 2 - 1)
+ ", but current index is "
+ currentDtvCcPacket.currentIndex
+ " (sequence number "
+ currentDtvCcPacket.sequenceNumber
+ ");");
// We've received cc_type=0x03 (packet start) before receiving packetSize byte pairs of data.
// This might indicate a byte pair has been lost, but we'll still attempt to process the data
// we have received.
} }
serviceBlockPacket.reset(currentDtvCcPacket.packetData, currentDtvCcPacket.currentIndex); serviceBlockPacket.reset(currentDtvCcPacket.packetData, currentDtvCcPacket.currentIndex);
......
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