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

Function addLengthDistance

samples/shared/lodepng.cpp:1317–1334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1315}
1316
1317static void addLengthDistance(uivector* values, size_t length, size_t distance)
1318{
1319 /*values in encoded vector are those used by deflate:
1320 0-255: literal bytes
1321 256: end
1322 257-285: length/distance pair (length code, followed by extra length bits, distance code, extra distance bits)
1323 286-287: invalid*/
1324
1325 unsigned length_code = (unsigned)searchCodeIndex(LENGTHBASE, 29, length);
1326 unsigned extra_length = (unsigned)(length - LENGTHBASE[length_code]);
1327 unsigned dist_code = (unsigned)searchCodeIndex(DISTANCEBASE, 30, distance);
1328 unsigned extra_distance = (unsigned)(distance - DISTANCEBASE[dist_code]);
1329
1330 uivector_push_back(values, length_code + FIRST_LENGTH_CODE_INDEX);
1331 uivector_push_back(values, extra_length);
1332 uivector_push_back(values, dist_code);
1333 uivector_push_back(values, extra_distance);
1334}
1335
1336/*3 bytes of data get encoded into two bytes. The hash cannot use more than 3
1337bytes 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