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

Function hufEncode

tutorials/common/image/tinyexr.h:2737–2778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2735//
2736
2737static int hufEncode // return: output size (in bits)
2738 (const long long *hcode, // i : encoding table
2739 const unsigned short *in, // i : uncompressed input buffer
2740 const int ni, // i : input buffer size (in bytes)
2741 int rlc, // i : rl code
2742 char *out) // o: compressed output buffer
2743{
2744 char *outStart = out;
2745 long long c = 0; // bits not yet written to out
2746 int lc = 0; // number of valid bits in c (LSB)
2747 int s = in[0];
2748 int cs = 0;
2749
2750 //
2751 // Loop on input values
2752 //
2753
2754 for (int i = 1; i < ni; i++) {
2755 //
2756 // Count same values or send code
2757 //
2758
2759 if (s == in[i] && cs < 255) {
2760 cs++;
2761 } else {
2762 sendCode(hcode[s], cs, hcode[rlc], c, lc, out);
2763 cs = 0;
2764 }
2765
2766 s = in[i];
2767 }
2768
2769 //
2770 // Send remaining code
2771 //
2772
2773 sendCode(hcode[s], cs, hcode[rlc], c, lc, out);
2774
2775 if (lc) *out = (c << (8 - lc)) & 0xff;
2776
2777 return (out - outStart) * 8 + lc;
2778}
2779
2780//
2781// DECODING

Callers 1

hufCompressFunction · 0.85

Calls 1

sendCodeFunction · 0.85

Tested by

no test coverage detected