libebml: no need to put the internal code of EbmlCRC32 in the public header

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@486 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Steve Lhomme 2010-08-08 11:16:14 +00:00
parent 5c051f95f2
commit df5620c733
5 changed files with 362 additions and 353 deletions

View File

@ -1,3 +1,7 @@
2010-08-xx robux4
New 1.1.1 version:
- no need to put the internal code of EbmlCrc32 in the public header
2010-07-xx robux4 2010-07-xx robux4
New 1.1.0 version: New 1.1.0 version:
- EbmlElement::VoidMe() now returns a uint64 - EbmlElement::VoidMe() now returns a uint64

View File

@ -44,16 +44,6 @@
START_LIBEBML_NAMESPACE START_LIBEBML_NAMESPACE
const uint32 CRC32_NEGL = 0xffffffffL;
#ifdef WORDS_BIGENDIAN
# define CRC32_INDEX(c) (c >> 24)
# define CRC32_SHIFTED(c) (c << 8)
#else
# define CRC32_INDEX(c) (c & 0xff)
# define CRC32_SHIFTED(c) (c >> 8)
#endif
DECLARE_EBML_BINARY(EbmlCrc32) DECLARE_EBML_BINARY(EbmlCrc32)
public: public:
EbmlCrc32(const EbmlCrc32 & ElementToClone); EbmlCrc32(const EbmlCrc32 & ElementToClone);
@ -69,11 +59,6 @@ DECLARE_EBML_BINARY(EbmlCrc32)
void AddElementCRC32(EbmlElement &ElementToCRC); void AddElementCRC32(EbmlElement &ElementToCRC);
bool CheckElementCRC32(EbmlElement &ElementToCRC); bool CheckElementCRC32(EbmlElement &ElementToCRC);
/*!
CRC Checksum Calculation
*/
enum {DIGESTSIZE = 4};
/*! /*!
Use this to quickly check a CRC32 with some data Use this to quickly check a CRC32 with some data
\return True if inputCRC matches CRC32 generated from input data \return True if inputCRC matches CRC32 generated from input data
@ -105,8 +90,8 @@ DECLARE_EBML_BINARY(EbmlCrc32)
#else #else
protected: protected:
#endif #endif
void ResetCRC() {m_crc = CRC32_NEGL;} void ResetCRC();
void UpdateByte(binary b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);} void UpdateByte(binary b);
static const uint32 m_tab[256]; static const uint32 m_tab[256];
uint32 m_crc; uint32 m_crc;

View File

@ -42,9 +42,9 @@
START_LIBEBML_NAMESPACE START_LIBEBML_NAMESPACE
#define LIBEBML_VERSION 0x010100 #define LIBEBML_VERSION 0x010101
static const std::string EbmlCodeVersion = "1.1.0"; static const std::string EbmlCodeVersion = "1.1.1";
static const std::string EbmlCodeDate = __TIMESTAMP__; static const std::string EbmlCodeDate = __TIMESTAMP__;
/*! /*!

View File

@ -2,7 +2,7 @@
LIB ebml LIB ebml
{ {
PROJECT_VERSION 1.1.0 PROJECT_VERSION 1.1.1
INCLUDE . INCLUDE .
EXPINCLUDE . EXPINCLUDE .

View File

@ -38,6 +38,16 @@
#include "ebml/EbmlContexts.h" #include "ebml/EbmlContexts.h"
#include "ebml/MemIOCallback.h" #include "ebml/MemIOCallback.h"
#ifdef WORDS_BIGENDIAN
# define CRC32_INDEX(c) (c >> 24)
# define CRC32_SHIFTED(c) (c << 8)
#else
# define CRC32_INDEX(c) (c & 0xff)
# define CRC32_SHIFTED(c) (c >> 8)
#endif
const uint32 CRC32_NEGL = 0xffffffffL;
START_LIBEBML_NAMESPACE START_LIBEBML_NAMESPACE
DEFINE_EBML_CLASS_GLOBAL(EbmlCrc32, 0xBF, 1, "EBMLCrc32\0ratamadabapa"); DEFINE_EBML_CLASS_GLOBAL(EbmlCrc32, 0xBF, 1, "EBMLCrc32\0ratamadabapa");
@ -155,7 +165,7 @@ const uint32 EbmlCrc32::m_tab[] = {
EbmlCrc32::EbmlCrc32() EbmlCrc32::EbmlCrc32()
{ {
ResetCRC(); ResetCRC();
SetDefaultSize(DIGESTSIZE); SetDefaultSize(4);
m_crc_final = 0; m_crc_final = 0;
SetSize_(4); SetSize_(4);
//This EbmlElement has been set //This EbmlElement has been set
@ -169,6 +179,16 @@ EbmlCrc32::EbmlCrc32(const EbmlCrc32 & ElementToClone)
m_crc_final = ElementToClone.m_crc_final; m_crc_final = ElementToClone.m_crc_final;
} }
void EbmlCrc32::ResetCRC()
{
m_crc = CRC32_NEGL;
}
void EbmlCrc32::UpdateByte(binary b)
{
m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);
}
void EbmlCrc32::AddElementCRC32(EbmlElement &ElementToCRC) void EbmlCrc32::AddElementCRC32(EbmlElement &ElementToCRC)
{ {
// Use a special IOCallback class that Render's to memory instead of to disk // Use a special IOCallback class that Render's to memory instead of to disk
@ -189,7 +209,7 @@ bool EbmlCrc32::CheckElementCRC32(EbmlElement &ElementToCRC)
filepos_t EbmlCrc32::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault) filepos_t EbmlCrc32::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
{ {
filepos_t Result = DIGESTSIZE; filepos_t Result = 4;
if (Result != 0) { if (Result != 0) {
output.writeFully(&m_crc_final, Result); output.writeFully(&m_crc_final, Result);