From 56ee4b5e7f4758c27c66001553fa38eb99549dfd Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Mon, 23 Sep 2024 17:02:09 +0930 Subject: [PATCH] base: add IMAGE__DIMENSION_MAX_INCL comment --- internal/cgen/base/image-public.h | 15 +++++++++++++++ release/c/wuffs-unsupported-snapshot.c | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/internal/cgen/base/image-public.h b/internal/cgen/base/image-public.h index 6aa5084c..62ac9146 100644 --- a/internal/cgen/base/image-public.h +++ b/internal/cgen/base/image-public.h @@ -10,6 +10,21 @@ // ---------------- Images +// WUFFS_BASE__IMAGE__DIMENSION_MAX_INCL is the largest width or height +// (measured in pixels) supported by Wuffs' standard library's image codecs. +// +// Any non-negative integer N less than or equal to ((1 << 24) - 1) can be +// losslessly converted to and from single-precision floating point (what C +// calls the "float" type and what Go calls "float32"). +// +// A Wuffs image can have up to 4 channels and up to 8 bytes per channel (8 is +// also known as sizeof(double)), combining for up to 32 bytes per pixel. When +// calculating memory requirements, the 0xFFFFFF upper bound also means that: +// - (32 * N) will not overflow an int32_t or uint32_t. +// - (32 * N * N) will not overflow an int64_t or uint64_t, provided that N +// already has a 64-bit type. +// +// 0xFFFFFF in decimal is 16777215. #define WUFFS_BASE__IMAGE__DIMENSION_MAX_INCL 0xFFFFFF // wuffs_base__color_u32_argb_premul is an 8 bit per channel premultiplied diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index e2c3b7a2..3755bfb2 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -4064,6 +4064,21 @@ wuffs_base__malloc_slice_u64(void* (*malloc_func)(size_t), uint64_t num_u64) { // ---------------- Images +// WUFFS_BASE__IMAGE__DIMENSION_MAX_INCL is the largest width or height +// (measured in pixels) supported by Wuffs' standard library's image codecs. +// +// Any non-negative integer N less than or equal to ((1 << 24) - 1) can be +// losslessly converted to and from single-precision floating point (what C +// calls the "float" type and what Go calls "float32"). +// +// A Wuffs image can have up to 4 channels and up to 8 bytes per channel (8 is +// also known as sizeof(double)), combining for up to 32 bytes per pixel. When +// calculating memory requirements, the 0xFFFFFF upper bound also means that: +// - (32 * N) will not overflow an int32_t or uint32_t. +// - (32 * N * N) will not overflow an int64_t or uint64_t, provided that N +// already has a 64-bit type. +// +// 0xFFFFFF in decimal is 16777215. #define WUFFS_BASE__IMAGE__DIMENSION_MAX_INCL 0xFFFFFF // wuffs_base__color_u32_argb_premul is an 8 bit per channel premultiplied