diff --git a/cmd/wuffs-c/internal/cgen/base-header.h b/cmd/wuffs-c/internal/cgen/base-header.h index a65f1237..3bfa8189 100644 --- a/cmd/wuffs-c/internal/cgen/base-header.h +++ b/cmd/wuffs-c/internal/cgen/base-header.h @@ -49,7 +49,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/cmd/wuffs-c/internal/cgen/data.go b/cmd/wuffs-c/internal/cgen/data.go index 636a61e1..97c61d39 100644 --- a/cmd/wuffs-c/internal/cgen/data.go +++ b/cmd/wuffs-c/internal/cgen/data.go @@ -20,7 +20,7 @@ const baseHeader = "" + "#ifndef WUFFS_BASE_HEADER_H\n#define WUFFS_BASE_HEADER_H\n\n// Copyright 2017 The Wuffs Authors.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// https://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n#include \n#include \n#include \n\n// Wuffs assumes that:\n// - converting a uint32_t to a size_t will never overflow.\n// - converting a size_t to a uint64_t will never overflow.\n#if (__WORDSIZE != 32) && (__WORDSIZE != 64)\n#error \"Wuffs requires a word size of either 32 or 64 bits\"\n#endif\n\n// WUFFS_VERSION is the major.minor version number " + "as a uint32_t. The major\n// number is the high 16 bits. The minor number is the low 16 bits.\n//\n// The intention is to bump the version number at least on every API / ABI\n// backwards incompatible change.\n//\n// For now, the API and ABI are simply unstable and can change at any time.\n//\n// TODO: don't hard code this in base-header.h.\n#define WUFFS_VERSION ((uint32_t)0x00001)\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct {\n} wuffs_base__empty_struct;\n\n" + "" + - "// ---------------- Numeric Types\n\n// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a\n// second. See https://github.com/OculusVR/Flicks\ntypedef uint64_t wuffs_base__flicks;\n\n#define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000)\n#define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600)\n\n" + + "// ---------------- Numeric Types\n\n// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a\n// second. See https://github.com/OculusVR/Flicks\ntypedef int64_t wuffs_base__flicks;\n\n#define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000)\n#define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600)\n\n" + "" + "// --------\n\nstatic inline uint8_t wuffs_base__u8__min(uint8_t x, uint8_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint8_t wuffs_base__u8__max(uint8_t x, uint8_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint16_t wuffs_base__u16__min(uint16_t x, uint16_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint16_t wuffs_base__u16__max(uint16_t x, uint16_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint32_t wuffs_base__u32__min(uint32_t x, uint32_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint32_t wuffs_base__u32__max(uint32_t x, uint32_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint64_t wuffs_base__u64__min(uint64_t x, uint64_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint64_t wuffs_base__u64__max(uint64_t x, uint64_t y) {\n return x > y ? x : y;\n}\n\n" + "" + diff --git a/gen/c/std/adler32.c b/gen/c/std/adler32.c index 765bdaf6..7e698064 100644 --- a/gen/c/std/adler32.c +++ b/gen/c/std/adler32.c @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/c/std/crc32.c b/gen/c/std/crc32.c index 852c7508..e201716c 100644 --- a/gen/c/std/crc32.c +++ b/gen/c/std/crc32.c @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/c/std/deflate.c b/gen/c/std/deflate.c index acf2aca2..c86bb4bd 100644 --- a/gen/c/std/deflate.c +++ b/gen/c/std/deflate.c @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index f338b14e..51107567 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index 2100f2d1..334576b1 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/c/std/lzw.c b/gen/c/std/lzw.c index 4bae412a..347f2d31 100644 --- a/gen/c/std/lzw.c +++ b/gen/c/std/lzw.c @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/c/std/zlib.c b/gen/c/std/zlib.c index 3e7eeb99..7e193f23 100644 --- a/gen/c/std/zlib.c +++ b/gen/c/std/zlib.c @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/h/std/adler32.h b/gen/h/std/adler32.h index b85ef54e..4a024454 100644 --- a/gen/h/std/adler32.h +++ b/gen/h/std/adler32.h @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/h/std/crc32.h b/gen/h/std/crc32.h index d4401f83..ea1504ef 100644 --- a/gen/h/std/crc32.h +++ b/gen/h/std/crc32.h @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/h/std/deflate.h b/gen/h/std/deflate.h index 2f9a97e1..bfd06368 100644 --- a/gen/h/std/deflate.h +++ b/gen/h/std/deflate.h @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/h/std/gif.h b/gen/h/std/gif.h index 274e16da..42bf0333 100644 --- a/gen/h/std/gif.h +++ b/gen/h/std/gif.h @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/h/std/gzip.h b/gen/h/std/gzip.h index d09f4192..fe4011ff 100644 --- a/gen/h/std/gzip.h +++ b/gen/h/std/gzip.h @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/h/std/lzw.h b/gen/h/std/lzw.h index 78a20615..ef83c92c 100644 --- a/gen/h/std/lzw.h +++ b/gen/h/std/lzw.h @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/gen/h/std/zlib.h b/gen/h/std/zlib.h index 5c1edd3e..716b97eb 100644 --- a/gen/h/std/zlib.h +++ b/gen/h/std/zlib.h @@ -52,7 +52,7 @@ typedef struct { // Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a // second. See https://github.com/OculusVR/Flicks -typedef uint64_t wuffs_base__flicks; +typedef int64_t wuffs_base__flicks; #define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000) #define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600) diff --git a/lang/builtin/builtin.go b/lang/builtin/builtin.go index 00321bdf..ca00f282 100644 --- a/lang/builtin/builtin.go +++ b/lang/builtin/builtin.go @@ -123,7 +123,9 @@ var Funcs = []string{ // ---- image_buffer "image_buffer.plane(p u32[..3])(ret table u8)", - "image_buffer.update!(dirty_rect rect_ie_u32, duration u64, blend bool, disposal u8, palette slice u8)()", + // Duration's upper bound is the maximum possible i64 value. + "image_buffer.update!(dirty_rect rect_ie_u32, duration u64[..0xFFFFFFFFFFFFFFF], " + + "blend bool, disposal u8, palette slice u8)()", // ---- image_config diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index 08ecc2c5..9126dcc0 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -61,7 +61,8 @@ pub struct decoder?( gc_has_transparent_index base.bool, gc_transparent_index base.u8, gc_disposal base.u8, - gc_duration base.u64, + // There are 7056000 flicks per centisecond. + gc_duration base.u64[..0xFFFF * 7056000], frame_rect base.rect_ie_u32,