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

Function hufBuildDecTable

Source/ThirdParty/tinyexr.h:2679–2761  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2677//
2678
2679static bool hufBuildDecTable(const long long *hcode, // i : encoding table
2680 int im, // i : min index in hcode
2681 int iM, // i : max index in hcode
2682 HufDec *hdecod) // o: (allocated by caller)
2683// decoding table [HUF_DECSIZE]
2684{
2685 //
2686 // Init hashtable & loop on all codes.
2687 // Assumes that hufClearDecTable(hdecod) has already been called.
2688 //
2689
2690 for (; im <= iM; im++) {
2691 long long c = hufCode(hcode[im]);
2692 int l = hufLength(hcode[im]);
2693
2694 if (c >> l) {
2695 //
2696 // Error: c is supposed to be an l-bit code,
2697 // but c contains a value that is greater
2698 // than the largest l-bit number.
2699 //
2700
2701 // invalidTableEntry();
2702 return false;
2703 }
2704
2705 if (l > HUF_DECBITS) {
2706 //
2707 // Long code: add a secondary entry
2708 //
2709
2710 HufDec *pl = hdecod + (c >> (l - HUF_DECBITS));
2711
2712 if (pl->len) {
2713 //
2714 // Error: a short code has already
2715 // been stored in table entry *pl.
2716 //
2717
2718 // invalidTableEntry();
2719 return false;
2720 }
2721
2722 pl->lit++;
2723
2724 if (pl->p) {
2725 unsigned int *p = pl->p;
2726 pl->p = new unsigned int[pl->lit];
2727
2728 for (unsigned int i = 0; i < pl->lit - 1u; ++i) pl->p[i] = p[i];
2729
2730 delete[] p;
2731 } else {
2732 pl->p = new unsigned int[1];
2733 }
2734
2735 pl->p[pl->lit - 1] = im;
2736 } else if (l) {

Callers 1

hufUncompressFunction · 0.85

Calls 2

hufCodeFunction · 0.85
hufLengthFunction · 0.85

Tested by

no test coverage detected