| 223 | } |
| 224 | |
| 225 | std::tuple<uint64_t, std::string> SubByteReader::readNS(uint64_t maxVal) |
| 226 | { |
| 227 | if (maxVal == 0) |
| 228 | return {}; |
| 229 | |
| 230 | // FloorLog2 |
| 231 | uint64_t floorVal; |
| 232 | { |
| 233 | auto x = maxVal; |
| 234 | unsigned s = 0; |
| 235 | while (x != 0) |
| 236 | { |
| 237 | x = x >> 1; |
| 238 | s++; |
| 239 | } |
| 240 | floorVal = s - 1; |
| 241 | } |
| 242 | |
| 243 | auto w = floorVal + 1; |
| 244 | auto m = (uint64_t(1) << w) - maxVal; |
| 245 | |
| 246 | auto [v, coding] = this->readBits(w - 1); |
| 247 | if (v < m) |
| 248 | return {v, coding}; |
| 249 | |
| 250 | auto [extra_bit, extra_bit_coding] = this->readBits(1); |
| 251 | return {(v << 1) - m + extra_bit, coding + extra_bit_coding}; |
| 252 | } |
| 253 | |
| 254 | std::tuple<int64_t, std::string> SubByteReader::readSU(unsigned nrBits) |
| 255 | { |
no test coverage detected