Writes bits to output in an endian safe way
| 5080 | |
| 5081 | // Writes bits to output in an endian safe way |
| 5082 | static inline void astc_set_bits(uint32_t* pOutput, int& bit_pos, uint32_t value, uint32_t total_bits) |
| 5083 | { |
| 5084 | uint8_t* pBytes = reinterpret_cast<uint8_t*>(pOutput); |
| 5085 | |
| 5086 | while (total_bits) |
| 5087 | { |
| 5088 | const uint32_t bits_to_write = basisu::minimum<int>(total_bits, 8 - (bit_pos & 7)); |
| 5089 | |
| 5090 | pBytes[bit_pos >> 3] |= static_cast<uint8_t>(value << (bit_pos & 7)); |
| 5091 | |
| 5092 | bit_pos += bits_to_write; |
| 5093 | total_bits -= bits_to_write; |
| 5094 | value >>= bits_to_write; |
| 5095 | } |
| 5096 | } |
| 5097 | |
| 5098 | // Encodes 5 values to output, usable for any range that uses trits and bits |
| 5099 | static void astc_encode_trits(uint32_t* pOutput, const uint8_t* pValues, int& bit_pos, int n) |
no outgoing calls
no test coverage detected