コード例 #1
0
ファイル: EbmlCrc32.cpp プロジェクト: Azpidatziak/mkvtoolnix
bool EbmlCrc32::CheckElementCRC32(EbmlElement &ElementToCRC)
{
	MemIOCallback memoryBuffer;
	ElementToCRC.Render(memoryBuffer);

	return CheckCRC(m_crc_final, memoryBuffer.GetDataBuffer(), memoryBuffer.GetDataBufferSize());
};
コード例 #2
0
ファイル: EbmlCrc32.cpp プロジェクト: Azpidatziak/mkvtoolnix
void EbmlCrc32::AddElementCRC32(EbmlElement &ElementToCRC)
{
	// Use a special IOCallback class that Render's to memory instead of to disk
	MemIOCallback memoryBuffer;
	ElementToCRC.Render(memoryBuffer, true, true);

	Update(memoryBuffer.GetDataBuffer(), memoryBuffer.GetDataBufferSize());
//	Finalize();
};
コード例 #3
0
ファイル: EbmlVoid.cpp プロジェクト: OS2World/LIB-MM-libebml
uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward, bool bWithDefault)
{
	EltToReplaceWith.UpdateSize(bWithDefault);
	if (HeadSize() + GetSize() < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) {
		// the element can't be written here !
		return INVALID_FILEPOS_T;
	}
	if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() == 1) {
		// there is not enough space to put a filling element
		return INVALID_FILEPOS_T;
	}

	uint64 CurrentPosition = output.getFilePointer();

	output.setFilePointer(GetElementPosition());
	EltToReplaceWith.Render(output, bWithDefault);

	if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() > 1) {
	  // fill the rest with another void element
	  EbmlVoid aTmp;
	  aTmp.SetSize_(HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() - 1); // 1 is the length of the Void ID
	  int HeadBefore = aTmp.HeadSize();
	  aTmp.SetSize_(aTmp.GetSize() - CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()));
	  int HeadAfter = aTmp.HeadSize();
	  if (HeadBefore != HeadAfter) {
		  aTmp.SetSizeLength(CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()) - (HeadAfter - HeadBefore));
	  }
	  aTmp.RenderHead(output, false, bWithDefault); // the rest of the data is not rewritten
	}

	if (ComeBackAfterward) {
		output.setFilePointer(CurrentPosition);
	}

	return GetSize() + HeadSize();
}