* @brief Read up to 8 bits at an arbitrary bit offset. * * The stored value is at most 8 bits, but can be stored at an offset of between 0 and 7 bits so may * span two separate bytes in memory. * * @param bitcount The number of bits to read. * @param bitoffset The bit offset to read from, between 0 and 7. * @param[in,out] ptr The data pointer to read from. * *
| 52 | * @return The read value. |
| 53 | */ |
| 54 | static inline int read_bits( |
| 55 | int bitcount, |
| 56 | int bitoffset, |
| 57 | const uint8_t* ptr |
| 58 | ) { |
| 59 | int mask = (1 << bitcount) - 1; |
| 60 | ptr += bitoffset >> 3; |
| 61 | bitoffset &= 7; |
| 62 | int value = ptr[0] | (ptr[1] << 8); |
| 63 | value >>= bitoffset; |
| 64 | value &= mask; |
| 65 | return value; |
| 66 | } |
| 67 | |
| 68 | #if !defined(ASTCENC_DECOMPRESS_ONLY) |
| 69 |
no outgoing calls
no test coverage detected