MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / hufPackEncTable

Function hufPackEncTable

Source/ThirdParty/tinyexr.h:2553–2592  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2551const int LONGEST_LONG_RUN = 255 + SHORTEST_LONG_RUN;
2552
2553static void hufPackEncTable(
2554 const long long *hcode, // i : encoding table [HUF_ENCSIZE]
2555 int im, // i : min hcode index
2556 int iM, // i : max hcode index
2557 char **pcode) // o: ptr to packed table (updated)
2558{
2559 char *p = *pcode;
2560 long long c = 0;
2561 int lc = 0;
2562
2563 for (; im <= iM; im++) {
2564 int l = hufLength(hcode[im]);
2565
2566 if (l == 0) {
2567 int zerun = 1;
2568
2569 while ((im < iM) && (zerun < LONGEST_LONG_RUN)) {
2570 if (hufLength(hcode[im + 1]) > 0) break;
2571 im++;
2572 zerun++;
2573 }
2574
2575 if (zerun >= 2) {
2576 if (zerun >= SHORTEST_LONG_RUN) {
2577 outputBits(6, LONG_ZEROCODE_RUN, c, lc, p);
2578 outputBits(8, zerun - SHORTEST_LONG_RUN, c, lc, p);
2579 } else {
2580 outputBits(6, SHORT_ZEROCODE_RUN + zerun - 2, c, lc, p);
2581 }
2582 continue;
2583 }
2584 }
2585
2586 outputBits(6, l, c, lc, p);
2587 }
2588
2589 if (lc > 0) *p++ = (unsigned char)(c << (8 - lc));
2590
2591 *pcode = p;
2592}
2593
2594//
2595// 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