1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-08 04:25:12 +01:00
GPXSee/src/map/IMG/huffmantext.cpp

34 lines
711 B
C++
Raw Normal View History

#include "subfile.h"
#include "huffmanstream.h"
#include "huffmantext.h"
2021-04-10 15:27:40 +02:00
using namespace IMG;
bool HuffmanText::load(const RGNFile *rgn, SubFile::Handle &rgnHdl)
{
if (!_table.load(rgn, rgnHdl))
return false;
Q_ASSERT(!(_table.symbolBits() & 7));
return !(_table.symbolBits() & 7);
}
bool HuffmanText::decode(const SubFile *file, SubFile::Handle &hdl,
quint32 size, QVector<quint8> &str) const
{
BitStream4F bs(*file, hdl, size);
HuffmanStream<BitStream4F> hs(bs, _table);
quint32 sym;
while (hs.readSymbol(sym)) {
for (quint32 i = 0; i < (_table.symbolBits() >> 3); i++) {
str.append((quint8)sym);
if (((quint8)sym == '\0'))
return true;
sym = sym >> 8;
}
}
return false;
}