Clean project structure.
This commit is contained in:
parent
78a4fa99ff
commit
947bf937fd
496 changed files with 206 additions and 137 deletions
43
src/base/compression/CyclicRedundancyChecker.cpp
Normal file
43
src/base/compression/CyclicRedundancyChecker.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include "CyclicRedundancyChecker.h"
|
||||
|
||||
void CyclicRedundancyChecker::createTable()
|
||||
{
|
||||
mTable = std::vector<unsigned long>(TABLE_SIZE, 0);
|
||||
unsigned long c{0};
|
||||
for (int n = 0; n < TABLE_SIZE; n++)
|
||||
{
|
||||
c = (unsigned long) n;
|
||||
for (int k = 0; k < 8; k++)
|
||||
{
|
||||
if (c & 1)
|
||||
{
|
||||
c = 0xedb88320L ^ (c >> 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
c = c >> 1;
|
||||
}
|
||||
}
|
||||
mTable[n] = c;
|
||||
}
|
||||
mTableComputed = true;
|
||||
}
|
||||
|
||||
void CyclicRedundancyChecker::addValue(unsigned char val)
|
||||
{
|
||||
if (!mTableComputed)
|
||||
{
|
||||
createTable();
|
||||
}
|
||||
mLastValue = mTable[(mLastValue ^ val) & 0xff] ^ (mLastValue >> 8);
|
||||
}
|
||||
|
||||
uint32_t CyclicRedundancyChecker::getChecksum() const
|
||||
{
|
||||
return mLastValue ^ 0xffffffffL;
|
||||
}
|
||||
|
||||
void CyclicRedundancyChecker::reset()
|
||||
{
|
||||
mLastValue = 0xffffffffL;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue