| 220 | } |
| 221 | |
| 222 | uint32_t ReadVBR(unsigned NumBits) { |
| 223 | uint32_t Piece = Read(NumBits); |
| 224 | if ((Piece & (1U << (NumBits-1))) == 0) |
| 225 | return Piece; |
| 226 | |
| 227 | uint32_t Result = 0; |
| 228 | unsigned NextBit = 0; |
| 229 | while (true) { |
| 230 | Result |= (Piece & ((1U << (NumBits-1))-1)) << NextBit; |
| 231 | |
| 232 | if ((Piece & (1U << (NumBits-1))) == 0) |
| 233 | return Result; |
| 234 | |
| 235 | NextBit += NumBits-1; |
| 236 | Piece = Read(NumBits); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | // Read a VBR that may have a value up to 64-bits in size. The chunk size of |
| 241 | // the VBR must still be <= 32 bits though. |
no test coverage detected