mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +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" +
|
||||
|
||||
@@ -1419,6 +1419,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) {
|
||||
|
||||
@@ -1418,6 +1418,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) {
|
||||
|
||||
@@ -1510,6 +1510,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) {
|
||||
|
||||
+80
-8
@@ -1198,10 +1198,6 @@ typedef struct {
|
||||
bool f_seen_num_loops;
|
||||
uint32_t f_num_loops;
|
||||
wuffs_base__rect_ie_u32 f_frame_rect;
|
||||
uint32_t f_frame_top;
|
||||
uint32_t f_frame_left;
|
||||
uint32_t f_frame_width;
|
||||
uint32_t f_frame_height;
|
||||
uint32_t f_uncompressed_ri;
|
||||
uint32_t f_uncompressed_wi;
|
||||
uint8_t f_uncompressed[4096];
|
||||
@@ -1245,6 +1241,8 @@ typedef struct {
|
||||
} c_decode_ae[1];
|
||||
struct {
|
||||
uint32_t coro_susp_point;
|
||||
uint32_t v_frame_x;
|
||||
uint32_t v_frame_y;
|
||||
uint8_t v_flags;
|
||||
uint32_t v_lct_size;
|
||||
uint32_t v_i;
|
||||
@@ -1535,6 +1533,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) {
|
||||
@@ -2755,6 +2813,8 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
||||
wuffs_base__io_reader a_src) {
|
||||
wuffs_gif__status status = WUFFS_GIF__STATUS_OK;
|
||||
|
||||
uint32_t v_frame_x;
|
||||
uint32_t v_frame_y;
|
||||
uint8_t v_flags;
|
||||
uint32_t v_lct_size;
|
||||
uint32_t v_i;
|
||||
@@ -2809,6 +2869,8 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.c_decode_id[0].coro_susp_point;
|
||||
if (coro_susp_point) {
|
||||
v_frame_x = self->private_impl.c_decode_id[0].v_frame_x;
|
||||
v_frame_y = self->private_impl.c_decode_id[0].v_frame_y;
|
||||
v_flags = self->private_impl.c_decode_id[0].v_flags;
|
||||
v_lct_size = self->private_impl.c_decode_id[0].v_lct_size;
|
||||
v_i = self->private_impl.c_decode_id[0].v_i;
|
||||
@@ -2855,7 +2917,7 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
||||
self->private_impl.c_decode_id[0].scratch |= ((uint64_t)(t_0)) << 56;
|
||||
}
|
||||
}
|
||||
self->private_impl.f_frame_left = ((uint32_t)(t_1));
|
||||
v_frame_x = ((uint32_t)(t_1));
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
@@ -2883,8 +2945,12 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
||||
self->private_impl.c_decode_id[0].scratch |= ((uint64_t)(t_2)) << 56;
|
||||
}
|
||||
}
|
||||
self->private_impl.f_frame_top = ((uint32_t)(t_3));
|
||||
v_frame_y = ((uint32_t)(t_3));
|
||||
}
|
||||
wuffs_base__rect_ie_u32__set_min_inclusive_x(
|
||||
&self->private_impl.f_frame_rect, v_frame_x);
|
||||
wuffs_base__rect_ie_u32__set_min_inclusive_y(
|
||||
&self->private_impl.f_frame_rect, v_frame_y);
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
uint16_t t_5;
|
||||
@@ -2911,7 +2977,7 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
||||
self->private_impl.c_decode_id[0].scratch |= ((uint64_t)(t_4)) << 56;
|
||||
}
|
||||
}
|
||||
self->private_impl.f_frame_width = ((uint32_t)(t_5));
|
||||
v_frame_x += ((uint32_t)(t_5));
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
@@ -2939,8 +3005,12 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
||||
self->private_impl.c_decode_id[0].scratch |= ((uint64_t)(t_6)) << 56;
|
||||
}
|
||||
}
|
||||
self->private_impl.f_frame_height = ((uint32_t)(t_7));
|
||||
v_frame_y += ((uint32_t)(t_7));
|
||||
}
|
||||
wuffs_base__rect_ie_u32__set_max_exclusive_x(
|
||||
&self->private_impl.f_frame_rect, v_frame_x);
|
||||
wuffs_base__rect_ie_u32__set_max_exclusive_y(
|
||||
&self->private_impl.f_frame_rect, v_frame_y);
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
if (WUFFS_BASE__UNLIKELY(ioptr_src == iobounds1_src)) {
|
||||
@@ -3115,6 +3185,8 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.c_decode_id[0].coro_susp_point = coro_susp_point;
|
||||
self->private_impl.c_decode_id[0].v_frame_x = v_frame_x;
|
||||
self->private_impl.c_decode_id[0].v_frame_y = v_frame_y;
|
||||
self->private_impl.c_decode_id[0].v_flags = v_flags;
|
||||
self->private_impl.c_decode_id[0].v_lct_size = v_lct_size;
|
||||
self->private_impl.c_decode_id[0].v_i = v_i;
|
||||
|
||||
@@ -1713,6 +1713,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) {
|
||||
|
||||
@@ -1713,6 +1713,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) {
|
||||
|
||||
+2
-4
@@ -1198,10 +1198,6 @@ typedef struct {
|
||||
bool f_seen_num_loops;
|
||||
uint32_t f_num_loops;
|
||||
wuffs_base__rect_ie_u32 f_frame_rect;
|
||||
uint32_t f_frame_top;
|
||||
uint32_t f_frame_left;
|
||||
uint32_t f_frame_width;
|
||||
uint32_t f_frame_height;
|
||||
uint32_t f_uncompressed_ri;
|
||||
uint32_t f_uncompressed_wi;
|
||||
uint8_t f_uncompressed[4096];
|
||||
@@ -1245,6 +1241,8 @@ typedef struct {
|
||||
} c_decode_ae[1];
|
||||
struct {
|
||||
uint32_t coro_susp_point;
|
||||
uint32_t v_frame_x;
|
||||
uint32_t v_frame_y;
|
||||
uint8_t v_flags;
|
||||
uint32_t v_lct_size;
|
||||
uint32_t v_i;
|
||||
|
||||
@@ -104,6 +104,20 @@ var Funcs = []string{
|
||||
"u64.max(x u64)(ret u64)",
|
||||
"u64.min(x u64)(ret u64)",
|
||||
|
||||
// ---- rect_ie_u32
|
||||
|
||||
"rect_ie_u32.set_min_inclusive_x!(x u32)()",
|
||||
"rect_ie_u32.set_min_inclusive_y!(y u32)()",
|
||||
"rect_ie_u32.set_max_exclusive_x!(x u32)()",
|
||||
"rect_ie_u32.set_max_exclusive_y!(y u32)()",
|
||||
|
||||
// ---- rect_ii_u32
|
||||
|
||||
"rect_ii_u32.set_min_inclusive_x!(x u32)()",
|
||||
"rect_ii_u32.set_min_inclusive_y!(y u32)()",
|
||||
"rect_ii_u32.set_max_inclusive_x!(x u32)()",
|
||||
"rect_ii_u32.set_max_inclusive_y!(y u32)()",
|
||||
|
||||
// ---- image_buffer
|
||||
|
||||
"image_buffer.plane(p u32[..3])(ret table u8)",
|
||||
|
||||
@@ -482,6 +482,13 @@ const (
|
||||
IDStride = ID(0x217)
|
||||
IDWidth = ID(0x218)
|
||||
IDLinearize = ID(0x219)
|
||||
|
||||
IDSetMaxExclusiveX = ID(0x240)
|
||||
IDSetMaxExclusiveY = ID(0x241)
|
||||
IDSetMaxInclusiveX = ID(0x242)
|
||||
IDSetMaxInclusiveY = ID(0x243)
|
||||
IDSetMinInclusiveX = ID(0x244)
|
||||
IDSetMinInclusiveY = ID(0x245)
|
||||
)
|
||||
|
||||
var builtInsByID = [nBuiltInIDs]string{
|
||||
@@ -692,6 +699,13 @@ var builtInsByID = [nBuiltInIDs]string{
|
||||
IDStride: "stride",
|
||||
IDWidth: "width",
|
||||
IDLinearize: "linearize",
|
||||
|
||||
IDSetMaxExclusiveX: "set_max_exclusive_x",
|
||||
IDSetMaxExclusiveY: "set_max_exclusive_y",
|
||||
IDSetMaxInclusiveX: "set_max_inclusive_x",
|
||||
IDSetMaxInclusiveY: "set_max_inclusive_y",
|
||||
IDSetMinInclusiveX: "set_min_inclusive_x",
|
||||
IDSetMinInclusiveY: "set_min_inclusive_y",
|
||||
}
|
||||
|
||||
var builtInsByName = map[string]ID{}
|
||||
|
||||
@@ -46,10 +46,6 @@ pub struct decoder?(
|
||||
num_loops base.u32 = 1,
|
||||
|
||||
frame_rect base.rect_ie_u32,
|
||||
frame_top base.u32[..65535],
|
||||
frame_left base.u32[..65535],
|
||||
frame_width base.u32[..65535],
|
||||
frame_height base.u32[..65535],
|
||||
|
||||
uncompressed_ri base.u32[..4096],
|
||||
uncompressed_wi base.u32[..4096],
|
||||
@@ -284,10 +280,14 @@ pri func decoder.decode_ae?(src base.io_reader)() {
|
||||
// TODO: dst should be a ptr base.image_buffer, not a base.io_writer.
|
||||
pri func decoder.decode_id?(ib ptr base.image_buffer, dst base.io_writer, src base.io_reader)() {
|
||||
// TODO: check that the frame rect is inside the image rect??
|
||||
this.frame_left = in.src.read_u16le?() as base.u32
|
||||
this.frame_top = in.src.read_u16le?() as base.u32
|
||||
this.frame_width = in.src.read_u16le?() as base.u32
|
||||
this.frame_height = in.src.read_u16le?() as base.u32
|
||||
var frame_x base.u32 = in.src.read_u16le?() as base.u32
|
||||
var frame_y base.u32 = in.src.read_u16le?() as base.u32
|
||||
this.frame_rect.set_min_inclusive_x!(x:frame_x)
|
||||
this.frame_rect.set_min_inclusive_y!(y:frame_y)
|
||||
frame_x ~mod+= in.src.read_u16le?() as base.u32
|
||||
frame_y ~mod+= in.src.read_u16le?() as base.u32
|
||||
this.frame_rect.set_max_exclusive_x!(x:frame_x)
|
||||
this.frame_rect.set_max_exclusive_y!(y:frame_y)
|
||||
|
||||
// TODO: use this.interlace.
|
||||
var flags base.u8 = in.src.read_u8?()
|
||||
|
||||
Reference in new issue
Block a user