MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / astc_set_bits

Function astc_set_bits

external/basisu/transcoder/basisu_transcoder.cpp:5082–5096  ·  view source on GitHub ↗

Writes bits to output in an endian safe way

Source from the content-addressed store, hash-verified

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)

Callers 8

astc_encode_tritsFunction · 0.85
pack_astc_solid_blockFunction · 0.85
astc_encode_quintsFunction · 0.85
pack_astc_blockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected