MCPcopy Create free account
hub / github.com/RenderKit/embree / hufPackEncTable

Function hufPackEncTable

tutorials/common/image/tinyexr.h:2483–2522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2481const int LONGEST_LONG_RUN = 255 + SHORTEST_LONG_RUN;
2482
2483static void hufPackEncTable(
2484 const long long *hcode, // i : encoding table [HUF_ENCSIZE]
2485 int im, // i : min hcode index
2486 int iM, // i : max hcode index
2487 char **pcode) // o: ptr to packed table (updated)
2488{
2489 char *p = *pcode;
2490 long long c = 0;
2491 int lc = 0;
2492
2493 for (; im <= iM; im++) {
2494 int l = hufLength(hcode[im]);
2495
2496 if (l == 0) {
2497 int zerun = 1;
2498
2499 while ((im < iM) && (zerun < LONGEST_LONG_RUN)) {
2500 if (hufLength(hcode[im + 1]) > 0) break;
2501 im++;
2502 zerun++;
2503 }
2504
2505 if (zerun >= 2) {
2506 if (zerun >= SHORTEST_LONG_RUN) {
2507 outputBits(6, LONG_ZEROCODE_RUN, c, lc, p);
2508 outputBits(8, zerun - SHORTEST_LONG_RUN, c, lc, p);
2509 } else {
2510 outputBits(6, SHORT_ZEROCODE_RUN + zerun - 2, c, lc, p);
2511 }
2512 continue;
2513 }
2514 }
2515
2516 outputBits(6, l, c, lc, p);
2517 }
2518
2519 if (lc > 0) *p++ = (unsigned char)(c << (8 - lc));
2520
2521 *pcode = p;
2522}
2523
2524//
2525// 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