MCPcopy Create free account
hub / github.com/ElementsProject/elements / GolombRiceEncode

Function GolombRiceEncode

src/util/golombrice.h:15–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13
14template <typename OStream>
15void GolombRiceEncode(BitStreamWriter<OStream>& bitwriter, uint8_t P, uint64_t x)
16{
17 // Write quotient as unary-encoded: q 1's followed by one 0.
18 uint64_t q = x >> P;
19 while (q > 0) {
20 int nbits = q <= 64 ? static_cast<int>(q) : 64;
21 bitwriter.Write(~0ULL, nbits);
22 q -= nbits;
23 }
24 bitwriter.Write(0, 1);
25
26 // Write the remainder in P bits. Since the remainder is just the bottom
27 // P bits of x, there is no need to mask first.
28 bitwriter.Write(x, P);
29}
30
31template <typename IStream>
32uint64_t GolombRiceDecode(BitStreamReader<IStream>& bitreader, uint8_t P)

Callers 2

GCSFilterMethod · 0.85
FUZZ_TARGETFunction · 0.85

Calls 1

WriteMethod · 0.45

Tested by 1

FUZZ_TARGETFunction · 0.68