mirror of
https://github.com/androidx/media.git
synced 2025-05-05 06:30:24 +08:00
Fix alignment in track scanner
This commit is contained in:
parent
ec26539aeb
commit
167c2f3fc0
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user