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

Function write_bits

Source/astcenc_integer_sequence.cpp:446–464  ·  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

444 * @param[in,out] ptr The data pointer to write to.
445 */
446static inline void write_bits(
447 unsigned int value,
448 unsigned int bitcount,
449 unsigned int bitoffset,
450 uint8_t ptr[2]
451) {
452 unsigned int mask = (1 << bitcount) - 1;
453 value &= mask;
454 ptr += bitoffset >> 3;
455 bitoffset &= 7;
456 value <<= bitoffset;
457 mask <<= bitoffset;
458 mask = ~mask;
459
460 ptr[0] &= mask;
461 ptr[0] |= value;
462 ptr[1] &= mask >> 8;
463 ptr[1] |= value >> 8;
464}
465
466/**
467 * @brief Read up to 16 bits from two bytes.

Callers 1

encode_iseFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected