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

Function hufBuildDecTable

tutorials/common/image/tinyexr.h:2609–2691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2607//
2608
2609static bool hufBuildDecTable(const long long *hcode, // i : encoding table
2610 int im, // i : min index in hcode
2611 int iM, // i : max index in hcode
2612 HufDec *hdecod) // o: (allocated by caller)
2613// decoding table [HUF_DECSIZE]
2614{
2615 //
2616 // Init hashtable & loop on all codes.
2617 // Assumes that hufClearDecTable(hdecod) has already been called.
2618 //
2619
2620 for (; im <= iM; im++) {
2621 long long c = hufCode(hcode[im]);
2622 int l = hufLength(hcode[im]);
2623
2624 if (c >> l) {
2625 //
2626 // Error: c is supposed to be an l-bit code,
2627 // but c contains a value that is greater
2628 // than the largest l-bit number.
2629 //
2630
2631 // invalidTableEntry();
2632 return false;
2633 }
2634
2635 if (l > HUF_DECBITS) {
2636 //
2637 // Long code: add a secondary entry
2638 //
2639
2640 HufDec *pl = hdecod + (c >> (l - HUF_DECBITS));
2641
2642 if (pl->len) {
2643 //
2644 // Error: a short code has already
2645 // been stored in table entry *pl.
2646 //
2647
2648 // invalidTableEntry();
2649 return false;
2650 }
2651
2652 pl->lit++;
2653
2654 if (pl->p) {
2655 unsigned int *p = pl->p;
2656 pl->p = new unsigned int[pl->lit];
2657
2658 for (unsigned int i = 0; i < pl->lit - 1u; ++i) pl->p[i] = p[i];
2659
2660 delete[] p;
2661 } else {
2662 pl->p = new unsigned int[1];
2663 }
2664
2665 pl->p[pl->lit - 1] = im;
2666 } else if (l) {

Callers 1

hufUncompressFunction · 0.85

Calls 2

hufCodeFunction · 0.85
hufLengthFunction · 0.85

Tested by

no test coverage detected