mirror of
https://github.com/androidx/media.git
synced 2025-05-04 22:20:47 +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
|
//If partial read
|
||||||
private transient AviTrack chunkHandler;
|
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() {
|
public AviExtractor() {
|
||||||
this(0);
|
this(0);
|
||||||
}
|
}
|
||||||
@ -406,11 +414,7 @@ public class AviExtractor implements Extractor {
|
|||||||
} else {
|
} else {
|
||||||
ByteBuffer byteBuffer = allocate(8);
|
ByteBuffer byteBuffer = allocate(8);
|
||||||
final byte[] bytes = byteBuffer.array();
|
final byte[] bytes = byteBuffer.array();
|
||||||
// This isn't documented anywhere, but most files are aligned to even bytes
|
alignInput(input);
|
||||||
// and can have gaps of zeros
|
|
||||||
if ((input.getPosition() & 1) == 1) {
|
|
||||||
input.skipFully(1);
|
|
||||||
}
|
|
||||||
input.readFully(bytes, 0, 1);
|
input.readFully(bytes, 0, 1);
|
||||||
while (bytes[0] == 0) {
|
while (bytes[0] == 0) {
|
||||||
input.readFully(bytes, 0, 1);
|
input.readFully(bytes, 0, 1);
|
||||||
|
@ -60,7 +60,7 @@ public class ListBox extends Box {
|
|||||||
byte [] bytes = headerBuffer.array();
|
byte [] bytes = headerBuffer.array();
|
||||||
input.readFully(bytes, 0, 4);
|
input.readFully(bytes, 0, 4);
|
||||||
final int listType = headerBuffer.getInt();
|
final int listType = headerBuffer.getInt();
|
||||||
|
//String listTypeName = AviExtractor.toString(listType);
|
||||||
long endPos = input.getPosition() + listSize - 4;
|
long endPos = input.getPosition() + listSize - 4;
|
||||||
while (input.getPosition() + 8 < endPos) {
|
while (input.getPosition() + 8 < endPos) {
|
||||||
headerBuffer.clear();
|
headerBuffer.clear();
|
||||||
@ -73,7 +73,7 @@ public class ListBox extends Box {
|
|||||||
} else {
|
} else {
|
||||||
box = boxFactory.createBox(type, size, input);
|
box = boxFactory.createBox(type, size, input);
|
||||||
}
|
}
|
||||||
|
AviExtractor.alignInput(input);
|
||||||
if (box != null) {
|
if (box != null) {
|
||||||
list.add(box);
|
list.add(box);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user