| 115 | { |
| 116 | template <class T> |
| 117 | inline int ReadBitpacked(skr_binary_reader_t* reader, T& value, IntegerPackConfig<T> config) |
| 118 | { |
| 119 | SKR_ASSERT(config.min <= config.max); |
| 120 | SKR_ASSERT(reader->vread_bits); |
| 121 | if (!reader->vread_bits) |
| 122 | { |
| 123 | SKR_LOG_ERROR(u8"vread_bits is not implemented. falling back to vread"); |
| 124 | return reader->read(&value, sizeof(T)); |
| 125 | } |
| 126 | auto bits = 64 - skr::CountLeadingZeros64(config.max - config.min); |
| 127 | T compressed = 0; |
| 128 | int ret = reader->read_bits(&compressed, bits); |
| 129 | if (ret != 0) |
| 130 | return ret; |
| 131 | value = compressed + config.min; |
| 132 | return ret; |
| 133 | } |
| 134 | template <class T, class ScalarType> |
| 135 | inline int ReadBitpacked(skr_binary_reader_t* reader, T& value, VectorPackConfig<ScalarType> config) |
| 136 | { |