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:
Ralph Giles 2012-05-22 20:21:46 -04:00
Родитель 71d9800c0d
Коммит 9038c5e7f0
1 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -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));
}