| 109 | } |
| 110 | |
| 111 | inline uint32_t read_bits32(const uint8_t* pBuf, uint32_t& bit_offset, uint32_t codesize) |
| 112 | { |
| 113 | assert(codesize <= 32); |
| 114 | uint32_t bits = 0; |
| 115 | uint32_t total_bits = 0; |
| 116 | |
| 117 | while (total_bits < codesize) |
| 118 | { |
| 119 | uint32_t byte_bit_offset = bit_offset & 7; |
| 120 | uint32_t bits_to_read = minimum<int>(codesize - total_bits, 8 - byte_bit_offset); |
| 121 | |
| 122 | uint32_t byte_bits = pBuf[bit_offset >> 3] >> byte_bit_offset; |
| 123 | byte_bits &= ((1 << bits_to_read) - 1); |
| 124 | |
| 125 | bits |= (byte_bits << total_bits); |
| 126 | |
| 127 | total_bits += bits_to_read; |
| 128 | bit_offset += bits_to_read; |
| 129 | } |
| 130 | |
| 131 | return bits; |
| 132 | } |
| 133 | |
| 134 | // Hashing |
| 135 |
no test coverage detected