6#include "TTauri/Foundation/exceptions.hpp"
17[[nodiscard]]
inline bool get_bit(nonstd::span<std::byte const> buffer, ssize_t &index)
noexcept
19 auto byte_index = index >> 3;
20 auto bit_index =
static_cast<uint8_t
>(index & 7);
23 tt_assume(byte_index < ssize(buffer));
24 return static_cast<bool>(
25 static_cast<int>(buffer[byte_index] >> bit_index) & 1
46[[nodiscard]]
inline int get_bits(nonstd::span<std::byte const> buffer, ssize_t &index,
int length)
noexcept
53 auto byte_index = index >> 3;
54 auto bit_index =
static_cast<int>(index & 7);
55 tt_assume(byte_index < ssize(buffer));
57 auto available_bits = 8 - bit_index;
58 auto nr_bits =
std::min(available_bits, todo);
60 auto mask = (1 << nr_bits) - 1;
62 auto tmp =
static_cast<int>(buffer[byte_index] >> bit_index) & mask;