1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-31 09:05:14 +01:00

Optmization

This commit is contained in:
Martin Tůma 2021-11-08 21:52:07 +01:00
parent 3deae0c57b
commit ca5b7d72c4

View File

@ -41,10 +41,10 @@ bool HuffmanStream<BitStream>::read(int bits, quint32 &val)
_symbolData = (_symbolData << nextSize) | next;
_symbolDataSize += nextSize;
}
if (_symbolDataSize < (quint32)bits)
return false;
}
val = (_symbolData << (32-_symbolDataSize)) >> (32 - bits);
_symbolDataSize -= bits;
@ -56,14 +56,18 @@ template <class BitStream>
bool HuffmanStream<BitStream>::readSymbol(quint32 &symbol)
{
quint8 size;
if (_symbolDataSize < _table.symBits()) {
quint32 next;
quint8 nextSize = qMin((quint64)(32 - _symbolDataSize), _bs.bitsAvailable());
quint8 nextSize = qMin((quint64)(32 - _symbolDataSize),
_bs.bitsAvailable());
if (!_bs.read(nextSize, next))
return false;
_symbolData = (_symbolData << nextSize) | next;
_symbolDataSize += nextSize;
}
symbol = _table.symbol(_symbolData << (32 - _symbolDataSize), size);
if (size > _symbolDataSize)