MCPcopy Create free account
hub / github.com/OpenPathGuidingLibrary/openpgl / hufPackEncTable

Function hufPackEncTable

third-party/tinyexr/tinyexr.h:2409–2448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2407const int LONGEST_LONG_RUN = 255 + SHORTEST_LONG_RUN;
2408
2409static void hufPackEncTable(
2410 const long long *hcode, // i : encoding table [HUF_ENCSIZE]
2411 int im, // i : min hcode index
2412 int iM, // i : max hcode index
2413 char **pcode) // o: ptr to packed table (updated)
2414{
2415 char *p = *pcode;
2416 long long c = 0;
2417 int lc = 0;
2418
2419 for (; im <= iM; im++) {
2420 int l = hufLength(hcode[im]);
2421
2422 if (l == 0) {
2423 int zerun = 1;
2424
2425 while ((im < iM) && (zerun < LONGEST_LONG_RUN)) {
2426 if (hufLength(hcode[im + 1]) > 0) break;
2427 im++;
2428 zerun++;
2429 }
2430
2431 if (zerun >= 2) {
2432 if (zerun >= SHORTEST_LONG_RUN) {
2433 outputBits(6, LONG_ZEROCODE_RUN, c, lc, p);
2434 outputBits(8, zerun - SHORTEST_LONG_RUN, c, lc, p);
2435 } else {
2436 outputBits(6, SHORT_ZEROCODE_RUN + zerun - 2, c, lc, p);
2437 }
2438 continue;
2439 }
2440 }
2441
2442 outputBits(6, l, c, lc, p);
2443 }
2444
2445 if (lc > 0) *p++ = (unsigned char)(c << (8 - lc));
2446
2447 *pcode = p;
2448}
2449
2450//
2451// Unpack an encoding table packed by hufPackEncTable():

Callers 1

hufCompressFunction · 0.85

Calls 2

hufLengthFunction · 0.85
outputBitsFunction · 0.85

Tested by

no test coverage detected