本文整理汇总了C++中SjByteVector::toUInt方法的典型用法代码示例。如果您正苦于以下问题:C++ SjByteVector::toUInt方法的具体用法?C++ SjByteVector::toUInt怎么用?C++ SjByteVector::toUInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SjByteVector
的用法示例。
在下文中一共展示了SjByteVector::toUInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
void MPEG_Header::parse(const SjByteVector &data)
{
// see http://www.mp3-tech.org/programmer/frame_header.html
m_isValid = false;
m_version = MPEG_Version1;
m_layer = 0;
m_protectionEnabled = false;
m_sampleRate = 0;
m_isPadded = false;
m_channelMode = MPEG_Stereo;
m_isCopyrighted = false;
m_isOriginal = false;
m_emphasis = 0;
m_frameLength = 0;
// check for the size and for the first synch byte
if(data.size() < 4 || (unsigned char)(data[0]) != 0xff)
{
wxLogDebug(wxT("MPEG::Header::parse() -- First byte did not mactch MPEG synch."));
return;
}
unsigned long flags = data.toUInt();
// Check for the second byte's part of the MPEG synch
if( !(flags&(1<<23)) || !(flags&(1<<22)) || !(flags&(1<<21)) )
{
wxLogDebug(wxT("MPEG::Header::parse() -- Second byte did not mactch MPEG synch."));
return;
}
// Set the MPEG version
if( !(flags&(1<<20)) && !(flags&(1<<19)) )
{
m_version = MPEG_Version2_5;
}
else if( (flags&(1<<20)) && !(flags&(1<<19)) )
{
m_version = MPEG_Version2;
}
else if( (flags&(1<<20)) && (flags&(1<<19)) )
{
m_version = MPEG_Version1;
}
// Set the MPEG layer
if( !(flags&(1<<18)) && (flags&(1<<17)) )
{
m_layer = 3;
}
else if( (flags&(1<<18)) && !(flags&(1<<17)) )
{
m_layer = 2;
}
else if( (flags&(1<<18)) && (flags&(1<<17)) )
{
m_layer = 1;
}
// set protection flags
m_protectionEnabled = !(flags&(1<<16));
// Set the bitrate
static const int bitrates[2][3][16] =
{
{ // Version 1
{ 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0 }, // layer 1
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0 }, // layer 2
{ 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0 } // layer 3
},
{ // Version 2 or 2.5
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0 }, // layer 1
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, // layer 2
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 } // layer 3
}
};
const int versionIndex = m_version == MPEG_Version1 ? 0 : 1;
const int layerIndex = m_layer > 0 ? m_layer - 1 : 0;
// The bitrate index is encoded as the first 4 bits of the 3rd byte,
// i.e. 1111xxxx
int i = (unsigned char)(data[2]) >> 4;
m_bitrate = bitrates[versionIndex][layerIndex][i];
// Set the sample rate
static const int sampleRates[3][4] =
{
{ 44100, 48000, 32000, 0 }, // Version 1
//.........这里部分代码省略.........
示例2:
static unsigned int get_le32(WMA_File *f)
{
SjByteVector bv = f->ReadBlock(4);
return bv.toUInt(false);
}