mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 08:38:14 +01:00
Add some base.rect_ie_u32 methods
This commit is contained in:
1 parent
ff618dd6ae
commit
0aeb589033
12 files changed
+482
-20
No files matched your search
@@ -243,6 +243,66 @@ static inline void wuffs_base__u64__sat_sub_indirect(uint64_t* x, uint64_t y) {
|
||||
*x = wuffs_base__u64__sat_sub(*x, y);
|
||||
}
|
||||
|
||||
// ---------------- Ranges and Rects
|
||||
|
||||
static inline wuffs_base__empty_struct
|
||||
wuffs_base__rect_ii_u32__set_min_inclusive_x(wuffs_base__rect_ii_u32* r,
|
||||
uint32_t x) {
|
||||
r->min_inclusive_x = x;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct
|
||||
wuffs_base__rect_ii_u32__set_min_inclusive_y(wuffs_base__rect_ii_u32* r,
|
||||
uint32_t y) {
|
||||
r->min_inclusive_y = y;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct
|
||||
wuffs_base__rect_ii_u32__set_max_inclusive_x(wuffs_base__rect_ii_u32* r,
|
||||
uint32_t x) {
|
||||
r->max_inclusive_x = x;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct
|
||||
wuffs_base__rect_ii_u32__set_max_inclusive_y(wuffs_base__rect_ii_u32* r,
|
||||
uint32_t y) {
|
||||
r->max_inclusive_y = y;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
static inline wuffs_base__empty_struct
|
||||
wuffs_base__rect_ie_u32__set_min_inclusive_x(wuffs_base__rect_ie_u32* r,
|
||||
uint32_t x) {
|
||||
r->min_inclusive_x = x;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct
|
||||
wuffs_base__rect_ie_u32__set_min_inclusive_y(wuffs_base__rect_ie_u32* r,
|
||||
uint32_t y) {
|
||||
r->min_inclusive_y = y;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct
|
||||
wuffs_base__rect_ie_u32__set_max_exclusive_x(wuffs_base__rect_ie_u32* r,
|
||||
uint32_t x) {
|
||||
r->max_exclusive_x = x;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct
|
||||
wuffs_base__rect_ie_u32__set_max_exclusive_y(wuffs_base__rect_ie_u32* r,
|
||||
uint32_t y) {
|
||||
r->max_exclusive_y = y;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
// ---------------- I/O
|
||||
|
||||
static inline bool wuffs_base__io_buffer__is_valid(wuffs_base__io_buffer buf) {
|
||||
|
||||
@@ -96,6 +96,10 @@ const baseImpl = "" +
|
||||
"" +
|
||||
"// --------\n\nstatic inline void wuffs_base__u8__sat_add_indirect(uint8_t* x, uint8_t y) {\n *x = wuffs_base__u8__sat_add(*x, y);\n}\n\nstatic inline void wuffs_base__u8__sat_sub_indirect(uint8_t* x, uint8_t y) {\n *x = wuffs_base__u8__sat_sub(*x, y);\n}\n\nstatic inline void wuffs_base__u16__sat_add_indirect(uint16_t* x, uint16_t y) {\n *x = wuffs_base__u16__sat_add(*x, y);\n}\n\nstatic inline void wuffs_base__u16__sat_sub_indirect(uint16_t* x, uint16_t y) {\n *x = wuffs_base__u16__sat_sub(*x, y);\n}\n\nstatic inline void wuffs_base__u32__sat_add_indirect(uint32_t* x, uint32_t y) {\n *x = wuffs_base__u32__sat_add(*x, y);\n}\n\nstatic inline void wuffs_base__u32__sat_sub_indirect(uint32_t* x, uint32_t y) {\n *x = wuffs_base__u32__sat_sub(*x, y);\n}\n\nstatic inline void wuffs_base__u64__sat_add_indirect(uint64_t* x, uint64_t y) {\n *x = wuffs_base__u64__sat_add(*x, y);\n}\n\nstatic inline void wuffs_base__u64__sat_sub_indirect(uint64_t* x, uint64_t y) {\n *x = wuffs_base__u64__sat_sub(*x, y);\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Ranges and Rects\n\nstatic inline wuffs_base__empty_struct\nwuffs_base__rect_ii_u32__set_min_inclusive_x(wuffs_base__rect_ii_u32* r,\n uint32_t x) {\n r->min_inclusive_x = x;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct\nwuffs_base__rect_ii_u32__set_min_inclusive_y(wuffs_base__rect_ii_u32* r,\n uint32_t y) {\n r->min_inclusive_y = y;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct\nwuffs_base__rect_ii_u32__set_max_inclusive_x(wuffs_base__rect_ii_u32* r,\n uint32_t x) {\n r->max_inclusive_x = x;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct\nwuffs_base__rect_ii_u32__set_max_inclusive_y(wuffs_base__rect_ii_u32* r,\n uint32_t y) {\n r->max_inclusive_y = y;\n return ((wuffs_base__empty_struct){});\n}\n\n" +
|
||||
"" +
|
||||
"// --------\n\nstatic inline wuffs_base__empty_struct\nwuffs_base__rect_ie_u32__set_min_inclusive_x(wuffs_base__rect_ie_u32* r,\n uint32_t x) {\n r->min_inclusive_x = x;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct\nwuffs_base__rect_ie_u32__set_min_inclusive_y(wuffs_base__rect_ie_u32* r,\n uint32_t y) {\n r->min_inclusive_y = y;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct\nwuffs_base__rect_ie_u32__set_max_exclusive_x(wuffs_base__rect_ie_u32* r,\n uint32_t x) {\n r->max_exclusive_x = x;\n return ((wuffs_base__empty_struct){});\n}\n\nstatic inline wuffs_base__empty_struct\nwuffs_base__rect_ie_u32__set_max_exclusive_y(wuffs_base__rect_ie_u32* r,\n uint32_t y) {\n r->max_exclusive_y = y;\n return ((wuffs_base__empty_struct){});\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- I/O\n\nstatic inline bool wuffs_base__io_buffer__is_valid(wuffs_base__io_buffer buf) {\n return (buf.ptr || (buf.len == 0)) && (buf.len >= buf.wi) &&\n (buf.wi >= buf.ri);\n}\n\nstatic inline bool wuffs_base__io_reader__is_eof(wuffs_base__io_reader o) {\n wuffs_base__io_buffer* buf = o.private_impl.buf;\n return buf && buf->closed && (buf->ptr + buf->wi == o.private_impl.bounds[1]);\n}\n\nstatic inline bool wuffs_base__io_reader__is_valid(wuffs_base__io_reader o) {\n wuffs_base__io_buffer* buf = o.private_impl.buf;\n // Note: if making this function public (i.e. moving it to base-header.h), it\n // also needs to allow NULL (i.e. implicit, callee-calculated) bounds.\n return buf ? ((buf->ptr <= o.private_impl.bounds[0]) &&\n (o.private_impl.bounds[0] <= o.private_impl.bounds[1]) &&\n (o.private_impl.bounds[1] <= buf->ptr + buf->len))\n : ((o.private_impl.bounds[0] == NULL) &&\n (o.private_impl.bounds[1] == NULL));\n}\n\nstatic inline bool wuf" +
|
||||
"fs_base__io_writer__is_valid(wuffs_base__io_writer o) {\n wuffs_base__io_buffer* buf = o.private_impl.buf;\n // Note: if making this function public (i.e. moving it to base-header.h), it\n // also needs to allow NULL (i.e. implicit, callee-calculated) bounds.\n return buf ? ((buf->ptr <= o.private_impl.bounds[0]) &&\n (o.private_impl.bounds[0] <= o.private_impl.bounds[1]) &&\n (o.private_impl.bounds[1] <= buf->ptr + buf->len))\n : ((o.private_impl.bounds[0] == NULL) &&\n (o.private_impl.bounds[1] == NULL));\n}\n\nstatic inline uint32_t wuffs_base__io_writer__copy_from_history32(\n uint8_t** ptr_ptr,\n uint8_t* start,\n uint8_t* end,\n uint32_t distance,\n uint32_t length) {\n if (!distance) {\n return 0;\n }\n uint8_t* ptr = *ptr_ptr;\n if ((size_t)(ptr - start) < (size_t)(distance)) {\n return 0;\n }\n start = ptr - distance;\n size_t n = end - ptr;\n if ((size_t)(length) > n) {\n length = n;\n } else {\n n = length;\n }\n // TODO: unrolling" +
|
||||
" by 3 seems best for the std/deflate benchmarks, but that\n // is mostly because 3 is the minimum length for the deflate format. This\n // function implementation shouldn't overfit to that one format. Perhaps the\n // copy_from_history32 Wuffs method should also take an unroll hint argument,\n // and the cgen can look if that argument is the constant expression '3'.\n //\n // See also wuffs_base__io_writer__copy_from_history32__bco below.\n //\n // Alternatively, or additionally, have a sloppy_copy_from_history32 method\n // that copies 8 bytes at a time, possibly writing more than length bytes?\n for (; n >= 3; n -= 3) {\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n }\n for (; n; n--) {\n *ptr++ = *start++;\n }\n *ptr_ptr = ptr;\n return length;\n}\n\n// wuffs_base__io_writer__copy_from_history32__bco is a Bounds Check Optimized\n// version of the wuffs_base__io_writer__copy_from_history32 function above.\n// The caller needs to prove that:\n// - distance > 0\n// - distance <= (*ptr_pt" +
|
||||
|
||||
Reference in new issue
Block a user