Clean up some test files.
This commit is contained in:
parent
1adc9272f8
commit
b45385e8c7
51 changed files with 485 additions and 281 deletions
|
@ -15,7 +15,7 @@ void HuffmanCodeLengthTable::buildCompressedLengthSequence()
|
|||
|
||||
for (const auto& entry : rle_encoded)
|
||||
{
|
||||
std::cout << "Got rle " << static_cast<int>(entry.first) << " | " << entry.second << std::endl;
|
||||
//std::cout << "Got rle " << static_cast<int>(entry.first) << " | " << entry.second << std::endl;
|
||||
}
|
||||
mCompressedLengthSequence.clear();
|
||||
|
||||
|
@ -152,7 +152,7 @@ bool HuffmanCodeLengthTable::readNextSymbol(unsigned& result, BitStream* stream)
|
|||
}
|
||||
else
|
||||
{
|
||||
std::cout << "SYMBOL NOT FOUND " << " with bits " << ByteUtils::toString(working_bits) << " and index " << working_index << std::endl;
|
||||
//std::cout << "SYMBOL NOT FOUND " << " with bits " << ByteUtils::toString(working_bits) << " and index " << working_index << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ void HuffmanCodeLengthTable::buildPrefixCodes()
|
|||
}
|
||||
}
|
||||
mTree.sortTable();
|
||||
std::cout << dumpPrefixCodes();
|
||||
//std::cout << dumpPrefixCodes();
|
||||
}
|
||||
|
||||
const PrefixCode& HuffmanCodeLengthTable::getCode(std::size_t index) const
|
||||
|
|
|
@ -22,18 +22,18 @@ void HuffmanEncoder::dumpNode(RawNode<CountPair>* node, unsigned depth) const
|
|||
|
||||
if (node->isLeaf())
|
||||
{
|
||||
std::cout << prefix << "Leaf with value: " << data.first << " and sum " << data.second << std::endl;
|
||||
//std::cout << prefix << "Leaf with value: " << data.first << " and sum " << data.second << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << prefix << "Intermediate with sum " << data.second << std::endl;
|
||||
std::cout << prefix << "Doing Left.." << std::endl;
|
||||
//std::cout << prefix << "Intermediate with sum " << data.second << std::endl;
|
||||
//std::cout << prefix << "Doing Left.." << std::endl;
|
||||
dumpNode(node->getLeftChild(), depth+1);
|
||||
|
||||
std::cout << prefix << "Doing Right.." << std::endl;
|
||||
//std::cout << prefix << "Doing Right.." << std::endl;
|
||||
dumpNode(node->getRightChild(), depth+1);
|
||||
|
||||
std::cout << prefix << "*****" << std::endl;
|
||||
//std::cout << prefix << "*****" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,9 +84,9 @@ void HuffmanEncoder::encode(const std::vector<unsigned>& counts)
|
|||
|
||||
//using TableEntry = std::tuple<>
|
||||
|
||||
dumpTree(tree);
|
||||
//dumpTree(tree);
|
||||
|
||||
std::cout << "********" << std::endl;
|
||||
//std::cout << "********" << std::endl;
|
||||
}
|
||||
|
||||
void HuffmanEncoder::encode(const std::unordered_map<unsigned char, unsigned>& counts)
|
||||
|
@ -165,7 +165,7 @@ void HuffmanEncoder::initializeLiteralLengthTable(const std::vector<Hit>& hits)
|
|||
{
|
||||
if (counts[idx]>0)
|
||||
{
|
||||
std::cout << "Count for " << idx << " is " << counts[idx] << std::endl;
|
||||
//std::cout << "Count for " << idx << " is " << counts[idx] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ void HuffmanStream::readCodeLengths()
|
|||
|
||||
if (!valid)
|
||||
{
|
||||
std::cout << "Hit unknown symbol - bailing out" << std::endl;
|
||||
//std::cout << "Hit unknown symbol - bailing out" << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ void HuffmanStream::readCodeLengths()
|
|||
unsigned char num_reps{0};
|
||||
mInputStream->readNextNBits(2, num_reps);
|
||||
|
||||
std::cout << "Got val 16 doing " << 3 + num_reps << std::endl;
|
||||
//std::cout << "Got val 16 doing " << 3 + num_reps << std::endl;
|
||||
for(unsigned idx=0; idx< 3 + num_reps; idx++)
|
||||
{
|
||||
addValue(last_value, count, last_value, literal_lengths, mNumLiterals, distance_lengths);
|
||||
|
@ -130,7 +130,7 @@ void HuffmanStream::readCodeLengths()
|
|||
unsigned char num_reps{0};
|
||||
mInputStream->readNextNBits(3, num_reps);
|
||||
|
||||
std::cout << "Got val 17 doing " << 3 + num_reps << std::endl;
|
||||
//std::cout << "Got val 17 doing " << 3 + num_reps << std::endl;
|
||||
for(unsigned idx=0; idx< 3 + num_reps; idx++)
|
||||
{
|
||||
addValue(0, count, last_value, literal_lengths, mNumLiterals, distance_lengths);
|
||||
|
@ -141,7 +141,7 @@ void HuffmanStream::readCodeLengths()
|
|||
unsigned char num_reps{0};
|
||||
mInputStream->readNextNBits(7, num_reps);
|
||||
|
||||
std::cout << "Got val 18 doing " << 11 + num_reps << std::endl;
|
||||
//std::cout << "Got val 18 doing " << 11 + num_reps << std::endl;
|
||||
for(unsigned idx=0; idx< 11 + num_reps; idx++)
|
||||
{
|
||||
addValue(0, count, last_value, literal_lengths, mNumLiterals, distance_lengths);
|
||||
|
@ -149,19 +149,19 @@ void HuffmanStream::readCodeLengths()
|
|||
}
|
||||
}
|
||||
|
||||
std::cout << "Got final literal length sequence " << std::endl;
|
||||
//std::cout << "Got final literal length sequence " << std::endl;
|
||||
for(unsigned idx=0; idx<literal_lengths.size(); idx++)
|
||||
{
|
||||
std::cout << static_cast<int>(literal_lengths[idx]) << "," ;
|
||||
//std::cout << static_cast<int>(literal_lengths[idx]) << "," ;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
//std::cout << std::endl;
|
||||
|
||||
std::cout << "Got final distance length sequence " << std::endl;
|
||||
//std::cout << "Got final distance length sequence " << std::endl;
|
||||
for(unsigned idx=0; idx<distance_lengths.size(); idx++)
|
||||
{
|
||||
std::cout << static_cast<int>(distance_lengths[idx]) << "," ;
|
||||
//std::cout << static_cast<int>(distance_lengths[idx]) << "," ;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
//std::cout << std::endl;
|
||||
|
||||
mLiteralTable.setInputLengthSequence(literal_lengths, false);
|
||||
mLiteralTable.buildPrefixCodes();
|
||||
|
@ -192,11 +192,11 @@ void HuffmanStream::readSymbols()
|
|||
const auto valid = readNextLiteralSymbol(symbol);
|
||||
if (!valid)
|
||||
{
|
||||
std::cout << "Hit unknown symbol - bailing out" << std::endl;
|
||||
//std::cout << "Hit unknown symbol - bailing out" << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
std::cout << "Got symbol " << symbol << std::endl;
|
||||
//std::cout << "Got symbol " << symbol << std::endl;
|
||||
|
||||
if(symbol <= 255)
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ void HuffmanStream::readSymbols()
|
|||
|
||||
if (hit_end_stream)
|
||||
{
|
||||
std::cout << "Found end of stream ok" << std::endl;
|
||||
//std::cout << "Found end of stream ok" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ bool HuffmanStream::decode()
|
|||
|
||||
readSymbols();
|
||||
|
||||
std::cout << "Got final buffer size " << mBuffer.size() << std::endl;
|
||||
//std::cout << "Got final buffer size " << mBuffer.size() << std::endl;
|
||||
for(unsigned idx=0; idx< 100; idx++)
|
||||
{
|
||||
//std::cout << idx << " | " << mBuffer[idx] << std::endl;
|
||||
|
@ -297,7 +297,7 @@ bool HuffmanStream::decode()
|
|||
|
||||
if (!valid)
|
||||
{
|
||||
std::cout << "Hit unknown symbol - bailing out" << std::endl;
|
||||
//std::cout << "Hit unknown symbol - bailing out" << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -317,25 +317,25 @@ void HuffmanStream::readCodingsTable()
|
|||
unsigned char h_lit{0};
|
||||
mInputStream->readNextNBits(5, h_lit);
|
||||
mNumLiterals = h_lit + 257;
|
||||
std::cout << "Got HLIT " << mNumLiterals << std::endl;
|
||||
//std::cout << "Got HLIT " << mNumLiterals << std::endl;
|
||||
|
||||
unsigned char h_dist{0};
|
||||
mInputStream->readNextNBits(5, h_dist);
|
||||
mNumDistances = h_dist + 1;
|
||||
std::cout << "Got HDIST " << mNumDistances << std::endl;
|
||||
//std::cout << "Got HDIST " << mNumDistances << std::endl;
|
||||
|
||||
unsigned char h_clen{0};
|
||||
mInputStream->readNextNBits(4, h_clen);
|
||||
|
||||
auto num_code_lengths = h_clen + 4;
|
||||
std::cout << "Got HCLEN " << num_code_lengths << std::endl;
|
||||
//std::cout << "Got HCLEN " << num_code_lengths << std::endl;
|
||||
|
||||
auto sequence = std::vector<unsigned char>(num_code_lengths, 0);
|
||||
unsigned char buffer{0};
|
||||
for(unsigned idx = 0; idx< num_code_lengths; idx++)
|
||||
{
|
||||
mInputStream->readNextNBits(3, buffer);
|
||||
std::cout << "Got coding table value " << idx << " | " << static_cast<int>(buffer) << " | " << ByteUtils::toString(buffer) << std::endl;
|
||||
//std::cout << "Got coding table value " << idx << " | " << static_cast<int>(buffer) << " | " << ByteUtils::toString(buffer) << std::endl;
|
||||
sequence[idx] = buffer;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue