Make wuffs_base__pixel_subsampling a struct
diff --git a/doc/changelog.md b/doc/changelog.md index 6ee47ad..f04191e 100644 --- a/doc/changelog.md +++ b/doc/changelog.md
@@ -5,6 +5,7 @@ - Renamed warnings to notes. - Made `wuffs_base__pixel_format` a struct. +- Made `wuffs_base__pixel_subsampling` a struct. - Made `wuffs_base__status` a struct.
diff --git a/example/gifplayer/gifplayer.c b/example/gifplayer/gifplayer.c index 9a7641f..f33f73c 100644 --- a/example/gifplayer/gifplayer.c +++ b/example/gifplayer/gifplayer.c
@@ -330,7 +330,8 @@ wuffs_base__pixel_config__set( &ic.pixcfg, wuffs_base__make_pixel_format(WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL), - WUFFS_BASE__PIXEL_SUBSAMPLING__NONE, width, height); + wuffs_base__make_pixel_subsampling(WUFFS_BASE__PIXEL_SUBSAMPLING__NONE), + width, height); const char* msg = allocate(&dec, &ic); if (msg) {
diff --git a/internal/cgen/base/image-public.h b/internal/cgen/base/image-public.h index 8c046e9..968d39b 100644 --- a/internal/cgen/base/image-public.h +++ b/internal/cgen/base/image-public.h
@@ -177,28 +177,39 @@ // // Do not manipulate its bits directly; they are private implementation // details. Use methods such as wuffs_base__pixel_subsampling__bias_x instead. -typedef uint32_t wuffs_base__pixel_subsampling; +typedef struct { + uint32_t repr; -#define WUFFS_BASE__PIXEL_SUBSAMPLING__NONE ((wuffs_base__pixel_subsampling)0) +#ifdef __cplusplus + inline uint32_t bias_x(uint32_t plane) const; + inline uint32_t denominator_x(uint32_t plane) const; + inline uint32_t bias_y(uint32_t plane) const; + inline uint32_t denominator_y(uint32_t plane) const; +#endif // __cplusplus -#define WUFFS_BASE__PIXEL_SUBSAMPLING__444 \ - ((wuffs_base__pixel_subsampling)0x000000) -#define WUFFS_BASE__PIXEL_SUBSAMPLING__440 \ - ((wuffs_base__pixel_subsampling)0x010100) -#define WUFFS_BASE__PIXEL_SUBSAMPLING__422 \ - ((wuffs_base__pixel_subsampling)0x101000) -#define WUFFS_BASE__PIXEL_SUBSAMPLING__420 \ - ((wuffs_base__pixel_subsampling)0x111100) -#define WUFFS_BASE__PIXEL_SUBSAMPLING__411 \ - ((wuffs_base__pixel_subsampling)0x303000) -#define WUFFS_BASE__PIXEL_SUBSAMPLING__410 \ - ((wuffs_base__pixel_subsampling)0x313100) +} wuffs_base__pixel_subsampling; + +static inline wuffs_base__pixel_subsampling // +wuffs_base__make_pixel_subsampling(uint32_t repr) { + wuffs_base__pixel_subsampling s; + s.repr = repr; + return s; +} + +#define WUFFS_BASE__PIXEL_SUBSAMPLING__NONE 0x00000000 + +#define WUFFS_BASE__PIXEL_SUBSAMPLING__444 0x000000 +#define WUFFS_BASE__PIXEL_SUBSAMPLING__440 0x010100 +#define WUFFS_BASE__PIXEL_SUBSAMPLING__422 0x101000 +#define WUFFS_BASE__PIXEL_SUBSAMPLING__420 0x111100 +#define WUFFS_BASE__PIXEL_SUBSAMPLING__411 0x303000 +#define WUFFS_BASE__PIXEL_SUBSAMPLING__410 0x313100 static inline uint32_t // wuffs_base__pixel_subsampling__bias_x(const wuffs_base__pixel_subsampling* s, uint32_t plane) { uint32_t shift = ((plane & 0x03) * 8) + 6; - return (*s >> shift) & 0x03; + return (s->repr >> shift) & 0x03; } static inline uint32_t // @@ -206,14 +217,14 @@ const wuffs_base__pixel_subsampling* s, uint32_t plane) { uint32_t shift = ((plane & 0x03) * 8) + 4; - return ((*s >> shift) & 0x03) + 1; + return ((s->repr >> shift) & 0x03) + 1; } static inline uint32_t // wuffs_base__pixel_subsampling__bias_y(const wuffs_base__pixel_subsampling* s, uint32_t plane) { uint32_t shift = ((plane & 0x03) * 8) + 2; - return (*s >> shift) & 0x03; + return (s->repr >> shift) & 0x03; } static inline uint32_t // @@ -221,9 +232,33 @@ const wuffs_base__pixel_subsampling* s, uint32_t plane) { uint32_t shift = ((plane & 0x03) * 8) + 0; - return ((*s >> shift) & 0x03) + 1; + return ((s->repr >> shift) & 0x03) + 1; } +#ifdef __cplusplus + +inline uint32_t // +wuffs_base__pixel_subsampling::bias_x(uint32_t plane) const { + return wuffs_base__pixel_subsampling__bias_x(this, plane); +} + +inline uint32_t // +wuffs_base__pixel_subsampling::denominator_x(uint32_t plane) const { + return wuffs_base__pixel_subsampling__denominator_x(this, plane); +} + +inline uint32_t // +wuffs_base__pixel_subsampling::bias_y(uint32_t plane) const { + return wuffs_base__pixel_subsampling__bias_y(this, plane); +} + +inline uint32_t // +wuffs_base__pixel_subsampling::denominator_y(uint32_t plane) const { + return wuffs_base__pixel_subsampling__denominator_y(this, plane); +} + +#endif // __cplusplus + // -------- typedef struct { @@ -257,7 +292,7 @@ wuffs_base__null_pixel_config() { wuffs_base__pixel_config ret; ret.private_impl.pixfmt.repr = 0; - ret.private_impl.pixsub = 0; + ret.private_impl.pixsub.repr = 0; ret.private_impl.width = 0; ret.private_impl.height = 0; return ret; @@ -286,7 +321,7 @@ } c->private_impl.pixfmt.repr = 0; - c->private_impl.pixsub = 0; + c->private_impl.pixsub.repr = 0; c->private_impl.width = 0; c->private_impl.height = 0; } @@ -295,7 +330,7 @@ wuffs_base__pixel_config__invalidate(wuffs_base__pixel_config* c) { if (c) { c->private_impl.pixfmt.repr = 0; - c->private_impl.pixsub = 0; + c->private_impl.pixsub.repr = 0; c->private_impl.width = 0; c->private_impl.height = 0; } @@ -313,7 +348,7 @@ static inline wuffs_base__pixel_subsampling // wuffs_base__pixel_config__pixel_subsampling(const wuffs_base__pixel_config* c) { - return c ? c->private_impl.pixsub : 0; + return c ? c->private_impl.pixsub : wuffs_base__make_pixel_subsampling(0); } static inline wuffs_base__rect_ie_u32 // @@ -448,7 +483,7 @@ #ifdef __cplusplus inline void set(uint32_t pixfmt_repr, - wuffs_base__pixel_subsampling pixsub, + uint32_t pixsub_repr, uint32_t width, uint32_t height, uint64_t first_frame_io_position, @@ -474,7 +509,7 @@ static inline void // wuffs_base__image_config__set(wuffs_base__image_config* c, uint32_t pixfmt_repr, - wuffs_base__pixel_subsampling pixsub, + uint32_t pixsub_repr, uint32_t width, uint32_t height, uint64_t first_frame_io_position, @@ -484,7 +519,7 @@ } if (pixfmt_repr) { c->pixcfg.private_impl.pixfmt.repr = pixfmt_repr; - c->pixcfg.private_impl.pixsub = pixsub; + c->pixcfg.private_impl.pixsub.repr = pixsub_repr; c->pixcfg.private_impl.width = width; c->pixcfg.private_impl.height = height; c->private_impl.first_frame_io_position = first_frame_io_position; @@ -493,7 +528,7 @@ } c->pixcfg.private_impl.pixfmt.repr = 0; - c->pixcfg.private_impl.pixsub = 0; + c->pixcfg.private_impl.pixsub.repr = 0; c->pixcfg.private_impl.width = 0; c->pixcfg.private_impl.height = 0; c->private_impl.first_frame_io_position = 0; @@ -504,7 +539,7 @@ wuffs_base__image_config__invalidate(wuffs_base__image_config* c) { if (c) { c->pixcfg.private_impl.pixfmt.repr = 0; - c->pixcfg.private_impl.pixsub = 0; + c->pixcfg.private_impl.pixsub.repr = 0; c->pixcfg.private_impl.width = 0; c->pixcfg.private_impl.height = 0; c->private_impl.first_frame_io_position = 0; @@ -533,12 +568,12 @@ inline void // wuffs_base__image_config::set(uint32_t pixfmt_repr, - wuffs_base__pixel_subsampling pixsub, + uint32_t pixsub_repr, uint32_t width, uint32_t height, uint64_t first_frame_io_position, bool first_frame_is_opaque) { - wuffs_base__image_config__set(this, pixfmt_repr, pixsub, width, height, + wuffs_base__image_config__set(this, pixfmt_repr, pixsub_repr, width, height, first_frame_io_position, first_frame_is_opaque); }
diff --git a/internal/cgen/data.go b/internal/cgen/data.go index 33636c1..e3578f2 100644 --- a/internal/cgen/data.go +++ b/internal/cgen/data.go
@@ -113,21 +113,21 @@ " wuffs_base__pixel_format__bits_per_channel[0x0F & (f->repr >> 8)] +\n wuffs_base__pixel_format__bits_per_channel[0x0F & (f->repr >> 12)];\n}\n\nstatic inline bool //\nwuffs_base__pixel_format__is_indexed(const wuffs_base__pixel_format* f) {\n return (f->repr >> 18) & 0x01;\n}\n\nstatic inline bool //\nwuffs_base__pixel_format__is_interleaved(const wuffs_base__pixel_format* f) {\n return ((f->repr >> 16) & 0x03) == 0;\n}\n\nstatic inline bool //\nwuffs_base__pixel_format__is_planar(const wuffs_base__pixel_format* f) {\n return ((f->repr >> 16) & 0x03) != 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_format__num_planes(const wuffs_base__pixel_format* f) {\n return ((f->repr >> 16) & 0x03) + 1;\n}\n\n#define WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX 4\n\n#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__INDEX_PLANE 0\n#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE 3\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__pixel_format::is_valid() const {\n return wuffs_base__pixel_format__is_valid(this);\n}\n\ninline " + "uint32_t //\nwuffs_base__pixel_format::bits_per_pixel() const {\n return wuffs_base__pixel_format__bits_per_pixel(this);\n}\n\ninline bool //\nwuffs_base__pixel_format::is_indexed() const {\n return wuffs_base__pixel_format__is_indexed(this);\n}\n\ninline bool //\nwuffs_base__pixel_format::is_interleaved() const {\n return wuffs_base__pixel_format__is_interleaved(this);\n}\n\ninline bool //\nwuffs_base__pixel_format::is_planar() const {\n return wuffs_base__pixel_format__is_planar(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_format::num_planes() const {\n return wuffs_base__pixel_format__num_planes(this);\n}\n\n#endif // __cplusplus\n\n" + "" + - "// --------\n\n// wuffs_base__pixel_subsampling encodes whether sample values cover one pixel\n// or cover multiple pixels.\n//\n// See https://github.com/google/wuffs/blob/master/doc/note/pixel-subsampling.md\n//\n// Do not manipulate its bits directly; they are private implementation\n// details. Use methods such as wuffs_base__pixel_subsampling__bias_x instead.\ntypedef uint32_t wuffs_base__pixel_subsampling;\n\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__NONE ((wuffs_base__pixel_subsampling)0)\n\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__444 \\\n ((wuffs_base__pixel_subsampling)0x000000)\n#define WUFFS_BASE__PIXEL_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)0x303000)\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__410 \\\n ((wuffs_base__pixel_subsampling)0x313100)\n\ns" + - "tatic inline uint32_t //\nwuffs_base__pixel_subsampling__bias_x(const 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 //\nwuffs_base__pixel_subsampling__denominator_x(\n const wuffs_base__pixel_subsampling* s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 4;\n return ((*s >> shift) & 0x03) + 1;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__bias_y(const 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 //\nwuffs_base__pixel_subsampling__denominator_y(\n const wuffs_base__pixel_subsampling* s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 0;\n return ((*s >> shift) & 0x03) + 1;\n}\n\n" + + "// --------\n\n// wuffs_base__pixel_subsampling encodes whether sample values cover one pixel\n// or cover multiple pixels.\n//\n// See https://github.com/google/wuffs/blob/master/doc/note/pixel-subsampling.md\n//\n// Do not manipulate its bits directly; they are private implementation\n// details. Use methods such as wuffs_base__pixel_subsampling__bias_x instead.\ntypedef struct {\n uint32_t repr;\n\n#ifdef __cplusplus\n inline uint32_t bias_x(uint32_t plane) const;\n inline uint32_t denominator_x(uint32_t plane) const;\n inline uint32_t bias_y(uint32_t plane) const;\n inline uint32_t denominator_y(uint32_t plane) const;\n#endif // __cplusplus\n\n} wuffs_base__pixel_subsampling;\n\nstatic inline wuffs_base__pixel_subsampling //\nwuffs_base__make_pixel_subsampling(uint32_t repr) {\n wuffs_base__pixel_subsampling s;\n s.repr = repr;\n return s;\n}\n\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__NONE 0x00000000\n\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__444 0x000000\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__440 0x010100\n#define WUFFS_BASE__" + + "PIXEL_SUBSAMPLING__422 0x101000\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__420 0x111100\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__411 0x303000\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__410 0x313100\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__bias_x(const wuffs_base__pixel_subsampling* s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 6;\n return (s->repr >> shift) & 0x03;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__denominator_x(\n const wuffs_base__pixel_subsampling* s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 4;\n return ((s->repr >> shift) & 0x03) + 1;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__bias_y(const wuffs_base__pixel_subsampling* s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 2;\n return (s->repr >> shift) & 0x03;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__denominator_y(\n const wuffs_base__pixel_subsampling* s," + + "\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 0;\n return ((s->repr >> shift) & 0x03) + 1;\n}\n\n#ifdef __cplusplus\n\ninline uint32_t //\nwuffs_base__pixel_subsampling::bias_x(uint32_t plane) const {\n return wuffs_base__pixel_subsampling__bias_x(this, plane);\n}\n\ninline uint32_t //\nwuffs_base__pixel_subsampling::denominator_x(uint32_t plane) const {\n return wuffs_base__pixel_subsampling__denominator_x(this, plane);\n}\n\ninline uint32_t //\nwuffs_base__pixel_subsampling::bias_y(uint32_t plane) const {\n return wuffs_base__pixel_subsampling__bias_y(this, plane);\n}\n\ninline uint32_t //\nwuffs_base__pixel_subsampling::denominator_y(uint32_t plane) const {\n return wuffs_base__pixel_subsampling__denominator_y(this, plane);\n}\n\n#endif // __cplusplus\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 } private_impl;\n\n#ifdef __cplusplus\n inline void set(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height);\n inline void invalidate();\n inline bool is_valid() const;\n inline wuffs_base__pixel_format pixel_format() const;\n inline wuffs_base__pixel_subsampling pixel_subsampling() const;\n inline wuffs_base__rect_ie_u32 bounds() const;\n inline uint32_t width() const;\n inline uint32_t height() const;\n inline uint64_t pixbuf_len() const;\n#endif // __cplusplus\n\n} wuffs_base__pixel_config;\n\nstatic inline wuffs_base__pixel_config //\nwuffs_base__null_pixel_config() {\n wuffs_base__pixel_config ret;\n ret.private_impl.pix" + - "fmt.repr = 0;\n ret.private_impl.pixsub = 0;\n ret.private_impl.width = 0;\n ret.private_impl.height = 0;\n return ret;\n}\n\n// TODO: Should this function return bool? An error type?\nstatic inline void //\nwuffs_base__pixel_config__set(wuffs_base__pixel_config* c,\n wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height) {\n if (!c) {\n return;\n }\n if (pixfmt.repr) {\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 return;\n }\n }\n\n c->private_impl.pixfmt.repr = 0;\n c->private_impl.pixsub = 0;\n c->private_impl.width = 0;\n c->private_impl.height = 0;\n}\n\nstatic inline void //\nwuffs" + - "_base__pixel_config__invalidate(wuffs_base__pixel_config* c) {\n if (c) {\n c->private_impl.pixfmt.repr = 0;\n c->private_impl.pixsub = 0;\n c->private_impl.width = 0;\n c->private_impl.height = 0;\n }\n}\n\nstatic inline bool //\nwuffs_base__pixel_config__is_valid(const wuffs_base__pixel_config* c) {\n return c && c->private_impl.pixfmt.repr;\n}\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__pixel_config__pixel_format(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixfmt : wuffs_base__make_pixel_format(0);\n}\n\nstatic inline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config__pixel_subsampling(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixsub : 0;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_config__bounds(const wuffs_base__pixel_config* c) {\n if (c) {\n wuffs_base__rect_ie_u32 ret;\n ret.min_incl_x = 0;\n ret.min_incl_y = 0;\n ret.max_excl_x = c->private_impl.width;\n ret.max_excl_y = c->private_impl.height;\n return" + - " ret;\n }\n\n wuffs_base__rect_ie_u32 ret;\n ret.min_incl_x = 0;\n ret.min_incl_y = 0;\n ret.max_excl_x = 0;\n ret.max_excl_y = 0;\n return ret;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__width(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__height(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.height : 0;\n}\n\n// TODO: this is the right API for planar (not interleaved) pixbufs? Should it\n// allow decoding into a color model different from the format's intrinsic one?\n// For example, decoding a JPEG image straight to RGBA instead of to YCbCr?\nstatic inline uint64_t //\nwuffs_base__pixel_config__pixbuf_len(const wuffs_base__pixel_config* c) {\n if (!c) {\n return 0;\n }\n if (wuffs_base__pixel_format__is_planar(&c->private_impl.pixfmt)) {\n // TODO: support planar pixel formats, concious of pixel subsampling.\n return 0;\n }\n uint32_t bits_per_pixel =\n wuffs_base__pixel_format__bits_per_" + - "pixel(&c->private_impl.pixfmt);\n if ((bits_per_pixel == 0) || ((bits_per_pixel % 8) != 0)) {\n // TODO: support fraction-of-byte pixels, e.g. 1 bit per pixel?\n return 0;\n }\n uint64_t bytes_per_pixel = bits_per_pixel / 8;\n\n uint64_t n =\n ((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);\n if (n > (UINT64_MAX / bytes_per_pixel)) {\n return 0;\n }\n n *= bytes_per_pixel;\n\n if (wuffs_base__pixel_format__is_indexed(&c->private_impl.pixfmt)) {\n if (n > (UINT64_MAX - 1024)) {\n return 0;\n }\n n += 1024;\n }\n\n return n;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__pixel_config::set(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height) {\n wuffs_base__pixel_config__set(this, pixfmt, pixsub, width, height);\n}\n\ninline void //\nwuffs_base__pixel_config::invalidate() {\n wuffs_base__pixel_config__invalidate(this);\n}\n\ninline boo" + - "l //\nwuffs_base__pixel_config::is_valid() const {\n return wuffs_base__pixel_config__is_valid(this);\n}\n\ninline wuffs_base__pixel_format //\nwuffs_base__pixel_config::pixel_format() const {\n return wuffs_base__pixel_config__pixel_format(this);\n}\n\ninline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config::pixel_subsampling() const {\n return wuffs_base__pixel_config__pixel_subsampling(this);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_config::bounds() const {\n return wuffs_base__pixel_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config::width() const {\n return wuffs_base__pixel_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config::height() const {\n return wuffs_base__pixel_config__height(this);\n}\n\ninline uint64_t //\nwuffs_base__pixel_config::pixbuf_len() const {\n return wuffs_base__pixel_config__pixbuf_len(this);\n}\n\n#endif // __cplusplus\n\n" + + "fmt.repr = 0;\n ret.private_impl.pixsub.repr = 0;\n ret.private_impl.width = 0;\n ret.private_impl.height = 0;\n return ret;\n}\n\n// TODO: Should this function return bool? An error type?\nstatic inline void //\nwuffs_base__pixel_config__set(wuffs_base__pixel_config* c,\n wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height) {\n if (!c) {\n return;\n }\n if (pixfmt.repr) {\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 return;\n }\n }\n\n c->private_impl.pixfmt.repr = 0;\n c->private_impl.pixsub.repr = 0;\n c->private_impl.width = 0;\n c->private_impl.height = 0;\n}\n\nstatic inline void" + + " //\nwuffs_base__pixel_config__invalidate(wuffs_base__pixel_config* c) {\n if (c) {\n c->private_impl.pixfmt.repr = 0;\n c->private_impl.pixsub.repr = 0;\n c->private_impl.width = 0;\n c->private_impl.height = 0;\n }\n}\n\nstatic inline bool //\nwuffs_base__pixel_config__is_valid(const wuffs_base__pixel_config* c) {\n return c && c->private_impl.pixfmt.repr;\n}\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__pixel_config__pixel_format(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixfmt : wuffs_base__make_pixel_format(0);\n}\n\nstatic inline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config__pixel_subsampling(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixsub : wuffs_base__make_pixel_subsampling(0);\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_config__bounds(const wuffs_base__pixel_config* c) {\n if (c) {\n wuffs_base__rect_ie_u32 ret;\n ret.min_incl_x = 0;\n ret.min_incl_y = 0;\n ret.max_excl_x = c->private_impl.width;\n " + + "ret.max_excl_y = c->private_impl.height;\n return ret;\n }\n\n wuffs_base__rect_ie_u32 ret;\n ret.min_incl_x = 0;\n ret.min_incl_y = 0;\n ret.max_excl_x = 0;\n ret.max_excl_y = 0;\n return ret;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__width(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__height(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.height : 0;\n}\n\n// TODO: this is the right API for planar (not interleaved) pixbufs? Should it\n// allow decoding into a color model different from the format's intrinsic one?\n// For example, decoding a JPEG image straight to RGBA instead of to YCbCr?\nstatic inline uint64_t //\nwuffs_base__pixel_config__pixbuf_len(const wuffs_base__pixel_config* c) {\n if (!c) {\n return 0;\n }\n if (wuffs_base__pixel_format__is_planar(&c->private_impl.pixfmt)) {\n // TODO: support planar pixel formats, concious of pixel subsampling.\n return 0;\n }\n uint32_t bits_pe" + + "r_pixel =\n wuffs_base__pixel_format__bits_per_pixel(&c->private_impl.pixfmt);\n if ((bits_per_pixel == 0) || ((bits_per_pixel % 8) != 0)) {\n // TODO: support fraction-of-byte pixels, e.g. 1 bit per pixel?\n return 0;\n }\n uint64_t bytes_per_pixel = bits_per_pixel / 8;\n\n uint64_t n =\n ((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);\n if (n > (UINT64_MAX / bytes_per_pixel)) {\n return 0;\n }\n n *= bytes_per_pixel;\n\n if (wuffs_base__pixel_format__is_indexed(&c->private_impl.pixfmt)) {\n if (n > (UINT64_MAX - 1024)) {\n return 0;\n }\n n += 1024;\n }\n\n return n;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__pixel_config::set(wuffs_base__pixel_format pixfmt,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height) {\n wuffs_base__pixel_config__set(this, pixfmt, pixsub, width, height);\n}\n\ninline void //\nwuffs_base__pixel_config::invalidate() {\n wuffs_" + + "base__pixel_config__invalidate(this);\n}\n\ninline bool //\nwuffs_base__pixel_config::is_valid() const {\n return wuffs_base__pixel_config__is_valid(this);\n}\n\ninline wuffs_base__pixel_format //\nwuffs_base__pixel_config::pixel_format() const {\n return wuffs_base__pixel_config__pixel_format(this);\n}\n\ninline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config::pixel_subsampling() const {\n return wuffs_base__pixel_config__pixel_subsampling(this);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_config::bounds() const {\n return wuffs_base__pixel_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config::width() const {\n return wuffs_base__pixel_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config::height() const {\n return wuffs_base__pixel_config__height(this);\n}\n\ninline uint64_t //\nwuffs_base__pixel_config::pixbuf_len() const {\n return wuffs_base__pixel_config__pixbuf_len(this);\n}\n\n#endif // __cplusplus\n\n" + "" + - "// --------\n\ntypedef struct {\n wuffs_base__pixel_config pixcfg;\n\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 uint64_t first_frame_io_position;\n bool first_frame_is_opaque;\n } private_impl;\n\n#ifdef __cplusplus\n inline void set(uint32_t pixfmt_repr,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque);\n inline void invalidate();\n inline bool is_valid() const;\n inline uint64_t first_frame_io_position() const;\n inline bool first_frame_is_opaque() const;\n#endif // __cplusplus\n\n} wuffs_base__image_config;\n\nstatic inline wuffs_base__image_config //\nwuffs_base__null_image_config() {\n wuffs_base__image_config ret;\n ret.pixcfg = wuffs_base__null_pixel_config();\n ret.private_impl.first_frame_io_position = 0;\n ret.private_impl.first_frame_is" + - "_opaque = false;\n return ret;\n}\n\n// TODO: Should this function return bool? An error type?\nstatic inline void //\nwuffs_base__image_config__set(wuffs_base__image_config* c,\n uint32_t pixfmt_repr,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque) {\n if (!c) {\n return;\n }\n if (pixfmt_repr) {\n c->pixcfg.private_impl.pixfmt.repr = pixfmt_repr;\n c->pixcfg.private_impl.pixsub = pixsub;\n c->pixcfg.private_impl.width = width;\n c->pixcfg.private_impl.height = height;\n c->private_impl.first_frame_io_position = first_frame_io_position;\n c->private_impl.first_frame_is_opaque = first_frame_is_opaque;\n return;\n }\n\n c->pixcfg.private_impl.pixfmt.repr = 0;\n c->pixcfg.private_impl.pixsub = 0;\n c->pixcfg.private_impl.width = 0;\n c->pixcf" + - "g.private_impl.height = 0;\n c->private_impl.first_frame_io_position = 0;\n c->private_impl.first_frame_is_opaque = 0;\n}\n\nstatic inline void //\nwuffs_base__image_config__invalidate(wuffs_base__image_config* c) {\n if (c) {\n c->pixcfg.private_impl.pixfmt.repr = 0;\n c->pixcfg.private_impl.pixsub = 0;\n c->pixcfg.private_impl.width = 0;\n c->pixcfg.private_impl.height = 0;\n c->private_impl.first_frame_io_position = 0;\n c->private_impl.first_frame_is_opaque = 0;\n }\n}\n\nstatic inline bool //\nwuffs_base__image_config__is_valid(const wuffs_base__image_config* c) {\n return c && wuffs_base__pixel_config__is_valid(&(c->pixcfg));\n}\n\nstatic inline uint64_t //\nwuffs_base__image_config__first_frame_io_position(\n const wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_io_position : 0;\n}\n\nstatic inline bool //\nwuffs_base__image_config__first_frame_is_opaque(\n const wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_is_opaque : false;\n}\n\n#ifdef __cplusplus\n" + - "\ninline void //\nwuffs_base__image_config::set(uint32_t pixfmt_repr,\n wuffs_base__pixel_subsampling pixsub,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque) {\n wuffs_base__image_config__set(this, pixfmt_repr, pixsub, width, height,\n first_frame_io_position, first_frame_is_opaque);\n}\n\ninline void //\nwuffs_base__image_config::invalidate() {\n wuffs_base__image_config__invalidate(this);\n}\n\ninline bool //\nwuffs_base__image_config::is_valid() const {\n return wuffs_base__image_config__is_valid(this);\n}\n\ninline uint64_t //\nwuffs_base__image_config::first_frame_io_position() const {\n return wuffs_base__image_config__first_frame_io_position(this);\n}\n\ninline bool //\nwuffs_base__image_config::first_frame_is_opaque() const {\n return wuffs_base__image_config__first_frame_is_opaque(this);\n}\n\n#" + - "endif // __cplusplus\n\n" + + "// --------\n\ntypedef struct {\n wuffs_base__pixel_config pixcfg;\n\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 uint64_t first_frame_io_position;\n bool first_frame_is_opaque;\n } private_impl;\n\n#ifdef __cplusplus\n inline void set(uint32_t pixfmt_repr,\n uint32_t pixsub_repr,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque);\n inline void invalidate();\n inline bool is_valid() const;\n inline uint64_t first_frame_io_position() const;\n inline bool first_frame_is_opaque() const;\n#endif // __cplusplus\n\n} wuffs_base__image_config;\n\nstatic inline wuffs_base__image_config //\nwuffs_base__null_image_config() {\n wuffs_base__image_config ret;\n ret.pixcfg = wuffs_base__null_pixel_config();\n ret.private_impl.first_frame_io_position = 0;\n ret.private_impl.first_frame_is_opaque = false;" + + "\n return ret;\n}\n\n// TODO: Should this function return bool? An error type?\nstatic inline void //\nwuffs_base__image_config__set(wuffs_base__image_config* c,\n uint32_t pixfmt_repr,\n uint32_t pixsub_repr,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque) {\n if (!c) {\n return;\n }\n if (pixfmt_repr) {\n c->pixcfg.private_impl.pixfmt.repr = pixfmt_repr;\n c->pixcfg.private_impl.pixsub.repr = pixsub_repr;\n c->pixcfg.private_impl.width = width;\n c->pixcfg.private_impl.height = height;\n c->private_impl.first_frame_io_position = first_frame_io_position;\n c->private_impl.first_frame_is_opaque = first_frame_is_opaque;\n return;\n }\n\n c->pixcfg.private_impl.pixfmt.repr = 0;\n c->pixcfg.private_impl.pixsub.repr = 0;\n c->pixcfg.private_impl.width = 0;\n c->pixcfg.private_impl.he" + + "ight = 0;\n c->private_impl.first_frame_io_position = 0;\n c->private_impl.first_frame_is_opaque = 0;\n}\n\nstatic inline void //\nwuffs_base__image_config__invalidate(wuffs_base__image_config* c) {\n if (c) {\n c->pixcfg.private_impl.pixfmt.repr = 0;\n c->pixcfg.private_impl.pixsub.repr = 0;\n c->pixcfg.private_impl.width = 0;\n c->pixcfg.private_impl.height = 0;\n c->private_impl.first_frame_io_position = 0;\n c->private_impl.first_frame_is_opaque = 0;\n }\n}\n\nstatic inline bool //\nwuffs_base__image_config__is_valid(const wuffs_base__image_config* c) {\n return c && wuffs_base__pixel_config__is_valid(&(c->pixcfg));\n}\n\nstatic inline uint64_t //\nwuffs_base__image_config__first_frame_io_position(\n const wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_io_position : 0;\n}\n\nstatic inline bool //\nwuffs_base__image_config__first_frame_is_opaque(\n const wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_is_opaque : false;\n}\n\n#ifdef __cplusplus\n\ninline void" + + " //\nwuffs_base__image_config::set(uint32_t pixfmt_repr,\n uint32_t pixsub_repr,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque) {\n wuffs_base__image_config__set(this, pixfmt_repr, pixsub_repr, width, height,\n first_frame_io_position, first_frame_is_opaque);\n}\n\ninline void //\nwuffs_base__image_config::invalidate() {\n wuffs_base__image_config__invalidate(this);\n}\n\ninline bool //\nwuffs_base__image_config::is_valid() const {\n return wuffs_base__image_config__is_valid(this);\n}\n\ninline uint64_t //\nwuffs_base__image_config::first_frame_io_position() const {\n return wuffs_base__image_config__first_frame_io_position(this);\n}\n\ninline bool //\nwuffs_base__image_config::first_frame_is_opaque() const {\n return wuffs_base__image_config__first_frame_is_opaque(this);\n}\n\n#endif // __cplusplus\n\n" + "" + "// --------\n\n// wuffs_base__animation_blend encodes, for an animated image, how to blend the\n// transparent pixels of this frame with the existing canvas. In Porter-Duff\n// compositing operator terminology:\n// - 0 means the frame may be transparent, and should be blended \"src over\n// dst\", also known as just \"over\".\n// - 1 means the frame may be transparent, and should be blended \"src\".\n// - 2 means the frame is completely opaque, so that \"src over dst\" and \"src\"\n// are equivalent.\n//\n// These semantics are conservative. It is valid for a completely opaque frame\n// to have a blend value other than 2.\ntypedef uint8_t wuffs_base__animation_blend;\n\n#define WUFFS_BASE__ANIMATION_BLEND__SRC_OVER_DST \\\n ((wuffs_base__animation_blend)0)\n#define WUFFS_BASE__ANIMATION_BLEND__SRC ((wuffs_base__animation_blend)1)\n#define WUFFS_BASE__ANIMATION_BLEND__OPAQUE ((wuffs_base__animation_blend)2)\n\n" + "" +
diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 9105c1c..96b44e5 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c
@@ -1619,28 +1619,39 @@ // // Do not manipulate its bits directly; they are private implementation // details. Use methods such as wuffs_base__pixel_subsampling__bias_x instead. -typedef uint32_t wuffs_base__pixel_subsampling; +typedef struct { + uint32_t repr; -#define WUFFS_BASE__PIXEL_SUBSAMPLING__NONE ((wuffs_base__pixel_subsampling)0) +#ifdef __cplusplus + inline uint32_t bias_x(uint32_t plane) const; + inline uint32_t denominator_x(uint32_t plane) const; + inline uint32_t bias_y(uint32_t plane) const; + inline uint32_t denominator_y(uint32_t plane) const; +#endif // __cplusplus -#define WUFFS_BASE__PIXEL_SUBSAMPLING__444 \ - ((wuffs_base__pixel_subsampling)0x000000) -#define WUFFS_BASE__PIXEL_SUBSAMPLING__440 \ - ((wuffs_base__pixel_subsampling)0x010100) -#define WUFFS_BASE__PIXEL_SUBSAMPLING__422 \ - ((wuffs_base__pixel_subsampling)0x101000) -#define WUFFS_BASE__PIXEL_SUBSAMPLING__420 \ - ((wuffs_base__pixel_subsampling)0x111100) -#define WUFFS_BASE__PIXEL_SUBSAMPLING__411 \ - ((wuffs_base__pixel_subsampling)0x303000) -#define WUFFS_BASE__PIXEL_SUBSAMPLING__410 \ - ((wuffs_base__pixel_subsampling)0x313100) +} wuffs_base__pixel_subsampling; + +static inline wuffs_base__pixel_subsampling // +wuffs_base__make_pixel_subsampling(uint32_t repr) { + wuffs_base__pixel_subsampling s; + s.repr = repr; + return s; +} + +#define WUFFS_BASE__PIXEL_SUBSAMPLING__NONE 0x00000000 + +#define WUFFS_BASE__PIXEL_SUBSAMPLING__444 0x000000 +#define WUFFS_BASE__PIXEL_SUBSAMPLING__440 0x010100 +#define WUFFS_BASE__PIXEL_SUBSAMPLING__422 0x101000 +#define WUFFS_BASE__PIXEL_SUBSAMPLING__420 0x111100 +#define WUFFS_BASE__PIXEL_SUBSAMPLING__411 0x303000 +#define WUFFS_BASE__PIXEL_SUBSAMPLING__410 0x313100 static inline uint32_t // wuffs_base__pixel_subsampling__bias_x(const wuffs_base__pixel_subsampling* s, uint32_t plane) { uint32_t shift = ((plane & 0x03) * 8) + 6; - return (*s >> shift) & 0x03; + return (s->repr >> shift) & 0x03; } static inline uint32_t // @@ -1648,14 +1659,14 @@ const wuffs_base__pixel_subsampling* s, uint32_t plane) { uint32_t shift = ((plane & 0x03) * 8) + 4; - return ((*s >> shift) & 0x03) + 1; + return ((s->repr >> shift) & 0x03) + 1; } static inline uint32_t // wuffs_base__pixel_subsampling__bias_y(const wuffs_base__pixel_subsampling* s, uint32_t plane) { uint32_t shift = ((plane & 0x03) * 8) + 2; - return (*s >> shift) & 0x03; + return (s->repr >> shift) & 0x03; } static inline uint32_t // @@ -1663,9 +1674,33 @@ const wuffs_base__pixel_subsampling* s, uint32_t plane) { uint32_t shift = ((plane & 0x03) * 8) + 0; - return ((*s >> shift) & 0x03) + 1; + return ((s->repr >> shift) & 0x03) + 1; } +#ifdef __cplusplus + +inline uint32_t // +wuffs_base__pixel_subsampling::bias_x(uint32_t plane) const { + return wuffs_base__pixel_subsampling__bias_x(this, plane); +} + +inline uint32_t // +wuffs_base__pixel_subsampling::denominator_x(uint32_t plane) const { + return wuffs_base__pixel_subsampling__denominator_x(this, plane); +} + +inline uint32_t // +wuffs_base__pixel_subsampling::bias_y(uint32_t plane) const { + return wuffs_base__pixel_subsampling__bias_y(this, plane); +} + +inline uint32_t // +wuffs_base__pixel_subsampling::denominator_y(uint32_t plane) const { + return wuffs_base__pixel_subsampling__denominator_y(this, plane); +} + +#endif // __cplusplus + // -------- typedef struct { @@ -1699,7 +1734,7 @@ wuffs_base__null_pixel_config() { wuffs_base__pixel_config ret; ret.private_impl.pixfmt.repr = 0; - ret.private_impl.pixsub = 0; + ret.private_impl.pixsub.repr = 0; ret.private_impl.width = 0; ret.private_impl.height = 0; return ret; @@ -1728,7 +1763,7 @@ } c->private_impl.pixfmt.repr = 0; - c->private_impl.pixsub = 0; + c->private_impl.pixsub.repr = 0; c->private_impl.width = 0; c->private_impl.height = 0; } @@ -1737,7 +1772,7 @@ wuffs_base__pixel_config__invalidate(wuffs_base__pixel_config* c) { if (c) { c->private_impl.pixfmt.repr = 0; - c->private_impl.pixsub = 0; + c->private_impl.pixsub.repr = 0; c->private_impl.width = 0; c->private_impl.height = 0; } @@ -1755,7 +1790,7 @@ static inline wuffs_base__pixel_subsampling // wuffs_base__pixel_config__pixel_subsampling(const wuffs_base__pixel_config* c) { - return c ? c->private_impl.pixsub : 0; + return c ? c->private_impl.pixsub : wuffs_base__make_pixel_subsampling(0); } static inline wuffs_base__rect_ie_u32 // @@ -1890,7 +1925,7 @@ #ifdef __cplusplus inline void set(uint32_t pixfmt_repr, - wuffs_base__pixel_subsampling pixsub, + uint32_t pixsub_repr, uint32_t width, uint32_t height, uint64_t first_frame_io_position, @@ -1916,7 +1951,7 @@ static inline void // wuffs_base__image_config__set(wuffs_base__image_config* c, uint32_t pixfmt_repr, - wuffs_base__pixel_subsampling pixsub, + uint32_t pixsub_repr, uint32_t width, uint32_t height, uint64_t first_frame_io_position, @@ -1926,7 +1961,7 @@ } if (pixfmt_repr) { c->pixcfg.private_impl.pixfmt.repr = pixfmt_repr; - c->pixcfg.private_impl.pixsub = pixsub; + c->pixcfg.private_impl.pixsub.repr = pixsub_repr; c->pixcfg.private_impl.width = width; c->pixcfg.private_impl.height = height; c->private_impl.first_frame_io_position = first_frame_io_position; @@ -1935,7 +1970,7 @@ } c->pixcfg.private_impl.pixfmt.repr = 0; - c->pixcfg.private_impl.pixsub = 0; + c->pixcfg.private_impl.pixsub.repr = 0; c->pixcfg.private_impl.width = 0; c->pixcfg.private_impl.height = 0; c->private_impl.first_frame_io_position = 0; @@ -1946,7 +1981,7 @@ wuffs_base__image_config__invalidate(wuffs_base__image_config* c) { if (c) { c->pixcfg.private_impl.pixfmt.repr = 0; - c->pixcfg.private_impl.pixsub = 0; + c->pixcfg.private_impl.pixsub.repr = 0; c->pixcfg.private_impl.width = 0; c->pixcfg.private_impl.height = 0; c->private_impl.first_frame_io_position = 0; @@ -1975,12 +2010,12 @@ inline void // wuffs_base__image_config::set(uint32_t pixfmt_repr, - wuffs_base__pixel_subsampling pixsub, + uint32_t pixsub_repr, uint32_t width, uint32_t height, uint64_t first_frame_io_position, bool first_frame_is_opaque) { - wuffs_base__image_config__set(this, pixfmt_repr, pixsub, width, height, + wuffs_base__image_config__set(this, pixfmt_repr, pixsub_repr, width, height, first_frame_io_position, first_frame_is_opaque); }
diff --git a/test/c/std/gif.c b/test/c/std/gif.c index d4cd2c4..c4f348c 100644 --- a/test/c/std/gif.c +++ b/test/c/std/gif.c
@@ -209,10 +209,11 @@ CHECK_STATUS("decode_image_config", wuffs_gif__decoder__decode_image_config(&dec, &ic, src)); - wuffs_base__pixel_config__set(&ic.pixcfg, pixfmt, - WUFFS_BASE__PIXEL_SUBSAMPLING__NONE, - wuffs_base__pixel_config__width(&ic.pixcfg), - wuffs_base__pixel_config__height(&ic.pixcfg)); + wuffs_base__pixel_config__set( + &ic.pixcfg, pixfmt, + wuffs_base__make_pixel_subsampling(WUFFS_BASE__PIXEL_SUBSAMPLING__NONE), + wuffs_base__pixel_config__width(&ic.pixcfg), + wuffs_base__pixel_config__height(&ic.pixcfg)); wuffs_base__pixel_buffer pb = ((wuffs_base__pixel_buffer){}); CHECK_STATUS("set_from_slice", wuffs_base__pixel_buffer__set_from_slice( @@ -282,7 +283,9 @@ } wuffs_base__pixel_config__set( - &ic.pixcfg, dst_pixfmt, WUFFS_BASE__PIXEL_SUBSAMPLING__NONE, 160, 120); + &ic.pixcfg, dst_pixfmt, + wuffs_base__make_pixel_subsampling(WUFFS_BASE__PIXEL_SUBSAMPLING__NONE), + 160, 120); CHECK_STATUS("set_from_slice", wuffs_base__pixel_buffer__set_from_slice( &pb, &ic.pixcfg, global_pixel_slice));