mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
have image_buffer.set_from_slice return an error
This commit is contained in:
1 parent
bc702b4c2b
commit
26ce04ab64
21 files changed
+241
-193
No files matched your search
@@ -1075,32 +1075,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1108,6 +1108,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
@@ -83,12 +83,12 @@ const basePublicH = "" +
|
||||
"" +
|
||||
"// --------\n\n// wuffs_base__animation_disposal encodes, for an animated image, how to\n// dispose of a frame after displaying it:\n// - None means to draw the next frame on top of this one.\n// - Restore Background means to clear the frame's dirty rectangle to \"the\n// background color\" (in practice, this means transparent black) before\n// drawing the next frame.\n// - Restore Previous means to undo the current frame, so that the next frame\n// is drawn on top of the previous one.\ntypedef uint8_t wuffs_base__animation_disposal;\n\n#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)\n#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \\\n ((wuffs_base__animation_disposal)1)\n#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \\\n ((wuffs_base__animation_disposal)2)\n\n" +
|
||||
"" +
|
||||
"// --------\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 wuffs_base__image_config config;\n uint32_t loop_count; // 0-based count of the current loop.\n wuffs_base__pixel_buffer pixbuf;\n // TODO: color spaces.\n wuffs_base__rect_ie_u32 dirty_rect;\n wuffs_base__flicks duration;\n bool blend;\n wuffs_base__animation_disposal disposal;\n bool palette_changed;\n uint8_t palette[1024];\n } private_impl;\n} wuffs_base__image_buffer;\n\nstatic inline void wuffs_base__image_buffer__set_from_pixbuf(\n wuffs_base__image_buffer* b,\n wuffs_base__image_config config,\n wuffs_base__pixel_buffer pixbuf) {\n if (!b) {\n return;\n }\n *b = ((wuffs_base__image_buffer){});\n b->private_impl.config = config;\n b->private_impl.pixbuf = pixbuf;\n}\n\n// TODO: Should this function return bool? An error type?\nstatic inline void wuffs_base__image_buffer__set_from_slice(\n wuffs_base__image_buff" +
|
||||
"er* b,\n wuffs_base__image_config config,\n wuffs_base__slice_u8 pixbuf_memory) {\n if (!b) {\n return;\n }\n *b = ((wuffs_base__image_buffer){});\n // TODO: don't assume 1 byte per pixel. Don't assume packed.\n uint64_t wh = ((uint64_t)config.private_impl.width) *\n ((uint64_t)config.private_impl.height);\n if (wh > pixbuf_memory.len) {\n return;\n }\n b->private_impl.config = config;\n wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];\n tab->ptr = pixbuf_memory.ptr;\n tab->width = config.private_impl.width;\n tab->height = config.private_impl.height;\n tab->stride = config.private_impl.width;\n}\n\n// The palette argument is ignored unless its length is exactly 1024.\nstatic inline void wuffs_base__image_buffer__update(\n wuffs_base__image_buffer* b,\n wuffs_base__rect_ie_u32 dirty_rect,\n wuffs_base__flicks duration,\n bool blend,\n wuffs_base__animation_disposal disposal,\n wuffs_base__slice_u8 palette) {\n if (!b) {\n return;\n }\n\n // Clip the dirty_rect to t" +
|
||||
"he image bounds.\n dirty_rect.max_excl_x = wuffs_base__u32__min(\n dirty_rect.max_excl_x, b->private_impl.config.private_impl.width);\n dirty_rect.max_excl_y = wuffs_base__u32__min(\n dirty_rect.max_excl_y, b->private_impl.config.private_impl.height);\n b->private_impl.dirty_rect = dirty_rect;\n\n b->private_impl.duration = duration;\n b->private_impl.blend = blend;\n b->private_impl.disposal = disposal;\n b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);\n if (b->private_impl.palette_changed) {\n memmove(b->private_impl.palette, palette.ptr, 1024);\n }\n}\n\n// wuffs_base__image_buffer__loop returns whether the image decoder should loop\n// back to the beginning of the animation, assuming that we've reached the end\n// of the encoded stream. If so, it increments b's count of the animation loops\n// played so far.\nstatic inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* b) {\n if (!b) {\n return false;\n }\n uint32_t n = b->private_impl.config.private_impl.num_loo" +
|
||||
"ps;\n if (n == 0) {\n return true;\n }\n if (b->private_impl.loop_count < n - 1) {\n b->private_impl.loop_count++;\n return true;\n }\n return false;\n}\n\n// wuffs_base__image_config returns the overall configuration for this frame.\nstatic inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(\n wuffs_base__image_buffer* b) {\n return b ? &b->private_impl.config : NULL;\n}\n\n// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of\n// this frame's pixels differs from the previous frame.\nstatic inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});\n}\n\n// wuffs_base__image_buffer__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nstatic inline wuffs_base__flicks wuffs_base__image_buffer__duration(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.duration : 0;\n" +
|
||||
"}\n\n// wuffs_base__image_buffer__blend returns, for a transparent image, whether to\n// blend this frame with the existing canvas.\n//\n// In Porter-Duff compositing operator terminology, false means \"src\" and true\n// means \"src over dst\".\nstatic inline bool wuffs_base__image_buffer__blend(\n wuffs_base__image_buffer* b) {\n return b && b->private_impl.blend;\n}\n\n// wuffs_base__image_buffer__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.disposal : 0;\n}\n\n// wuffs_base__image_buffer__palette_changed returns whether this frame's\n// palette differs from the previous frame. It is conservative and may return\n// false positives (but never false negatives).\nstatic inline bool wuffs_base__image_buffer__palette_changed(\n wuffs_base__image_buffer* b) {\n return b && b->private_impl.palette_changed;\n}\n\n// wuffs_base__image_buffer__" +
|
||||
"palette returns the palette that the pixel data\n// can index. The backing array is inside b and has length 1024.\nstatic inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(\n wuffs_base__image_buffer* b) {\n return b ? ((wuffs_base__slice_u8){.ptr = b->private_impl.palette,\n .len = 1024})\n : ((wuffs_base__slice_u8){});\n}\n\nstatic inline wuffs_base__table_u8 wuffs_base__image_buffer__plane(\n wuffs_base__image_buffer* b,\n uint32_t p) {\n return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))\n ? b->private_impl.pixbuf.planes[p]\n : ((wuffs_base__table_u8){});\n}\n\n#endif // WUFFS_BASE_PUBLIC_H\n" +
|
||||
"// --------\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 wuffs_base__image_config config;\n uint32_t loop_count; // 0-based count of the current loop.\n wuffs_base__pixel_buffer pixbuf;\n // TODO: color spaces.\n wuffs_base__rect_ie_u32 dirty_rect;\n wuffs_base__flicks duration;\n bool blend;\n wuffs_base__animation_disposal disposal;\n bool palette_changed;\n uint8_t palette[1024];\n } private_impl;\n} wuffs_base__image_buffer;\n\nstatic inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(\n wuffs_base__image_buffer* b,\n wuffs_base__image_config config,\n wuffs_base__pixel_buffer pixbuf) {\n if (!b) {\n return WUFFS_BASE__ERROR_BAD_RECEIVER;\n }\n *b = ((wuffs_base__image_buffer){});\n b->private_impl.config = config;\n b->private_impl.pixbuf = pixbuf;\n return WUFFS_BASE__STATUS_OK;\n}\n\nstatic inline wuffs_base__status wuffs_base__image_buffer__set_from_" +
|
||||
"slice(\n wuffs_base__image_buffer* b,\n wuffs_base__image_config config,\n wuffs_base__slice_u8 pixbuf_memory) {\n if (!b) {\n return WUFFS_BASE__ERROR_BAD_RECEIVER;\n }\n *b = ((wuffs_base__image_buffer){});\n // TODO: don't assume 1 byte per pixel. Don't assume packed.\n uint64_t wh = ((uint64_t)config.private_impl.width) *\n ((uint64_t)config.private_impl.height);\n if (wh > pixbuf_memory.len) {\n return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;\n }\n b->private_impl.config = config;\n wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];\n tab->ptr = pixbuf_memory.ptr;\n tab->width = config.private_impl.width;\n tab->height = config.private_impl.height;\n tab->stride = config.private_impl.width;\n return WUFFS_BASE__STATUS_OK;\n}\n\n// The palette argument is ignored unless its length is exactly 1024.\nstatic inline void wuffs_base__image_buffer__update(\n wuffs_base__image_buffer* b,\n wuffs_base__rect_ie_u32 dirty_rect,\n wuffs_base__flicks duration,\n bool bl" +
|
||||
"end,\n wuffs_base__animation_disposal disposal,\n wuffs_base__slice_u8 palette) {\n if (!b) {\n return;\n }\n\n // Clip the dirty_rect to the image bounds.\n dirty_rect.max_excl_x = wuffs_base__u32__min(\n dirty_rect.max_excl_x, b->private_impl.config.private_impl.width);\n dirty_rect.max_excl_y = wuffs_base__u32__min(\n dirty_rect.max_excl_y, b->private_impl.config.private_impl.height);\n b->private_impl.dirty_rect = dirty_rect;\n\n b->private_impl.duration = duration;\n b->private_impl.blend = blend;\n b->private_impl.disposal = disposal;\n b->private_impl.palette_changed = palette.ptr && (palette.len == 1024);\n if (b->private_impl.palette_changed) {\n memmove(b->private_impl.palette, palette.ptr, 1024);\n }\n}\n\n// wuffs_base__image_buffer__loop returns whether the image decoder should loop\n// back to the beginning of the animation, assuming that we've reached the end\n// of the encoded stream. If so, it increments b's count of the animation loops\n// played so far.\nstatic inline bool wuffs_base" +
|
||||
"__image_buffer__loop(wuffs_base__image_buffer* b) {\n if (!b) {\n return false;\n }\n uint32_t n = b->private_impl.config.private_impl.num_loops;\n if (n == 0) {\n return true;\n }\n if (b->private_impl.loop_count < n - 1) {\n b->private_impl.loop_count++;\n return true;\n }\n return false;\n}\n\n// wuffs_base__image_config returns the overall configuration for this frame.\nstatic inline wuffs_base__image_config* wuffs_base__image_buffer__image_config(\n wuffs_base__image_buffer* b) {\n return b ? &b->private_impl.config : NULL;\n}\n\n// wuffs_base__image_buffer__dirty_rect returns an upper bound for what part of\n// this frame's pixels differs from the previous frame.\nstatic inline wuffs_base__rect_ie_u32 wuffs_base__image_buffer__dirty_rect(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.dirty_rect : ((wuffs_base__rect_ie_u32){0});\n}\n\n// wuffs_base__image_buffer__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nsta" +
|
||||
"tic inline wuffs_base__flicks wuffs_base__image_buffer__duration(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.duration : 0;\n}\n\n// wuffs_base__image_buffer__blend returns, for a transparent image, whether to\n// blend this frame with the existing canvas.\n//\n// In Porter-Duff compositing operator terminology, false means \"src\" and true\n// means \"src over dst\".\nstatic inline bool wuffs_base__image_buffer__blend(\n wuffs_base__image_buffer* b) {\n return b && b->private_impl.blend;\n}\n\n// wuffs_base__image_buffer__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal wuffs_base__image_buffer__disposal(\n wuffs_base__image_buffer* b) {\n return b ? b->private_impl.disposal : 0;\n}\n\n// wuffs_base__image_buffer__palette_changed returns whether this frame's\n// palette differs from the previous frame. It is conservative and may return\n// false positives (but never false negatives).\nstatic inline bool wuffs_base__i" +
|
||||
"mage_buffer__palette_changed(\n wuffs_base__image_buffer* b) {\n return b && b->private_impl.palette_changed;\n}\n\n// wuffs_base__image_buffer__palette returns the palette that the pixel data\n// can index. The backing array is inside b and has length 1024.\nstatic inline wuffs_base__slice_u8 wuffs_base__image_buffer__palette(\n wuffs_base__image_buffer* b) {\n return b ? ((wuffs_base__slice_u8){.ptr = b->private_impl.palette,\n .len = 1024})\n : ((wuffs_base__slice_u8){});\n}\n\nstatic inline wuffs_base__table_u8 wuffs_base__image_buffer__plane(\n wuffs_base__image_buffer* b,\n uint32_t p) {\n return (b && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX))\n ? b->private_impl.pixbuf.planes[p]\n : ((wuffs_base__table_u8){});\n}\n\n#endif // WUFFS_BASE_PUBLIC_H\n" +
|
||||
""
|
||||
|
||||
const basePrivateH = "" +
|
||||
|
||||
@@ -248,9 +248,11 @@ const char* play() {
|
||||
return "could not allocate print buffer";
|
||||
}
|
||||
}
|
||||
// TODO: check wuffs_base__image_buffer__set_from_slice errors?
|
||||
wuffs_base__image_buffer__set_from_slice(
|
||||
s = wuffs_base__image_buffer__set_from_slice(
|
||||
&ib, ic, ((wuffs_base__slice_u8){.ptr = image_buffer, .len = image_len}));
|
||||
if (s) {
|
||||
return wuffs_gif__status__string(s);
|
||||
}
|
||||
|
||||
if (!seen_num_loops) {
|
||||
seen_num_loops = true;
|
||||
|
||||
@@ -74,9 +74,12 @@ const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
||||
ret = "out of memory";
|
||||
goto exit;
|
||||
}
|
||||
// TODO: check wuffs_base__image_buffer__set_from_slice errors?
|
||||
wuffs_base__image_buffer__set_from_slice(
|
||||
s = wuffs_base__image_buffer__set_from_slice(
|
||||
&ib, ic, ((wuffs_base__slice_u8){.ptr = pixbuf, .len = pixbuf_size}));
|
||||
if (s) {
|
||||
ret = wuffs_gif__status__string(s);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
bool seen_ok = false;
|
||||
while (true) {
|
||||
|
||||
+21
-17
@@ -84,11 +84,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1105,32 +1106,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1138,6 +1139,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
@@ -1270,11 +1272,13 @@ static const char wuffs_base__status__string_data[] = {
|
||||
0x6B, 0x5F, 0x77, 0x75, 0x66, 0x66, 0x73, 0x5F, 0x76, 0x65, 0x72, 0x73,
|
||||
0x69, 0x6F, 0x6E, 0x20, 0x6E, 0x6F, 0x74, 0x20, 0x63, 0x61, 0x6C, 0x6C,
|
||||
0x65, 0x64, 0x00, 0x62, 0x61, 0x64, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6D,
|
||||
0x65, 0x6E, 0x74, 0x00, 0x62, 0x61, 0x64, 0x20, 0x72, 0x65, 0x63, 0x65,
|
||||
0x69, 0x76, 0x65, 0x72, 0x00, 0x62, 0x61, 0x64, 0x20, 0x73, 0x69, 0x7A,
|
||||
0x65, 0x6F, 0x66, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72,
|
||||
0x00, 0x62, 0x61, 0x64, 0x20, 0x77, 0x75, 0x66, 0x66, 0x73, 0x20, 0x76,
|
||||
0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x00,
|
||||
0x65, 0x6E, 0x74, 0x20, 0x28, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20,
|
||||
0x74, 0x6F, 0x6F, 0x20, 0x73, 0x68, 0x6F, 0x72, 0x74, 0x29, 0x00, 0x62,
|
||||
0x61, 0x64, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x00,
|
||||
0x62, 0x61, 0x64, 0x20, 0x73, 0x69, 0x7A, 0x65, 0x6F, 0x66, 0x20, 0x72,
|
||||
0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x00, 0x62, 0x61, 0x64, 0x20,
|
||||
0x77, 0x75, 0x66, 0x66, 0x73, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F,
|
||||
0x6E, 0x00,
|
||||
};
|
||||
|
||||
static const uint16_t wuffs_base__status__string_offsets[] = {
|
||||
@@ -1306,7 +1310,7 @@ static const uint16_t wuffs_base__status__string_offsets[] = {
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0079, 0x008F, 0x00B0, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x00CF, 0x00DC, 0x00E9, 0x00FD,
|
||||
0x00CF, 0x00EF, 0x00FC, 0x0110,
|
||||
};
|
||||
|
||||
const char* wuffs_base__status__string(wuffs_base__status s) {
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
+13
-11
@@ -73,11 +73,12 @@ typedef struct {
|
||||
// details. Use methods such as wuffs_base__status__is_error instead.
|
||||
typedef int32_t wuffs_base__status;
|
||||
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__STATUS_OK 0 // 0x00000000
|
||||
#define WUFFS_BASE__ERROR_BAD_WUFFS_VERSION -16777216 // 0xFF000000
|
||||
#define WUFFS_BASE__ERROR_BAD_SIZEOF_RECEIVER -33554432 // 0xFE000000
|
||||
#define WUFFS_BASE__ERROR_BAD_RECEIVER -50331648 // 0xFD000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT -67108864 // 0xFC000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_NOT_CALLED \
|
||||
-268435456 // 0xF0000000
|
||||
#define WUFFS_BASE__ERROR_CHECK_WUFFS_VERSION_CALLED_TWICE \
|
||||
@@ -1094,32 +1095,32 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_buffer;
|
||||
|
||||
static inline void wuffs_base__image_buffer__set_from_pixbuf(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_pixbuf(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__pixel_buffer pixbuf) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
b->private_impl.config = config;
|
||||
b->private_impl.pixbuf = pixbuf;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
static inline wuffs_base__status wuffs_base__image_buffer__set_from_slice(
|
||||
wuffs_base__image_buffer* b,
|
||||
wuffs_base__image_config config,
|
||||
wuffs_base__slice_u8 pixbuf_memory) {
|
||||
if (!b) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_RECEIVER;
|
||||
}
|
||||
*b = ((wuffs_base__image_buffer){});
|
||||
// TODO: don't assume 1 byte per pixel. Don't assume packed.
|
||||
uint64_t wh = ((uint64_t)config.private_impl.width) *
|
||||
((uint64_t)config.private_impl.height);
|
||||
if (wh > pixbuf_memory.len) {
|
||||
return;
|
||||
return WUFFS_BASE__ERROR_BAD_ARGUMENT_LENGTH_TOO_SHORT;
|
||||
}
|
||||
b->private_impl.config = config;
|
||||
wuffs_base__table_u8* tab = &b->private_impl.pixbuf.planes[0];
|
||||
@@ -1127,6 +1128,7 @@ static inline void wuffs_base__image_buffer__set_from_slice(
|
||||
tab->width = config.private_impl.width;
|
||||
tab->height = config.private_impl.height;
|
||||
tab->stride = config.private_impl.width;
|
||||
return WUFFS_BASE__STATUS_OK;
|
||||
}
|
||||
|
||||
// The palette argument is ignored unless its length is exactly 1024.
|
||||
|
||||
@@ -43,6 +43,7 @@ var StatusList = [...]Status{
|
||||
{t.IDError, -0x02, "bad sizeof receiver"},
|
||||
{t.IDError, -0x03, "bad receiver"},
|
||||
{t.IDError, -0x04, "bad argument"},
|
||||
{t.IDError, -0x04, "bad argument (length too short)"},
|
||||
|
||||
{t.IDError, -0x10, "check_wuffs_version not called"},
|
||||
{t.IDError, -0x11, "check_wuffs_version called twice"},
|
||||
|
||||
+15
-6
@@ -204,13 +204,16 @@ const char* wuffs_gif_decode(wuffs_base__io_buffer* dst,
|
||||
if (s) {
|
||||
return wuffs_gif__status__string(s);
|
||||
}
|
||||
// TODO: check wuffs_base__image_buffer__set_from_slice errors?
|
||||
wuffs_base__image_buffer__set_from_slice(
|
||||
s = wuffs_base__image_buffer__set_from_slice(
|
||||
&ib, ic,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = global_pixel_buffer,
|
||||
.len = WUFFS_TESTLIB_ARRAY_SIZE(global_pixel_buffer),
|
||||
}));
|
||||
if (s) {
|
||||
return wuffs_gif__status__string(s);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
s = wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader,
|
||||
((wuffs_base__slice_u8){}));
|
||||
@@ -279,13 +282,16 @@ bool do_test_wuffs_gif_decode(const char* filename,
|
||||
wuffs_base__image_config__num_loops(&ic));
|
||||
return false;
|
||||
}
|
||||
// TODO: check wuffs_base__image_buffer__set_from_slice errors?
|
||||
wuffs_base__image_buffer__set_from_slice(
|
||||
status = wuffs_base__image_buffer__set_from_slice(
|
||||
&ib, ic,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = global_pixel_buffer,
|
||||
.len = WUFFS_TESTLIB_ARRAY_SIZE(global_pixel_buffer),
|
||||
}));
|
||||
if (status) {
|
||||
FAIL("set_from_slice: %s", wuffs_gif__status__string(status));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int num_iters = 0;
|
||||
@@ -441,13 +447,16 @@ bool do_test_wuffs_gif_decode_animated(
|
||||
wuffs_base__image_config__num_loops(&ic), want_num_loops);
|
||||
return false;
|
||||
}
|
||||
// TODO: check wuffs_base__image_buffer__set_from_slice errors?
|
||||
wuffs_base__image_buffer__set_from_slice(
|
||||
status = wuffs_base__image_buffer__set_from_slice(
|
||||
&ib, ic,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = global_pixel_buffer,
|
||||
.len = WUFFS_TESTLIB_ARRAY_SIZE(global_pixel_buffer),
|
||||
}));
|
||||
if (status) {
|
||||
FAIL("set_from_slice: %s", wuffs_gif__status__string(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < want_num_frames; i++) {
|
||||
|
||||
Reference in new issue
Block a user