Go to the documentation of this file.
32 inline size_t to_power_of_two(
size_t v) {
if(v == 0)
return 0;
size_t r = 1;
while(r < v && r != 0xffffffff) r <<= 1;
return r; }
34 inline uint16_t
readULE16(
const uchar *addr) {
return (uint16_t)addr[1] << 8 | addr[0]; }
38 inline void writeULE16(
uchar *addr, uint16_t value) { addr[1] = value >> 8; addr[0] = (uint8_t)value; }
42 inline int16_t
readSLE16(
const uchar *addr) {
return (int16_t)addr[1] << 8 | addr[0]; }
46 inline void writeSLE16(
uchar *addr, int16_t value) { addr[1] = value >> 8; addr[0] = (int8_t)value; }
50 uint32_t
adler32(
const uint8_t *buffer,
size_t size);
55 double round(
double r);
58 T
clamp(T x, T min, T max) {
return std::max<T>(min, std::min<T>(x, max)); }
uint16_t readULE16(const uchar *addr)
bool is_power_of_two(size_t v)
void writeULE64(uchar *addr, uint64_t value)
void writeULE16(uchar *addr, uint16_t value)
int32_t readSLE32(const uchar *addr)
void writeULE32(uchar *addr, uint32_t value)
void writeSLE32(uchar *addr, int32_t value)
void writeSLE16(uchar *addr, int16_t value)
uint32_t adler32(const uint8_t *buffer, size_t size)
T clamp(T x, T min, T max)
uint64_t readULE64(const uchar *addr)
void writeSLE64(uchar *addr, int64_t value)
int64_t readSLE64(const uchar *addr)
long random_range(long min, long max)
size_t to_power_of_two(size_t v)
uint32_t readULE32(const uchar *addr)
int16_t readSLE16(const uchar *addr)