Further compression and png work.
This commit is contained in:
parent
318b481ccc
commit
9c8faa534b
34 changed files with 1164 additions and 203 deletions
49
src/core/streams/BufferBitStream.cpp
Normal file
49
src/core/streams/BufferBitStream.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
#include "BufferBitStream.h"
|
||||
|
||||
bool BufferBitStream::isFinished() const
|
||||
{
|
||||
return mByteOffset == mBuffer.size();
|
||||
}
|
||||
|
||||
std::vector<unsigned char> BufferBitStream::peekNextNBytes(unsigned n) const
|
||||
{
|
||||
std::vector<unsigned char> ret (n, 0);
|
||||
unsigned count = 0;
|
||||
for(unsigned idx=mByteOffset; idx<mByteOffset + n; idx++)
|
||||
{
|
||||
if (idx == mBuffer.size())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ret[count] = mBuffer[idx];
|
||||
count ++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::optional<unsigned char> BufferBitStream::readNextByte()
|
||||
{
|
||||
if (mByteOffset + 1 == mBuffer.size())
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
else
|
||||
{
|
||||
mByteOffset++;
|
||||
mCurrentByte = mBuffer[mByteOffset];
|
||||
return mCurrentByte;
|
||||
}
|
||||
}
|
||||
|
||||
void BufferBitStream::setBuffer(const std::vector<unsigned char>& data)
|
||||
{
|
||||
mBuffer = data;
|
||||
}
|
||||
|
||||
void BufferBitStream::writeByte(unsigned char data)
|
||||
{
|
||||
mBuffer.push_back(data);
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue