Fix mp3 extraction failure for short frames
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=134660133
This commit is contained in:
parent
040fe3b194
commit
8bf0243daf
@ -272,14 +272,17 @@ public final class Mp3Extractor implements Extractor {
|
|||||||
|
|
||||||
long position = input.getPosition();
|
long position = input.getPosition();
|
||||||
long length = input.getLength();
|
long length = input.getLength();
|
||||||
|
int headerData = 0;
|
||||||
|
Seeker seeker = null;
|
||||||
|
|
||||||
// Check if there is a Xing header.
|
// Check if there is a Xing header.
|
||||||
int xingBase = (synchronizedHeader.version & 1) != 0
|
int xingBase = (synchronizedHeader.version & 1) != 0
|
||||||
? (synchronizedHeader.channels != 1 ? 36 : 21) // MPEG 1
|
? (synchronizedHeader.channels != 1 ? 36 : 21) // MPEG 1
|
||||||
: (synchronizedHeader.channels != 1 ? 21 : 13); // MPEG 2 or 2.5
|
: (synchronizedHeader.channels != 1 ? 21 : 13); // MPEG 2 or 2.5
|
||||||
|
if (frame.limit() >= xingBase + 4) {
|
||||||
frame.setPosition(xingBase);
|
frame.setPosition(xingBase);
|
||||||
int headerData = frame.readInt();
|
headerData = frame.readInt();
|
||||||
Seeker seeker = null;
|
}
|
||||||
if (headerData == XING_HEADER || headerData == INFO_HEADER) {
|
if (headerData == XING_HEADER || headerData == INFO_HEADER) {
|
||||||
seeker = XingSeeker.create(synchronizedHeader, frame, position, length);
|
seeker = XingSeeker.create(synchronizedHeader, frame, position, length);
|
||||||
if (seeker != null && !gaplessInfoHolder.hasGaplessInfo()) {
|
if (seeker != null && !gaplessInfoHolder.hasGaplessInfo()) {
|
||||||
@ -291,7 +294,7 @@ public final class Mp3Extractor implements Extractor {
|
|||||||
gaplessInfoHolder.setFromXingHeaderValue(scratch.readUnsignedInt24());
|
gaplessInfoHolder.setFromXingHeaderValue(scratch.readUnsignedInt24());
|
||||||
}
|
}
|
||||||
input.skipFully(synchronizedHeader.frameSize);
|
input.skipFully(synchronizedHeader.frameSize);
|
||||||
} else {
|
} else if (frame.limit() >= 40) {
|
||||||
// Check if there is a VBRI header.
|
// Check if there is a VBRI header.
|
||||||
frame.setPosition(36); // MPEG audio header (4 bytes) + 32 bytes.
|
frame.setPosition(36); // MPEG audio header (4 bytes) + 32 bytes.
|
||||||
headerData = frame.readInt();
|
headerData = frame.readInt();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user