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

Function read_bits1_to_9_fst

engine/dlib/src/basis/transcoder/basisu_transcoder.cpp:12151–12180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12149 }
12150
12151 static inline uint32_t read_bits1_to_9_fst(const uint8_t* pBuf, uint32_t& bit_offset, uint32_t codesize)
12152 {
12153 assert(codesize <= 9);
12154 if (!codesize)
12155 return 0;
12156 assert(bit_offset < 112);
12157
12158 if ((BASISD_IS_BIG_ENDIAN) || (!BASISD_USE_UNALIGNED_WORD_READS))
12159 {
12160 const uint8_t* pBytes = &pBuf[bit_offset >> 3U];
12161
12162 uint32_t byte_bit_offset = bit_offset & 7U;
12163
12164 uint32_t bits = pBytes[0] >> byte_bit_offset;
12165 uint32_t bits_read = basisu::minimum<int>(codesize, 8 - byte_bit_offset);
12166
12167 uint32_t bits_remaining = codesize - bits_read;
12168 if (bits_remaining)
12169 bits |= ((uint32_t)pBytes[1]) << bits_read;
12170
12171 bit_offset += codesize;
12172
12173 return bits & ((1U << codesize) - 1U);
12174 }
12175
12176 uint32_t byte_bit_offset = bit_offset & 7U;
12177 const uint16_t w = *(const uint16_t*)(&pBuf[bit_offset >> 3U]);
12178 bit_offset += codesize;
12179 return (w >> byte_bit_offset)& ((1U << codesize) - 1U);
12180 }
12181
12182 bool unpack_uastc(const uastc_block& blk, unpacked_uastc_block& unpacked, bool blue_contract_check, bool read_hints)
12183 {

Callers 1

unpack_uastcFunction · 0.85

Calls 1

assertFunction · 0.50

Tested by

no test coverage detected