| 164 | } |
| 165 | |
| 166 | void EncodeStream::writeEncodedUint64(uint64_t value) { |
| 167 | static const uint64_t valueMask = 127; |
| 168 | static const uint8_t hasNext = 128; |
| 169 | uint8_t byte = 0; |
| 170 | for (int i = 0; i < 64; i += 7) { |
| 171 | byte = static_cast<uint8_t>(value & valueMask); |
| 172 | value >>= 7; |
| 173 | if (value > 0) { |
| 174 | byte |= hasNext; |
| 175 | } |
| 176 | if (!checkCapacity(1)) { |
| 177 | break; |
| 178 | } |
| 179 | bytes[_position++] = byte; |
| 180 | positionChanged(0); |
| 181 | if (value == 0) { |
| 182 | break; |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | void EncodeStream::writeBits(int32_t value, uint8_t numBits) { |
| 188 | auto data = static_cast<uint32_t>(value) << (33 - numBits); |