Commit 92f085bc by Oliver Woodman

Remove intermediate copy steps in TsExtractor.

1. AdtsReader would previously copy all data through an intermediate
adtsBuffer. This change eliminates the additional copy step, and
instead copies directly into Sample objects.

2. PesReader would previously accumulate a whole packet by copying
multiple TS packets into an intermediate buffer. This change
eliminates this copy step. After the change, TS packet buffers
are propagated directly to PesPayloadReaders, which are required
to handle partial payload data correctly. The copy steps in the
extractor are simplified from:

DataSource->Ts_BitArray->Pes_BitArray->Sample->SampleHolder

To:

DataSource->Ts_BitArray->Sample->SampleHolder

Issue: #278
parent 797fa7f8
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package com.google.android.exoplayer.util; package com.google.android.exoplayer.util;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Arrays;
/** /**
* Wraps a byte array, providing a set of methods for parsing data from it. Numerical values are * Wraps a byte array, providing a set of methods for parsing data from it. Numerical values are
...@@ -69,39 +68,27 @@ public final class ParsableByteArray { ...@@ -69,39 +68,27 @@ public final class ParsableByteArray {
limit = 0; limit = 0;
} }
// TODO: This method is temporary
public void append(ParsableByteArray buffer, int length) {
if (data == null) {
data = new byte[length];
} else if (data.length < limit + length) {
data = Arrays.copyOf(data, limit + length);
}
buffer.readBytes(data, limit, length);
limit += length;
}
// TODO: This method is temporary
public void clearReadData() {
System.arraycopy(data, position, data, 0, limit - position);
limit -= position;
position = 0;
}
// TODO: This method is temporary
public boolean isEmpty() {
return limit == 0;
}
/** Returns the number of bytes yet to be read. */ /** Returns the number of bytes yet to be read. */
public int bytesLeft() { public int bytesLeft() {
return limit - position; return limit - position;
} }
/** Returns the number of bytes in the array. */ /** Returns the number of bytes in the array. */
// TODO: Rename to limit.
public int length() { public int length() {
return limit; return limit;
} }
/**
* Sets the limit.
*
* @param limit The limit to set.
*/
public void setLimit(int limit) {
Assertions.checkArgument(limit >= 0 && limit <= data.length);
this.limit = limit;
}
/** Returns the current offset in the array, in bytes. */ /** Returns the current offset in the array, in bytes. */
public int getPosition() { public int getPosition() {
return position; return position;
......
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