Initial fixed huffman coding for png.
This commit is contained in:
parent
e4f9393ee7
commit
7f5009fb5e
39 changed files with 1294 additions and 440 deletions
|
@ -1,5 +1,7 @@
|
|||
#include "BufferBitStream.h"
|
||||
|
||||
#include "ByteUtils.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
bool BufferBitStream::isFinished() const
|
||||
|
@ -50,13 +52,27 @@ void BufferBitStream::setBuffer(const std::vector<unsigned char>& data)
|
|||
mBuffer = data;
|
||||
}
|
||||
|
||||
void BufferBitStream::writeByte(unsigned char data)
|
||||
void BufferBitStream::writeByte(unsigned char data, bool checkOverflow)
|
||||
{
|
||||
unsigned char out_byte{0};
|
||||
if (checkOverflow && mBitOffset > 0)
|
||||
{
|
||||
out_byte = ByteUtils::getLowerNBits(mCurrentByte, mBitOffset);
|
||||
out_byte |= data << mBitOffset;
|
||||
|
||||
mCurrentByte = ByteUtils::getHigherNBits(data, mBitOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
out_byte = data;
|
||||
}
|
||||
|
||||
if (mChecksumCalculator)
|
||||
{
|
||||
mChecksumCalculator->addValue(data);
|
||||
mChecksumCalculator->addValue(out_byte);
|
||||
}
|
||||
mBuffer.push_back(data);
|
||||
std::cout << "Writing byte " << ByteUtils::toString(out_byte) << " had bitoffset of " << mBitOffset << std::endl;
|
||||
mBuffer.push_back(out_byte);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue