MCPcopy Create free account
hub / github.com/darktable-org/rawspeed / push

Method push

src/librawspeed/io/BitStream.h:79–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77struct BitStreamCacheRightInLeftOut : BitStreamCacheBase
78{
79 inline void push(uint64_t bits, uint32_t count) noexcept {
80 assert(count + fillLevel <= Size);
81 assert(count != 0);
82 // If the maximal size of the cache is BitStreamCacheBase::Size, and we
83 // have fillLevel [high] bits set, how many empty [low] bits do we have?
84 const uint32_t vacantBits = BitStreamCacheBase::Size - fillLevel;
85 // If we just directly 'or' these low bits into the cache right now,
86 // how many unfilled bits of a gap will there be in the middle of a cache?
87 const uint32_t emptyBitsGap = vacantBits - count;
88 // So just shift the new bits so that there is no gap in the middle.
89 cache |= bits << emptyBitsGap;
90 fillLevel += count;
91 }
92
93 inline uint32_t peek(uint32_t count) const noexcept {
94 return extractHighBits(cache, count, /*effectiveBitwidth=*/BitStreamCacheBase::Size);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected