зеркало из https://github.com/mozilla/pjs.git
Bug 757600 - Update the Opus version field parser. r=cpearce
On 2012 May 10, the Ogg encapsulation spec for Opus at https://wiki.xiph.org/OggOpus bumped the version number from zero to one. The one-byte field is also now notionally split into major and minor subfields, with incompatible changes signalled by the major field. We update nsOpusState::DecodeHeader to parse the version field separately from the stream identification and reject any stream where the high four bits of the version field is non-zero. The opus-tools repo was updated 2012 May 22 to set with version = 1. This commit enables playback of those files.
This commit is contained in:
Родитель
276989e5c1
Коммит
20b75a4654
|
@ -818,7 +818,7 @@ bool nsOpusState::DecodeHeader(ogg_packet* aPacket)
|
|||
}
|
||||
|
||||
// Otherwise, parse as the id header.
|
||||
if (aPacket->bytes < 19 || memcmp(aPacket->packet, "OpusHead\0", 9)) {
|
||||
if (aPacket->bytes < 19 || memcmp(aPacket->packet, "OpusHead", 8)) {
|
||||
LOG(PR_LOG_DEBUG, ("Invalid Opus file: unrecognized header"));
|
||||
mActive = false;
|
||||
return true;
|
||||
|
@ -826,6 +826,14 @@ bool nsOpusState::DecodeHeader(ogg_packet* aPacket)
|
|||
|
||||
mRate = 48000; // The Opus decoder runs at 48 kHz regardless.
|
||||
|
||||
int version = aPacket->packet[8];
|
||||
// Accept file format versions 0.x.
|
||||
if ((version & 0xf0) != 0) {
|
||||
LOG(PR_LOG_DEBUG, ("Rejecting unknown Opus file version %d", version));
|
||||
mActive = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
mChannels= aPacket->packet[9];
|
||||
mPreSkip = LEUint16(aPacket->packet + 10);
|
||||
mNominalRate = LEUint32(aPacket->packet + 12);
|
||||
|
@ -860,7 +868,7 @@ PRInt64 nsOpusState::Time(PRInt64 granulepos)
|
|||
bool nsOpusState::IsHeader(ogg_packet* aPacket)
|
||||
{
|
||||
return aPacket->bytes >= 16 &&
|
||||
(!memcmp(aPacket->packet, "OpusHead\0", 9) ||
|
||||
(!memcmp(aPacket->packet, "OpusHead", 8) ||
|
||||
!memcmp(aPacket->packet, "OpusTags", 8));
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче