mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Fix some more -Wconversion warnings
This commit is contained in:
1 parent
665355bd8a
commit
3c86337cac
10 files changed
+382
-293
No files matched your search
+2
-2
@@ -54,7 +54,7 @@ $CC -c \
|
||||
-Wall -Werror -Wpedantic -Wconversion -std=c99 \
|
||||
release/c/wuffs-unsupported-snapshot.c -o /dev/null
|
||||
$CC -c -DWUFFS_IMPLEMENTATION \
|
||||
-Wall -Werror -Wpedantic -std=c99 \
|
||||
-Wall -Werror -Wpedantic -Wconversion -std=c99 \
|
||||
release/c/wuffs-unsupported-snapshot.c -o /dev/null
|
||||
|
||||
echo "Checking snapshot compiles cleanly (as C++)"
|
||||
@@ -62,7 +62,7 @@ $CXX -c \
|
||||
-Wall -Werror -Wpedantic -Wconversion -std=c++11 \
|
||||
release/c/wuffs-unsupported-snapshot.c -o /dev/null
|
||||
$CXX -c -DWUFFS_IMPLEMENTATION \
|
||||
-Wall -Werror -Wpedantic -std=c++11 \
|
||||
-Wall -Werror -Wpedantic -Wconversion -std=c++11 \
|
||||
release/c/wuffs-unsupported-snapshot.c -o /dev/null
|
||||
|
||||
wuffs genlib -skipgen
|
||||
|
||||
@@ -92,12 +92,12 @@ wuffs_base__load_u8be(uint8_t* p) {
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__load_u16be(uint8_t* p) {
|
||||
return ((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0);
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0));
|
||||
}
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__load_u16le(uint8_t* p) {
|
||||
return ((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8);
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8));
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -193,128 +193,128 @@ wuffs_base__store_u8be(uint8_t* p, uint8_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u16be(uint8_t* p, uint16_t x) {
|
||||
p[0] = x >> 8;
|
||||
p[1] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 8);
|
||||
p[1] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u16le(uint8_t* p, uint16_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u24be(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 16;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 16);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u24le(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u32be(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 24;
|
||||
p[1] = x >> 16;
|
||||
p[2] = x >> 8;
|
||||
p[3] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 24);
|
||||
p[1] = (uint8_t)(x >> 16);
|
||||
p[2] = (uint8_t)(x >> 8);
|
||||
p[3] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u32le(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u40be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 32;
|
||||
p[1] = x >> 24;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 8;
|
||||
p[4] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 32);
|
||||
p[1] = (uint8_t)(x >> 24);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 8);
|
||||
p[4] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u40le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u48be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 40;
|
||||
p[1] = x >> 32;
|
||||
p[2] = x >> 24;
|
||||
p[3] = x >> 16;
|
||||
p[4] = x >> 8;
|
||||
p[5] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 40);
|
||||
p[1] = (uint8_t)(x >> 32);
|
||||
p[2] = (uint8_t)(x >> 24);
|
||||
p[3] = (uint8_t)(x >> 16);
|
||||
p[4] = (uint8_t)(x >> 8);
|
||||
p[5] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u48le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[5] = x >> 40;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
p[5] = (uint8_t)(x >> 40);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u56be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 48;
|
||||
p[1] = x >> 40;
|
||||
p[2] = x >> 32;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 16;
|
||||
p[5] = x >> 8;
|
||||
p[6] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 48);
|
||||
p[1] = (uint8_t)(x >> 40);
|
||||
p[2] = (uint8_t)(x >> 32);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 16);
|
||||
p[5] = (uint8_t)(x >> 8);
|
||||
p[6] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u56le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[5] = x >> 40;
|
||||
p[6] = x >> 48;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
p[5] = (uint8_t)(x >> 40);
|
||||
p[6] = (uint8_t)(x >> 48);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u64be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 56;
|
||||
p[1] = x >> 48;
|
||||
p[2] = x >> 40;
|
||||
p[3] = x >> 32;
|
||||
p[4] = x >> 24;
|
||||
p[5] = x >> 16;
|
||||
p[6] = x >> 8;
|
||||
p[7] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 56);
|
||||
p[1] = (uint8_t)(x >> 48);
|
||||
p[2] = (uint8_t)(x >> 40);
|
||||
p[3] = (uint8_t)(x >> 32);
|
||||
p[4] = (uint8_t)(x >> 24);
|
||||
p[5] = (uint8_t)(x >> 16);
|
||||
p[6] = (uint8_t)(x >> 8);
|
||||
p[7] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u64le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[5] = x >> 40;
|
||||
p[6] = x >> 48;
|
||||
p[7] = x >> 56;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
p[5] = (uint8_t)(x >> 40);
|
||||
p[6] = (uint8_t)(x >> 48);
|
||||
p[7] = (uint8_t)(x >> 56);
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
@@ -59,7 +59,7 @@ wuffs_base__pixel_swizzler__copy_4_1(wuffs_base__slice_u8 dst,
|
||||
|
||||
s += 1 * N;
|
||||
d += 4 * N;
|
||||
n -= 1 * N;
|
||||
n -= (size_t)(1 * N);
|
||||
}
|
||||
|
||||
while (n >= 1) {
|
||||
@@ -69,7 +69,7 @@ wuffs_base__pixel_swizzler__copy_4_1(wuffs_base__slice_u8 dst,
|
||||
|
||||
s += 1 * 1;
|
||||
d += 4 * 1;
|
||||
n -= 1 * 1;
|
||||
n -= (size_t)(1 * 1);
|
||||
}
|
||||
|
||||
return len;
|
||||
|
||||
@@ -74,11 +74,11 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w,
|
||||
return 0;
|
||||
}
|
||||
uint8_t* q = p - distance;
|
||||
size_t n = io1_w - p;
|
||||
size_t n = (size_t)(io1_w - p);
|
||||
if ((size_t)(length) > n) {
|
||||
length = n;
|
||||
length = (uint32_t)(n);
|
||||
} else {
|
||||
n = length;
|
||||
n = (size_t)(length);
|
||||
}
|
||||
// TODO: unrolling by 3 seems best for the std/deflate benchmarks, but that
|
||||
// is mostly because 3 is the minimum length for the deflate format. This
|
||||
@@ -138,18 +138,18 @@ wuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w,
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = length;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
n = (size_t)(io1_w - iop_w);
|
||||
}
|
||||
uint8_t* iop_r = *ptr_iop_r;
|
||||
if (n > ((size_t)(io1_r - iop_r))) {
|
||||
n = io1_r - iop_r;
|
||||
n = (size_t)(io1_r - iop_r);
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(iop_w, iop_r, n);
|
||||
*ptr_iop_w += n;
|
||||
*ptr_iop_r += n;
|
||||
}
|
||||
return n;
|
||||
return (uint32_t)(n);
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
@@ -159,13 +159,13 @@ wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = src.len;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
n = (size_t)(io1_w - iop_w);
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
return (uint64_t)(n);
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -179,13 +179,13 @@ wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w,
|
||||
n = length;
|
||||
}
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
n = (size_t)(io1_w - iop_w);
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
return (uint32_t)(n);
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
|
||||
+33
-21
@@ -40,21 +40,39 @@ func (g *gen) writeBuiltinCall(b *buffer, n *a.Expr, depth uint32) error {
|
||||
switch recvTyp.Decorator() {
|
||||
case 0:
|
||||
// No-op.
|
||||
|
||||
case t.IDNptr, t.IDPtr:
|
||||
// TODO: don't hard-code set.
|
||||
if method.Ident() != t.IDSet {
|
||||
u64ToFlicksIndex := -1
|
||||
|
||||
// TODO: don't hard-code these, or a_dst.
|
||||
switch meth := method.Ident(); {
|
||||
case (meth == t.IDSet) && (recvTyp.Inner().QID() == t.QID{t.IDBase, t.IDImageConfig}):
|
||||
b.writes("wuffs_base__image_config__set(a_dst")
|
||||
case (meth == t.IDUpdate) && (recvTyp.Inner().QID() == t.QID{t.IDBase, t.IDFrameConfig}):
|
||||
b.writes("wuffs_base__frame_config__update(a_dst")
|
||||
u64ToFlicksIndex = 1
|
||||
default:
|
||||
return errNoSuchBuiltin
|
||||
}
|
||||
// TODO: don't hard-code a_dst.
|
||||
b.printf("wuffs_base__image_config__set(a_dst")
|
||||
for _, o := range n.Args() {
|
||||
|
||||
for i, o := range n.Args() {
|
||||
b.writeb(',')
|
||||
if i == u64ToFlicksIndex {
|
||||
if o.AsArg().Name().Str(g.tm) != "duration" {
|
||||
return errors.New("cgen: internal error: inconsistent frame_config.update argument")
|
||||
}
|
||||
b.writes("((wuffs_base__flicks)(")
|
||||
}
|
||||
if err := g.writeExpr(b, o.AsArg().Value(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
if i == u64ToFlicksIndex {
|
||||
b.writes("))")
|
||||
}
|
||||
}
|
||||
b.printf(")")
|
||||
b.writeb(')')
|
||||
return nil
|
||||
|
||||
case t.IDSlice:
|
||||
return g.writeBuiltinSlice(b, recv, method.Ident(), n.Args(), depth)
|
||||
case t.IDTable:
|
||||
@@ -128,7 +146,7 @@ func (g *gen) writeBuiltinIOReader(b *buffer, recv *a.Expr, method t.ID, args []
|
||||
|
||||
case t.IDPosition:
|
||||
b.printf("(a_src.private_impl.buf ? wuffs_base__u64__sat_add(" +
|
||||
"a_src.private_impl.buf->meta.pos, iop_a_src - a_src.private_impl.buf->data.ptr) : 0)")
|
||||
"a_src.private_impl.buf->meta.pos, ((uint64_t)(iop_a_src - a_src.private_impl.buf->data.ptr))) : 0)")
|
||||
return nil
|
||||
|
||||
case t.IDSetLimit:
|
||||
@@ -600,7 +618,7 @@ func (g *gen) writeBuiltinQuestionCall(b *buffer, n *a.Expr, depth uint32) error
|
||||
}
|
||||
|
||||
b.printf("if (%s > ((uint64_t)(io1_a_src - iop_a_src))) {\n", scratchName)
|
||||
b.printf("%s -= io1_a_src - iop_a_src;\n", scratchName)
|
||||
b.printf("%s -= ((uint64_t)(io1_a_src - iop_a_src));\n", scratchName)
|
||||
b.printf("iop_a_src = io1_a_src;\n")
|
||||
|
||||
b.writes("status = wuffs_base__suspension__short_read; goto suspend; }\n")
|
||||
@@ -686,32 +704,26 @@ func (g *gen) writeReadUxxAsUyy(b *buffer, n *a.Expr, preName string, xx uint8,
|
||||
preName, preName)
|
||||
|
||||
b.printf("uint64_t *scratch = &%s;", scratchName)
|
||||
b.printf("uint32_t num_bits_%d = *scratch", temp)
|
||||
b.printf("uint32_t num_bits_%d = ((uint32_t)(*scratch", temp)
|
||||
switch endianness {
|
||||
case 'b':
|
||||
b.writes("& 0xFF; *scratch >>= 8; *scratch <<= 8;")
|
||||
b.writes("& 0xFF)); *scratch >>= 8; *scratch <<= 8;")
|
||||
b.printf("*scratch |= ((uint64_t)(*%s%s++)) << (56 - num_bits_%d);",
|
||||
iopPrefix, preName, temp)
|
||||
case 'l':
|
||||
b.writes(">> 56; *scratch <<= 8; *scratch >>= 8;")
|
||||
b.writes(">> 56)); *scratch <<= 8; *scratch >>= 8;")
|
||||
b.printf("*scratch |= ((uint64_t)(*%s%s++)) << num_bits_%d;",
|
||||
iopPrefix, preName, temp)
|
||||
}
|
||||
|
||||
b.printf("if (num_bits_%d == %d) { %s%d =", temp, xx-8, tPrefix, temp)
|
||||
if xx != yy {
|
||||
b.printf("((uint%d_t)(", yy)
|
||||
}
|
||||
b.printf("if (num_bits_%d == %d) { %s%d = ((uint%d_t)(", temp, xx-8, tPrefix, temp, yy)
|
||||
switch endianness {
|
||||
case 'b':
|
||||
b.printf("*scratch >> %d", 64-xx)
|
||||
b.printf("*scratch >> %d));", 64-xx)
|
||||
case 'l':
|
||||
b.printf("*scratch")
|
||||
b.printf("*scratch));")
|
||||
}
|
||||
if xx != yy {
|
||||
b.writes("))")
|
||||
}
|
||||
b.printf("; break;")
|
||||
b.printf("break;")
|
||||
b.printf("}")
|
||||
|
||||
b.printf("num_bits_%d += 8;", temp)
|
||||
|
||||
+19
-18
@@ -25,10 +25,10 @@ const baseAllImplC = "" +
|
||||
|
||||
const baseImageImplC = "" +
|
||||
"// ---------------- Images\n\nconst uint32_t wuffs_base__pixel_format__bits_per_channel[16] = {\n 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n 0x08, 0x0A, 0x0C, 0x10, 0x18, 0x20, 0x30, 0x40,\n};\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__copy_1_1(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n return wuffs_base__slice_u8__copy_from_slice(dst, src);\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__copy_4_1(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n if (dst_palette.len != 1024) {\n return 0;\n }\n size_t dst_len4 = dst.len / 4;\n size_t len = dst_len4 < src.len ? dst_len4 : src.len;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n\n size_t n = len;\n const int N = 4;\n\n while (n >= N) {\n wuffs_base__store_u32le(\n d + (0 * 4),\n wuffs_base__load_u3" +
|
||||
"2le(dst_palette.ptr + ((uint32_t)(s[0]) * 4)));\n wuffs_base__store_u32le(\n d + (1 * 4),\n wuffs_base__load_u32le(dst_palette.ptr + ((uint32_t)(s[1]) * 4)));\n wuffs_base__store_u32le(\n d + (2 * 4),\n wuffs_base__load_u32le(dst_palette.ptr + ((uint32_t)(s[2]) * 4)));\n wuffs_base__store_u32le(\n d + (3 * 4),\n wuffs_base__load_u32le(dst_palette.ptr + ((uint32_t)(s[3]) * 4)));\n\n s += 1 * N;\n d += 4 * N;\n n -= 1 * N;\n }\n\n while (n >= 1) {\n wuffs_base__store_u32le(\n d + (0 * 4),\n wuffs_base__load_u32le(dst_palette.ptr + ((uint32_t)(s[0]) * 4)));\n\n s += 1 * 1;\n d += 4 * 1;\n n -= 1 * 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__swap_rgbx_bgrx(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src) {\n size_t len4 = (dst.len < src.len ? dst.len : src.len) / 4;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n\n size_t n = len4;\n while (n--) {\n uint8_t b0 = s[0];\n " +
|
||||
"uint8_t b1 = s[1];\n uint8_t b2 = s[2];\n uint8_t b3 = s[3];\n d[0] = b2;\n d[1] = b1;\n d[2] = b0;\n d[3] = b3;\n s += 4;\n d += 4;\n }\n return len4 * 4;\n}\n\nvoid //\nwuffs_base__pixel_swizzler__prepare(wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_format,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__pixel_format src_format,\n wuffs_base__slice_u8 src_palette) {\n if (!p) {\n return;\n }\n\n // TODO: support many more formats.\n\n uint64_t (*func)(wuffs_base__slice_u8 dst, wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) = NULL;\n\n switch (src_format) {\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY:\n switch (dst_format) {\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BG" +
|
||||
"RA_BINARY:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n 1024) {\n break;\n }\n func = wuffs_base__pixel_swizzler__copy_1_1;\n break;\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n 1024) {\n break;\n }\n func = wuffs_base__pixel_swizzler__copy_4_1;\n break;\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n if (wuffs_base__pixel_swizzler__swap_rgbx_bgrx(dst_palette,\n src_palette) != 1024) {\n break;\n }\n func = wuffs_base__pixel_swizzler__copy_4_1;\n break;\n default:\n br" +
|
||||
"eak;\n }\n break;\n\n default:\n break;\n }\n\n p->private_impl.func = func;\n}\n\nuint64_t //\nwuffs_base__pixel_swizzler__swizzle_packed(wuffs_base__pixel_swizzler* p,\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n if (p && p->private_impl.func) {\n return (*(p->private_impl.func))(dst, dst_palette, src);\n }\n return 0;\n}\n" +
|
||||
"2le(dst_palette.ptr + ((uint32_t)(s[0]) * 4)));\n wuffs_base__store_u32le(\n d + (1 * 4),\n wuffs_base__load_u32le(dst_palette.ptr + ((uint32_t)(s[1]) * 4)));\n wuffs_base__store_u32le(\n d + (2 * 4),\n wuffs_base__load_u32le(dst_palette.ptr + ((uint32_t)(s[2]) * 4)));\n wuffs_base__store_u32le(\n d + (3 * 4),\n wuffs_base__load_u32le(dst_palette.ptr + ((uint32_t)(s[3]) * 4)));\n\n s += 1 * N;\n d += 4 * N;\n n -= (size_t)(1 * N);\n }\n\n while (n >= 1) {\n wuffs_base__store_u32le(\n d + (0 * 4),\n wuffs_base__load_u32le(dst_palette.ptr + ((uint32_t)(s[0]) * 4)));\n\n s += 1 * 1;\n d += 4 * 1;\n n -= (size_t)(1 * 1);\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__swap_rgbx_bgrx(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src) {\n size_t len4 = (dst.len < src.len ? dst.len : src.len) / 4;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n\n size_t n = len4;\n while (n--) {\n uin" +
|
||||
"t8_t b0 = s[0];\n uint8_t b1 = s[1];\n uint8_t b2 = s[2];\n uint8_t b3 = s[3];\n d[0] = b2;\n d[1] = b1;\n d[2] = b0;\n d[3] = b3;\n s += 4;\n d += 4;\n }\n return len4 * 4;\n}\n\nvoid //\nwuffs_base__pixel_swizzler__prepare(wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_format,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__pixel_format src_format,\n wuffs_base__slice_u8 src_palette) {\n if (!p) {\n return;\n }\n\n // TODO: support many more formats.\n\n uint64_t (*func)(wuffs_base__slice_u8 dst, wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) = NULL;\n\n switch (src_format) {\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY:\n switch (dst_format) {\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL" +
|
||||
"_FORMAT__INDEXED__BGRA_BINARY:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n 1024) {\n break;\n }\n func = wuffs_base__pixel_swizzler__copy_1_1;\n break;\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n 1024) {\n break;\n }\n func = wuffs_base__pixel_swizzler__copy_4_1;\n break;\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n if (wuffs_base__pixel_swizzler__swap_rgbx_bgrx(dst_palette,\n src_palette) != 1024) {\n break;\n }\n func = wuffs_base__pixel_swizzler__copy_4_1;\n break;\n d" +
|
||||
"efault:\n break;\n }\n break;\n\n default:\n break;\n }\n\n p->private_impl.func = func;\n}\n\nuint64_t //\nwuffs_base__pixel_swizzler__swizzle_packed(wuffs_base__pixel_swizzler* p,\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n if (p && p->private_impl.func) {\n return (*(p->private_impl.func))(dst, dst_palette, src);\n }\n return 0;\n}\n" +
|
||||
""
|
||||
|
||||
const baseCorePrivateH = "" +
|
||||
@@ -36,14 +36,15 @@ const baseCorePrivateH = "" +
|
||||
"__((fallthrough))\n#else\n#define WUFFS_BASE__FALLTHROUGH\n#endif\n\n// Use switch cases for coroutine suspension points, similar to the technique\n// in https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html\n//\n// We use trivial macros instead of an explicit assignment and case statement\n// so that clang-format doesn't get confused by the unusual \"case\"s.\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0 case 0:;\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT(n) \\\n coro_susp_point = n; \\\n WUFFS_BASE__FALLTHROUGH; \\\n case n:;\n\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(n) \\\n if (!status) { \\\n goto ok; \\\n } else if (*status != '$') { \\\n goto exit; \\\n } \\\n coro_susp_point = n; " +
|
||||
" \\\n goto suspend; \\\n case n:;\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__LIKELY(expr) (__builtin_expect(!!(expr), 1))\n#define WUFFS_BASE__UNLIKELY(expr) (__builtin_expect(!!(expr), 0))\n#else\n#define WUFFS_BASE__LIKELY(expr) (expr)\n#define WUFFS_BASE__UNLIKELY(expr) (expr)\n#endif\n\n// The helpers below are functions, instead of macros, because their arguments\n// can be an expression that we shouldn't evaluate more than once.\n//\n// They are static, so that linking multiple wuffs .o files won't complain about\n// duplicate function definitions.\n//\n// They are explicitly marked inline, even if modern compilers don't use the\n// inline attribute to guide optimizations such as inlining, to avoid the\n// -Wunused-function warning, and we like to compile with -Wall -Werror.\n\n" +
|
||||
"" +
|
||||
"// ---------------- Numeric Types\n\nstatic inline uint8_t //\nwuffs_base__load_u8be(uint8_t* p) {\n return p[0];\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16be(uint8_t* p) {\n return ((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0);\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16le(uint8_t* p) {\n return ((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 16) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 16);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |\n ((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uin" +
|
||||
"t32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u40be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 32) | ((uint64_t)(p[1]) << 24) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 8) |\n ((uint64_t)(p[4]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u40le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u48be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 40) | ((uint64_t)(p[1]) << 32) |\n ((uint64_t)(p[2]) << 24) | ((uint64_t)(p[3]) << 16) |\n ((uint64_t)(p[4]) << 8) | ((uint64_t)(p[5]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u48le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40);\n}\n\nstatic inline u" +
|
||||
"int64_t //\nwuffs_base__load_u56be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 48) | ((uint64_t)(p[1]) << 40) |\n ((uint64_t)(p[2]) << 32) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 16) | ((uint64_t)(p[5]) << 8) |\n ((uint64_t)(p[6]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u56le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |\n ((uint64_t)(p[6]) << 48);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u64be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 56) | ((uint64_t)(p[1]) << 48) |\n ((uint64_t)(p[2]) << 40) | ((uint64_t)(p[3]) << 32) |\n ((uint64_t)(p[4]) << 24) | ((uint64_t)(p[5]) << 16) |\n ((uint64_t)(p[6]) << 8) | ((uint64_t)(p[7]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u64le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)" +
|
||||
"(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |\n ((uint64_t)(p[6]) << 48) | ((uint64_t)(p[7]) << 56);\n}\n\n" +
|
||||
"// ---------------- Numeric Types\n\nstatic inline uint8_t //\nwuffs_base__load_u8be(uint8_t* p) {\n return p[0];\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16be(uint8_t* p) {\n return (uint16_t)(((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0));\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16le(uint8_t* p) {\n return (uint16_t)(((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8));\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 16) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 16);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |\n ((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]" +
|
||||
") << 8) |\n ((uint32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u40be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 32) | ((uint64_t)(p[1]) << 24) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 8) |\n ((uint64_t)(p[4]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u40le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u48be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 40) | ((uint64_t)(p[1]) << 32) |\n ((uint64_t)(p[2]) << 24) | ((uint64_t)(p[3]) << 16) |\n ((uint64_t)(p[4]) << 8) | ((uint64_t)(p[5]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u48le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) <<" +
|
||||
" 40);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u56be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 48) | ((uint64_t)(p[1]) << 40) |\n ((uint64_t)(p[2]) << 32) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 16) | ((uint64_t)(p[5]) << 8) |\n ((uint64_t)(p[6]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u56le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |\n ((uint64_t)(p[6]) << 48);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u64be(uint8_t* p) {\n return ((uint64_t)(p[0]) << 56) | ((uint64_t)(p[1]) << 48) |\n ((uint64_t)(p[2]) << 40) | ((uint64_t)(p[3]) << 32) |\n ((uint64_t)(p[4]) << 24) | ((uint64_t)(p[5]) << 16) |\n ((uint64_t)(p[6]) << 8) | ((uint64_t)(p[7]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u64le(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8" +
|
||||
") |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |\n ((uint64_t)(p[6]) << 48) | ((uint64_t)(p[7]) << 56);\n}\n\n" +
|
||||
"" +
|
||||
"// --------\n\nstatic inline void //\nwuffs_base__store_u8be(uint8_t* p, uint8_t x) {\n p[0] = x;\n}\n\nstatic inline void //\nwuffs_base__store_u16be(uint8_t* p, uint16_t x) {\n p[0] = x >> 8;\n p[1] = x >> 0;\n}\n\nstatic inline void //\nwuffs_base__store_u16le(uint8_t* p, uint16_t x) {\n p[0] = x >> 0;\n p[1] = x >> 8;\n}\n\nstatic inline void //\nwuffs_base__store_u24be(uint8_t* p, uint32_t x) {\n p[0] = x >> 16;\n p[1] = x >> 8;\n p[2] = x >> 0;\n}\n\nstatic inline void //\nwuffs_base__store_u24le(uint8_t* p, uint32_t x) {\n p[0] = x >> 0;\n p[1] = x >> 8;\n p[2] = x >> 16;\n}\n\nstatic inline void //\nwuffs_base__store_u32be(uint8_t* p, uint32_t x) {\n p[0] = x >> 24;\n p[1] = x >> 16;\n p[2] = x >> 8;\n p[3] = x >> 0;\n}\n\nstatic inline void //\nwuffs_base__store_u32le(uint8_t* p, uint32_t x) {\n p[0] = x >> 0;\n p[1] = x >> 8;\n p[2] = x >> 16;\n p[3] = x >> 24;\n}\n\nstatic inline void //\nwuffs_base__store_u40be(uint8_t* p, uint64_t x) {\n p[0] = x >> 32;\n p[1] = x >> 24;\n p[2] = x >> 16;\n p[3] = x >> 8;\n p[4] = x >>" +
|
||||
" 0;\n}\n\nstatic inline void //\nwuffs_base__store_u40le(uint8_t* p, uint64_t x) {\n p[0] = x >> 0;\n p[1] = x >> 8;\n p[2] = x >> 16;\n p[3] = x >> 24;\n p[4] = x >> 32;\n}\n\nstatic inline void //\nwuffs_base__store_u48be(uint8_t* p, uint64_t x) {\n p[0] = x >> 40;\n p[1] = x >> 32;\n p[2] = x >> 24;\n p[3] = x >> 16;\n p[4] = x >> 8;\n p[5] = x >> 0;\n}\n\nstatic inline void //\nwuffs_base__store_u48le(uint8_t* p, uint64_t x) {\n p[0] = x >> 0;\n p[1] = x >> 8;\n p[2] = x >> 16;\n p[3] = x >> 24;\n p[4] = x >> 32;\n p[5] = x >> 40;\n}\n\nstatic inline void //\nwuffs_base__store_u56be(uint8_t* p, uint64_t x) {\n p[0] = x >> 48;\n p[1] = x >> 40;\n p[2] = x >> 32;\n p[3] = x >> 24;\n p[4] = x >> 16;\n p[5] = x >> 8;\n p[6] = x >> 0;\n}\n\nstatic inline void //\nwuffs_base__store_u56le(uint8_t* p, uint64_t x) {\n p[0] = x >> 0;\n p[1] = x >> 8;\n p[2] = x >> 16;\n p[3] = x >> 24;\n p[4] = x >> 32;\n p[5] = x >> 40;\n p[6] = x >> 48;\n}\n\nstatic inline void //\nwuffs_base__store_u64be(uint8_t* p, uint64_t x) {\n p[0] = x >> 56" +
|
||||
";\n p[1] = x >> 48;\n p[2] = x >> 40;\n p[3] = x >> 32;\n p[4] = x >> 24;\n p[5] = x >> 16;\n p[6] = x >> 8;\n p[7] = x >> 0;\n}\n\nstatic inline void //\nwuffs_base__store_u64le(uint8_t* p, uint64_t x) {\n p[0] = x >> 0;\n p[1] = x >> 8;\n p[2] = x >> 16;\n p[3] = x >> 24;\n p[4] = x >> 32;\n p[5] = x >> 40;\n p[6] = x >> 48;\n p[7] = x >> 56;\n}\n\n" +
|
||||
"// --------\n\nstatic inline void //\nwuffs_base__store_u8be(uint8_t* p, uint8_t x) {\n p[0] = x;\n}\n\nstatic inline void //\nwuffs_base__store_u16be(uint8_t* p, uint16_t x) {\n p[0] = (uint8_t)(x >> 8);\n p[1] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u16le(uint8_t* p, uint16_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n}\n\nstatic inline void //\nwuffs_base__store_u24be(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 16);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u24le(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n}\n\nstatic inline void //\nwuffs_base__store_u32be(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 24);\n p[1] = (uint8_t)(x >> 16);\n p[2] = (uint8_t)(x >> 8);\n p[3] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u32le(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x" +
|
||||
" >> 16);\n p[3] = (uint8_t)(x >> 24);\n}\n\nstatic inline void //\nwuffs_base__store_u40be(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 32);\n p[1] = (uint8_t)(x >> 24);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 8);\n p[4] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u40le(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n}\n\nstatic inline void //\nwuffs_base__store_u48be(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 40);\n p[1] = (uint8_t)(x >> 32);\n p[2] = (uint8_t)(x >> 24);\n p[3] = (uint8_t)(x >> 16);\n p[4] = (uint8_t)(x >> 8);\n p[5] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u48le(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n p[5] = (uint8_t)(x >> 40);\n}\n\nstatic inline void //\nwuffs_base__store_u56be(ui" +
|
||||
"nt8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 48);\n p[1] = (uint8_t)(x >> 40);\n p[2] = (uint8_t)(x >> 32);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 16);\n p[5] = (uint8_t)(x >> 8);\n p[6] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u56le(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n p[5] = (uint8_t)(x >> 40);\n p[6] = (uint8_t)(x >> 48);\n}\n\nstatic inline void //\nwuffs_base__store_u64be(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 56);\n p[1] = (uint8_t)(x >> 48);\n p[2] = (uint8_t)(x >> 40);\n p[3] = (uint8_t)(x >> 32);\n p[4] = (uint8_t)(x >> 24);\n p[5] = (uint8_t)(x >> 16);\n p[6] = (uint8_t)(x >> 8);\n p[7] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u64le(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32" +
|
||||
");\n p[5] = (uint8_t)(x >> 40);\n p[6] = (uint8_t)(x >> 48);\n p[7] = (uint8_t)(x >> 56);\n}\n\n" +
|
||||
"" +
|
||||
"// --------\n\nextern const uint8_t wuffs_base__low_bits_mask__u8[9];\nextern const uint16_t wuffs_base__low_bits_mask__u16[17];\nextern const uint32_t wuffs_base__low_bits_mask__u32[33];\nextern const uint64_t wuffs_base__low_bits_mask__u64[65];\n\n#define WUFFS_BASE__LOW_BITS_MASK__U8(n) (wuffs_base__low_bits_mask__u8[n])\n#define WUFFS_BASE__LOW_BITS_MASK__U16(n) (wuffs_base__low_bits_mask__u16[n])\n#define WUFFS_BASE__LOW_BITS_MASK__U32(n) (wuffs_base__low_bits_mask__u32[n])\n#define WUFFS_BASE__LOW_BITS_MASK__U64(n) (wuffs_base__low_bits_mask__u64[n])\n\n" +
|
||||
"" +
|
||||
@@ -155,13 +156,13 @@ const baseImagePublicH = "" +
|
||||
const baseIOPrivateH = "" +
|
||||
"// ---------------- I/O\n\nstatic inline bool //\nwuffs_base__io_buffer__is_valid(wuffs_base__io_buffer buf) {\n return (buf.data.ptr || (buf.data.len == 0)) &&\n (buf.data.len >= buf.meta.wi) && (buf.meta.wi >= buf.meta.ri);\n}\n\n// TODO: wuffs_base__io_reader__is_eof is no longer used by Wuffs per se, but\n// it might be handy to programs that use Wuffs. Either delete it, or promote\n// it to the public API.\n//\n// If making this function public (i.e. moving it to base-header.h), it also\n// needs to allow NULL (i.e. implicit, callee-calculated) mark/limit.\n\nstatic inline bool //\nwuffs_base__io_reader__is_eof(wuffs_base__io_reader o) {\n wuffs_base__io_buffer* buf = o.private_impl.buf;\n return buf && buf->meta.closed &&\n (buf->data.ptr + buf->meta.wi == o.private_impl.limit);\n}\n\nstatic inline bool //\nwuffs_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) mark/limit.\n return buf ? ((buf->data.ptr <= o.private_impl.mark) &&\n (o.private_impl.mark <= o.private_impl.limit) &&\n (o.private_impl.limit <= buf->data.ptr + buf->data.len))\n : ((o.private_impl.mark == NULL) &&\n (o.private_impl.limit == NULL));\n}\n\nstatic inline bool //\nwuffs_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) mark/limit.\n return buf ? ((buf->data.ptr <= o.private_impl.mark) &&\n (o.private_impl.mark <= o.private_impl.limit) &&\n (o.private_impl.limit <= buf->data.ptr + buf->data.len))\n : ((o.private_impl.mark == NULL) &&\n (o.private_impl.limit == NULL));\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_history(uin" +
|
||||
"t8_t** ptr_iop_w,\n uint8_t* io0_w,\n uint8_t* io1_w,\n uint32_t length,\n uint32_t distance) {\n if (!distance) {\n return 0;\n }\n uint8_t* p = *ptr_iop_w;\n if ((size_t)(p - io0_w) < (size_t)(distance)) {\n return 0;\n }\n uint8_t* q = p - distance;\n size_t n = io1_w - p;\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_n_from_history 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_n_from_history_fast below.\n //\n // Alternatively, or additionall" +
|
||||
"y, have a sloppy_copy_n_from_history method\n // that copies 8 bytes at a time, possibly writing more than length bytes?\n for (; n >= 3; n -= 3) {\n *p++ = *q++;\n *p++ = *q++;\n *p++ = *q++;\n }\n for (; n; n--) {\n *p++ = *q++;\n }\n *ptr_iop_w = p;\n return length;\n}\n\n// wuffs_base__io_writer__copy_n_from_history_fast is like the\n// wuffs_base__io_writer__copy_n_from_history function above, but has stronger\n// pre-conditions. The caller needs to prove that:\n// - distance > 0\n// - distance <= (*ptr_iop_w - io0_w)\n// - length <= (io1_w - *ptr_iop_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_iop_w,\n uint8_t* io0_w,\n uint8_t* io1_w,\n uint32_t length,\n uint32_t distance) {\n uint8_t* p = *ptr_iop_w;\n uint8_t* q = p - distance;\n uint32_t n = length;\n for (; n" +
|
||||
" >= 3; n -= 3) {\n *p++ = *q++;\n *p++ = *q++;\n *p++ = *q++;\n }\n for (; n; n--) {\n *p++ = *q++;\n }\n *ptr_iop_w = p;\n return length;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint32_t length,\n uint8_t** ptr_iop_r,\n uint8_t* io1_r) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = length;\n if (n > ((size_t)(io1_w - iop_w))) {\n n = io1_w - iop_w;\n }\n uint8_t* iop_r = *ptr_iop_r;\n if (n > ((size_t)(io1_r - iop_r))) {\n n = io1_r - iop_r;\n }\n if (n > 0) {\n memmove(iop_w, iop_r, n);\n *ptr_iop_w += n;\n *ptr_iop_r += n;\n }\n return n;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n wuffs_base__slice_u8 src) {\n uint8_t* iop" +
|
||||
"_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > ((size_t)(io1_w - iop_w))) {\n n = io1_w - iop_w;\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return n;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint32_t length,\n wuffs_base__slice_u8 src) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(io1_w - iop_w))) {\n n = io1_w - iop_w;\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return n;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set(wuffs_base__io_reader* o,\n wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_r,\n uint8_t** ptr_io1_r,\n wuffs_base__slice_u8 data) {\n b->data = " +
|
||||
"data;\n b->meta.wi = data.len;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ptr_iop_r = data.ptr;\n *ptr_io1_r = data.ptr + data.len;\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,\n uint8_t* iop_r,\n uint64_t limit) {\n if (o && (((size_t)(o->private_impl.limit - iop_r)) > limit)) {\n o->private_impl.limit = iop_r + limit;\n }\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io_reader__take(uint8_" +
|
||||
"t** ptr_iop_r, uint8_t* io1_r, uint64_t n) {\n if (n <= ((size_t)(io1_r - *ptr_iop_r))) {\n uint8_t* p = *ptr_iop_r;\n *ptr_iop_r += n;\n return wuffs_base__make_slice_u8(p, n);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set(wuffs_base__io_writer* o,\n wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_w,\n uint8_t** ptr_io1_w,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = 0;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ptr_iop_w = data.ptr;\n *ptr_io1_w = data.ptr + data.len;\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set_mark(wuffs_base__io_writer* o, uint8_t* mark) {\n o->private_impl.mark = " +
|
||||
"mark;\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\n" +
|
||||
"t8_t** ptr_iop_w,\n uint8_t* io0_w,\n uint8_t* io1_w,\n uint32_t length,\n uint32_t distance) {\n if (!distance) {\n return 0;\n }\n uint8_t* p = *ptr_iop_w;\n if ((size_t)(p - io0_w) < (size_t)(distance)) {\n return 0;\n }\n uint8_t* q = p - distance;\n size_t n = (size_t)(io1_w - p);\n if ((size_t)(length) > n) {\n length = (uint32_t)(n);\n } else {\n n = (size_t)(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_n_from_history 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_n_from_history_fast below.\n //\n " +
|
||||
"// Alternatively, or additionally, have a sloppy_copy_n_from_history method\n // that copies 8 bytes at a time, possibly writing more than length bytes?\n for (; n >= 3; n -= 3) {\n *p++ = *q++;\n *p++ = *q++;\n *p++ = *q++;\n }\n for (; n; n--) {\n *p++ = *q++;\n }\n *ptr_iop_w = p;\n return length;\n}\n\n// wuffs_base__io_writer__copy_n_from_history_fast is like the\n// wuffs_base__io_writer__copy_n_from_history function above, but has stronger\n// pre-conditions. The caller needs to prove that:\n// - distance > 0\n// - distance <= (*ptr_iop_w - io0_w)\n// - length <= (io1_w - *ptr_iop_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_iop_w,\n uint8_t* io0_w,\n uint8_t* io1_w,\n uint32_t length,\n uint32_t distance) {\n uint8_t* p = *ptr_iop_w;\n uint8_t* q = p - distance;\n " +
|
||||
" uint32_t n = length;\n for (; n >= 3; n -= 3) {\n *p++ = *q++;\n *p++ = *q++;\n *p++ = *q++;\n }\n for (; n; n--) {\n *p++ = *q++;\n }\n *ptr_iop_w = p;\n return length;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint32_t length,\n uint8_t** ptr_iop_r,\n uint8_t* io1_r) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = length;\n if (n > ((size_t)(io1_w - iop_w))) {\n n = (size_t)(io1_w - iop_w);\n }\n uint8_t* iop_r = *ptr_iop_r;\n if (n > ((size_t)(io1_r - iop_r))) {\n n = (size_t)(io1_r - iop_r);\n }\n if (n > 0) {\n memmove(iop_w, iop_r, n);\n *ptr_iop_w += n;\n *ptr_iop_r += n;\n }\n return (uint32_t)(n);\n}\n\nstatic inline uint64_t //\nwuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n " +
|
||||
" wuffs_base__slice_u8 src) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > ((size_t)(io1_w - iop_w))) {\n n = (size_t)(io1_w - iop_w);\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return (uint64_t)(n);\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint32_t length,\n wuffs_base__slice_u8 src) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(io1_w - iop_w))) {\n n = (size_t)(io1_w - iop_w);\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return (uint32_t)(n);\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set(wuffs_base__io_reader* o,\n wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_r,\n " +
|
||||
" uint8_t** ptr_io1_r,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = data.len;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ptr_iop_r = data.ptr;\n *ptr_io1_r = data.ptr + data.len;\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,\n uint8_t* iop_r,\n uint64_t limit) {\n if (o && (((size_t)(o->private_impl.limit - iop_r)) > limit)) {\n o->private_impl.limit = iop_r + limit;\n }\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n\n wuffs_base__empty_struct ret;\n ret." +
|
||||
"private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io_reader__take(uint8_t** ptr_iop_r, uint8_t* io1_r, uint64_t n) {\n if (n <= ((size_t)(io1_r - *ptr_iop_r))) {\n uint8_t* p = *ptr_iop_r;\n *ptr_iop_r += n;\n return wuffs_base__make_slice_u8(p, n);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__io_writer__set(wuffs_base__io_writer* o,\n wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_w,\n uint8_t** ptr_io1_w,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = 0;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n o->private_impl.buf = b;\n o->private_impl.mark = data.ptr;\n o->private_impl.limit = data.ptr + data.len;\n *ptr_iop_w = data.ptr;\n *ptr_io1_w = data.ptr + data.len;\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__empty_str" +
|
||||
"uct //\nwuffs_base__io_writer__set_mark(wuffs_base__io_writer* o, uint8_t* mark) {\n o->private_impl.mark = mark;\n\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return ret;\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- I/O (Utility)\n\n#define wuffs_base__utility__null_io_reader wuffs_base__null_io_reader\n#define wuffs_base__utility__null_io_writer wuffs_base__null_io_writer\n" +
|
||||
""
|
||||
|
||||
@@ -175,7 +175,7 @@ func (g *gen) writeStatementAssign1(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
|
||||
return err
|
||||
}
|
||||
|
||||
opName, closer := "", ""
|
||||
opName, closer, disableWconversion := "", "", false
|
||||
if lTyp := lhs.MType(); lTyp.IsArrayType() {
|
||||
b.writes("memcpy(")
|
||||
opName, closer = ",", fmt.Sprintf(", sizeof(%s))", lhsBuf)
|
||||
@@ -194,6 +194,14 @@ func (g *gen) writeStatementAssign1(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
|
||||
b.printf("wuffs_base__u%d__sat_%s_indirect(&", uBits, uOp)
|
||||
opName, closer = ",", ")"
|
||||
|
||||
case t.IDPlusEq, t.IDMinusEq:
|
||||
if lTyp.IsNumType() {
|
||||
if u := lTyp.QID()[1]; u == t.IDU8 || u == t.IDU16 {
|
||||
disableWconversion = true
|
||||
}
|
||||
}
|
||||
fallthrough
|
||||
|
||||
default:
|
||||
opName = cOpName(op)
|
||||
if opName == "" {
|
||||
@@ -202,6 +210,16 @@ func (g *gen) writeStatementAssign1(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
|
||||
}
|
||||
}
|
||||
|
||||
// "x += 1" triggers -Wconversion, if x is smaller than an int (i.e. a
|
||||
// uint8_t or a uint16_t). This is arguably a clang/gcc bug, but in any
|
||||
// case, we work around it in Wuffs.
|
||||
if disableWconversion {
|
||||
b.writes("#if defined(__GNUC__)\n")
|
||||
b.writes("#pragma GCC diagnostic push\n")
|
||||
b.writes("#pragma GCC diagnostic ignored \"-Wconversion\"\n")
|
||||
b.writes("#endif\n")
|
||||
}
|
||||
|
||||
b.writex(lhsBuf)
|
||||
b.writes(opName)
|
||||
if rhs.Effect().Coroutine() {
|
||||
@@ -216,6 +234,12 @@ func (g *gen) writeStatementAssign1(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
|
||||
b.writes(closer)
|
||||
b.writes(";\n")
|
||||
|
||||
if disableWconversion {
|
||||
b.writes("#if defined(__GNUC__)\n")
|
||||
b.writes("#pragma GCC diagnostic pop\n")
|
||||
b.writes("#endif\n")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -140,10 +140,10 @@ func (g *gen) writeSaveDerivedVar(b *buffer, hack string, prefix string, name t.
|
||||
}
|
||||
// TODO: also remove this hack.
|
||||
if hack == "w" {
|
||||
b.printf("%sw.meta.wi = %s%sw - %sw.data.ptr;\n", uPrefix, iopPrefix, vPrefix, uPrefix)
|
||||
b.printf("%sw.meta.wi = ((size_t)(%s%sw - %sw.data.ptr));\n", uPrefix, iopPrefix, vPrefix, uPrefix)
|
||||
return nil
|
||||
} else if hack == "r" {
|
||||
b.printf("%sr.meta.ri = %s%sr - %sr.data.ptr;\n", uPrefix, iopPrefix, vPrefix, uPrefix)
|
||||
b.printf("%sr.meta.ri = ((size_t)(%s%sr - %sr.data.ptr));\n", uPrefix, iopPrefix, vPrefix, uPrefix)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ func (g *gen) writeSaveDerivedVar(b *buffer, hack string, prefix string, name t.
|
||||
}
|
||||
|
||||
b.printf("if (%s.private_impl.buf) {", preName)
|
||||
b.printf("%s.private_impl.buf->meta.%s = %s%s - %s.private_impl.buf->data.ptr;",
|
||||
b.printf("%s.private_impl.buf->meta.%s = ((size_t)(%s%s - %s.private_impl.buf->data.ptr));",
|
||||
preName, i0, iopPrefix, preName, preName)
|
||||
b.printf("}\n")
|
||||
return nil
|
||||
|
||||
@@ -582,6 +582,7 @@ const (
|
||||
IDReset = ID(0x201)
|
||||
IDSet = ID(0x202)
|
||||
IDUnroll = ID(0x203)
|
||||
IDUpdate = ID(0x204)
|
||||
|
||||
// TODO: range/rect methods like intersection and contains?
|
||||
|
||||
@@ -911,6 +912,7 @@ var builtInsByID = [nBuiltInIDs]string{
|
||||
IDReset: "reset",
|
||||
IDSet: "set",
|
||||
IDUnroll: "unroll",
|
||||
IDUpdate: "update",
|
||||
|
||||
IDHighBits: "high_bits",
|
||||
IDLowBits: "low_bits",
|
||||
|
||||
@@ -3916,12 +3916,12 @@ wuffs_base__load_u8be(uint8_t* p) {
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__load_u16be(uint8_t* p) {
|
||||
return ((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0);
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0));
|
||||
}
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__load_u16le(uint8_t* p) {
|
||||
return ((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8);
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8));
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -4017,128 +4017,128 @@ wuffs_base__store_u8be(uint8_t* p, uint8_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u16be(uint8_t* p, uint16_t x) {
|
||||
p[0] = x >> 8;
|
||||
p[1] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 8);
|
||||
p[1] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u16le(uint8_t* p, uint16_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u24be(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 16;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 16);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u24le(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u32be(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 24;
|
||||
p[1] = x >> 16;
|
||||
p[2] = x >> 8;
|
||||
p[3] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 24);
|
||||
p[1] = (uint8_t)(x >> 16);
|
||||
p[2] = (uint8_t)(x >> 8);
|
||||
p[3] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u32le(uint8_t* p, uint32_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u40be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 32;
|
||||
p[1] = x >> 24;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 8;
|
||||
p[4] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 32);
|
||||
p[1] = (uint8_t)(x >> 24);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 8);
|
||||
p[4] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u40le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u48be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 40;
|
||||
p[1] = x >> 32;
|
||||
p[2] = x >> 24;
|
||||
p[3] = x >> 16;
|
||||
p[4] = x >> 8;
|
||||
p[5] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 40);
|
||||
p[1] = (uint8_t)(x >> 32);
|
||||
p[2] = (uint8_t)(x >> 24);
|
||||
p[3] = (uint8_t)(x >> 16);
|
||||
p[4] = (uint8_t)(x >> 8);
|
||||
p[5] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u48le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[5] = x >> 40;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
p[5] = (uint8_t)(x >> 40);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u56be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 48;
|
||||
p[1] = x >> 40;
|
||||
p[2] = x >> 32;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 16;
|
||||
p[5] = x >> 8;
|
||||
p[6] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 48);
|
||||
p[1] = (uint8_t)(x >> 40);
|
||||
p[2] = (uint8_t)(x >> 32);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 16);
|
||||
p[5] = (uint8_t)(x >> 8);
|
||||
p[6] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u56le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[5] = x >> 40;
|
||||
p[6] = x >> 48;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
p[5] = (uint8_t)(x >> 40);
|
||||
p[6] = (uint8_t)(x >> 48);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u64be(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 56;
|
||||
p[1] = x >> 48;
|
||||
p[2] = x >> 40;
|
||||
p[3] = x >> 32;
|
||||
p[4] = x >> 24;
|
||||
p[5] = x >> 16;
|
||||
p[6] = x >> 8;
|
||||
p[7] = x >> 0;
|
||||
p[0] = (uint8_t)(x >> 56);
|
||||
p[1] = (uint8_t)(x >> 48);
|
||||
p[2] = (uint8_t)(x >> 40);
|
||||
p[3] = (uint8_t)(x >> 32);
|
||||
p[4] = (uint8_t)(x >> 24);
|
||||
p[5] = (uint8_t)(x >> 16);
|
||||
p[6] = (uint8_t)(x >> 8);
|
||||
p[7] = (uint8_t)(x >> 0);
|
||||
}
|
||||
|
||||
static inline void //
|
||||
wuffs_base__store_u64le(uint8_t* p, uint64_t x) {
|
||||
p[0] = x >> 0;
|
||||
p[1] = x >> 8;
|
||||
p[2] = x >> 16;
|
||||
p[3] = x >> 24;
|
||||
p[4] = x >> 32;
|
||||
p[5] = x >> 40;
|
||||
p[6] = x >> 48;
|
||||
p[7] = x >> 56;
|
||||
p[0] = (uint8_t)(x >> 0);
|
||||
p[1] = (uint8_t)(x >> 8);
|
||||
p[2] = (uint8_t)(x >> 16);
|
||||
p[3] = (uint8_t)(x >> 24);
|
||||
p[4] = (uint8_t)(x >> 32);
|
||||
p[5] = (uint8_t)(x >> 40);
|
||||
p[6] = (uint8_t)(x >> 48);
|
||||
p[7] = (uint8_t)(x >> 56);
|
||||
}
|
||||
|
||||
// --------
|
||||
@@ -4356,11 +4356,11 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w,
|
||||
return 0;
|
||||
}
|
||||
uint8_t* q = p - distance;
|
||||
size_t n = io1_w - p;
|
||||
size_t n = (size_t)(io1_w - p);
|
||||
if ((size_t)(length) > n) {
|
||||
length = n;
|
||||
length = (uint32_t)(n);
|
||||
} else {
|
||||
n = length;
|
||||
n = (size_t)(length);
|
||||
}
|
||||
// TODO: unrolling by 3 seems best for the std/deflate benchmarks, but that
|
||||
// is mostly because 3 is the minimum length for the deflate format. This
|
||||
@@ -4420,18 +4420,18 @@ wuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w,
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = length;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
n = (size_t)(io1_w - iop_w);
|
||||
}
|
||||
uint8_t* iop_r = *ptr_iop_r;
|
||||
if (n > ((size_t)(io1_r - iop_r))) {
|
||||
n = io1_r - iop_r;
|
||||
n = (size_t)(io1_r - iop_r);
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(iop_w, iop_r, n);
|
||||
*ptr_iop_w += n;
|
||||
*ptr_iop_r += n;
|
||||
}
|
||||
return n;
|
||||
return (uint32_t)(n);
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
@@ -4441,13 +4441,13 @@ wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = src.len;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
n = (size_t)(io1_w - iop_w);
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
return (uint64_t)(n);
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -4461,13 +4461,13 @@ wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w,
|
||||
n = length;
|
||||
}
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
n = (size_t)(io1_w - iop_w);
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
return (uint32_t)(n);
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
@@ -4682,7 +4682,7 @@ wuffs_base__pixel_swizzler__copy_4_1(wuffs_base__slice_u8 dst,
|
||||
|
||||
s += 1 * N;
|
||||
d += 4 * N;
|
||||
n -= 1 * N;
|
||||
n -= (size_t)(1 * N);
|
||||
}
|
||||
|
||||
while (n >= 1) {
|
||||
@@ -4692,7 +4692,7 @@ wuffs_base__pixel_swizzler__copy_4_1(wuffs_base__slice_u8 dst,
|
||||
|
||||
s += 1 * 1;
|
||||
d += 4 * 1;
|
||||
n -= 1 * 1;
|
||||
n -= (size_t)(1 * 1);
|
||||
}
|
||||
|
||||
return len;
|
||||
@@ -6243,7 +6243,7 @@ wuffs_deflate__decoder__decode_io_writer(wuffs_deflate__decoder* self,
|
||||
{
|
||||
if (a_dst.private_impl.buf) {
|
||||
a_dst.private_impl.buf->meta.wi =
|
||||
iop_a_dst - a_dst.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_dst - a_dst.private_impl.buf->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_0 =
|
||||
wuffs_deflate__decoder__decode_blocks(self, a_dst, a_src);
|
||||
@@ -6314,7 +6314,7 @@ suspend:
|
||||
exit:
|
||||
if (a_dst.private_impl.buf) {
|
||||
a_dst.private_impl.buf->meta.wi =
|
||||
iop_a_dst - a_dst.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_dst - a_dst.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(status)) {
|
||||
@@ -6380,7 +6380,7 @@ wuffs_deflate__decoder__decode_blocks(wuffs_deflate__decoder* self,
|
||||
if (v_type == 0) {
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
status =
|
||||
@@ -6408,7 +6408,7 @@ wuffs_deflate__decoder__decode_blocks(wuffs_deflate__decoder* self,
|
||||
} else if (v_type == 2) {
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
status = wuffs_deflate__decoder__init_dynamic_huffman(self, a_src);
|
||||
@@ -6427,7 +6427,7 @@ wuffs_deflate__decoder__decode_blocks(wuffs_deflate__decoder* self,
|
||||
while (true) {
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
v_status =
|
||||
wuffs_deflate__decoder__decode_huffman_fast(self, a_dst, a_src);
|
||||
@@ -6444,7 +6444,7 @@ wuffs_deflate__decoder__decode_blocks(wuffs_deflate__decoder* self,
|
||||
}
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
status =
|
||||
@@ -6477,7 +6477,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -6557,12 +6557,12 @@ wuffs_deflate__decoder__decode_uncompressed(wuffs_deflate__decoder* self,
|
||||
}
|
||||
uint64_t* scratch =
|
||||
&self->private_data.s_decode_uncompressed[0].scratch;
|
||||
uint32_t num_bits_0 = *scratch >> 56;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_0;
|
||||
if (num_bits_0 == 24) {
|
||||
t_0 = *scratch;
|
||||
t_0 = ((uint32_t)(*scratch));
|
||||
break;
|
||||
}
|
||||
num_bits_0 += 8;
|
||||
@@ -6608,11 +6608,11 @@ suspend:
|
||||
exit:
|
||||
if (a_dst.private_impl.buf) {
|
||||
a_dst.private_impl.buf->meta.wi =
|
||||
iop_a_dst - a_dst.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_dst - a_dst.private_impl.buf->data.ptr));
|
||||
}
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -6907,7 +6907,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -6951,7 +6951,14 @@ wuffs_deflate__decoder__init_huff(wuffs_deflate__decoder* self,
|
||||
if (v_counts[(self->private_data.f_code_lengths[v_i] & 15)] >= 320) {
|
||||
return wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state;
|
||||
}
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_counts[(self->private_data.f_code_lengths[v_i] & 15)] += 1;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
v_i += 1;
|
||||
}
|
||||
if ((((uint32_t)(v_counts[0])) + a_n_codes0) == a_n_codes1) {
|
||||
@@ -6997,7 +7004,14 @@ wuffs_deflate__decoder__init_huff(wuffs_deflate__decoder* self,
|
||||
}
|
||||
v_symbols[v_offsets[(self->private_data.f_code_lengths[v_i] & 15)]] =
|
||||
((uint16_t)((v_i - a_n_codes0)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_offsets[(self->private_data.f_code_lengths[v_i] & 15)] += 1;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
v_i += 1;
|
||||
}
|
||||
@@ -7104,7 +7118,14 @@ label_1_break:;
|
||||
if ((v_key >= 512) || (v_counts[v_prev_cl] <= 0)) {
|
||||
return wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state;
|
||||
}
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_counts[v_prev_cl] -= 1;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
v_reversed_key = (((uint32_t)(wuffs_deflate__reverse8[(v_key >> 1)])) |
|
||||
((v_key & 1) << 8));
|
||||
v_reversed_key >>= (9 - v_cl);
|
||||
@@ -7435,11 +7456,11 @@ label_0_break:;
|
||||
exit:
|
||||
if (a_dst.private_impl.buf) {
|
||||
a_dst.private_impl.buf->meta.wi =
|
||||
iop_a_dst - a_dst.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_dst - a_dst.private_impl.buf->data.ptr));
|
||||
}
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -7844,11 +7865,11 @@ suspend:
|
||||
exit:
|
||||
if (a_dst.private_impl.buf) {
|
||||
a_dst.private_impl.buf->meta.wi =
|
||||
iop_a_dst - a_dst.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_dst - a_dst.private_impl.buf->data.ptr));
|
||||
}
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -8255,7 +8276,7 @@ label_0_break:;
|
||||
self->private_impl.f_output_wi = v_output_wi;
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return wuffs_base__make_empty_struct();
|
||||
@@ -8331,7 +8352,7 @@ suspend:
|
||||
exit:
|
||||
if (a_dst.private_impl.buf) {
|
||||
a_dst.private_impl.buf->meta.wi =
|
||||
iop_a_dst - a_dst.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_dst - a_dst.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -8788,7 +8809,7 @@ wuffs_gif__decoder__decode_frame_config(wuffs_gif__decoder* self,
|
||||
self->private_impl.f_width),
|
||||
wuffs_base__u32__min(self->private_impl.f_frame_rect_y1,
|
||||
self->private_impl.f_height)),
|
||||
self->private_impl.f_gc_duration,
|
||||
((wuffs_base__flicks)(self->private_impl.f_gc_duration)),
|
||||
self->private_impl.f_num_decoded_frame_configs_value,
|
||||
self->private_impl.f_frame_config_io_position, v_blend,
|
||||
self->private_impl.f_gc_disposal);
|
||||
@@ -8861,7 +8882,8 @@ wuffs_gif__decoder__skip_frame(wuffs_gif__decoder* self,
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
if (self->private_data.s_skip_frame[0].scratch >
|
||||
((uint64_t)(io1_a_src - iop_a_src))) {
|
||||
self->private_data.s_skip_frame[0].scratch -= io1_a_src - iop_a_src;
|
||||
self->private_data.s_skip_frame[0].scratch -=
|
||||
((uint64_t)(io1_a_src - iop_a_src));
|
||||
iop_a_src = io1_a_src;
|
||||
status = wuffs_base__suspension__short_read;
|
||||
goto suspend;
|
||||
@@ -8876,7 +8898,7 @@ wuffs_gif__decoder__skip_frame(wuffs_gif__decoder* self,
|
||||
iop_a_src++;
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
status = wuffs_gif__decoder__skip_blocks(self, a_src);
|
||||
@@ -8905,7 +8927,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -9033,13 +9055,14 @@ wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
|
||||
(a_src.private_impl.buf
|
||||
? wuffs_base__u64__sat_add(
|
||||
a_src.private_impl.buf->meta.pos,
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr)
|
||||
((uint64_t)(iop_a_src - a_src.private_impl.buf->data.ptr)))
|
||||
: 0);
|
||||
} else if (self->private_impl.f_frame_config_io_position !=
|
||||
(a_src.private_impl.buf
|
||||
? wuffs_base__u64__sat_add(
|
||||
a_src.private_impl.buf->meta.pos,
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr)
|
||||
((uint64_t)(iop_a_src -
|
||||
a_src.private_impl.buf->data.ptr)))
|
||||
: 0)) {
|
||||
status = wuffs_base__error__bad_restart;
|
||||
goto exit;
|
||||
@@ -9059,7 +9082,7 @@ wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
|
||||
if (v_block_type == 33) {
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
status = wuffs_gif__decoder__decode_extension(self, a_src);
|
||||
@@ -9073,7 +9096,7 @@ wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
|
||||
} else if (v_block_type == 44) {
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
status = wuffs_gif__decoder__decode_id_part0(self, a_src);
|
||||
@@ -9109,7 +9132,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -9182,7 +9205,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -9240,7 +9263,7 @@ wuffs_gif__decoder__decode_lsd(wuffs_gif__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_lsd[0].scratch;
|
||||
uint32_t num_bits_0 = *scratch >> 56;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_0;
|
||||
@@ -9269,7 +9292,7 @@ wuffs_gif__decoder__decode_lsd(wuffs_gif__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_lsd[0].scratch;
|
||||
uint32_t num_bits_1 = *scratch >> 56;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_1;
|
||||
@@ -9296,7 +9319,8 @@ wuffs_gif__decoder__decode_lsd(wuffs_gif__decoder* self,
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
if (self->private_data.s_decode_lsd[0].scratch >
|
||||
((uint64_t)(io1_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_lsd[0].scratch -= io1_a_src - iop_a_src;
|
||||
self->private_data.s_decode_lsd[0].scratch -=
|
||||
((uint64_t)(io1_a_src - iop_a_src));
|
||||
iop_a_src = io1_a_src;
|
||||
status = wuffs_base__suspension__short_read;
|
||||
goto suspend;
|
||||
@@ -9321,7 +9345,7 @@ wuffs_gif__decoder__decode_lsd(wuffs_gif__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_lsd[0].scratch;
|
||||
uint32_t num_bits_3 = *scratch & 0xFF;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_3);
|
||||
@@ -9373,7 +9397,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -9421,7 +9445,7 @@ wuffs_gif__decoder__decode_extension(wuffs_gif__decoder* self,
|
||||
if (v_label == 249) {
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
status = wuffs_gif__decoder__decode_gc(self, a_src);
|
||||
@@ -9437,7 +9461,7 @@ wuffs_gif__decoder__decode_extension(wuffs_gif__decoder* self,
|
||||
} else if (v_label == 255) {
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
status = wuffs_gif__decoder__decode_ae(self, a_src);
|
||||
@@ -9453,7 +9477,7 @@ wuffs_gif__decoder__decode_extension(wuffs_gif__decoder* self,
|
||||
}
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
status = wuffs_gif__decoder__skip_blocks(self, a_src);
|
||||
@@ -9479,7 +9503,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -9533,7 +9557,8 @@ wuffs_gif__decoder__skip_blocks(wuffs_gif__decoder* self,
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
if (self->private_data.s_skip_blocks[0].scratch >
|
||||
((uint64_t)(io1_a_src - iop_a_src))) {
|
||||
self->private_data.s_skip_blocks[0].scratch -= io1_a_src - iop_a_src;
|
||||
self->private_data.s_skip_blocks[0].scratch -=
|
||||
((uint64_t)(io1_a_src - iop_a_src));
|
||||
iop_a_src = io1_a_src;
|
||||
status = wuffs_base__suspension__short_read;
|
||||
goto suspend;
|
||||
@@ -9555,7 +9580,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -9616,7 +9641,8 @@ wuffs_gif__decoder__decode_ae(wuffs_gif__decoder* self,
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
if (self->private_data.s_decode_ae[0].scratch >
|
||||
((uint64_t)(io1_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_ae[0].scratch -= io1_a_src - iop_a_src;
|
||||
self->private_data.s_decode_ae[0].scratch -=
|
||||
((uint64_t)(io1_a_src - iop_a_src));
|
||||
iop_a_src = io1_a_src;
|
||||
status = wuffs_base__suspension__short_read;
|
||||
goto suspend;
|
||||
@@ -9641,7 +9667,14 @@ wuffs_gif__decoder__decode_ae(wuffs_gif__decoder* self,
|
||||
(v_not_animexts || (v_c != wuffs_gif__animexts1dot0[v_block_size]));
|
||||
v_not_netscape =
|
||||
(v_not_netscape || (v_c != wuffs_gif__netscape2dot0[v_block_size]));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_block_size += 1;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
if (v_not_animexts && v_not_netscape) {
|
||||
goto label_0_break;
|
||||
@@ -9660,7 +9693,8 @@ wuffs_gif__decoder__decode_ae(wuffs_gif__decoder* self,
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
if (self->private_data.s_decode_ae[0].scratch >
|
||||
((uint64_t)(io1_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_ae[0].scratch -= io1_a_src - iop_a_src;
|
||||
self->private_data.s_decode_ae[0].scratch -=
|
||||
((uint64_t)(io1_a_src - iop_a_src));
|
||||
iop_a_src = io1_a_src;
|
||||
status = wuffs_base__suspension__short_read;
|
||||
goto suspend;
|
||||
@@ -9682,7 +9716,8 @@ wuffs_gif__decoder__decode_ae(wuffs_gif__decoder* self,
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
if (self->private_data.s_decode_ae[0].scratch >
|
||||
((uint64_t)(io1_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_ae[0].scratch -= io1_a_src - iop_a_src;
|
||||
self->private_data.s_decode_ae[0].scratch -=
|
||||
((uint64_t)(io1_a_src - iop_a_src));
|
||||
iop_a_src = io1_a_src;
|
||||
status = wuffs_base__suspension__short_read;
|
||||
goto suspend;
|
||||
@@ -9705,7 +9740,7 @@ wuffs_gif__decoder__decode_ae(wuffs_gif__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_ae[0].scratch;
|
||||
uint32_t num_bits_4 = *scratch >> 56;
|
||||
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_4;
|
||||
@@ -9729,7 +9764,7 @@ wuffs_gif__decoder__decode_ae(wuffs_gif__decoder* self,
|
||||
label_0_break:;
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
|
||||
status = wuffs_gif__decoder__skip_blocks(self, a_src);
|
||||
@@ -9758,7 +9793,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -9846,12 +9881,12 @@ wuffs_gif__decoder__decode_gc(wuffs_gif__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_gc[0].scratch;
|
||||
uint32_t num_bits_2 = *scratch >> 56;
|
||||
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_2;
|
||||
if (num_bits_2 == 8) {
|
||||
t_2 = *scratch;
|
||||
t_2 = ((uint16_t)(*scratch));
|
||||
break;
|
||||
}
|
||||
num_bits_2 += 8;
|
||||
@@ -9900,7 +9935,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -9949,7 +9984,7 @@ wuffs_gif__decoder__decode_id_part0(wuffs_gif__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_id_part0[0].scratch;
|
||||
uint32_t num_bits_0 = *scratch >> 56;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_0;
|
||||
@@ -9978,7 +10013,7 @@ wuffs_gif__decoder__decode_id_part0(wuffs_gif__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_id_part0[0].scratch;
|
||||
uint32_t num_bits_1 = *scratch >> 56;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_1;
|
||||
@@ -10007,7 +10042,7 @@ wuffs_gif__decoder__decode_id_part0(wuffs_gif__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_id_part0[0].scratch;
|
||||
uint32_t num_bits_2 = *scratch >> 56;
|
||||
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_2;
|
||||
@@ -10037,7 +10072,7 @@ wuffs_gif__decoder__decode_id_part0(wuffs_gif__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_id_part0[0].scratch;
|
||||
uint32_t num_bits_3 = *scratch >> 56;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_3;
|
||||
@@ -10075,7 +10110,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -10155,7 +10190,7 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self,
|
||||
}
|
||||
uint64_t* scratch =
|
||||
&self->private_data.s_decode_id_part1[0].scratch;
|
||||
uint32_t num_bits_1 = *scratch & 0xFF;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_1);
|
||||
@@ -10259,7 +10294,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -10391,7 +10426,7 @@ wuffs_gif__decoder__decode_id_part2(wuffs_gif__decoder* self,
|
||||
self->private_impl.f_compressed_ri,
|
||||
self->private_impl.f_compressed_wi));
|
||||
{
|
||||
u_r.meta.ri = iop_v_r - u_r.data.ptr;
|
||||
u_r.meta.ri = ((size_t)(iop_v_r - u_r.data.ptr));
|
||||
wuffs_base__status t_1 = wuffs_lzw__decoder__decode_io_writer(
|
||||
&self->private_data.f_lzw,
|
||||
wuffs_base__utility__null_io_writer(), v_r,
|
||||
@@ -10424,7 +10459,7 @@ wuffs_gif__decoder__decode_id_part2(wuffs_gif__decoder* self,
|
||||
if (self->private_data.s_decode_id_part2[0].scratch >
|
||||
((uint64_t)(io1_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_id_part2[0].scratch -=
|
||||
io1_a_src - iop_a_src;
|
||||
((uint64_t)(io1_a_src - iop_a_src));
|
||||
iop_a_src = io1_a_src;
|
||||
status = wuffs_base__suspension__short_read;
|
||||
goto suspend;
|
||||
@@ -10432,7 +10467,7 @@ wuffs_gif__decoder__decode_id_part2(wuffs_gif__decoder* self,
|
||||
iop_a_src += self->private_data.s_decode_id_part2[0].scratch;
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
status = wuffs_gif__decoder__skip_blocks(self, a_src);
|
||||
@@ -10489,7 +10524,7 @@ suspend:
|
||||
exit:
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -10558,7 +10593,14 @@ label_0_continue:;
|
||||
while (
|
||||
(self->private_impl.f_interlace > 0) &&
|
||||
(self->private_impl.f_dst_y >= self->private_impl.f_frame_rect_y1)) {
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
self->private_impl.f_interlace -= 1;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
self->private_impl.f_dst_y = wuffs_base__u32__sat_add(
|
||||
self->private_impl.f_frame_rect_y0,
|
||||
wuffs_gif__interlace_start[self->private_impl.f_interlace]);
|
||||
@@ -10585,7 +10627,14 @@ label_0_continue:;
|
||||
while (
|
||||
(self->private_impl.f_interlace > 0) &&
|
||||
(self->private_impl.f_dst_y >= self->private_impl.f_frame_rect_y1)) {
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
self->private_impl.f_interlace -= 1;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
self->private_impl.f_dst_y = wuffs_base__u32__sat_add(
|
||||
self->private_impl.f_frame_rect_y0,
|
||||
wuffs_gif__interlace_start[self->private_impl.f_interlace]);
|
||||
@@ -10846,7 +10895,8 @@ wuffs_gzip__decoder__decode_io_writer(wuffs_gzip__decoder* self,
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
if (self->private_data.s_decode_io_writer[0].scratch >
|
||||
((uint64_t)(io1_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_io_writer[0].scratch -= io1_a_src - iop_a_src;
|
||||
self->private_data.s_decode_io_writer[0].scratch -=
|
||||
((uint64_t)(io1_a_src - iop_a_src));
|
||||
iop_a_src = io1_a_src;
|
||||
status = wuffs_base__suspension__short_read;
|
||||
goto suspend;
|
||||
@@ -10869,12 +10919,12 @@ wuffs_gzip__decoder__decode_io_writer(wuffs_gzip__decoder* self,
|
||||
}
|
||||
uint64_t* scratch =
|
||||
&self->private_data.s_decode_io_writer[0].scratch;
|
||||
uint32_t num_bits_4 = *scratch >> 56;
|
||||
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_4;
|
||||
if (num_bits_4 == 8) {
|
||||
t_4 = *scratch;
|
||||
t_4 = ((uint16_t)(*scratch));
|
||||
break;
|
||||
}
|
||||
num_bits_4 += 8;
|
||||
@@ -10888,7 +10938,7 @@ wuffs_gzip__decoder__decode_io_writer(wuffs_gzip__decoder* self,
|
||||
if (self->private_data.s_decode_io_writer[0].scratch >
|
||||
((uint64_t)(io1_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_io_writer[0].scratch -=
|
||||
io1_a_src - iop_a_src;
|
||||
((uint64_t)(io1_a_src - iop_a_src));
|
||||
iop_a_src = io1_a_src;
|
||||
status = wuffs_base__suspension__short_read;
|
||||
goto suspend;
|
||||
@@ -10935,7 +10985,7 @@ wuffs_gzip__decoder__decode_io_writer(wuffs_gzip__decoder* self,
|
||||
if (self->private_data.s_decode_io_writer[0].scratch >
|
||||
((uint64_t)(io1_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_io_writer[0].scratch -=
|
||||
io1_a_src - iop_a_src;
|
||||
((uint64_t)(io1_a_src - iop_a_src));
|
||||
iop_a_src = io1_a_src;
|
||||
status = wuffs_base__suspension__short_read;
|
||||
goto suspend;
|
||||
@@ -10951,11 +11001,11 @@ wuffs_gzip__decoder__decode_io_writer(wuffs_gzip__decoder* self,
|
||||
{
|
||||
if (a_dst.private_impl.buf) {
|
||||
a_dst.private_impl.buf->meta.wi =
|
||||
iop_a_dst - a_dst.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_dst - a_dst.private_impl.buf->data.ptr));
|
||||
}
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_7 = wuffs_deflate__decoder__decode_io_writer(
|
||||
&self->private_data.f_flate, a_dst, a_src, a_workbuf);
|
||||
@@ -11000,12 +11050,12 @@ wuffs_gzip__decoder__decode_io_writer(wuffs_gzip__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_io_writer[0].scratch;
|
||||
uint32_t num_bits_8 = *scratch >> 56;
|
||||
uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_8;
|
||||
if (num_bits_8 == 24) {
|
||||
t_8 = *scratch;
|
||||
t_8 = ((uint32_t)(*scratch));
|
||||
break;
|
||||
}
|
||||
num_bits_8 += 8;
|
||||
@@ -11029,12 +11079,12 @@ wuffs_gzip__decoder__decode_io_writer(wuffs_gzip__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_io_writer[0].scratch;
|
||||
uint32_t num_bits_9 = *scratch >> 56;
|
||||
uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_9;
|
||||
if (num_bits_9 == 24) {
|
||||
t_9 = *scratch;
|
||||
t_9 = ((uint32_t)(*scratch));
|
||||
break;
|
||||
}
|
||||
num_bits_9 += 8;
|
||||
@@ -11070,11 +11120,11 @@ suspend:
|
||||
exit:
|
||||
if (a_dst.private_impl.buf) {
|
||||
a_dst.private_impl.buf->meta.wi =
|
||||
iop_a_dst - a_dst.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_dst - a_dst.private_impl.buf->data.ptr));
|
||||
}
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(status)) {
|
||||
@@ -11287,12 +11337,12 @@ wuffs_zlib__decoder__decode_io_writer(wuffs_zlib__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_io_writer[0].scratch;
|
||||
uint32_t num_bits_0 = *scratch & 0xFF;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_0);
|
||||
if (num_bits_0 == 8) {
|
||||
t_0 = *scratch >> 48;
|
||||
t_0 = ((uint16_t)(*scratch >> 48));
|
||||
break;
|
||||
}
|
||||
num_bits_0 += 8;
|
||||
@@ -11322,11 +11372,11 @@ wuffs_zlib__decoder__decode_io_writer(wuffs_zlib__decoder* self,
|
||||
{
|
||||
if (a_dst.private_impl.buf) {
|
||||
a_dst.private_impl.buf->meta.wi =
|
||||
iop_a_dst - a_dst.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_dst - a_dst.private_impl.buf->data.ptr));
|
||||
}
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_1 = wuffs_deflate__decoder__decode_io_writer(
|
||||
&self->private_data.f_flate, a_dst, a_src, a_workbuf);
|
||||
@@ -11369,12 +11419,12 @@ wuffs_zlib__decoder__decode_io_writer(wuffs_zlib__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_io_writer[0].scratch;
|
||||
uint32_t num_bits_2 = *scratch & 0xFF;
|
||||
uint32_t num_bits_2 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_2);
|
||||
if (num_bits_2 == 24) {
|
||||
t_2 = *scratch >> 32;
|
||||
t_2 = ((uint32_t)(*scratch >> 32));
|
||||
break;
|
||||
}
|
||||
num_bits_2 += 8;
|
||||
@@ -11405,11 +11455,11 @@ suspend:
|
||||
exit:
|
||||
if (a_dst.private_impl.buf) {
|
||||
a_dst.private_impl.buf->meta.wi =
|
||||
iop_a_dst - a_dst.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_dst - a_dst.private_impl.buf->data.ptr));
|
||||
}
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(status)) {
|
||||
|
||||
Reference in new issue
Block a user