| 12096 | } |
| 12097 | |
| 12098 | static inline uint32_t read_bits1_to_9(const uint8_t* pBuf, uint32_t& bit_offset, uint32_t codesize) |
| 12099 | { |
| 12100 | assert(codesize <= 9); |
| 12101 | if (!codesize) |
| 12102 | return 0; |
| 12103 | |
| 12104 | if ((BASISD_IS_BIG_ENDIAN) || (!BASISD_USE_UNALIGNED_WORD_READS) || (bit_offset >= 112)) |
| 12105 | { |
| 12106 | const uint8_t* pBytes = &pBuf[bit_offset >> 3U]; |
| 12107 | |
| 12108 | uint32_t byte_bit_offset = bit_offset & 7U; |
| 12109 | |
| 12110 | uint32_t bits = pBytes[0] >> byte_bit_offset; |
| 12111 | uint32_t bits_read = basisu::minimum<int>(codesize, 8 - byte_bit_offset); |
| 12112 | |
| 12113 | uint32_t bits_remaining = codesize - bits_read; |
| 12114 | if (bits_remaining) |
| 12115 | bits |= ((uint32_t)pBytes[1]) << bits_read; |
| 12116 | |
| 12117 | bit_offset += codesize; |
| 12118 | |
| 12119 | return bits & ((1U << codesize) - 1U); |
| 12120 | } |
| 12121 | |
| 12122 | uint32_t byte_bit_offset = bit_offset & 7U; |
| 12123 | const uint16_t w = *(const uint16_t *)(&pBuf[bit_offset >> 3U]); |
| 12124 | bit_offset += codesize; |
| 12125 | return (w >> byte_bit_offset) & ((1U << codesize) - 1U); |
| 12126 | } |
| 12127 | |
| 12128 | inline uint64_t read_bits64(const uint8_t* pBuf, uint32_t& bit_offset, uint32_t codesize) |
| 12129 | { |
no test coverage detected