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


C++ SjByteVector类代码示例

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


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

示例1: size

SjByteVector ID3v2_Frame::fieldData(const SjByteVector &frameData) const
{
	SjUint headerSize = ID3v2_FrameHeader::size(m_header->version());

	SjUint frameDataOffset = headerSize;
	SjUint frameDataLength = size();

	if(m_header->compression() || m_header->dataLengthIndicator()) {
		frameDataLength = frameData.mid(headerSize, 4).toUInt();
		frameDataOffset += 4;
	}

	if(m_header->compression()) {
		SjByteVector data(frameDataLength);

		uLongf uLongTmp = data.size(); // normally, this should be same as frameDataLength - however, on allocation errors, this may be 0!
		::uncompress((Bytef *) data.getWriteableData(),
		             (uLongf *) &uLongTmp,
		             (Bytef *) frameData.getReadableData() + frameDataOffset,
		             size());
		return data;
	}
	else
		return frameData.mid(frameDataOffset, frameDataLength);
}
开发者ID:antonivich,项目名称:Silverjuke,代码行数:25,代码来源:tg_id3v2_frame.cpp

示例2: parse

void MPEG_XingHeader::parse(const SjByteVector &data)
{
	// Check to see if a valid Xing header is available.

	if(!data.startsWith((unsigned char*)"Xing"))
	{
		return;
	}

	// If the XingHeader doesn't contain the number of frames and the total stream
	// info it's invalid.

	if(!(data[7] & 0x02))
	{
		wxLogDebug(wxT("MPEG::XingHeader::parse() -- Xing header doesn't contain the total number of frames."));
		return;
	}

	if(!(data[7] & 0x04))
	{
		wxLogDebug(wxT("MPEG::XingHeader::parse() -- Xing header doesn't contain the total stream size."));
		return;
	}

	m_frames = data.mid(8, 4).toUInt();
	m_size = data.mid(12, 4).toUInt();

	m_valid = true;
}
开发者ID:antonivich,项目名称:Silverjuke,代码行数:29,代码来源:tg_mpeg_header.cpp

示例3:

SjByteVector ID3v2_TextIdentificationFrame::renderFields() const
{
	SjByteVector v;

	if(m_fieldList.GetCount() > 0) {

		v.append((unsigned char)(m_textEncoding));

		/*for(StringList::Iterator it = d->fieldList.begin(); it != d->fieldList.end(); it++) {

		  // Since the field list is null delimited, if this is not the first
		  // element in the list, append the appropriate delimiter for this
		  // encoding.

		  if(it != d->fieldList.begin())
		    v.append(textDelimiter(d->textEncoding));

		  v.append((*it).data(d->textEncoding));
		}*/
		int i, iCount = m_fieldList.GetCount();
		for( i = 0; i < iCount; i++ )
		{
			if( i )
				v.append(textDelimiter(m_textEncoding));

			v.appendString(m_fieldList.Item(i), m_textEncoding);
		}
	}

	return v;
}
开发者ID:boh1996,项目名称:silverjuke,代码行数:31,代码来源:tg_id3v2_knownframes.cpp

示例4:

SjByteVector ID3v2_Frame::textDelimiter(SjStringType t)
{
	SjByteVector d = (unsigned char)(0);
	if(t == SJ_UTF16 || t == SJ_UTF16BE)
		d.append((unsigned char)(0));
	return d;
}
开发者ID:antonivich,项目名称:Silverjuke,代码行数:7,代码来源:tg_id3v2_frame.cpp

示例5: removeFrames

void ID3v2_Tag::setTextFrame(const wxString &id, const wxString &value)
{
	if(value.IsEmpty()) {
		removeFrames(id);
		return;
	}

	//if(!d->frameListMap[id].isEmpty())
	//  d->frameListMap[id].front()->setText(value);
	ID3v2_FrameList* it = frameList(id);
	if( it )
	{
		ID3v2_FrameList::Node* l = it->GetFirst();
		if( l )
		{
			l->GetData()->setText(value);
		}
	}
	else
	{
		const SjStringType encoding = m_factory->defaultTextEncoding();

		SjByteVector idBv;
		idBv.appendString(id, SJ_LATIN1);
		ID3v2_TextIdentificationFrame *f = new ID3v2_TextIdentificationFrame(idBv, encoding);

		addFrame(f);
		f->setText(value);
	}
}
开发者ID:antonivich,项目名称:Silverjuke,代码行数:30,代码来源:tg_id3v2_tag.cpp

示例6: while

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

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

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

示例9: s

void ID3v2_TextIdentificationFrame::parseFields(const SjByteVector &data)
{
	// read the string data type (the first byte of the field data)

	m_textEncoding = (SjStringType)(data[0]);

	// split the byte array into chunks based on the string type (two byte delimiter
	// for unicode encodings)

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

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

	m_fieldList.Empty();

	// append those split values to the list and make sure that the new string's
	// type is the same specified for this frame

	/*for(ByteVectorList::Iterator it = l.begin(); it != l.end(); it++) {
	  String s(*it, d->textEncoding);
	  d->fieldList.append(s);
	}
	*/
	int i, iCount = l.GetCount();
	for( i = 0; i < iCount; i++ )
	{
		m_fieldList.Add(l.Item(i).toString(m_textEncoding));
	}
}
开发者ID:boh1996,项目名称:silverjuke,代码行数:30,代码来源:tg_id3v2_knownframes.cpp

示例10: render

SjByteVector APE_Footer::render(bool isHeader) const
{
	SjByteVector v;

	// add the file identifier -- "APETAGEX"
	v.append(fileIdentifier());

	// add the version number -- we always render a 2.000 tag regardless of what
	// the tag originally was.
	v.append(SjByteVector::fromUint(2000, false));

	// add the tag size
	v.append(SjByteVector::fromUint(m_tagSize, false));

	// add the item count
	v.append(SjByteVector::fromUint(m_itemCount, false));

	// render and add the flags (footer is always present)
	unsigned long flags = 0;
	flags |= m_headerPresent? 0x80000000UL : 0UL;
	flags |= isHeader? 0x20000000UL : 0UL;

	v.append(SjByteVector::fromUint(flags, false));

	// add the reserved 64bit
	v.append(SjByteVector::fromLongLong(0));

	// done
	return v;
}
开发者ID:boh1996,项目名称:silverjuke,代码行数:30,代码来源:tg_ape_tag.cpp

示例11: get_str16_nolen

static void get_str16_nolen(WMA_File *f, int len, wxString& s)
{
	SjByteVector bv = f->ReadBlock(len); // len here is apparently in bytes (see code below)
	bv.append( SjByteVector::fromShort(0) ); // NULL terminator
	s = bv.toString(SJ_UTF16LE);
	//s = String(bv, String::UTF16LE);

//   int c;
//   char *q;

//   q = buf;
//   while (len > 0) {
//     c = get_le16(f);
//     if ((q - buf) < buf_size - 1)
//             *q++ = c;
//     len-=2;
//   }
//   *q = '\0';
}
开发者ID:boh1996,项目名称:silverjuke,代码行数:19,代码来源:tg_wma_file_asf.cpp

示例12: ReadBlock

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

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

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

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


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