MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / write_bits

Function write_bits

Source/astcenc_symbolic_physical.cpp:81–99  ·  view source on GitHub ↗

* @brief Write 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 value The value to write. * @param bitcount The number of bits to write, starting from LSB. * @param bitoffset The bit offset to store at, between 0 and

Source from the content-addressed store, hash-verified

79 * @param[in,out] ptr The data pointer to write to.
80 */
81static inline void write_bits(
82 int value,
83 int bitcount,
84 int bitoffset,
85 uint8_t* ptr
86) {
87 int mask = (1 << bitcount) - 1;
88 value &= mask;
89 ptr += bitoffset >> 3;
90 bitoffset &= 7;
91 value <<= bitoffset;
92 mask <<= bitoffset;
93 mask = ~mask;
94
95 ptr[0] &= mask;
96 ptr[0] |= value;
97 ptr[1] &= mask >> 8;
98 ptr[1] |= value >> 8;
99}
100
101/* See header for documentation. */
102void symbolic_to_physical(

Callers 1

symbolic_to_physicalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected