MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / writeLZ77data

Function writeLZ77data

samples/shared/lodepng.cpp:1666–1692  ·  view source on GitHub ↗

write the lz77-encoded data, which has lit, len and dist codes, to compressed stream using huffman trees. tree_ll: the tree for lit and len codes. tree_d: the tree for distance codes. */

Source from the content-addressed store, hash-verified

1664tree_d: the tree for distance codes.
1665*/
1666static void writeLZ77data(size_t* bp, ucvector* out, const uivector* lz77_encoded,
1667 const HuffmanTree* tree_ll, const HuffmanTree* tree_d)
1668{
1669 size_t i = 0;
1670 for(i = 0; i < lz77_encoded->size; i++)
1671 {
1672 unsigned val = lz77_encoded->data[i];
1673 addHuffmanSymbol(bp, out, HuffmanTree_getCode(tree_ll, val), HuffmanTree_getLength(tree_ll, val));
1674 if(val > 256) /*for a length code, 3 more things have to be added*/
1675 {
1676 unsigned length_index = val - FIRST_LENGTH_CODE_INDEX;
1677 unsigned n_length_extra_bits = LENGTHEXTRA[length_index];
1678 unsigned length_extra_bits = lz77_encoded->data[++i];
1679
1680 unsigned distance_code = lz77_encoded->data[++i];
1681
1682 unsigned distance_index = distance_code;
1683 unsigned n_distance_extra_bits = DISTANCEEXTRA[distance_index];
1684 unsigned distance_extra_bits = lz77_encoded->data[++i];
1685
1686 addBitsToStream(bp, out, length_extra_bits, n_length_extra_bits);
1687 addHuffmanSymbol(bp, out, HuffmanTree_getCode(tree_d, distance_code),
1688 HuffmanTree_getLength(tree_d, distance_code));
1689 addBitsToStream(bp, out, distance_extra_bits, n_distance_extra_bits);
1690 }
1691 }
1692}
1693
1694/*Deflate for a block of type "dynamic", that is, with freely, optimally, created huffman trees*/
1695static unsigned deflateDynamic(ucvector* out, size_t* bp, Hash* hash,

Callers 2

deflateDynamicFunction · 0.85
deflateFixedFunction · 0.85

Calls 4

addHuffmanSymbolFunction · 0.85
HuffmanTree_getCodeFunction · 0.85
HuffmanTree_getLengthFunction · 0.85
addBitsToStreamFunction · 0.85

Tested by

no test coverage detected