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


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

本文整理汇总了C++中SjByteVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ SjByteVector::size方法的具体用法?C++ SjByteVector::size怎么用?C++ SjByteVector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SjByteVector的用法示例。


在下文中一共展示了SjByteVector::size方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: previousFrameOffset

long MPEG_File::previousFrameOffset(long position)
{
	// TODO: This will miss syncs spanning buffer read boundaries.

	while(int(position - BufferSize()) > int(BufferSize()))
	{
		position -= BufferSize();
		Seek(position);
		SjByteVector buffer = ReadBlock(BufferSize());

		// If the amount of data is smaller than an MPEG header (4 bytes) there's no
		// chance of this being valid.

		if(buffer.size() < 4)
		{
			return -1;
		}

		for(int i = buffer.size() - 2; i >= 0; i--)
		{
			if((unsigned char)(buffer[i]) == 0xff && secondSynchByte(buffer[i + 1]))
			{
				return position + i;
			}
		}
	}

	return -1;
}
开发者ID:boh1996,项目名称:silverjuke,代码行数:29,代码来源:tg_mpeg_file.cpp

示例2:

void ID3v2_PopularimeterFrame::parseFields(const SjByteVector& data)
{
	m_email.Empty();
	m_rating255 = 0;
	m_counter = 0;

	int offset, pos = 0, size = (int)data.size();
	offset = data.find(textDelimiter(SJ_LATIN1), pos);
	if( offset < pos ) {
		return;
	}

	m_email = data.mid(pos, offset - pos).toString(SJ_LATIN1);
	pos = offset + 1;

	if(pos < size)
	{
		m_rating255 = (int)(data[pos]);
		pos++;

		if(pos < size)
		{
			m_counter = data.mid(pos, 4).toUInt();
		}
	}
}
开发者ID:boh1996,项目名称:silverjuke,代码行数:26,代码来源:tg_id3v2_knownframes.cpp

示例3: renderFields

SjByteVector ID3v2_Frame::render() const
{
	SjByteVector fieldData = renderFields();
	m_header->setFrameSize(fieldData.size());
	SjByteVector headerData = m_header->render();

	return headerData + fieldData;
}
开发者ID:antonivich,项目名称:Silverjuke,代码行数:8,代码来源:tg_id3v2_frame.cpp

示例4: char

SjByteVector ID3v2_Tag::render()
{
	// We need to render the "tag data" first so that we have to correct size to
	// render in the tag's header.  The "tag data" -- everything that is included
	// in ID3v2::Header::tagSize() -- includes the extended header, frames and
	// padding, but does not include the tag's header or footer.

	SjByteVector tagData;

	// TODO: Render the extended header.

	// Loop through the frames rendering them and adding them to the tagData.

	//for(FrameList::Iterator it = d->frameList.begin(); it != d->frameList.end(); it++)
	for ( ID3v2_FrameList::Node *node = m_frameList.GetFirst(); node; node = node->GetNext() )
	{
		ID3v2_Frame* it = node->GetData();
		if(!it->header()->tagAlterPreservation())
			tagData.append(it->render());
	}

	// Compute the amount of padding, and append that to tagData.

	SjUint paddingSize = 0;
	SjUint originalSize = m_header.tagSize();

	if(tagData.size() < originalSize)
		paddingSize = originalSize - tagData.size();
	else
		paddingSize = 1024;

	tagData.append(SjByteVector(paddingSize, char(0)));

	// Set the tag size.
	m_header.setTagSize(tagData.size());

	// TODO: This should eventually include d->footer->render().
	return m_header.render() + tagData;
}
开发者ID:antonivich,项目名称:Silverjuke,代码行数:39,代码来源:tg_id3v2_tag.cpp

示例5: nextFrameOffset

long MPEG_File::nextFrameOffset(long position)
{
	// TODO: This will miss syncs spanning buffer read boundaries.

	SjByteVector buffer = ReadBlock(BufferSize());

	while(buffer.size() > 0)
	{
		Seek(position);
		SjByteVector buffer = ReadBlock(BufferSize());

		for(SjUint i = 0; i < buffer.size(); i++)
		{
			if((unsigned char)(buffer[i]) == 0xff && secondSynchByte(buffer[i + 1]))
			{
				return position + i;
			}
		}
		position += BufferSize();
	}

	return -1;
}
开发者ID:boh1996,项目名称:silverjuke,代码行数:23,代码来源:tg_mpeg_file.cpp

示例6: parse

void APE_Tag::parse(const SjByteVector &data)
{
	SjUint pos = 0;

	// 11 bytes is the minimum size for an APE item
	for(SjUint i = 0; i < m_footer.itemCount() && pos <= data.size() - 11; i++)
	{
		APE_Item item;
		item.parse(data.mid(pos));

		setItem(item.key().Upper(), item);

		pos += item.size();
	}
}
开发者ID:boh1996,项目名称:silverjuke,代码行数:15,代码来源:tg_ape_tag.cpp

示例7: render

SjByteVector APE_Tag::render() const
{
	SjByteVector data;
	SjUint itemCount = 0;

	{
		SjHashIterator iterator;
		APE_Item* item;
		wxString key;
		while( (item=(APE_Item*)m_itemListMap.Iterate(iterator, key)) )
		{
			data.append(item->render());
			itemCount++;
		}
	}

	m_footer.setItemCount(itemCount);
	m_footer.setTagSize(data.size()+APE_FOOTER_SIZE);
	m_footer.setHeaderPresent(true);

	return m_footer.renderHeader() + data + m_footer.renderFooter();
}
开发者ID:boh1996,项目名称:silverjuke,代码行数:22,代码来源:tg_ape_tag.cpp

示例8: String

void ID3v2_CommentsFrame::parseFields(const SjByteVector &data)
{
	if(data.size() < 5) {
		wxLogDebug(wxT("A comment frame must contain at least 5 bytes."));
		return;
	}

	m_textEncoding = (SjStringType)(data[0]);
	m_language = data.mid(1, 3);

	int byteAlign = (m_textEncoding == SJ_LATIN1 || m_textEncoding == SJ_UTF8) ? 1 : 2;

	//ByteVectorList l = ByteVectorList::split(data.mid(4), textDelimiter(d->textEncoding), byteAlign, 2);
	SjArrayByteVector l = data.mid(4).splitToArray(textDelimiter(m_textEncoding), byteAlign, 2);

	if(l.GetCount() == 2) {
		/*d->description = String(l.front(), d->textEncoding);
		d->text = String(l.back(), d->textEncoding);
		*/
		m_description = l.Item(0).toString(m_textEncoding);
		m_text = l.Item(1).toString(m_textEncoding);
	}
}
开发者ID:boh1996,项目名称:silverjuke,代码行数:23,代码来源:tg_id3v2_knownframes.cpp

示例9: BufferSize

long MPEG_File::findID3v2()
{
	// This method is based on the contents of Tagger_File::find(), but because
	// of some subtlteies -- specifically the need to look for the bit pattern of
	// an MPEG sync, it has been modified for use here.

	if( IsValid()
	        && ID3v2_Header::fileIdentifier().size() <= BufferSize() )
	{
		// The position in the file that the current buffer starts at.

		long bufferOffset = 0;
		SjByteVector buffer;

		// These variables are used to keep track of a partial match that happens at
		// the end of a buffer.

		int previousPartialMatch = -1;
		bool previousPartialSynchMatch = false;

		// Save the location of the current read pointer.  We will restore the
		// position using seek() before all returns.

		long originalPosition = Tell();

		// Start the search at the beginning of the file.

		Seek(0);

		// This loop is the crux of the find method.  There are three cases that we
		// want to account for:
		// (1) The previously searched buffer contained a partial match of the search
		// pattern and we want to see if the next one starts with the remainder of
		// that pattern.
		//
		// (2) The search pattern is wholly contained within the current buffer.
		//
		// (3) The current buffer ends with a partial match of the pattern.  We will
		// note this for use in the next itteration, where we will check for the rest
		// of the pattern.

		for(buffer = ReadBlock(BufferSize()); buffer.size() > 0; buffer = ReadBlock(BufferSize()))
		{

			// (1) previous partial match

			if(previousPartialSynchMatch && secondSynchByte(buffer[0]))
			{
				return -1;
			}

			if(previousPartialMatch >= 0 && int(BufferSize()) > previousPartialMatch)
			{
				const int patternOffset = (BufferSize() - previousPartialMatch);
				if(buffer.containsAt(ID3v2_Header::fileIdentifier(), 0, patternOffset))
				{
					Seek(originalPosition);
					return bufferOffset - BufferSize() + previousPartialMatch;
				}
			}

			// (2) pattern contained in current buffer

			long location = buffer.find(ID3v2_Header::fileIdentifier());
			if(location >= 0)
			{
				Seek(originalPosition);
				return bufferOffset + location;
			}

			int firstSynchByte = buffer.find(/*(char)*/((unsigned char)(255)));

			// Here we have to loop because there could be several of the first
			// (11111111) byte, and we want to check all such instances until we find
			// a full match (11111111 111) or hit the end of the buffer.

			while(firstSynchByte >= 0)
			{

				// if this *is not* at the end of the buffer

				if(firstSynchByte < int(buffer.size()) - 1)
				{
					if(secondSynchByte(buffer[firstSynchByte + 1]))
					{
						// We've found the frame synch pattern.
						Seek(originalPosition);
						return -1;
					}
					else
					{

						// We found 11111111 at the end of the current buffer indicating a
						// partial match of the synch pattern.  The find() below should
						// return -1 and break out of the loop.

						previousPartialSynchMatch = true;
					}
				}

//.........这里部分代码省略.........
开发者ID:boh1996,项目名称:silverjuke,代码行数:101,代码来源:tg_mpeg_file.cpp

示例10:

void ID3v2_Tag::parse(const SjByteVector &data)
{
	SjUint frameDataPosition = 0;
	SjUint frameDataLength = data.size();

	// check for extended header

	if(m_header.extendedHeader()) {
		if(!m_extendedHeader)
			m_extendedHeader = new ID3v2_ExtendedHeader;
		m_extendedHeader->setData(data);
		if(m_extendedHeader->size() <= data.size()) {
			frameDataPosition += m_extendedHeader->size();
			frameDataLength -= m_extendedHeader->size();
		}
	}

	// check for footer -- we don't actually need to parse it, as it *must*
	// contain the same data as the header, but we do need to account for its
	// size.

	if(m_header.footerPresent() && ID3v2_Footer::size() <= frameDataLength)
		frameDataLength -= ID3v2_Footer::size();

	// parse frames

	// Make sure that there is at least enough room in the remaining frame data for
	// a frame header.

	while(frameDataPosition < frameDataLength - ID3v2_Frame::headerSize(m_header.majorVersion())) {

		// If the next data is position is 0, assume that we've hit the padding
		// portion of the frame data.

		if(data.at(frameDataPosition) == 0) {
			if(m_header.footerPresent())
				wxLogDebug(wxT("Padding *and* a footer found.  This is not allowed by the spec."));

			m_paddingSize = frameDataLength - frameDataPosition;
			return;
		}

		ID3v2_Frame *frame = m_factory->createFrame(data.mid(frameDataPosition),
		                     m_header.majorVersion());

		if(!frame)
			return;

		// get the next frame position

		frameDataPosition += frame->size() + ID3v2_Frame::headerSize(m_header.majorVersion());

		// add the frame if it has a size of at least 1 byte (smaller frames are not allowed
		// by the specification, but they're returned from createFrame() to allow seeking to the
		// next frame).
		// modification by me

		if(frame->size() <= 0) {
			delete frame;
		}
		else {
			addFrame(frame);
		}
	}
}
开发者ID:antonivich,项目名称:Silverjuke,代码行数:65,代码来源:tg_id3v2_tag.cpp

示例11:

void ID3v2_FrameHeader::setData(const SjByteVector &data, SjUint version)
{
	// this was ID3v2_FrameHeaderPrivate
	m_isOkay = FALSE;
	m_frameSize = 0;
	m_version = 4;
	m_tagAlterPreservation = false;
	m_fileAlterPreservation = false;
	m_readOnly = false;
	m_groupingIdentity = false;
	m_compression = false;
	m_encryption = false;
	m_unsyncronisation = false;
	m_dataLengthIndicator = false;
	// /ID3v2_FrameHeaderPrivate


	m_version = version;

	switch(version) {
		case 0:
		case 1:
		case 2:
		{
			// ID3v2.2

			if(data.size() < 3) {
				wxLogDebug(wxT("You must at least specify a frame ID."));
				return;
			}

			// Set the frame ID -- the first three bytes

			m_frameID = data.mid(0, 3);

			// If the full header information was not passed in, do not continue to the
			// steps to parse the frame size and flags.

			if(data.size() < 6) {
				return;
			}

			m_frameSize = data.mid(3, 3).toUInt();

			break;
		}
		case 3:
		{
			// ID3v2.3 - see http://www.id3.org/id3v2.3.0.html#sec3.3

			if(data.size() < 4) {
				wxLogDebug(wxT("You must at least specify a frame ID."));
				return;
			}

			// Set the frame ID -- the first four bytes

			m_frameID = data.mid(0, 4);

			// If the full header information was not passed in, do not continue to the
			// steps to parse the frame size and flags.

			if(data.size() < 10) {
				return;
			}

			// Set the size -- the frame size is the four bytes starting at byte four in
			// the frame header (structure 4)

			m_frameSize = data.mid(4, 4).toUInt();

			{	// read the first byte of flags
				/*std::bitset<8> flags(data[8]);
				d->tagAlterPreservation  = flags[7]; // (structure 3.3.1.a)
				d->fileAlterPreservation = flags[6]; // (structure 3.3.1.b)
				d->readOnly              = flags[5]; // (structure 3.3.1.c)*/
				unsigned char flags = data[8];
				m_tagAlterPreservation    = (flags & (1<<7)) != 0;
				m_fileAlterPreservation   = (flags & (1<<6)) != 0;
				m_readOnly                = (flags & (1<<5)) != 0;
			}

			{	// read the second byte of flags
				/*std::bitset<8> flags(data[9]);
				d->compression         = flags[7]; // (structure 3.3.1.i)
				d->encryption          = flags[6]; // (structure 3.3.1.j)
				d->groupingIdentity    = flags[5]; // (structure 3.3.1.k)*/
				unsigned char flags = data[9];
				m_compression     = (flags & (1<<7)) != 0;
				m_encryption          = (flags & (1<<6)) != 0;
				m_groupingIdentity    = (flags & (1<<5)) != 0;
			}
			break;
		}
		case 4:
		default:
		{
			// ID3v2.4

			if(data.size() < 4) {
//.........这里部分代码省略.........
开发者ID:antonivich,项目名称:Silverjuke,代码行数:101,代码来源:tg_id3v2_frame.cpp

示例12: 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


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