MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / addLengthDistance

Function addLengthDistance

dependency/densecrf/examples/lodepng.cpp:1343–1360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1341}
1342
1343static void addLengthDistance(uivector* values, size_t length, size_t distance)
1344{
1345 /*values in encoded vector are those used by deflate:
1346 0-255: literal bytes
1347 256: end
1348 257-285: length/distance pair (length code, followed by extra length bits, distance code, extra distance bits)
1349 286-287: invalid*/
1350
1351 unsigned length_code = (unsigned)searchCodeIndex(LENGTHBASE, 29, length);
1352 unsigned extra_length = (unsigned)(length - LENGTHBASE[length_code]);
1353 unsigned dist_code = (unsigned)searchCodeIndex(DISTANCEBASE, 30, distance);
1354 unsigned extra_distance = (unsigned)(distance - DISTANCEBASE[dist_code]);
1355
1356 uivector_push_back(values, length_code + FIRST_LENGTH_CODE_INDEX);
1357 uivector_push_back(values, extra_length);
1358 uivector_push_back(values, dist_code);
1359 uivector_push_back(values, extra_distance);
1360}
1361
1362/*3 bytes of data get encoded into two bytes. The hash cannot use more than 3
1363 bytes as input because 3 is the minimum match length for deflate*/

Callers 1

encodeLZ77Function · 0.85

Calls 2

searchCodeIndexFunction · 0.85
uivector_push_backFunction · 0.85

Tested by

no test coverage detected