Convert lz77 to use fixed buffer sizes.
This commit is contained in:
parent
a6e31c8d39
commit
af6fad72eb
9 changed files with 362 additions and 110 deletions
|
@ -98,3 +98,47 @@ void HuffmanEncoder::encode(const std::unordered_map<unsigned char, unsigned>& c
|
|||
|
||||
std::cout << "********" << std::endl;
|
||||
}
|
||||
|
||||
void HuffmanEncoder::setUseFixedCode(bool useFixed)
|
||||
{
|
||||
mUseFixedCode = useFixed;
|
||||
}
|
||||
|
||||
uint32_t HuffmanEncoder::getLengthValue(unsigned length)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::optional<PrefixCode> HuffmanEncoder::getLiteralValue(unsigned char value) const
|
||||
{
|
||||
return mLiteralLengthTable.getCodeForSymbol(value);
|
||||
}
|
||||
|
||||
std::optional<PrefixCode> HuffmanEncoder::getLengthValue(unsigned length) const
|
||||
{
|
||||
return mLiteralLengthTable.getCodeForSymbol(length);
|
||||
}
|
||||
|
||||
std::optional<PrefixCode> HuffmanEncoder::getDistanceValue(unsigned distance) const
|
||||
{
|
||||
return mDistanceTable.getCodeForSymbol(distance);
|
||||
}
|
||||
|
||||
std::optional<PrefixCode> HuffmanEncoder::getEndOfStreamValue() const
|
||||
{
|
||||
return mLiteralLengthTable.getCodeForSymbol(256);
|
||||
}
|
||||
|
||||
void HuffmanEncoder::initializeTrees()
|
||||
{
|
||||
initializeLiteralLengthTable();
|
||||
}
|
||||
|
||||
void HuffmanEncoder::initializeLiteralLengthTable()
|
||||
{
|
||||
if(mUseFixedCode)
|
||||
{
|
||||
mLiteralLengthTable.setInputLengthSequence(HuffmanFixedCodes::getDeflateFixedHuffmanCodes(), false);
|
||||
mLiteralLengthTable.buildPrefixCodes();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue