16#ifndef RANS_INTERNAL_PACK_DICTCOMPRESSION_H_
17#define RANS_INTERNAL_PACK_DICTCOMPRESSION_H_
30template <
typename buffer_IT>
33 using value_type = uint64_t;
36 for (buffer_IT iter =
end; iter-- != begin;) {
37 auto value =
static_cast<value_type
>(*iter);
49 assert(iter >= begin);
55template <
typename source_T>
65 template <
typename buffer_IT>
69 [[nodiscard]]
bool hasNext()
const;
74 template <
typename buffer_IT>
75 [[nodiscard]]
BitPtr seekStreamEnd(buffer_IT begin, buffer_IT
end)
const;
85template <
typename source_T>
86template <
typename buffer_IT>
89 static_assert(std::is_pointer_v<buffer_IT>,
"can only deserialize from raw pointers");
93 throw ParsingError{
"failed to read renormed dictionary: could not find end of data stream"};
95 if (decodeNext() != 1) {
96 throw ParsingError{
"failed to read renormed dictionary: could not find end of stream delimiter"};
98 mIncompressibleSymbolFrequency = decodeNext() - 1;
101template <
typename source_T>
102template <
typename buffer_IT>
105 using value_type = uint64_t;
106 assert(
end >= begin);
108 for (buffer_IT iter =
end; iter-- != begin;) {
109 auto value =
static_cast<value_type
>(*iter);
119template <
typename source_T>
120[[nodiscard]]
inline auto DictionaryStreamParser<source_T>::decodeNext() -> count_type
122 assert(mPos >= mEnd);
124 return eliasDeltaDecode<count_type>(mPos, delta);
127template <
typename source_T>
130 return mIncompressibleSymbolFrequency;
133template <
typename source_T>
136 assert(mPos >= mEnd);
140template <
typename source_T>
147 frequency = decodeNext();
150 const auto offset = decodeNext();
151 frequency = decodeNext();
154 return {mIndex, frequency};
common helper classes and functions
DictionaryStreamParser(buffer_IT begin, buffer_IT end, source_type max)
source_type getIndex() const noexcept
std::ptrdiff_t difference_type
count_type getIncompressibleSymbolFrequency() const
std::pair< source_type, count_type > value_type
compress data stream using Elias-Delta coding.
GLsizei const GLfloat * value
constexpr intptr_t getEliasDeltaOffset(BitPtr begin, BitPtr iter)
constexpr BitPtr seekEliasDeltaEnd(buffer_IT begin, buffer_IT end)
constexpr size_t EliasDeltaDecodeMaxBits