MCPcopy Create free account
hub / github.com/SheepChef/Abracadabra / encodeCount

Function encodeCount

src/javascript/unishox2.js:224–244  ·  view source on GitHub ↗
(out, olen, ol, count)

Source from the content-addressed store, hash-verified

222// First five bits are code and Last three bits of codes represent length
223const count_codes = new Uint8Array([0x01, 0x82, 0xc3, 0xe4, 0xf4]);
224function encodeCount(out, olen, ol, count) {
225 for (var i = 0; i < 5; i++) {
226 if (count < count_adder[i]) {
227 ol = append_bits(
228 out,
229 olen,
230 ol,
231 count_codes[i] & 0xf8,
232 count_codes[i] & 0x07
233 );
234 var count16 =
235 (count - (i > 0 ? count_adder[i - 1] : 0)) << (16 - count_bit_lens[i]);
236 if (count_bit_lens[i] > 8) {
237 ol = append_bits(out, olen, ol, count16 >> 8, 8);
238 ol = append_bits(out, olen, ol, count16 & 0xff, count_bit_lens[i] - 8);
239 } else ol = append_bits(out, olen, ol, count16 >> 8, count_bit_lens[i]);
240 return ol;
241 }
242 }
243 return ol;
244}
245
246const uni_bit_len = new Uint8Array([6, 12, 14, 16, 21]);
247const uni_adder = [0, 64, 4160, 20544, 86080];

Callers 3

matchOccuranceFunction · 0.85
matchLineFunction · 0.85
unishox2_compressFunction · 0.85

Calls 1

append_bitsFunction · 0.85

Tested by

no test coverage detected