mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Add an image_config concept
This commit is contained in:
1 parent
de9000cc70
commit
d750ea7653
15 files changed
+600
-88
No files matched your search
@@ -45,6 +45,8 @@
|
||||
// TODO: don't hard code this in base-header.h.
|
||||
#define WUFFS_VERSION (0x00001)
|
||||
|
||||
// ---------------- I/O
|
||||
|
||||
// wuffs_base__slice_u8 is a 1-dimensional buffer (a pointer and length).
|
||||
//
|
||||
// A value with all fields NULL or zero is a valid, empty slice.
|
||||
@@ -102,4 +104,72 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__writer1;
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
uint32_t flags;
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
// TODO: color model, including both packed RGBA and planar,
|
||||
// chroma-subsampled YCbCr.
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
wuffs_base__image_config* c) {
|
||||
if (c) {
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool wuffs_base__image_config__valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !(c->private_impl.flags & 1)) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.w : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.h : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
// decoding into a color model different from the format's intrinsic one? For
|
||||
// example, decoding a JPEG image straight to RGBA instead of to YCbCr?
|
||||
static inline size_t wuffs_base__image_config__pixbuf_size(
|
||||
wuffs_base__image_config* c) {
|
||||
if (wuffs_base__image_config__valid(c)) {
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return (size_t)wh;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t TODO_color_model) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c->private_impl.flags = 1;
|
||||
c->private_impl.w = width;
|
||||
c->private_impl.h = height;
|
||||
// TODO: color model.
|
||||
}
|
||||
|
||||
#endif // WUFFS_BASE_HEADER_H
|
||||
@@ -18,9 +18,11 @@ package cgen
|
||||
|
||||
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 <stdbool.h>\n#include <stdint.h>\n#include <string.h>\n\n// Wuffs requires a word size of at least 32 bits because it assumes that\n// converting a u32 to usize will never overflow. For example, the size of a\n// decoded image is often represented, explicitly or implicitly in an image\n// file, as a u32, and it is convenient to compare that to a buffer size.\n//\n// Si" +
|
||||
"milarly, the word size is at most 64 bits because it assumes that\n// converting a usize to u64 will never overflow.\n#if __WORDSIZE < 32\n#error \"Wuffs requires a word size of at least 32 bits\"\n#elif __WORDSIZE > 64\n#error \"Wuffs requires a word size of at most 64 bits\"\n#endif\n\n// WUFFS_VERSION is the major.minor version number as a uint32. 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 (0x00001)\n\n// wuffs_base__slice_u8 is a 1-dimensional buffer (a pointer and length).\n//\n// A value with all fields NULL or zero is a valid, empty slice.\ntypedef struct {\n uint8_t* ptr;\n size_t len;\n} wuffs_base__slice_u8;\n\n// wuffs_base__buf1 is a 1-dimensional buffer (a pointer and length), plus\n// additional indexes into that buffer, p" +
|
||||
"lus an opened / closed flag.\n//\n// A value with all fields NULL or zero is a valid, empty buffer.\ntypedef struct {\n uint8_t* ptr; // Pointer.\n size_t len; // Length.\n size_t wi; // Write index. Invariant: wi <= len.\n size_t ri; // Read index. Invariant: ri <= wi.\n bool closed; // No further writes are expected.\n} wuffs_base__buf1;\n\n// wuffs_base__limit1 provides a limited view of a 1-dimensional byte stream:\n// its first N bytes. That N can be greater than a buffer's current read or\n// write capacity. N decreases naturally over time as bytes are read from or\n// written to the stream.\n//\n// A value with all fields NULL or zero is a valid, unlimited view.\ntypedef struct wuffs_base__limit1 {\n uint64_t* ptr_to_len; // Pointer to N.\n struct wuffs_base__limit1* next; // Linked list of limits.\n} wuffs_base__limit1;\n\ntypedef struct {\n // TODO: move buf into private_impl? As it is, it looks like users can modify\n // the buf field to point to a different buffer, which can turn the l" +
|
||||
"imit and\n // mark fields into dangling pointers.\n wuffs_base__buf1* buf;\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__limit1 limit;\n uint8_t* mark;\n } private_impl;\n} wuffs_base__reader1;\n\ntypedef struct {\n // TODO: move buf into private_impl? As it is, it looks like users can modify\n // the buf field to point to a different buffer, which can turn the limit and\n // mark fields into dangling pointers.\n wuffs_base__buf1* buf;\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__limit1 limit;\n uint8_t* mark;\n } private_impl;\n} wuffs_base__writer1;\n\n#endif // WUFFS_BASE_HEADER_H\n" +
|
||||
"milarly, the word size is at most 64 bits because it assumes that\n// converting a usize to u64 will never overflow.\n#if __WORDSIZE < 32\n#error \"Wuffs requires a word size of at least 32 bits\"\n#elif __WORDSIZE > 64\n#error \"Wuffs requires a word size of at most 64 bits\"\n#endif\n\n// WUFFS_VERSION is the major.minor version number as a uint32. 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 (0x00001)\n\n// ---------------- I/O\n\n// wuffs_base__slice_u8 is a 1-dimensional buffer (a pointer and length).\n//\n// A value with all fields NULL or zero is a valid, empty slice.\ntypedef struct {\n uint8_t* ptr;\n size_t len;\n} wuffs_base__slice_u8;\n\n// wuffs_base__buf1 is a 1-dimensional buffer (a pointer and length), plus\n// additional in" +
|
||||
"dexes into that buffer, plus an opened / closed flag.\n//\n// A value with all fields NULL or zero is a valid, empty buffer.\ntypedef struct {\n uint8_t* ptr; // Pointer.\n size_t len; // Length.\n size_t wi; // Write index. Invariant: wi <= len.\n size_t ri; // Read index. Invariant: ri <= wi.\n bool closed; // No further writes are expected.\n} wuffs_base__buf1;\n\n// wuffs_base__limit1 provides a limited view of a 1-dimensional byte stream:\n// its first N bytes. That N can be greater than a buffer's current read or\n// write capacity. N decreases naturally over time as bytes are read from or\n// written to the stream.\n//\n// A value with all fields NULL or zero is a valid, unlimited view.\ntypedef struct wuffs_base__limit1 {\n uint64_t* ptr_to_len; // Pointer to N.\n struct wuffs_base__limit1* next; // Linked list of limits.\n} wuffs_base__limit1;\n\ntypedef struct {\n // TODO: move buf into private_impl? As it is, it looks like users can modify\n // the buf field to point to a different buf" +
|
||||
"fer, which can turn the limit and\n // mark fields into dangling pointers.\n wuffs_base__buf1* buf;\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__limit1 limit;\n uint8_t* mark;\n } private_impl;\n} wuffs_base__reader1;\n\ntypedef struct {\n // TODO: move buf into private_impl? As it is, it looks like users can modify\n // the buf field to point to a different buffer, which can turn the limit and\n // mark fields into dangling pointers.\n wuffs_base__buf1* buf;\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__limit1 limit;\n uint8_t* mark;\n } private_impl;\n} wuffs_base__writer1;\n\n// ---------------- Images\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n uint32_t flags;\n uint32_t w;\n " +
|
||||
" uint32_t h;\n // TODO: color model, including both packed RGBA and planar,\n // chroma-subsampled YCbCr.\n } private_impl;\n} wuffs_base__image_config;\n\nstatic inline void wuffs_base__image_config__invalidate(\n wuffs_base__image_config* c) {\n if (c) {\n *c = ((wuffs_base__image_config){});\n }\n}\n\nstatic inline bool wuffs_base__image_config__valid(\n wuffs_base__image_config* c) {\n if (!c || !(c->private_impl.flags & 1)) {\n return false;\n }\n uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);\n // TODO: handle things other than 1 byte per pixel.\n return wh <= ((uint64_t)SIZE_MAX);\n}\n\nstatic inline uint32_t wuffs_base__image_config__width(\n wuffs_base__image_config* c) {\n return wuffs_base__image_config__valid(c) ? c->private_impl.w : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__height(\n wuffs_base__image_config* c) {\n return wuffs_base__image_config__valid(c) ? c->private_impl.h : 0;\n}\n\n// TODO: this is the right API for planar (not packed) pixbuf" +
|
||||
"s? Should it allow\n// decoding into a color model different from the format's intrinsic one? For\n// example, decoding a JPEG image straight to RGBA instead of to YCbCr?\nstatic inline size_t wuffs_base__image_config__pixbuf_size(\n wuffs_base__image_config* c) {\n if (wuffs_base__image_config__valid(c)) {\n uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);\n // TODO: handle things other than 1 byte per pixel.\n return (size_t)wh;\n }\n return 0;\n}\n\nstatic inline void wuffs_base__image_config__initialize(\n wuffs_base__image_config* c,\n uint32_t width,\n uint32_t height,\n uint32_t TODO_color_model) {\n if (!c) {\n return;\n }\n c->private_impl.flags = 1;\n c->private_impl.w = width;\n c->private_impl.h = height;\n // TODO: color model.\n}\n\n#endif // WUFFS_BASE_HEADER_H\n" +
|
||||
""
|
||||
|
||||
const baseImpl = "" +
|
||||
|
||||
@@ -581,6 +581,11 @@ func (g *gen) writeCTypeName(b *buffer, n *a.TypeExpr, varNamePrefix string, var
|
||||
// See gen.writeInitializerImpl for a similar use of otherPkg.
|
||||
prefix = "wuffs_" + otherPkg + "__"
|
||||
}
|
||||
// TODO: remove this hack when "image_config" in Wuffs code becomes
|
||||
// "base.image_config".
|
||||
if qid[1] == t.IDImageConfig {
|
||||
prefix = "wuffs_base__"
|
||||
}
|
||||
b.printf("%s%s", prefix, qid[1].Str(g.tm))
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,9 @@ size_t pjw_len;
|
||||
static void ignore_return_value(int ignored) {}
|
||||
|
||||
static const char* decode() {
|
||||
wuffs_gif__decoder dec;
|
||||
wuffs_gif__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
||||
wuffs_base__image_config ic = {{0}};
|
||||
uint8_t dst_buffer[DST_BUFFER_SIZE];
|
||||
wuffs_base__buf1 dst = {.ptr = dst_buffer, .len = DST_BUFFER_SIZE};
|
||||
wuffs_base__buf1 src = {
|
||||
@@ -56,10 +59,8 @@ static const char* decode() {
|
||||
wuffs_base__writer1 dst_writer = {.buf = &dst};
|
||||
wuffs_base__reader1 src_reader = {.buf = &src};
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
wuffs_gif__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
||||
wuffs_gif__status s =
|
||||
wuffs_gif__decoder__decode_config(&dec, dst_writer, src_reader);
|
||||
wuffs_gif__decoder__decode_config(&dec, &ic, src_reader);
|
||||
if (s) {
|
||||
return wuffs_gif__status__string(s);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
// TODO: don't hard code this in base-header.h.
|
||||
#define WUFFS_VERSION (0x00001)
|
||||
|
||||
// ---------------- I/O
|
||||
|
||||
// wuffs_base__slice_u8 is a 1-dimensional buffer (a pointer and length).
|
||||
//
|
||||
// A value with all fields NULL or zero is a valid, empty slice.
|
||||
@@ -105,6 +107,74 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__writer1;
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
uint32_t flags;
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
// TODO: color model, including both packed RGBA and planar,
|
||||
// chroma-subsampled YCbCr.
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
wuffs_base__image_config* c) {
|
||||
if (c) {
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool wuffs_base__image_config__valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !(c->private_impl.flags & 1)) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.w : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.h : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
// decoding into a color model different from the format's intrinsic one? For
|
||||
// example, decoding a JPEG image straight to RGBA instead of to YCbCr?
|
||||
static inline size_t wuffs_base__image_config__pixbuf_size(
|
||||
wuffs_base__image_config* c) {
|
||||
if (wuffs_base__image_config__valid(c)) {
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return (size_t)wh;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t TODO_color_model) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c->private_impl.flags = 1;
|
||||
c->private_impl.w = width;
|
||||
c->private_impl.h = height;
|
||||
// TODO: color model.
|
||||
}
|
||||
|
||||
#endif // WUFFS_BASE_HEADER_H
|
||||
|
||||
// ---------------- Use Declarations
|
||||
|
||||
+82
-6
@@ -48,6 +48,8 @@
|
||||
// TODO: don't hard code this in base-header.h.
|
||||
#define WUFFS_VERSION (0x00001)
|
||||
|
||||
// ---------------- I/O
|
||||
|
||||
// wuffs_base__slice_u8 is a 1-dimensional buffer (a pointer and length).
|
||||
//
|
||||
// A value with all fields NULL or zero is a valid, empty slice.
|
||||
@@ -105,6 +107,74 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__writer1;
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
uint32_t flags;
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
// TODO: color model, including both packed RGBA and planar,
|
||||
// chroma-subsampled YCbCr.
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
wuffs_base__image_config* c) {
|
||||
if (c) {
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool wuffs_base__image_config__valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !(c->private_impl.flags & 1)) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.w : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.h : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
// decoding into a color model different from the format's intrinsic one? For
|
||||
// example, decoding a JPEG image straight to RGBA instead of to YCbCr?
|
||||
static inline size_t wuffs_base__image_config__pixbuf_size(
|
||||
wuffs_base__image_config* c) {
|
||||
if (wuffs_base__image_config__valid(c)) {
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return (size_t)wh;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t TODO_color_model) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c->private_impl.flags = 1;
|
||||
c->private_impl.w = width;
|
||||
c->private_impl.h = height;
|
||||
// TODO: color model.
|
||||
}
|
||||
|
||||
#endif // WUFFS_BASE_HEADER_H
|
||||
|
||||
// ---------------- Use Declarations
|
||||
@@ -261,9 +331,10 @@ void wuffs_gif__decoder__initialize(wuffs_gif__decoder* self,
|
||||
|
||||
// ---------------- Public Function Prototypes
|
||||
|
||||
wuffs_gif__status wuffs_gif__decoder__decode_config(wuffs_gif__decoder* self,
|
||||
wuffs_base__writer1 a_dst,
|
||||
wuffs_base__reader1 a_src);
|
||||
wuffs_gif__status wuffs_gif__decoder__decode_config(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__reader1 a_src);
|
||||
|
||||
wuffs_gif__status wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
||||
wuffs_base__writer1 a_dst,
|
||||
@@ -746,9 +817,10 @@ void wuffs_gif__decoder__initialize(wuffs_gif__decoder* self,
|
||||
|
||||
// ---------------- Function Implementations
|
||||
|
||||
wuffs_gif__status wuffs_gif__decoder__decode_config(wuffs_gif__decoder* self,
|
||||
wuffs_base__writer1 a_dst,
|
||||
wuffs_base__reader1 a_src) {
|
||||
wuffs_gif__status wuffs_gif__decoder__decode_config(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__reader1 a_src) {
|
||||
if (!self) {
|
||||
return WUFFS_GIF__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
@@ -759,6 +831,10 @@ wuffs_gif__status wuffs_gif__decoder__decode_config(wuffs_gif__decoder* self,
|
||||
return self->private_impl.status;
|
||||
}
|
||||
wuffs_gif__status status = WUFFS_GIF__STATUS_OK;
|
||||
if (!a_dst) {
|
||||
status = WUFFS_GIF__ERROR_BAD_ARGUMENT;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point =
|
||||
self->private_impl.c_decode_config[0].coro_susp_point;
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
// TODO: don't hard code this in base-header.h.
|
||||
#define WUFFS_VERSION (0x00001)
|
||||
|
||||
// ---------------- I/O
|
||||
|
||||
// wuffs_base__slice_u8 is a 1-dimensional buffer (a pointer and length).
|
||||
//
|
||||
// A value with all fields NULL or zero is a valid, empty slice.
|
||||
@@ -105,6 +107,74 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__writer1;
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
uint32_t flags;
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
// TODO: color model, including both packed RGBA and planar,
|
||||
// chroma-subsampled YCbCr.
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
wuffs_base__image_config* c) {
|
||||
if (c) {
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool wuffs_base__image_config__valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !(c->private_impl.flags & 1)) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.w : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.h : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
// decoding into a color model different from the format's intrinsic one? For
|
||||
// example, decoding a JPEG image straight to RGBA instead of to YCbCr?
|
||||
static inline size_t wuffs_base__image_config__pixbuf_size(
|
||||
wuffs_base__image_config* c) {
|
||||
if (wuffs_base__image_config__valid(c)) {
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return (size_t)wh;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t TODO_color_model) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c->private_impl.flags = 1;
|
||||
c->private_impl.w = width;
|
||||
c->private_impl.h = height;
|
||||
// TODO: color model.
|
||||
}
|
||||
|
||||
#endif // WUFFS_BASE_HEADER_H
|
||||
|
||||
// ---------------- Use Declarations
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
// TODO: don't hard code this in base-header.h.
|
||||
#define WUFFS_VERSION (0x00001)
|
||||
|
||||
// ---------------- I/O
|
||||
|
||||
// wuffs_base__slice_u8 is a 1-dimensional buffer (a pointer and length).
|
||||
//
|
||||
// A value with all fields NULL or zero is a valid, empty slice.
|
||||
@@ -105,6 +107,74 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__writer1;
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
uint32_t flags;
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
// TODO: color model, including both packed RGBA and planar,
|
||||
// chroma-subsampled YCbCr.
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
wuffs_base__image_config* c) {
|
||||
if (c) {
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool wuffs_base__image_config__valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !(c->private_impl.flags & 1)) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.w : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.h : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
// decoding into a color model different from the format's intrinsic one? For
|
||||
// example, decoding a JPEG image straight to RGBA instead of to YCbCr?
|
||||
static inline size_t wuffs_base__image_config__pixbuf_size(
|
||||
wuffs_base__image_config* c) {
|
||||
if (wuffs_base__image_config__valid(c)) {
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return (size_t)wh;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t TODO_color_model) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c->private_impl.flags = 1;
|
||||
c->private_impl.w = width;
|
||||
c->private_impl.h = height;
|
||||
// TODO: color model.
|
||||
}
|
||||
|
||||
#endif // WUFFS_BASE_HEADER_H
|
||||
|
||||
// ---------------- Use Declarations
|
||||
|
||||
+74
-3
@@ -48,6 +48,8 @@
|
||||
// TODO: don't hard code this in base-header.h.
|
||||
#define WUFFS_VERSION (0x00001)
|
||||
|
||||
// ---------------- I/O
|
||||
|
||||
// wuffs_base__slice_u8 is a 1-dimensional buffer (a pointer and length).
|
||||
//
|
||||
// A value with all fields NULL or zero is a valid, empty slice.
|
||||
@@ -105,6 +107,74 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__writer1;
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
uint32_t flags;
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
// TODO: color model, including both packed RGBA and planar,
|
||||
// chroma-subsampled YCbCr.
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
wuffs_base__image_config* c) {
|
||||
if (c) {
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool wuffs_base__image_config__valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !(c->private_impl.flags & 1)) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.w : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.h : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
// decoding into a color model different from the format's intrinsic one? For
|
||||
// example, decoding a JPEG image straight to RGBA instead of to YCbCr?
|
||||
static inline size_t wuffs_base__image_config__pixbuf_size(
|
||||
wuffs_base__image_config* c) {
|
||||
if (wuffs_base__image_config__valid(c)) {
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return (size_t)wh;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t TODO_color_model) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c->private_impl.flags = 1;
|
||||
c->private_impl.w = width;
|
||||
c->private_impl.h = height;
|
||||
// TODO: color model.
|
||||
}
|
||||
|
||||
#endif // WUFFS_BASE_HEADER_H
|
||||
|
||||
// ---------------- Use Declarations
|
||||
@@ -261,9 +331,10 @@ void wuffs_gif__decoder__initialize(wuffs_gif__decoder* self,
|
||||
|
||||
// ---------------- Public Function Prototypes
|
||||
|
||||
wuffs_gif__status wuffs_gif__decoder__decode_config(wuffs_gif__decoder* self,
|
||||
wuffs_base__writer1 a_dst,
|
||||
wuffs_base__reader1 a_src);
|
||||
wuffs_gif__status wuffs_gif__decoder__decode_config(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__reader1 a_src);
|
||||
|
||||
wuffs_gif__status wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
||||
wuffs_base__writer1 a_dst,
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
// TODO: don't hard code this in base-header.h.
|
||||
#define WUFFS_VERSION (0x00001)
|
||||
|
||||
// ---------------- I/O
|
||||
|
||||
// wuffs_base__slice_u8 is a 1-dimensional buffer (a pointer and length).
|
||||
//
|
||||
// A value with all fields NULL or zero is a valid, empty slice.
|
||||
@@ -105,6 +107,74 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__writer1;
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
uint32_t flags;
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
// TODO: color model, including both packed RGBA and planar,
|
||||
// chroma-subsampled YCbCr.
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
wuffs_base__image_config* c) {
|
||||
if (c) {
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool wuffs_base__image_config__valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !(c->private_impl.flags & 1)) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.w : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__valid(c) ? c->private_impl.h : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
// decoding into a color model different from the format's intrinsic one? For
|
||||
// example, decoding a JPEG image straight to RGBA instead of to YCbCr?
|
||||
static inline size_t wuffs_base__image_config__pixbuf_size(
|
||||
wuffs_base__image_config* c) {
|
||||
if (wuffs_base__image_config__valid(c)) {
|
||||
uint64_t wh = ((uint64_t)c->private_impl.w) * ((uint64_t)c->private_impl.h);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
return (size_t)wh;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t TODO_color_model) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
c->private_impl.flags = 1;
|
||||
c->private_impl.w = width;
|
||||
c->private_impl.h = height;
|
||||
// TODO: color model.
|
||||
}
|
||||
|
||||
#endif // WUFFS_BASE_HEADER_H
|
||||
|
||||
// ---------------- Use Declarations
|
||||
|
||||
@@ -72,6 +72,7 @@ var Types = []string{
|
||||
"status",
|
||||
"reader1",
|
||||
"writer1",
|
||||
"image_config",
|
||||
}
|
||||
|
||||
var Funcs = []string{
|
||||
|
||||
+18
-16
@@ -38,14 +38,15 @@ var (
|
||||
typeExprIdeal = a.NewTypeExpr(0, 0, t.IDDoubleZ, nil, nil, nil)
|
||||
typeExprList = a.NewTypeExpr(0, 0, t.IDDollar, nil, nil, nil)
|
||||
|
||||
typeExprU8 = a.NewTypeExpr(0, 0, t.IDU8, nil, nil, nil)
|
||||
typeExprU16 = a.NewTypeExpr(0, 0, t.IDU16, nil, nil, nil)
|
||||
typeExprU32 = a.NewTypeExpr(0, 0, t.IDU32, nil, nil, nil)
|
||||
typeExprU64 = a.NewTypeExpr(0, 0, t.IDU64, nil, nil, nil)
|
||||
typeExprBool = a.NewTypeExpr(0, 0, t.IDBool, nil, nil, nil)
|
||||
typeExprStatus = a.NewTypeExpr(0, 0, t.IDStatus, nil, nil, nil)
|
||||
typeExprReader1 = a.NewTypeExpr(0, 0, t.IDReader1, nil, nil, nil)
|
||||
typeExprWriter1 = a.NewTypeExpr(0, 0, t.IDWriter1, nil, nil, nil)
|
||||
typeExprU8 = a.NewTypeExpr(0, 0, t.IDU8, nil, nil, nil)
|
||||
typeExprU16 = a.NewTypeExpr(0, 0, t.IDU16, nil, nil, nil)
|
||||
typeExprU32 = a.NewTypeExpr(0, 0, t.IDU32, nil, nil, nil)
|
||||
typeExprU64 = a.NewTypeExpr(0, 0, t.IDU64, nil, nil, nil)
|
||||
typeExprBool = a.NewTypeExpr(0, 0, t.IDBool, nil, nil, nil)
|
||||
typeExprStatus = a.NewTypeExpr(0, 0, t.IDStatus, nil, nil, nil)
|
||||
typeExprReader1 = a.NewTypeExpr(0, 0, t.IDReader1, nil, nil, nil)
|
||||
typeExprWriter1 = a.NewTypeExpr(0, 0, t.IDWriter1, nil, nil, nil)
|
||||
typeExprImageConfig = a.NewTypeExpr(0, 0, t.IDImageConfig, nil, nil, nil)
|
||||
|
||||
typeExprSliceU8 = a.NewTypeExpr(t.IDColon, 0, 0, nil, nil, typeExprU8)
|
||||
|
||||
@@ -59,14 +60,15 @@ var (
|
||||
type typeMap map[t.ID]*a.TypeExpr
|
||||
|
||||
var builtInTypeMap = typeMap{
|
||||
t.IDU8: typeExprU8,
|
||||
t.IDU16: typeExprU16,
|
||||
t.IDU32: typeExprU32,
|
||||
t.IDU64: typeExprU64,
|
||||
t.IDBool: typeExprBool,
|
||||
t.IDStatus: typeExprStatus,
|
||||
t.IDReader1: typeExprReader1,
|
||||
t.IDWriter1: typeExprWriter1,
|
||||
t.IDU8: typeExprU8,
|
||||
t.IDU16: typeExprU16,
|
||||
t.IDU32: typeExprU32,
|
||||
t.IDU64: typeExprU64,
|
||||
t.IDBool: typeExprBool,
|
||||
t.IDStatus: typeExprStatus,
|
||||
t.IDReader1: typeExprReader1,
|
||||
t.IDWriter1: typeExprWriter1,
|
||||
t.IDImageConfig: typeExprImageConfig,
|
||||
}
|
||||
|
||||
func (c *Checker) builtInFunc(qqid t.QQID) (*a.Func, error) {
|
||||
|
||||
+48
-45
@@ -274,21 +274,22 @@ const (
|
||||
KeyOut = Key(IDOut >> KeyShift)
|
||||
KeyCapitalT = Key(IDCapitalT >> KeyShift)
|
||||
|
||||
KeyI8 = Key(IDI8 >> KeyShift)
|
||||
KeyI16 = Key(IDI16 >> KeyShift)
|
||||
KeyI32 = Key(IDI32 >> KeyShift)
|
||||
KeyI64 = Key(IDI64 >> KeyShift)
|
||||
KeyU8 = Key(IDU8 >> KeyShift)
|
||||
KeyU16 = Key(IDU16 >> KeyShift)
|
||||
KeyU32 = Key(IDU32 >> KeyShift)
|
||||
KeyU64 = Key(IDU64 >> KeyShift)
|
||||
KeyUsize = Key(IDUsize >> KeyShift) // TODO: unused?
|
||||
KeyBool = Key(IDBool >> KeyShift)
|
||||
KeyBuf1 = Key(IDBuf1 >> KeyShift) // TODO: unused?
|
||||
KeyReader1 = Key(IDReader1 >> KeyShift)
|
||||
KeyWriter1 = Key(IDWriter1 >> KeyShift)
|
||||
KeyBuf2 = Key(IDBuf2 >> KeyShift) // TODO: unused?
|
||||
KeyStatus = Key(IDStatus >> KeyShift)
|
||||
KeyI8 = Key(IDI8 >> KeyShift)
|
||||
KeyI16 = Key(IDI16 >> KeyShift)
|
||||
KeyI32 = Key(IDI32 >> KeyShift)
|
||||
KeyI64 = Key(IDI64 >> KeyShift)
|
||||
KeyU8 = Key(IDU8 >> KeyShift)
|
||||
KeyU16 = Key(IDU16 >> KeyShift)
|
||||
KeyU32 = Key(IDU32 >> KeyShift)
|
||||
KeyU64 = Key(IDU64 >> KeyShift)
|
||||
KeyUsize = Key(IDUsize >> KeyShift) // TODO: unused?
|
||||
KeyBool = Key(IDBool >> KeyShift)
|
||||
KeyBuf1 = Key(IDBuf1 >> KeyShift) // TODO: unused?
|
||||
KeyReader1 = Key(IDReader1 >> KeyShift)
|
||||
KeyWriter1 = Key(IDWriter1 >> KeyShift)
|
||||
KeyBuf2 = Key(IDBuf2 >> KeyShift) // TODO: unused?
|
||||
KeyStatus = Key(IDStatus >> KeyShift)
|
||||
KeyImageConfig = Key(IDImageConfig >> KeyShift)
|
||||
|
||||
KeyMark = Key(IDMark >> KeyShift)
|
||||
KeyReadU8 = Key(IDReadU8 >> KeyShift)
|
||||
@@ -465,21 +466,22 @@ const (
|
||||
IDOut = ID(0x7B<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDCapitalT = ID(0x7C<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
|
||||
IDI8 = ID(0x80<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDI16 = ID(0x81<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDI32 = ID(0x82<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDI64 = ID(0x83<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDU8 = ID(0x84<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDU16 = ID(0x85<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDU32 = ID(0x86<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDU64 = ID(0x87<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDUsize = ID(0x88<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDBool = ID(0x89<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDBuf1 = ID(0x8A<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDReader1 = ID(0x8B<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDWriter1 = ID(0x8C<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDBuf2 = ID(0x8D<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDStatus = ID(0x8E<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDI8 = ID(0x80<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDI16 = ID(0x81<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDI32 = ID(0x82<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDI64 = ID(0x83<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDU8 = ID(0x84<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDU16 = ID(0x85<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDU32 = ID(0x86<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDU64 = ID(0x87<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDUsize = ID(0x88<<KeyShift | FlagsIdent | FlagsImplicitSemicolon | FlagsNumType)
|
||||
IDBool = ID(0x89<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDBuf1 = ID(0x8A<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDReader1 = ID(0x8B<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDWriter1 = ID(0x8C<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDBuf2 = ID(0x8D<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDStatus = ID(0x8E<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDImageConfig = ID(0x8F<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
|
||||
IDMark = ID(0x90<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDReadU8 = ID(0x91<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
@@ -678,21 +680,22 @@ var builtInsByKey = [nBuiltInKeys]struct {
|
||||
|
||||
// Change MaxIntBits if a future update adds an i128 or u128 type.
|
||||
|
||||
KeyI8: {"i8", IDI8},
|
||||
KeyI16: {"i16", IDI16},
|
||||
KeyI32: {"i32", IDI32},
|
||||
KeyI64: {"i64", IDI64},
|
||||
KeyU8: {"u8", IDU8},
|
||||
KeyU16: {"u16", IDU16},
|
||||
KeyU32: {"u32", IDU32},
|
||||
KeyU64: {"u64", IDU64},
|
||||
KeyUsize: {"usize", IDUsize},
|
||||
KeyBool: {"bool", IDBool},
|
||||
KeyBuf1: {"buf1", IDBuf1},
|
||||
KeyReader1: {"reader1", IDReader1},
|
||||
KeyWriter1: {"writer1", IDWriter1},
|
||||
KeyBuf2: {"buf2", IDBuf2},
|
||||
KeyStatus: {"status", IDStatus},
|
||||
KeyI8: {"i8", IDI8},
|
||||
KeyI16: {"i16", IDI16},
|
||||
KeyI32: {"i32", IDI32},
|
||||
KeyI64: {"i64", IDI64},
|
||||
KeyU8: {"u8", IDU8},
|
||||
KeyU16: {"u16", IDU16},
|
||||
KeyU32: {"u32", IDU32},
|
||||
KeyU64: {"u64", IDU64},
|
||||
KeyUsize: {"usize", IDUsize},
|
||||
KeyBool: {"bool", IDBool},
|
||||
KeyBuf1: {"buf1", IDBuf1},
|
||||
KeyReader1: {"reader1", IDReader1},
|
||||
KeyWriter1: {"writer1", IDWriter1},
|
||||
KeyBuf2: {"buf2", IDBuf2},
|
||||
KeyStatus: {"status", IDStatus},
|
||||
KeyImageConfig: {"image_config", IDImageConfig},
|
||||
|
||||
KeyMark: {"mark", IDMark},
|
||||
KeyReadU8: {"read_u8", IDReadU8},
|
||||
|
||||
@@ -42,13 +42,14 @@ pub struct decoder?(
|
||||
lzw lzw_decoder,
|
||||
)
|
||||
|
||||
// TODO: dst should be an image_config, not a writer1.
|
||||
pub func decoder.decode_config?(dst writer1, src reader1)() {
|
||||
// TODO: should dst be an nptr instead of a ptr?
|
||||
pub func decoder.decode_config?(dst ptr image_config, src reader1)() {
|
||||
if this.call_sequence >= 1 {
|
||||
return error "invalid call sequence"
|
||||
}
|
||||
this.decode_header?(src:in.src)
|
||||
this.decode_lsd?(src:in.src)
|
||||
// TODO: fill in dst.
|
||||
this.call_sequence = 1
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -50,9 +50,9 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the
|
||||
|
||||
void test_basic_bad_receiver() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_base__writer1 dst = {0};
|
||||
wuffs_base__image_config ic = {{0}};
|
||||
wuffs_base__reader1 src = {0};
|
||||
wuffs_gif__status status = wuffs_gif__decoder__decode_config(NULL, dst, src);
|
||||
wuffs_gif__status status = wuffs_gif__decoder__decode_config(NULL, &ic, src);
|
||||
if (status != WUFFS_GIF__ERROR_BAD_RECEIVER) {
|
||||
FAIL("status: got %d, want %d", status, WUFFS_GIF__ERROR_BAD_RECEIVER);
|
||||
}
|
||||
@@ -61,9 +61,9 @@ void test_basic_bad_receiver() {
|
||||
void test_basic_initializer_not_called() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_gif__decoder dec = {{0}};
|
||||
wuffs_base__writer1 dst = {0};
|
||||
wuffs_base__image_config ic = {{0}};
|
||||
wuffs_base__reader1 src = {0};
|
||||
wuffs_gif__status status = wuffs_gif__decoder__decode_config(&dec, dst, src);
|
||||
wuffs_gif__status status = wuffs_gif__decoder__decode_config(&dec, &ic, src);
|
||||
if (status != WUFFS_GIF__ERROR_INITIALIZER_NOT_CALLED) {
|
||||
FAIL("status: got %d, want %d", status,
|
||||
WUFFS_GIF__ERROR_INITIALIZER_NOT_CALLED);
|
||||
@@ -362,10 +362,11 @@ void bench_wuffs_lzw_decode_100k() {
|
||||
const char* wuffs_gif_decode(wuffs_base__buf1* dst, wuffs_base__buf1* src) {
|
||||
wuffs_gif__decoder dec;
|
||||
wuffs_gif__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
||||
wuffs_base__image_config ic = {{0}};
|
||||
wuffs_base__writer1 dst_writer = {.buf = dst};
|
||||
wuffs_base__reader1 src_reader = {.buf = src};
|
||||
wuffs_gif__status s =
|
||||
wuffs_gif__decoder__decode_config(&dec, dst_writer, src_reader);
|
||||
wuffs_gif__decoder__decode_config(&dec, &ic, src_reader);
|
||||
if (s) {
|
||||
return wuffs_gif__status__string(s);
|
||||
}
|
||||
@@ -392,10 +393,10 @@ bool do_test_wuffs_gif_decode(const char* filename,
|
||||
wuffs_gif__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
||||
|
||||
{
|
||||
wuffs_base__writer1 got_writer = {.buf = &got};
|
||||
wuffs_base__image_config ic = {{0}};
|
||||
wuffs_base__reader1 src_reader = {.buf = &src};
|
||||
wuffs_gif__status status =
|
||||
wuffs_gif__decoder__decode_config(&dec, got_writer, src_reader);
|
||||
wuffs_gif__decoder__decode_config(&dec, &ic, src_reader);
|
||||
if (status != WUFFS_GIF__STATUS_OK) {
|
||||
FAIL("status: got %" PRIi32 " (%s)", status,
|
||||
wuffs_gif__status__string(status));
|
||||
@@ -555,7 +556,6 @@ void test_wuffs_gif_decode_input_is_a_gif_many_small_writes_reads() {
|
||||
void test_wuffs_gif_decode_input_is_a_png() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__buf1 got = {.ptr = global_got_buffer, .len = BUFFER_SIZE};
|
||||
wuffs_base__buf1 src = {.ptr = global_src_buffer, .len = BUFFER_SIZE};
|
||||
|
||||
if (!read_file(&src, "../../testdata/bricks-dither.png")) {
|
||||
@@ -564,11 +564,11 @@ void test_wuffs_gif_decode_input_is_a_png() {
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
wuffs_gif__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
||||
wuffs_base__writer1 got_writer = {.buf = &got};
|
||||
wuffs_base__image_config ic = {{0}};
|
||||
wuffs_base__reader1 src_reader = {.buf = &src};
|
||||
|
||||
wuffs_gif__status status =
|
||||
wuffs_gif__decoder__decode_config(&dec, got_writer, src_reader);
|
||||
wuffs_gif__decoder__decode_config(&dec, &ic, src_reader);
|
||||
if (status != WUFFS_GIF__ERROR_BAD_GIF_HEADER) {
|
||||
FAIL("status: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", status,
|
||||
wuffs_gif__status__string(status), WUFFS_GIF__ERROR_BAD_GIF_HEADER,
|
||||
|
||||
Reference in new issue
Block a user