当前位置: 首页>>代码示例>>C++>>正文


C++ SjByteVector::toUInt方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:antonivich,项目名称:Silverjuke,代码行数:101,代码来源:tg_mpeg_header.cpp

示例2:

static unsigned int get_le32(WMA_File *f)
{
	SjByteVector bv = f->ReadBlock(4);
	return bv.toUInt(false);
}
开发者ID:boh1996,项目名称:silverjuke,代码行数:5,代码来源:tg_wma_file_asf.cpp


注:本文中的SjByteVector::toUInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。