MCPcopy Create free account
hub / github.com/defold/defold / read_bits32

Function read_bits32

engine/dlib/src/basis/encoder/basisu_enc.h:111–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

unpack_bc7_mode0_2Function · 0.85
unpack_bc7_mode1_3_7Function · 0.85
unpack_bc7_mode4_5Function · 0.85

Calls 1

assertFunction · 0.50

Tested by

no test coverage detected