mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Check wuffs_base__image_config's validity earlier
This commit is contained in:
1 parent
84594cd5e9
commit
5bc95b9ea4
14 files changed
+263
-276
No files matched your search
@@ -869,6 +869,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -879,13 +880,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -897,15 +904,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -915,22 +914,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -938,7 +937,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
@@ -69,9 +69,9 @@ const baseHeader = "" +
|
||||
"SUBSAMPLING__440 \\\n ((wuffs_base__pixel_subsampling)0x010100)\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__422 \\\n ((wuffs_base__pixel_subsampling)0x101000)\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__420 \\\n ((wuffs_base__pixel_subsampling)0x111100)\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__411 \\\n ((wuffs_base__pixel_subsampling)0x202000)\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__410 \\\n ((wuffs_base__pixel_subsampling)0x212100)\n\nstatic inline uint32_t wuffs_base__pixel_subsampling__bias_x(\n wuffs_base__pixel_subsampling s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 6;\n return (s >> shift) & 0x03;\n}\n\nstatic inline uint32_t wuffs_base__pixel_subsampling__shift_x(\n wuffs_base__pixel_subsampling s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 4;\n return (s >> shift) & 0x03;\n}\n\nstatic inline uint32_t wuffs_base__pixel_subsampling__bias_y(\n wuffs_base__pixel_subsampling s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 2;\n return (s >> shift) & 0x03;\n}\n\nstatic" +
|
||||
" inline uint32_t wuffs_base__pixel_subsampling__shift_y(\n wuffs_base__pixel_subsampling s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 0;\n return (s >> shift) & 0x03;\n}\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__pixel_format pixfmt;\n wuffs_base__pixel_subsampling pixsub;\n uint32_t width;\n uint32_t height;\n uint32_t num_loops;\n } private_impl;\n} wuffs_base__image_config;\n\nstatic inline void wuffs_base__image_config__initialize(\n wuffs_base__image_config* c,\n wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint32_t num_loops) {\n if (!c) {\n return;\n }\n // TODO: move the check from wuffs_base__image_config__is_valid here. Should\n // this function return bool? An error type?\n c->private_impl.pixfmt = pixfmt;\n c->private_impl.pixsub = pixsub;\n c->private_impl.width = width;\n c->private_impl.height = height;\n c->private_impl.num_loops = num_loops;\n}\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__is_valid(\n wuffs_base__image_config* c) {\n if (!c || !c->private_impl.pixfmt) {\n return false;\n }\n uint64_t wh =\n ((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);\n // TODO: handle things other than 1 byte per pixel.\n //\n // TODO: move the check to wuffs_base__image_config__initialize.\n return wh <= ((uint64_t)SIZE_MAX);\n}\n\nstatic inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(\n wuffs_base__image_config* c) {\n return c ? c->private_impl.pixfmt : 0;\n}\n\nstatic inline wuffs_base__pixel_subsampling\nwuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {\n return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__width(\n wuffs_base__image_config* c) {\n return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t wuff" +
|
||||
"s_base__image_config__height(\n wuffs_base__image_config* c) {\n return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__num_loops(\n wuffs_base__image_config* c) {\n return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;\n}\n\n// TODO: this is the right API for planar (not packed) pixbufs? 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__is_valid(c)) {\n uint64_t wh =\n ((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);\n // TODO: handle things other than 1 byte per pixel.\n return (size_t)wh;\n }\n return 0;\n}\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__pixel_format pixfmt;\n wuffs_base__pixel_subsampling pixsub;\n uint32_t width;\n uint32_t height;\n uint32_t num_loops;\n } private_impl;\n} wuffs_base__image_config;\n\n// TODO: Should this function return bool? An error type?\nstatic inline void wuffs_base__image_config__initialize(\n wuffs_base__image_config* c,\n wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint32_t num_loops) {\n if (!c) {\n return;\n }\n if (pixfmt) {\n uint64_t wh = ((uint64_t)width) * ((uint64_t)height);\n // TODO: handle things other than 1 byte per pixel.\n if (wh <= ((uint64_t)SIZE_MAX)) {\n c->private_impl.pixfmt = pixfmt;\n c->private_impl.pixsub = pixsub;\n c->private_impl.width = width;\n c->private_impl.height = height;\n c->private_imp" +
|
||||
"l.num_loops = num_loops;\n return;\n }\n }\n *c = ((wuffs_base__image_config){});\n}\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__is_valid(\n wuffs_base__image_config* c) {\n return c && c->private_impl.pixfmt;\n}\n\nstatic inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(\n wuffs_base__image_config* c) {\n return c ? c->private_impl.pixfmt : 0;\n}\n\nstatic inline wuffs_base__pixel_subsampling\nwuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {\n return c ? c->private_impl.pixsub : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__width(\n wuffs_base__image_config* c) {\n return c ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__height(\n wuffs_base__image_config* c) {\n return c ? c->private_impl.height : 0;\n}\n\nstatic inline uint32_t wuffs_base__image_config__num_loops(\n" +
|
||||
" wuffs_base__image_config* c) {\n return c ? c->private_impl.num_loops : 0;\n}\n\n// TODO: this is the right API for planar (not packed) pixbufs? 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 (c) {\n uint64_t wh =\n ((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);\n // TODO: handle things other than 1 byte per pixel.\n return (size_t)wh;\n }\n return 0;\n}\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 uint8_t palette[1024];\n } private_impl;\n} wuffs_base__image_buffer;\n\nstatic inline void wuffs_base__image_buffer__initialize(\n wuffs_base__image_buffer* f,\n wuffs_base__image_config config,\n wuffs_base__pixel_buffer pixbuf) {\n if (!f) {\n return;\n }\n *f = ((wuffs_base__image_buffer){});\n f->private_impl.config = config;\n f->private_impl.pixbuf = pixbuf;\n}\n\nstatic inline void wuffs_base__image_buffer__update(\n wuffs_base__image_buffer* f,\n wuffs_base__rect_ie_u32 dirty_rect,\n wuffs_base__flicks duration,\n uint8_t* palette_ptr,\n size_t palette_len) {\n if (!f) {\n return;\n " +
|
||||
"}\n f->private_impl.dirty_rect = dirty_rect;\n f->private_impl.duration = duration;\n if (palette_ptr) {\n memmove(f->private_impl.palette, palette_ptr,\n palette_len <= 1024 ? palette_len : 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 f's count of the animation loops\n// played so far.\nstatic inline bool wuffs_base__image_buffer__loop(wuffs_base__image_buffer* f) {\n if (!f) {\n return false;\n }\n uint32_t n = f->private_impl.config.private_impl.num_loops;\n if (n == 0) {\n return true;\n }\n if (f->private_impl.loop_count < n - 1) {\n f->private_impl.loop_count++;\n return true;\n }\n return false;\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 wu" +
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
+20
-21
@@ -872,6 +872,7 @@ typedef struct {
|
||||
} private_impl;
|
||||
} wuffs_base__image_config;
|
||||
|
||||
// TODO: Should this function return bool? An error type?
|
||||
static inline void wuffs_base__image_config__initialize(
|
||||
wuffs_base__image_config* c,
|
||||
wuffs_base__pixel_format pixfmt,
|
||||
@@ -882,13 +883,19 @@ static inline void wuffs_base__image_config__initialize(
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
// TODO: move the check from wuffs_base__image_config__is_valid here. Should
|
||||
// this function return bool? An error type?
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
if (pixfmt) {
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh <= ((uint64_t)SIZE_MAX)) {
|
||||
c->private_impl.pixfmt = pixfmt;
|
||||
c->private_impl.pixsub = pixsub;
|
||||
c->private_impl.width = width;
|
||||
c->private_impl.height = height;
|
||||
c->private_impl.num_loops = num_loops;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*c = ((wuffs_base__image_config){});
|
||||
}
|
||||
|
||||
static inline void wuffs_base__image_config__invalidate(
|
||||
@@ -900,15 +907,7 @@ static inline void wuffs_base__image_config__invalidate(
|
||||
|
||||
static inline bool wuffs_base__image_config__is_valid(
|
||||
wuffs_base__image_config* c) {
|
||||
if (!c || !c->private_impl.pixfmt) {
|
||||
return false;
|
||||
}
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
//
|
||||
// TODO: move the check to wuffs_base__image_config__initialize.
|
||||
return wh <= ((uint64_t)SIZE_MAX);
|
||||
return c && c->private_impl.pixfmt;
|
||||
}
|
||||
|
||||
static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
@@ -918,22 +917,22 @@ static inline wuffs_base__pixel_format wuffs_base__image_config__pixel_format(
|
||||
|
||||
static inline wuffs_base__pixel_subsampling
|
||||
wuffs_base__image_config__pixel_subsampling(wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.pixsub : 0;
|
||||
return c ? c->private_impl.pixsub : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__width(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.width : 0;
|
||||
return c ? c->private_impl.width : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__height(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.height : 0;
|
||||
return c ? c->private_impl.height : 0;
|
||||
}
|
||||
|
||||
static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
wuffs_base__image_config* c) {
|
||||
return wuffs_base__image_config__is_valid(c) ? c->private_impl.num_loops : 0;
|
||||
return c ? c->private_impl.num_loops : 0;
|
||||
}
|
||||
|
||||
// TODO: this is the right API for planar (not packed) pixbufs? Should it allow
|
||||
@@ -941,7 +940,7 @@ static inline uint32_t wuffs_base__image_config__num_loops(
|
||||
// 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__is_valid(c)) {
|
||||
if (c) {
|
||||
uint64_t wh =
|
||||
((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
|
||||
Reference in new issue
Block a user