Go to the documentation of this file.
29 return (b && (a > UINT_MAX / b));
32 return (b && (a > UINT64_MAX / b));
68 std::cout <<
"[" <<
x0 <<
"," <<
y0 <<
"," <<
x1 <<
"," <<
y1 <<
"]"
91 temp.
x0 = std::max<T>(
x0, r2.
x0);
92 temp.
y0 = std::max<T>(
y0, r2.
y0);
94 temp.
x1 = std::min<T>(
x1, r2.
x1);
95 temp.
y1 = std::min<T>(
y1, r2.
y1);
158 std::max<T>(
y0,rhs.
y0),
159 std::min<T>(
x1,rhs.
x1),
160 std::min<T>(
y1,rhs.
y1));
164 return (uint64_t)(
x1 -
x0) * (
y1 -
y0);
191 return grow(boundary, boundary);
206 using grk_rect = grk_rectangle<int64_t>;
211 grk_buffer(T *buffer,
size_t off,
size_t length,
bool ownsData) :
buf(buffer),
232 if (
offset > (
size_t)(SIZE_MAX - (
size_t)off)){
237 GROK_WARN(
"grk_buf: attempt to increment buffer offset out of bounds");
245 if (
offset < (
size_t)(-off)) {
295 uint64_t data_size_needed =
stride *
height() *
sizeof(T);
296 if (!data_size_needed)
302 memset(
data, 0, data_size_needed);
326 void transfer(T** buffer,
bool* owns, uint32_t *strd){
grk_rectangle< T > & subsample(uint32_t dx, uint32_t dy)
Definition: util.h:183
grk_buffer(T *buffer, size_t length, bool ownsData)
Definition: util.h:217
grk_rect_u32 to_u32()
Definition: util.h:62
void transfer(T **buffer, bool *owns, uint32_t *strd)
Definition: util.h:326
grk_rectangle< T > & rectceildivpow2(uint32_t power)
Definition: util.h:136
virtual ~grk_buffer_2d()
Definition: util.h:287
void grk_aligned_free(void *ptr)
grk_buffer(T *buffer, size_t off, size_t length, bool ownsData)
Definition: util.h:211
bool mult_will_overflow(uint32_t a, uint32_t b)
Definition: util.h:28
virtual ~grk_buffer()
Definition: util.h:220
grk_rectangle< T > & pan(T x, T y)
Definition: util.h:175
size_t offset
Definition: util.h:263
bool owns_data
Definition: util.h:337
grk_rectangle< T > & operator-=(const grk_rectangle< T > &rhs)
Definition: util.h:126
void acquire(T *buffer, uint32_t strd)
Definition: util.h:318
bool is_non_degenerate(void)
Definition: util.h:80
grk_rectangle(T x0, T y0, T x1, T y1)
Definition: util.h:54
grk_rectangle< T > & grow(T boundaryx, T boundaryy)
Definition: util.h:194
grk_rectangle< int64_t > grk_rect
Definition: util.h:45
grk_buffer_2d(uint32_t w, uint32_t h)
Definition: util.h:281
void attach(T *buffer, uint32_t strd)
Definition: util.h:310
bool clip(grk_rectangle< T > &r2, grk_rectangle< T > *result)
Definition: util.h:84
bool alloc(bool clear)
Definition: util.h:292
T ceildivpow2(T a, uint32_t b)
Definition: grok_intmath.h:57
T x1
Definition: util.h:51
grk_rectangle< T > intersection(const grk_rectangle< T > &rhs)
Definition: util.h:156
uint32_t ceildiv(T a, T b)
Divide an integer by another integer and round upwards.
Definition: grok_intmath.h:52
bool owns_data
Definition: util.h:265
grk_buffer_2d(T *buffer, bool ownsData, uint32_t w, uint32_t h)
Definition: util.h:277
grk_rectangle(const grk_rectangle &rhs)
Definition: util.h:58
T * curr_ptr()
Definition: util.h:255
uint32_t grk_make_aligned_width(uint32_t width)
uint64_t area(void)
Definition: util.h:163
grk_point(T _x, T _y)
Definition: util.h:37
grk_rectangle< T > & grow(T boundary)
Definition: util.h:190
T * buf
Definition: util.h:262
void print(void)
Definition: util.h:67
void GROK_WARN(const char *fmt,...)
grk_buffer_2d(void)
Definition: util.h:285
grk_point()
Definition: util.h:36
uint32_t stride
Definition: util.h:338
T height()
Definition: util.h:170
grk_rectangle< T > & operator-(const grk_rectangle< T > &rhs)
Definition: util.h:117
Copyright (C) 2016-2020 Grok Image Compression Inc.
Definition: BitIO.h:27
size_t len
Definition: util.h:264
grk_rectangle< uint32_t > grk_rect_u32
Definition: util.h:46
grk_rectangle< T > & mulpow2(uint32_t power)
Definition: util.h:146
void incr_offset(ptrdiff_t off)
Definition: util.h:229
T width()
Definition: util.h:167
grk_buffer_2d(uint32_t w, uint32_t strd, uint32_t h)
Definition: util.h:279
void * grk_aligned_malloc(size_t size)
Allocate memory aligned to a 16 byte boundary.
T * data
Definition: util.h:336
grk_rectangle< T > & operator=(const grk_rectangle< T > &rhs)
Definition: util.h:104
T x0
Definition: util.h:49
T y1
Definition: util.h:52
bool mult64_will_overflow(uint64_t a, uint64_t b)
Definition: util.h:31
grk_buffer_2d(T *buffer, bool ownsData, uint32_t w, uint32_t strd, uint32_t h)
Definition: util.h:272
grk_buffer_2d(grk_rect_u32 b)
Definition: util.h:283
T y0
Definition: util.h:50
bool is_valid(void)
Definition: util.h:76
grk_rectangle(void)
Definition: util.h:72