MCPcopy Create free account
hub / github.com/DFHack/dfhack / generateFixedLitLenTree

Function generateFixedLitLenTree

depends/lodepng/lodepng.cpp:1062–1077  ·  view source on GitHub ↗

get the literal and length code tree of a deflated block with fixed tree, as per the deflate specification*/

Source from the content-addressed store, hash-verified

1060
1061/*get the literal and length code tree of a deflated block with fixed tree, as per the deflate specification*/
1062static unsigned generateFixedLitLenTree(HuffmanTree* tree) {
1063 unsigned i, error = 0;
1064 unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DEFLATE_CODE_SYMBOLS * sizeof(unsigned));
1065 if(!bitlen) return 83; /*alloc fail*/
1066
1067 /*288 possible codes: 0-255=literals, 256=endcode, 257-285=lengthcodes, 286-287=unused*/
1068 for(i = 0; i <= 143; ++i) bitlen[i] = 8;
1069 for(i = 144; i <= 255; ++i) bitlen[i] = 9;
1070 for(i = 256; i <= 279; ++i) bitlen[i] = 7;
1071 for(i = 280; i <= 287; ++i) bitlen[i] = 8;
1072
1073 error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DEFLATE_CODE_SYMBOLS, 15);
1074
1075 lodepng_free(bitlen);
1076 return error;
1077}
1078
1079/*get the distance code tree of a deflated block with fixed tree, as specified in the deflate specification*/
1080static unsigned generateFixedDistanceTree(HuffmanTree* tree) {

Callers 2

getTreeInflateFixedFunction · 0.85
deflateFixedFunction · 0.85

Calls 3

lodepng_mallocFunction · 0.85
lodepng_freeFunction · 0.85

Tested by

no test coverage detected