mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
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:
parent
197ac505a3
commit
a580b38664
@ -818,7 +818,7 @@ bool nsOpusState::DecodeHeader(ogg_packet* aPacket)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, parse as the id header.
|
// 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"));
|
LOG(PR_LOG_DEBUG, ("Invalid Opus file: unrecognized header"));
|
||||||
mActive = false;
|
mActive = false;
|
||||||
return true;
|
return true;
|
||||||
@ -826,6 +826,14 @@ bool nsOpusState::DecodeHeader(ogg_packet* aPacket)
|
|||||||
|
|
||||||
mRate = 48000; // The Opus decoder runs at 48 kHz regardless.
|
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];
|
mChannels= aPacket->packet[9];
|
||||||
mPreSkip = LEUint16(aPacket->packet + 10);
|
mPreSkip = LEUint16(aPacket->packet + 10);
|
||||||
mNominalRate = LEUint32(aPacket->packet + 12);
|
mNominalRate = LEUint32(aPacket->packet + 12);
|
||||||
@ -860,7 +868,7 @@ PRInt64 nsOpusState::Time(PRInt64 granulepos)
|
|||||||
bool nsOpusState::IsHeader(ogg_packet* aPacket)
|
bool nsOpusState::IsHeader(ogg_packet* aPacket)
|
||||||
{
|
{
|
||||||
return aPacket->bytes >= 16 &&
|
return aPacket->bytes >= 16 &&
|
||||||
(!memcmp(aPacket->packet, "OpusHead\0", 9) ||
|
(!memcmp(aPacket->packet, "OpusHead", 8) ||
|
||||||
!memcmp(aPacket->packet, "OpusTags", 8));
|
!memcmp(aPacket->packet, "OpusTags", 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user