| 19 | |
| 20 | template <class CHIMP_TYPE, bool EMPTY> |
| 21 | struct ChimpCompressionState { |
| 22 | |
| 23 | ChimpCompressionState() |
| 24 | : previous_leading_zeros(NumericLimits<uint8_t>::Maximum()) { |
| 25 | previous_value = 0; |
| 26 | } |
| 27 | |
| 28 | inline void SetLeadingZeros(int32_t value = NumericLimits<uint8_t>::Maximum()) { |
| 29 | this->previous_leading_zeros = value; |
| 30 | } |
| 31 | |
| 32 | void Flush() { leading_zero_buffer.Flush(); } |
| 33 | |
| 34 | // Reset the state |
| 35 | void Reset() { |
| 36 | first = true; |
| 37 | SetLeadingZeros(); |
| 38 | leading_zero_buffer.Reset(); |
| 39 | flag_buffer.Reset(); |
| 40 | previous_value = 0; |
| 41 | } |
| 42 | |
| 43 | CHIMP_TYPE BitsWritten() const { |
| 44 | return output.BitsWritten() + leading_zero_buffer.BitsWritten() + flag_buffer.BitsWritten(); |
| 45 | } |
| 46 | |
| 47 | OutputBitStream<EMPTY> output; // The stream to write to |
| 48 | LeadingZeroBuffer<EMPTY> leading_zero_buffer; |
| 49 | FlagBuffer<EMPTY> flag_buffer; |
| 50 | uint8_t previous_leading_zeros; //! The leading zeros of the reference value |
| 51 | CHIMP_TYPE previous_value = 0; |
| 52 | bool first = true; |
| 53 | }; |
| 54 | |
| 55 | template <class CHIMP_TYPE, bool EMPTY> |
| 56 | class ChimpCompression { |
nothing calls this directly
no outgoing calls
no test coverage detected