Go to the documentation of this file.
30 static inline uint32_t
uint_subs(uint32_t a, uint32_t b)
32 return (a >= b) ? a - b : 0;
41 static inline uint32_t
uint_adds(uint32_t a, uint32_t b) {
42 uint64_t sum = (uint64_t) a + (uint64_t) b;
43 return (uint32_t)(-(int32_t)(sum >> 32)) | (uint32_t) sum;
52 template<
typename T> uint32_t
ceildiv(T a, T b) {
54 return (uint32_t)((a + (uint64_t) b - 1) / b);
58 return (T)((a + ((uint64_t) 1 << b) - 1) >> b);
68 return (uint32_t)((a + ((uint64_t) 1 << b) - 1) >> b);
85 for (l = 0; a > 1; l++) {
98 #if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
99 int64_t temp = __emul(a, b);
101 int64_t temp = (int64_t) a * (int64_t) b;
104 assert((temp >> 13) <= (int64_t) 0x7FFFFFFF);
105 assert((temp >> 13) >= (-(int64_t) 0x7FFFFFFF - (int64_t) 1));
108 return (int32_t)(temp >> 13);
T floorlog2(uint32_t a)
Get logarithm of an integer and round downwards.
Definition: grok_intmath.h:83
static uint32_t uint_floordivpow2(uint32_t a, uint32_t b)
Divide an unsigned integer by a power of 2 and round downwards.
Definition: grok_intmath.h:75
T ceildivpow2(T a, uint32_t b)
Definition: grok_intmath.h:57
uint32_t ceildiv(T a, T b)
Divide an integer by another integer and round upwards.
Definition: grok_intmath.h:52
static uint32_t uint_subs(uint32_t a, uint32_t b)
Get the saturated difference of two unsigned integers.
Definition: grok_intmath.h:30
static int32_t int_fix_mul(int32_t a, int32_t b)
Multiply two fixed-point numbers.
Definition: grok_intmath.h:97
Copyright (C) 2016-2020 Grok Image Compression Inc.
Definition: BitIO.h:27
static uint32_t uint_adds(uint32_t a, uint32_t b)
Get the saturated sum of two unsigned integers.
Definition: grok_intmath.h:41
static uint32_t uint64_ceildivpow2(uint64_t a, uint32_t b)
Divide a 64-bit integer by a power of 2 and round upwards.
Definition: grok_intmath.h:67