Commit 167c2f3f by Dustin

Fix alignment in track scanner

parent ec26539a
......@@ -84,6 +84,14 @@ public class AviExtractor implements Extractor {
//If partial read
private transient AviTrack chunkHandler;
static void alignInput(ExtractorInput input) throws IOException {
// This isn't documented anywhere, but most files are aligned to even bytes
// and can have gaps of zeros
if ((input.getPosition() & 1) == 1) {
input.skipFully(1);
}
}
public AviExtractor() {
this(0);
}
......@@ -406,11 +414,7 @@ public class AviExtractor implements Extractor {
} else {
ByteBuffer byteBuffer = allocate(8);
final byte[] bytes = byteBuffer.array();
// This isn't documented anywhere, but most files are aligned to even bytes
// and can have gaps of zeros
if ((input.getPosition() & 1) == 1) {
input.skipFully(1);
}
alignInput(input);
input.readFully(bytes, 0, 1);
while (bytes[0] == 0) {
input.readFully(bytes, 0, 1);
......
......@@ -60,7 +60,7 @@ public class ListBox extends Box {
byte [] bytes = headerBuffer.array();
input.readFully(bytes, 0, 4);
final int listType = headerBuffer.getInt();
//String listTypeName = AviExtractor.toString(listType);
long endPos = input.getPosition() + listSize - 4;
while (input.getPosition() + 8 < endPos) {
headerBuffer.clear();
......@@ -73,7 +73,7 @@ public class ListBox extends Box {
} else {
box = boxFactory.createBox(type, size, input);
}
AviExtractor.alignInput(input);
if (box != null) {
list.add(box);
}
......
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