release: wuffs gen -version=0.4.0-alpha.1
diff --git a/release/c/wuffs-v0.4.c b/release/c/wuffs-v0.4.c
new file mode 100644
index 0000000..5e8ec2f
--- /dev/null
+++ b/release/c/wuffs-v0.4.c
@@ -0,0 +1,64191 @@
+#ifndef WUFFS_INCLUDE_GUARD
+#define WUFFS_INCLUDE_GUARD
+
+// Wuffs ships as a "single file C library" or "header file library" as per
+// https://github.com/nothings/stb/blob/master/docs/stb_howto.txt
+//
+// To use that single file as a "foo.c"-like implementation, instead of a
+// "foo.h"-like header, #define WUFFS_IMPLEMENTATION before #include'ing or
+// compiling it.
+
+// Wuffs' C code is generated automatically, not hand-written. These warnings'
+// costs outweigh the benefits.
+//
+// The "elif defined(__clang__)" isn't redundant. While vanilla clang defines
+// __GNUC__, clang-cl (which mimics MSVC's cl.exe) does not.
+#if defined(__GNUC__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#pragma GCC diagnostic ignored "-Wunreachable-code"
+#pragma GCC diagnostic ignored "-Wunused-function"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#if defined(__cplusplus)
+#pragma GCC diagnostic ignored "-Wold-style-cast"
+#endif
+#elif defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
+#pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#pragma clang diagnostic ignored "-Wunreachable-code"
+#pragma clang diagnostic ignored "-Wunused-function"
+#pragma clang diagnostic ignored "-Wunused-parameter"
+#if defined(__cplusplus)
+#pragma clang diagnostic ignored "-Wold-style-cast"
+#endif
+#endif
+
+// Copyright 2017 The Wuffs Authors.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __cplusplus
+#if (__cplusplus >= 201103L) || defined(_MSC_VER)
+#include <memory>
+#define WUFFS_BASE__HAVE_EQ_DELETE
+#define WUFFS_BASE__HAVE_UNIQUE_PTR
+// The "defined(__clang__)" isn't redundant. While vanilla clang defines
+// __GNUC__, clang-cl (which mimics MSVC's cl.exe) does not.
+#elif defined(__GNUC__) || defined(__clang__)
+#warning "Wuffs' C++ code expects -std=c++11 or later"
+#endif
+
+extern "C" {
+#endif
+
+// ---------------- Version
+
+// WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/,
+// as a uint64_t. The major number is the high 32 bits. The minor number is the
+// middle 16 bits. The patch number is the low 16 bits. The pre-release label
+// and build metadata are part of the string representation (such as
+// "1.2.3-beta+456.20181231") but not the uint64_t representation.
+//
+// WUFFS_VERSION_PRE_RELEASE_LABEL (such as "", "beta" or "rc.1") being
+// non-empty denotes a developer preview, not a release version, and has no
+// backwards or forwards compatibility guarantees.
+//
+// WUFFS_VERSION_BUILD_METADATA_XXX, if non-zero, are the number of commits and
+// the last commit date in the repository used to build this library. Within
+// each major.minor branch, the commit count should increase monotonically.
+//
+// WUFFS_VERSION was overridden by "wuffs gen -version" based on revision
+// 5336b511e03b6166e6c2b8eed260e4d2b3fc1ae5 committed on 2023-10-06.
+#define WUFFS_VERSION 0x000040000
+#define WUFFS_VERSION_MAJOR 0
+#define WUFFS_VERSION_MINOR 4
+#define WUFFS_VERSION_PATCH 0
+#define WUFFS_VERSION_PRE_RELEASE_LABEL "alpha.1"
+#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 3597
+#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20231006
+#define WUFFS_VERSION_STRING "0.4.0-alpha.1+3597.20231006"
+
+// ---------------- Configuration
+
+// Define WUFFS_CONFIG__AVOID_CPU_ARCH to avoid any code tied to a specific CPU
+// architecture, such as SSE SIMD for the x86 CPU family.
+#if defined(WUFFS_CONFIG__AVOID_CPU_ARCH)  // (#if-chain ref AVOID_CPU_ARCH_0)
+// No-op.
+#else  // (#if-chain ref AVOID_CPU_ARCH_0)
+
+// The "defined(__clang__)" isn't redundant. While vanilla clang defines
+// __GNUC__, clang-cl (which mimics MSVC's cl.exe) does not.
+#if defined(__GNUC__) || defined(__clang__)
+#define WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET(arg) __attribute__((target(arg)))
+#else
+#define WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET(arg)
+#endif  // defined(__GNUC__) || defined(__clang__)
+
+#if defined(__GNUC__)  // (#if-chain ref AVOID_CPU_ARCH_1)
+
+// To simplify Wuffs code, "cpu_arch >= arm_xxx" requires xxx but also
+// unaligned little-endian load/stores.
+#if defined(__ARM_FEATURE_UNALIGNED) && !defined(__native_client__) && \
+    defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+// Not all gcc versions define __ARM_ACLE, even if they support crc32
+// intrinsics. Look for __ARM_FEATURE_CRC32 instead.
+#if defined(__ARM_FEATURE_CRC32)
+#include <arm_acle.h>
+#define WUFFS_BASE__CPU_ARCH__ARM_CRC32
+#endif  // defined(__ARM_FEATURE_CRC32)
+#if defined(__ARM_NEON)
+#include <arm_neon.h>
+#define WUFFS_BASE__CPU_ARCH__ARM_NEON
+#endif  // defined(__ARM_NEON)
+#endif  // defined(__ARM_FEATURE_UNALIGNED) etc
+
+// Similarly, "cpu_arch >= x86_sse42" requires SSE4.2 but also PCLMUL and
+// POPCNT. This is checked at runtime via cpuid, not at compile time.
+//
+// Likewise, "cpu_arch >= x86_avx2" also requires PCLMUL, POPCNT and SSE4.2.
+#if defined(__i386__) || defined(__x86_64__)
+#if !defined(__native_client__)
+#include <cpuid.h>
+#include <x86intrin.h>
+// X86_FAMILY means X86 (32-bit) or X86_64 (64-bit, obviously).
+#define WUFFS_BASE__CPU_ARCH__X86_FAMILY
+#if defined(__x86_64__)
+#define WUFFS_BASE__CPU_ARCH__X86_64
+#endif  // defined(__x86_64__)
+#endif  // !defined(__native_client__)
+#endif  // defined(__i386__) || defined(__x86_64__)
+
+#elif defined(_MSC_VER)  // (#if-chain ref AVOID_CPU_ARCH_1)
+
+#if defined(_M_IX86) || defined(_M_X64)
+#if defined(__AVX__) || defined(__clang__)
+
+// We need <intrin.h> for the __cpuid function.
+#include <intrin.h>
+// That's not enough for X64 SIMD, with clang-cl, if we want to use
+// "__attribute__((target(arg)))" without e.g. "/arch:AVX".
+//
+// Some web pages suggest that <immintrin.h> is all you need, as it pulls in
+// the earlier SIMD families like SSE4.2, but that doesn't seem to work in
+// practice, possibly for the same reason that just <intrin.h> doesn't work.
+#include <immintrin.h>  // AVX, AVX2, FMA, POPCNT
+#include <nmmintrin.h>  // SSE4.2
+#include <wmmintrin.h>  // AES, PCLMUL
+// X86_FAMILY means X86 (32-bit) or X86_64 (64-bit, obviously).
+#define WUFFS_BASE__CPU_ARCH__X86_FAMILY
+#if defined(_M_X64)
+#define WUFFS_BASE__CPU_ARCH__X86_64
+#endif  // defined(_M_X64)
+
+#else  // defined(__AVX__) || defined(__clang__)
+
+// clang-cl (which defines both __clang__ and _MSC_VER) supports
+// "__attribute__((target(arg)))".
+//
+// For MSVC's cl.exe (unlike clang or gcc), SIMD capability is a compile-time
+// property of the source file (e.g. a /arch:AVX or -mavx compiler flag), not
+// of individual functions (that can be conditionally selected at runtime).
+#pragma message("Wuffs with MSVC+IX86/X64 needs /arch:AVX for best performance")
+
+#endif  // defined(__AVX__) || defined(__clang__)
+#endif  // defined(_M_IX86) || defined(_M_X64)
+
+#endif  // (#if-chain ref AVOID_CPU_ARCH_1)
+#endif  // (#if-chain ref AVOID_CPU_ARCH_0)
+
+// --------
+
+// Define WUFFS_CONFIG__STATIC_FUNCTIONS (combined with WUFFS_IMPLEMENTATION)
+// to make all of Wuffs' functions have static storage.
+//
+// This can help the compiler ignore or discard unused code, which can produce
+// faster compiles and smaller binaries. Other motivations are discussed in the
+// "ALLOW STATIC IMPLEMENTATION" section of
+// https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt
+#if defined(WUFFS_CONFIG__STATIC_FUNCTIONS)
+#define WUFFS_BASE__MAYBE_STATIC static
+#else
+#define WUFFS_BASE__MAYBE_STATIC
+#endif  // defined(WUFFS_CONFIG__STATIC_FUNCTIONS)
+
+// ---------------- CPU Architecture
+
+static inline bool  //
+wuffs_base__cpu_arch__have_arm_crc32() {
+#if defined(WUFFS_BASE__CPU_ARCH__ARM_CRC32)
+  return true;
+#else
+  return false;
+#endif  // defined(WUFFS_BASE__CPU_ARCH__ARM_CRC32)
+}
+
+static inline bool  //
+wuffs_base__cpu_arch__have_arm_neon() {
+#if defined(WUFFS_BASE__CPU_ARCH__ARM_NEON)
+  return true;
+#else
+  return false;
+#endif  // defined(WUFFS_BASE__CPU_ARCH__ARM_NEON)
+}
+
+static inline bool  //
+wuffs_base__cpu_arch__have_x86_avx2() {
+#if defined(__PCLMUL__) && defined(__POPCNT__) && defined(__SSE4_2__) && \
+    defined(__AVX2__)
+  return true;
+#else
+#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
+  // GCC defines these macros but MSVC does not.
+  //  - bit_AVX2 = (1 <<  5)
+  const unsigned int avx2_ebx7 = 0x00000020;
+  // GCC defines these macros but MSVC does not.
+  //  - bit_PCLMUL = (1 <<  1)
+  //  - bit_POPCNT = (1 << 23)
+  //  - bit_SSE4_2 = (1 << 20)
+  const unsigned int avx2_ecx1 = 0x00900002;
+
+  // clang defines __GNUC__ and clang-cl defines _MSC_VER (but not __GNUC__).
+#if defined(__GNUC__)
+  unsigned int eax7 = 0;
+  unsigned int ebx7 = 0;
+  unsigned int ecx7 = 0;
+  unsigned int edx7 = 0;
+  if (__get_cpuid_count(7, 0, &eax7, &ebx7, &ecx7, &edx7) &&
+      ((ebx7 & avx2_ebx7) == avx2_ebx7)) {
+    unsigned int eax1 = 0;
+    unsigned int ebx1 = 0;
+    unsigned int ecx1 = 0;
+    unsigned int edx1 = 0;
+    if (__get_cpuid(1, &eax1, &ebx1, &ecx1, &edx1) &&
+        ((ecx1 & avx2_ecx1) == avx2_ecx1)) {
+      return true;
+    }
+  }
+#elif defined(_MSC_VER)  // defined(__GNUC__)
+  int x7[4];
+  __cpuidex(x7, 7, 0);
+  if ((((unsigned int)(x7[1])) & avx2_ebx7) == avx2_ebx7) {
+    int x1[4];
+    __cpuid(x1, 1);
+    if ((((unsigned int)(x1[2])) & avx2_ecx1) == avx2_ecx1) {
+      return true;
+    }
+  }
+#else
+#error "WUFFS_BASE__CPU_ARCH__ETC combined with an unsupported compiler"
+#endif  // defined(__GNUC__); defined(_MSC_VER)
+#endif  // defined(WUFFS_BASE__CPU_ARCH__X86_64)
+  return false;
+#endif  // defined(__PCLMUL__) && defined(__POPCNT__) && defined(__SSE4_2__) &&
+        // defined(__AVX2__)
+}
+
+static inline bool  //
+wuffs_base__cpu_arch__have_x86_bmi2() {
+#if defined(__BMI2__)
+  return true;
+#else
+#if defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
+  // GCC defines these macros but MSVC does not.
+  //  - bit_BMI2 = (1 <<  8)
+  const unsigned int bmi2_ebx7 = 0x00000100;
+
+  // clang defines __GNUC__ and clang-cl defines _MSC_VER (but not __GNUC__).
+#if defined(__GNUC__)
+  unsigned int eax7 = 0;
+  unsigned int ebx7 = 0;
+  unsigned int ecx7 = 0;
+  unsigned int edx7 = 0;
+  if (__get_cpuid_count(7, 0, &eax7, &ebx7, &ecx7, &edx7) &&
+      ((ebx7 & bmi2_ebx7) == bmi2_ebx7)) {
+    return true;
+  }
+#elif defined(_MSC_VER)  // defined(__GNUC__)
+  int x7[4];
+  __cpuidex(x7, 7, 0);
+  if ((((unsigned int)(x7[1])) & bmi2_ebx7) == bmi2_ebx7) {
+    return true;
+  }
+#else
+#error "WUFFS_BASE__CPU_ARCH__ETC combined with an unsupported compiler"
+#endif  // defined(__GNUC__); defined(_MSC_VER)
+#endif  // defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
+  return false;
+#endif  // defined(__BMI2__)
+}
+
+static inline bool  //
+wuffs_base__cpu_arch__have_x86_sse42() {
+#if defined(__PCLMUL__) && defined(__POPCNT__) && defined(__SSE4_2__)
+  return true;
+#else
+#if defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
+  // GCC defines these macros but MSVC does not.
+  //  - bit_PCLMUL = (1 <<  1)
+  //  - bit_POPCNT = (1 << 23)
+  //  - bit_SSE4_2 = (1 << 20)
+  const unsigned int sse42_ecx1 = 0x00900002;
+
+  // clang defines __GNUC__ and clang-cl defines _MSC_VER (but not __GNUC__).
+#if defined(__GNUC__)
+  unsigned int eax1 = 0;
+  unsigned int ebx1 = 0;
+  unsigned int ecx1 = 0;
+  unsigned int edx1 = 0;
+  if (__get_cpuid(1, &eax1, &ebx1, &ecx1, &edx1) &&
+      ((ecx1 & sse42_ecx1) == sse42_ecx1)) {
+    return true;
+  }
+#elif defined(_MSC_VER)  // defined(__GNUC__)
+  int x1[4];
+  __cpuid(x1, 1);
+  if ((((unsigned int)(x1[2])) & sse42_ecx1) == sse42_ecx1) {
+    return true;
+  }
+#else
+#error "WUFFS_BASE__CPU_ARCH__ETC combined with an unsupported compiler"
+#endif  // defined(__GNUC__); defined(_MSC_VER)
+#endif  // defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
+  return false;
+#endif  // defined(__PCLMUL__) && defined(__POPCNT__) && defined(__SSE4_2__)
+}
+
+// ---------------- Fundamentals
+
+// Wuffs assumes that:
+//  - converting a uint32_t to a size_t will never overflow.
+//  - converting a size_t to a uint64_t will never overflow.
+#if defined(__WORDSIZE)
+#if (__WORDSIZE != 32) && (__WORDSIZE != 64)
+#error "Wuffs requires a word size of either 32 or 64 bits"
+#endif
+#endif
+
+// The "defined(__clang__)" isn't redundant. While vanilla clang defines
+// __GNUC__, clang-cl (which mimics MSVC's cl.exe) does not.
+#if defined(__GNUC__) || defined(__clang__)
+#define WUFFS_BASE__POTENTIALLY_UNUSED __attribute__((unused))
+#define WUFFS_BASE__WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#else
+#define WUFFS_BASE__POTENTIALLY_UNUSED
+#define WUFFS_BASE__WARN_UNUSED_RESULT
+#endif
+
+// Clang's "-fsanitize=integer" checks for "unsigned-integer-overflow" even
+// though, for *unsigned* integers, it is *not* undefined behavior. The check
+// is still made because unsigned integer overflow "is often unintentional".
+// https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
+//
+// However, for Wuffs' generated C code, unsigned overflow is intentional. The
+// programmer has to use "~mod+" instead of a plain "+" operator in Wuffs code.
+// Further runtime checks for unsigned integer overflow can add performance
+// overhead (fuzzers can then time out) and can raise false negatives, without
+// generating much benefits. We disable the "unsigned-integer-overflow" check.
+#if defined(__has_feature)
+#if __has_feature(undefined_behavior_sanitizer)
+#define WUFFS_BASE__GENERATED_C_CODE \
+  __attribute__((no_sanitize("unsigned-integer-overflow")))
+#endif
+#endif
+#if !defined(WUFFS_BASE__GENERATED_C_CODE)
+#define WUFFS_BASE__GENERATED_C_CODE
+#endif
+
+// --------
+
+// Options (bitwise or'ed together) for wuffs_foo__bar__initialize functions.
+
+#define WUFFS_INITIALIZE__DEFAULT_OPTIONS ((uint32_t)0x00000000)
+
+// WUFFS_INITIALIZE__ALREADY_ZEROED means that the "self" receiver struct value
+// has already been set to all zeroes.
+#define WUFFS_INITIALIZE__ALREADY_ZEROED ((uint32_t)0x00000001)
+
+// WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED means that, absent
+// WUFFS_INITIALIZE__ALREADY_ZEROED, only some of the "self" receiver struct
+// value will be set to all zeroes. Internal buffers, which tend to be a large
+// proportion of the struct's size, will be left uninitialized. Internal means
+// that the buffer is contained by the receiver struct, as opposed to being
+// passed as a separately allocated "work buffer".
+//
+// For more detail, see:
+// https://github.com/google/wuffs/blob/main/doc/note/initialization.md
+#define WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED \
+  ((uint32_t)0x00000002)
+
+// --------
+
+#ifdef __cplusplus
+// Wuffs structs are just data, not resources (in the RAII sense). They don't
+// subclass anything. They don't have virtual destructors. They don't contain
+// pointers to dynamically allocated memory. They don't contain file
+// descriptors. And so on. Destroying such a struct (e.g. via a
+// wuffs_foo__bar::unique_ptr) can just call free, especially as
+// sizeof(wuffs_foo__bar) isn't supposed to be part of the public (stable) API.
+struct wuffs_unique_ptr_deleter {
+  void operator()(void* p) { free(p); }
+};
+#endif  // __cplusplus
+
+// --------
+
+// wuffs_base__empty_struct is used when a Wuffs function returns an empty
+// struct. In C, if a function f returns void, you can't say "x = f()", but in
+// Wuffs, if a function g returns empty, you can say "y = g()".
+typedef struct wuffs_base__empty_struct__struct {
+  // private_impl is a placeholder field. It isn't explicitly used, except that
+  // without it, the sizeof a struct with no fields can differ across C/C++
+  // compilers, and it is undefined behavior in C99. For example, gcc says that
+  // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to
+  // ABI incompatibility if a Wuffs .c file is processed by one compiler and
+  // its .h file with another compiler.
+  //
+  // Instead, we explicitly insert an otherwise unused field, so that the
+  // sizeof this struct is always 1.
+  uint8_t private_impl;
+} wuffs_base__empty_struct;
+
+static inline wuffs_base__empty_struct  //
+wuffs_base__make_empty_struct() {
+  wuffs_base__empty_struct ret;
+  ret.private_impl = 0;
+  return ret;
+}
+
+// wuffs_base__utility is a placeholder receiver type. It enables what Java
+// calls static methods, as opposed to regular methods.
+typedef struct wuffs_base__utility__struct {
+  // private_impl is a placeholder field. It isn't explicitly used, except that
+  // without it, the sizeof a struct with no fields can differ across C/C++
+  // compilers, and it is undefined behavior in C99. For example, gcc says that
+  // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to
+  // ABI incompatibility if a Wuffs .c file is processed by one compiler and
+  // its .h file with another compiler.
+  //
+  // Instead, we explicitly insert an otherwise unused field, so that the
+  // sizeof this struct is always 1.
+  uint8_t private_impl;
+} wuffs_base__utility;
+
+typedef struct wuffs_base__vtable__struct {
+  const char* vtable_name;
+  const void* function_pointers;
+} wuffs_base__vtable;
+
+// --------
+
+// See https://github.com/google/wuffs/blob/main/doc/note/statuses.md
+typedef struct wuffs_base__status__struct {
+  const char* repr;
+
+#ifdef __cplusplus
+  inline bool is_complete() const;
+  inline bool is_error() const;
+  inline bool is_note() const;
+  inline bool is_ok() const;
+  inline bool is_suspension() const;
+  inline bool is_truncated_input_error() const;
+  inline const char* message() const;
+#endif  // __cplusplus
+
+} wuffs_base__status;
+
+extern const char wuffs_base__note__i_o_redirect[];
+extern const char wuffs_base__note__end_of_data[];
+extern const char wuffs_base__note__metadata_reported[];
+extern const char wuffs_base__suspension__even_more_information[];
+extern const char wuffs_base__suspension__mispositioned_read[];
+extern const char wuffs_base__suspension__mispositioned_write[];
+extern const char wuffs_base__suspension__short_read[];
+extern const char wuffs_base__suspension__short_write[];
+extern const char wuffs_base__error__bad_i_o_position[];
+extern const char wuffs_base__error__bad_argument_length_too_short[];
+extern const char wuffs_base__error__bad_argument[];
+extern const char wuffs_base__error__bad_call_sequence[];
+extern const char wuffs_base__error__bad_data[];
+extern const char wuffs_base__error__bad_receiver[];
+extern const char wuffs_base__error__bad_restart[];
+extern const char wuffs_base__error__bad_sizeof_receiver[];
+extern const char wuffs_base__error__bad_vtable[];
+extern const char wuffs_base__error__bad_workbuf_length[];
+extern const char wuffs_base__error__bad_wuffs_version[];
+extern const char wuffs_base__error__cannot_return_a_suspension[];
+extern const char wuffs_base__error__disabled_by_previous_error[];
+extern const char wuffs_base__error__initialize_falsely_claimed_already_zeroed[];
+extern const char wuffs_base__error__initialize_not_called[];
+extern const char wuffs_base__error__interleaved_coroutine_calls[];
+extern const char wuffs_base__error__no_more_information[];
+extern const char wuffs_base__error__not_enough_data[];
+extern const char wuffs_base__error__out_of_bounds[];
+extern const char wuffs_base__error__unsupported_image_dimension[];
+extern const char wuffs_base__error__unsupported_method[];
+extern const char wuffs_base__error__unsupported_option[];
+extern const char wuffs_base__error__unsupported_pixel_swizzler_option[];
+extern const char wuffs_base__error__too_much_data[];
+
+static inline wuffs_base__status  //
+wuffs_base__make_status(const char* repr) {
+  wuffs_base__status z;
+  z.repr = repr;
+  return z;
+}
+
+static inline bool  //
+wuffs_base__status__is_complete(const wuffs_base__status* z) {
+  return (z->repr == NULL) || ((*z->repr != '$') && (*z->repr != '#'));
+}
+
+static inline bool  //
+wuffs_base__status__is_error(const wuffs_base__status* z) {
+  return z->repr && (*z->repr == '#');
+}
+
+static inline bool  //
+wuffs_base__status__is_note(const wuffs_base__status* z) {
+  return z->repr && (*z->repr != '$') && (*z->repr != '#');
+}
+
+static inline bool  //
+wuffs_base__status__is_ok(const wuffs_base__status* z) {
+  return z->repr == NULL;
+}
+
+static inline bool  //
+wuffs_base__status__is_suspension(const wuffs_base__status* z) {
+  return z->repr && (*z->repr == '$');
+}
+
+static inline bool  //
+wuffs_base__status__is_truncated_input_error(const wuffs_base__status* z) {
+  const char* p = z->repr;
+  if (!p || (*p != '#')) {
+    return false;
+  }
+  p++;
+  while (1) {
+    if (*p == 0) {
+      return false;
+    } else if (*p++ == ':') {
+      break;
+    }
+  }
+  return strcmp(p, " truncated input") == 0;
+}
+
+// wuffs_base__status__message strips the leading '$', '#' or '@'.
+static inline const char*  //
+wuffs_base__status__message(const wuffs_base__status* z) {
+  if (z->repr) {
+    if ((*z->repr == '$') || (*z->repr == '#') || (*z->repr == '@')) {
+      return z->repr + 1;
+    }
+  }
+  return z->repr;
+}
+
+#ifdef __cplusplus
+
+inline bool  //
+wuffs_base__status::is_complete() const {
+  return wuffs_base__status__is_complete(this);
+}
+
+inline bool  //
+wuffs_base__status::is_error() const {
+  return wuffs_base__status__is_error(this);
+}
+
+inline bool  //
+wuffs_base__status::is_note() const {
+  return wuffs_base__status__is_note(this);
+}
+
+inline bool  //
+wuffs_base__status::is_ok() const {
+  return wuffs_base__status__is_ok(this);
+}
+
+inline bool  //
+wuffs_base__status::is_suspension() const {
+  return wuffs_base__status__is_suspension(this);
+}
+
+inline bool  //
+wuffs_base__status::is_truncated_input_error() const {
+  return wuffs_base__status__is_truncated_input_error(this);
+}
+
+inline const char*  //
+wuffs_base__status::message() const {
+  return wuffs_base__status__message(this);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+// WUFFS_BASE__RESULT is a result type: either a status (an error) or a value.
+//
+// A result with all fields NULL or zero is as valid as a zero-valued T.
+#define WUFFS_BASE__RESULT(T)  \
+  struct {                     \
+    wuffs_base__status status; \
+    T value;                   \
+  }
+
+typedef WUFFS_BASE__RESULT(double) wuffs_base__result_f64;
+typedef WUFFS_BASE__RESULT(int64_t) wuffs_base__result_i64;
+typedef WUFFS_BASE__RESULT(uint64_t) wuffs_base__result_u64;
+
+// --------
+
+// wuffs_base__transform__output is the result of transforming from a src slice
+// to a dst slice.
+typedef struct wuffs_base__transform__output__struct {
+  wuffs_base__status status;
+  size_t num_dst;
+  size_t num_src;
+} wuffs_base__transform__output;
+
+// --------
+
+// FourCC constants. Four Character Codes are literally four ASCII characters
+// (sometimes padded with ' ' spaces) that pack neatly into a signed or
+// unsigned 32-bit integer. ASCII letters are conventionally upper case.
+//
+// They are often used to identify video codecs (e.g. "H265") and pixel formats
+// (e.g. "YV12"). Wuffs uses them for that but also generally for naming
+// various things: compression formats (e.g. "BZ2 "), image metadata (e.g.
+// "EXIF"), file formats (e.g. "HTML"), etc.
+//
+// Wuffs' u32 values are big-endian ("JPEG" is 0x4A504547 not 0x4745504A) to
+// preserve ordering: "JPEG" < "MP3 " and 0x4A504547 < 0x4D503320.
+
+// Background Color.
+#define WUFFS_BASE__FOURCC__BGCL 0x4247434C
+
+// Bitmap.
+#define WUFFS_BASE__FOURCC__BMP 0x424D5020
+
+// Brotli.
+#define WUFFS_BASE__FOURCC__BRTL 0x4252544C
+
+// Bzip2.
+#define WUFFS_BASE__FOURCC__BZ2 0x425A3220
+
+// Concise Binary Object Representation.
+#define WUFFS_BASE__FOURCC__CBOR 0x43424F52
+
+// Primary Chromaticities and White Point.
+#define WUFFS_BASE__FOURCC__CHRM 0x4348524D
+
+// Cascading Style Sheets.
+#define WUFFS_BASE__FOURCC__CSS 0x43535320
+
+// Encapsulated PostScript.
+#define WUFFS_BASE__FOURCC__EPS 0x45505320
+
+// Exchangeable Image File Format.
+#define WUFFS_BASE__FOURCC__EXIF 0x45584946
+
+// Free Lossless Audio Codec.
+#define WUFFS_BASE__FOURCC__FLAC 0x464C4143
+
+// Gamma Correction.
+#define WUFFS_BASE__FOURCC__GAMA 0x47414D41
+
+// Graphics Interchange Format.
+#define WUFFS_BASE__FOURCC__GIF 0x47494620
+
+// GNU Zip.
+#define WUFFS_BASE__FOURCC__GZ 0x475A2020
+
+// High Efficiency Image File.
+#define WUFFS_BASE__FOURCC__HEIF 0x48454946
+
+// Hypertext Markup Language.
+#define WUFFS_BASE__FOURCC__HTML 0x48544D4C
+
+// International Color Consortium Profile.
+#define WUFFS_BASE__FOURCC__ICCP 0x49434350
+
+// Icon.
+#define WUFFS_BASE__FOURCC__ICO 0x49434F20
+
+// Icon Vector Graphics.
+#define WUFFS_BASE__FOURCC__ICVG 0x49435647
+
+// Initialization.
+#define WUFFS_BASE__FOURCC__INI 0x494E4920
+
+// Joint Photographic Experts Group.
+#define WUFFS_BASE__FOURCC__JPEG 0x4A504547
+
+// JavaScript.
+#define WUFFS_BASE__FOURCC__JS 0x4A532020
+
+// JavaScript Object Notation.
+#define WUFFS_BASE__FOURCC__JSON 0x4A534F4E
+
+// JSON With Commas and Comments.
+#define WUFFS_BASE__FOURCC__JWCC 0x4A574343
+
+// Key-Value Pair.
+#define WUFFS_BASE__FOURCC__KVP 0x4B565020
+
+// Key-Value Pair (Key).
+#define WUFFS_BASE__FOURCC__KVPK 0x4B56504B
+
+// Key-Value Pair (Value).
+#define WUFFS_BASE__FOURCC__KVPV 0x4B565056
+
+// Lempel–Ziv 4.
+#define WUFFS_BASE__FOURCC__LZ4 0x4C5A3420
+
+// Lempel–Ziv Markov-chain Algorithm.
+#define WUFFS_BASE__FOURCC__LZMA 0x4C5A4D41
+
+// Markdown.
+#define WUFFS_BASE__FOURCC__MD 0x4D442020
+
+// Modification Time.
+#define WUFFS_BASE__FOURCC__MTIM 0x4D54494D
+
+// MPEG-1 Audio Layer III.
+#define WUFFS_BASE__FOURCC__MP3 0x4D503320
+
+// Naive Image.
+#define WUFFS_BASE__FOURCC__NIE 0x4E494520
+
+// Netpbm (Portable Anymap).
+#define WUFFS_BASE__FOURCC__NPBM 0x4E50424D
+
+// Offset (2-Dimensional).
+#define WUFFS_BASE__FOURCC__OFS2 0x4F465332
+
+// Open Type Format.
+#define WUFFS_BASE__FOURCC__OTF 0x4F544620
+
+// Portable Document Format.
+#define WUFFS_BASE__FOURCC__PDF 0x50444620
+
+// Physical Dimensions.
+#define WUFFS_BASE__FOURCC__PHYD 0x50485944
+
+// Portable Network Graphics.
+#define WUFFS_BASE__FOURCC__PNG 0x504E4720
+
+// PostScript.
+#define WUFFS_BASE__FOURCC__PS 0x50532020
+
+// Quite OK Image.
+#define WUFFS_BASE__FOURCC__QOI 0x514F4920
+
+// Random Access Compression.
+#define WUFFS_BASE__FOURCC__RAC 0x52414320
+
+// Raw.
+#define WUFFS_BASE__FOURCC__RAW 0x52415720
+
+// Resource Interchange File Format.
+#define WUFFS_BASE__FOURCC__RIFF 0x52494646
+
+// Riegeli Records.
+#define WUFFS_BASE__FOURCC__RIGL 0x5249474C
+
+// Snappy.
+#define WUFFS_BASE__FOURCC__SNPY 0x534E5059
+
+// Standard Red Green Blue (Rendering Intent).
+#define WUFFS_BASE__FOURCC__SRGB 0x53524742
+
+// Scalable Vector Graphics.
+#define WUFFS_BASE__FOURCC__SVG 0x53564720
+
+// Tape Archive.
+#define WUFFS_BASE__FOURCC__TAR 0x54415220
+
+// Text.
+#define WUFFS_BASE__FOURCC__TEXT 0x54455854
+
+// Truevision Advanced Raster Graphics Adapter.
+#define WUFFS_BASE__FOURCC__TGA 0x54474120
+
+// Tagged Image File Format.
+#define WUFFS_BASE__FOURCC__TIFF 0x54494646
+
+// Tom's Obvious Minimal Language.
+#define WUFFS_BASE__FOURCC__TOML 0x544F4D4C
+
+// Waveform.
+#define WUFFS_BASE__FOURCC__WAVE 0x57415645
+
+// Wireless Bitmap.
+#define WUFFS_BASE__FOURCC__WBMP 0x57424D50
+
+// Web Picture.
+#define WUFFS_BASE__FOURCC__WEBP 0x57454250
+
+// Web Open Font Format.
+#define WUFFS_BASE__FOURCC__WOFF 0x574F4646
+
+// Extensible Markup Language.
+#define WUFFS_BASE__FOURCC__XML 0x584D4C20
+
+// Extensible Metadata Platform.
+#define WUFFS_BASE__FOURCC__XMP 0x584D5020
+
+// Xz.
+#define WUFFS_BASE__FOURCC__XZ 0x585A2020
+
+// Zip.
+#define WUFFS_BASE__FOURCC__ZIP 0x5A495020
+
+// Zlib.
+#define WUFFS_BASE__FOURCC__ZLIB 0x5A4C4942
+
+// Zstandard.
+#define WUFFS_BASE__FOURCC__ZSTD 0x5A535444
+
+// --------
+
+// Quirks.
+
+#define WUFFS_BASE__QUIRK_IGNORE_CHECKSUM 1
+
+// --------
+
+// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a
+// second. See https://github.com/OculusVR/Flicks
+typedef int64_t wuffs_base__flicks;
+
+#define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000)
+#define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600)
+
+// ---------------- Numeric Types
+
+// The helpers below are functions, instead of macros, because their arguments
+// can be an expression that we shouldn't evaluate more than once.
+//
+// They are static, so that linking multiple wuffs .o files won't complain about
+// duplicate function definitions.
+//
+// They are explicitly marked inline, even if modern compilers don't use the
+// inline attribute to guide optimizations such as inlining, to avoid the
+// -Wunused-function warning, and we like to compile with -Wall -Werror.
+
+static inline int8_t  //
+wuffs_base__i8__min(int8_t x, int8_t y) {
+  return x < y ? x : y;
+}
+
+static inline int8_t  //
+wuffs_base__i8__max(int8_t x, int8_t y) {
+  return x > y ? x : y;
+}
+
+static inline int16_t  //
+wuffs_base__i16__min(int16_t x, int16_t y) {
+  return x < y ? x : y;
+}
+
+static inline int16_t  //
+wuffs_base__i16__max(int16_t x, int16_t y) {
+  return x > y ? x : y;
+}
+
+static inline int32_t  //
+wuffs_base__i32__min(int32_t x, int32_t y) {
+  return x < y ? x : y;
+}
+
+static inline int32_t  //
+wuffs_base__i32__max(int32_t x, int32_t y) {
+  return x > y ? x : y;
+}
+
+static inline int64_t  //
+wuffs_base__i64__min(int64_t x, int64_t y) {
+  return x < y ? x : y;
+}
+
+static inline int64_t  //
+wuffs_base__i64__max(int64_t x, int64_t y) {
+  return x > y ? x : y;
+}
+
+static inline uint8_t  //
+wuffs_base__u8__min(uint8_t x, uint8_t y) {
+  return x < y ? x : y;
+}
+
+static inline uint8_t  //
+wuffs_base__u8__max(uint8_t x, uint8_t y) {
+  return x > y ? x : y;
+}
+
+static inline uint16_t  //
+wuffs_base__u16__min(uint16_t x, uint16_t y) {
+  return x < y ? x : y;
+}
+
+static inline uint16_t  //
+wuffs_base__u16__max(uint16_t x, uint16_t y) {
+  return x > y ? x : y;
+}
+
+static inline uint32_t  //
+wuffs_base__u32__min(uint32_t x, uint32_t y) {
+  return x < y ? x : y;
+}
+
+static inline uint32_t  //
+wuffs_base__u32__max(uint32_t x, uint32_t y) {
+  return x > y ? x : y;
+}
+
+static inline uint64_t  //
+wuffs_base__u64__min(uint64_t x, uint64_t y) {
+  return x < y ? x : y;
+}
+
+static inline uint64_t  //
+wuffs_base__u64__max(uint64_t x, uint64_t y) {
+  return x > y ? x : y;
+}
+
+// --------
+
+static inline uint8_t  //
+wuffs_base__u8__rotate_left(uint8_t x, uint32_t n) {
+  n &= 7;
+  return ((uint8_t)(x << n)) | ((uint8_t)(x >> (8 - n)));
+}
+
+static inline uint8_t  //
+wuffs_base__u8__rotate_right(uint8_t x, uint32_t n) {
+  n &= 7;
+  return ((uint8_t)(x >> n)) | ((uint8_t)(x << (8 - n)));
+}
+
+static inline uint16_t  //
+wuffs_base__u16__rotate_left(uint16_t x, uint32_t n) {
+  n &= 15;
+  return ((uint16_t)(x << n)) | ((uint16_t)(x >> (16 - n)));
+}
+
+static inline uint16_t  //
+wuffs_base__u16__rotate_right(uint16_t x, uint32_t n) {
+  n &= 15;
+  return ((uint16_t)(x >> n)) | ((uint16_t)(x << (16 - n)));
+}
+
+static inline uint32_t  //
+wuffs_base__u32__rotate_left(uint32_t x, uint32_t n) {
+  n &= 31;
+  return ((uint32_t)(x << n)) | ((uint32_t)(x >> (32 - n)));
+}
+
+static inline uint32_t  //
+wuffs_base__u32__rotate_right(uint32_t x, uint32_t n) {
+  n &= 31;
+  return ((uint32_t)(x >> n)) | ((uint32_t)(x << (32 - n)));
+}
+
+static inline uint64_t  //
+wuffs_base__u64__rotate_left(uint64_t x, uint32_t n) {
+  n &= 63;
+  return ((uint64_t)(x << n)) | ((uint64_t)(x >> (64 - n)));
+}
+
+static inline uint64_t  //
+wuffs_base__u64__rotate_right(uint64_t x, uint32_t n) {
+  n &= 63;
+  return ((uint64_t)(x >> n)) | ((uint64_t)(x << (64 - n)));
+}
+
+// --------
+
+// Saturating arithmetic (sat_add, sat_sub) branchless bit-twiddling algorithms
+// are per https://locklessinc.com/articles/sat_arithmetic/
+//
+// It is important that the underlying types are unsigned integers, as signed
+// integer arithmetic overflow is undefined behavior in C.
+
+static inline uint8_t  //
+wuffs_base__u8__sat_add(uint8_t x, uint8_t y) {
+  uint8_t res = (uint8_t)(x + y);
+  res |= (uint8_t)(-(res < x));
+  return res;
+}
+
+static inline uint8_t  //
+wuffs_base__u8__sat_sub(uint8_t x, uint8_t y) {
+  uint8_t res = (uint8_t)(x - y);
+  res &= (uint8_t)(-(res <= x));
+  return res;
+}
+
+static inline uint16_t  //
+wuffs_base__u16__sat_add(uint16_t x, uint16_t y) {
+  uint16_t res = (uint16_t)(x + y);
+  res |= (uint16_t)(-(res < x));
+  return res;
+}
+
+static inline uint16_t  //
+wuffs_base__u16__sat_sub(uint16_t x, uint16_t y) {
+  uint16_t res = (uint16_t)(x - y);
+  res &= (uint16_t)(-(res <= x));
+  return res;
+}
+
+static inline uint32_t  //
+wuffs_base__u32__sat_add(uint32_t x, uint32_t y) {
+  uint32_t res = (uint32_t)(x + y);
+  res |= (uint32_t)(-(res < x));
+  return res;
+}
+
+static inline uint32_t  //
+wuffs_base__u32__sat_sub(uint32_t x, uint32_t y) {
+  uint32_t res = (uint32_t)(x - y);
+  res &= (uint32_t)(-(res <= x));
+  return res;
+}
+
+static inline uint64_t  //
+wuffs_base__u64__sat_add(uint64_t x, uint64_t y) {
+  uint64_t res = (uint64_t)(x + y);
+  res |= (uint64_t)(-(res < x));
+  return res;
+}
+
+static inline uint64_t  //
+wuffs_base__u64__sat_sub(uint64_t x, uint64_t y) {
+  uint64_t res = (uint64_t)(x - y);
+  res &= (uint64_t)(-(res <= x));
+  return res;
+}
+
+// --------
+
+typedef struct wuffs_base__multiply_u64__output__struct {
+  uint64_t lo;
+  uint64_t hi;
+} wuffs_base__multiply_u64__output;
+
+// wuffs_base__multiply_u64 returns x*y as a 128-bit value.
+//
+// The maximum inclusive output hi_lo is 0xFFFFFFFFFFFFFFFE_0000000000000001.
+static inline wuffs_base__multiply_u64__output  //
+wuffs_base__multiply_u64(uint64_t x, uint64_t y) {
+#if defined(__SIZEOF_INT128__)
+  __uint128_t z = ((__uint128_t)x) * ((__uint128_t)y);
+  wuffs_base__multiply_u64__output o;
+  o.lo = ((uint64_t)(z));
+  o.hi = ((uint64_t)(z >> 64));
+  return o;
+#else
+  // TODO: consider using the _mul128 intrinsic if defined(_MSC_VER).
+  uint64_t x0 = x & 0xFFFFFFFF;
+  uint64_t x1 = x >> 32;
+  uint64_t y0 = y & 0xFFFFFFFF;
+  uint64_t y1 = y >> 32;
+  uint64_t w0 = x0 * y0;
+  uint64_t t = (x1 * y0) + (w0 >> 32);
+  uint64_t w1 = t & 0xFFFFFFFF;
+  uint64_t w2 = t >> 32;
+  w1 += x0 * y1;
+  wuffs_base__multiply_u64__output o;
+  o.lo = x * y;
+  o.hi = (x1 * y1) + w2 + (w1 >> 32);
+  return o;
+#endif
+}
+
+// --------
+
+// The "defined(__clang__)" isn't redundant. While vanilla clang defines
+// __GNUC__, clang-cl (which mimics MSVC's cl.exe) does not.
+#if (defined(__GNUC__) || defined(__clang__)) && (__SIZEOF_LONG__ == 8)
+
+static inline uint32_t  //
+wuffs_base__count_leading_zeroes_u64(uint64_t u) {
+  return u ? ((uint32_t)(__builtin_clzl(u))) : 64u;
+}
+
+#else
+// TODO: consider using the _BitScanReverse intrinsic if defined(_MSC_VER).
+
+static inline uint32_t  //
+wuffs_base__count_leading_zeroes_u64(uint64_t u) {
+  if (u == 0) {
+    return 64;
+  }
+
+  uint32_t n = 0;
+  if ((u >> 32) == 0) {
+    n |= 32;
+    u <<= 32;
+  }
+  if ((u >> 48) == 0) {
+    n |= 16;
+    u <<= 16;
+  }
+  if ((u >> 56) == 0) {
+    n |= 8;
+    u <<= 8;
+  }
+  if ((u >> 60) == 0) {
+    n |= 4;
+    u <<= 4;
+  }
+  if ((u >> 62) == 0) {
+    n |= 2;
+    u <<= 2;
+  }
+  if ((u >> 63) == 0) {
+    n |= 1;
+    u <<= 1;
+  }
+  return n;
+}
+
+#endif  // (defined(__GNUC__) || defined(__clang__)) && (__SIZEOF_LONG__ == 8)
+
+// --------
+
+// Normally, the wuffs_base__peek_etc and wuffs_base__poke_etc implementations
+// are both (1) correct regardless of CPU endianness and (2) very fast (e.g. an
+// inlined wuffs_base__peek_u32le__no_bounds_check call, in an optimized clang
+// or gcc build, is a single MOV instruction on x86_64).
+//
+// However, the endian-agnostic implementations are slow on Microsoft's C
+// compiler (MSC). Alternative memcpy-based implementations restore speed, but
+// they are only correct on little-endian CPU architectures. Defining
+// WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE opts in to these implementations.
+//
+// https://godbolt.org/z/q4MfjzTPh
+#if defined(_MSC_VER) && !defined(__clang__) && \
+    (defined(_M_ARM64) || defined(_M_X64))
+#define WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE
+#endif
+
+#define wuffs_base__peek_u8be__no_bounds_check \
+  wuffs_base__peek_u8__no_bounds_check
+#define wuffs_base__peek_u8le__no_bounds_check \
+  wuffs_base__peek_u8__no_bounds_check
+
+static inline uint8_t  //
+wuffs_base__peek_u8__no_bounds_check(const uint8_t* p) {
+  return p[0];
+}
+
+static inline uint16_t  //
+wuffs_base__peek_u16be__no_bounds_check(const uint8_t* p) {
+#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
+  uint16_t x;
+  memcpy(&x, p, 2);
+  return _byteswap_ushort(x);
+#else
+  return (uint16_t)(((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0));
+#endif
+}
+
+static inline uint16_t  //
+wuffs_base__peek_u16le__no_bounds_check(const uint8_t* p) {
+#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
+  uint16_t x;
+  memcpy(&x, p, 2);
+  return x;
+#else
+  return (uint16_t)(((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8));
+#endif
+}
+
+static inline uint32_t  //
+wuffs_base__peek_u24be__no_bounds_check(const uint8_t* p) {
+  return ((uint32_t)(p[0]) << 16) | ((uint32_t)(p[1]) << 8) |
+         ((uint32_t)(p[2]) << 0);
+}
+
+static inline uint32_t  //
+wuffs_base__peek_u24le__no_bounds_check(const uint8_t* p) {
+  return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |
+         ((uint32_t)(p[2]) << 16);
+}
+
+static inline uint32_t  //
+wuffs_base__peek_u32be__no_bounds_check(const uint8_t* p) {
+#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
+  uint32_t x;
+  memcpy(&x, p, 4);
+  return _byteswap_ulong(x);
+#else
+  return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |
+         ((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);
+#endif
+}
+
+static inline uint32_t  //
+wuffs_base__peek_u32le__no_bounds_check(const uint8_t* p) {
+#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
+  uint32_t x;
+  memcpy(&x, p, 4);
+  return x;
+#else
+  return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |
+         ((uint32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);
+#endif
+}
+
+static inline uint64_t  //
+wuffs_base__peek_u40be__no_bounds_check(const uint8_t* p) {
+  return ((uint64_t)(p[0]) << 32) | ((uint64_t)(p[1]) << 24) |
+         ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 8) |
+         ((uint64_t)(p[4]) << 0);
+}
+
+static inline uint64_t  //
+wuffs_base__peek_u40le__no_bounds_check(const uint8_t* p) {
+  return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |
+         ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |
+         ((uint64_t)(p[4]) << 32);
+}
+
+static inline uint64_t  //
+wuffs_base__peek_u48be__no_bounds_check(const uint8_t* p) {
+  return ((uint64_t)(p[0]) << 40) | ((uint64_t)(p[1]) << 32) |
+         ((uint64_t)(p[2]) << 24) | ((uint64_t)(p[3]) << 16) |
+         ((uint64_t)(p[4]) << 8) | ((uint64_t)(p[5]) << 0);
+}
+
+static inline uint64_t  //
+wuffs_base__peek_u48le__no_bounds_check(const uint8_t* p) {
+  return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |
+         ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |
+         ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40);
+}
+
+static inline uint64_t  //
+wuffs_base__peek_u56be__no_bounds_check(const uint8_t* p) {
+  return ((uint64_t)(p[0]) << 48) | ((uint64_t)(p[1]) << 40) |
+         ((uint64_t)(p[2]) << 32) | ((uint64_t)(p[3]) << 24) |
+         ((uint64_t)(p[4]) << 16) | ((uint64_t)(p[5]) << 8) |
+         ((uint64_t)(p[6]) << 0);
+}
+
+static inline uint64_t  //
+wuffs_base__peek_u56le__no_bounds_check(const uint8_t* p) {
+  return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |
+         ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |
+         ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |
+         ((uint64_t)(p[6]) << 48);
+}
+
+static inline uint64_t  //
+wuffs_base__peek_u64be__no_bounds_check(const uint8_t* p) {
+#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
+  uint64_t x;
+  memcpy(&x, p, 8);
+  return _byteswap_uint64(x);
+#else
+  return ((uint64_t)(p[0]) << 56) | ((uint64_t)(p[1]) << 48) |
+         ((uint64_t)(p[2]) << 40) | ((uint64_t)(p[3]) << 32) |
+         ((uint64_t)(p[4]) << 24) | ((uint64_t)(p[5]) << 16) |
+         ((uint64_t)(p[6]) << 8) | ((uint64_t)(p[7]) << 0);
+#endif
+}
+
+static inline uint64_t  //
+wuffs_base__peek_u64le__no_bounds_check(const uint8_t* p) {
+#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
+  uint64_t x;
+  memcpy(&x, p, 8);
+  return x;
+#else
+  return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |
+         ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |
+         ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |
+         ((uint64_t)(p[6]) << 48) | ((uint64_t)(p[7]) << 56);
+#endif
+}
+
+// --------
+
+#define wuffs_base__poke_u8be__no_bounds_check \
+  wuffs_base__poke_u8__no_bounds_check
+#define wuffs_base__poke_u8le__no_bounds_check \
+  wuffs_base__poke_u8__no_bounds_check
+
+static inline void  //
+wuffs_base__poke_u8__no_bounds_check(uint8_t* p, uint8_t x) {
+  p[0] = x;
+}
+
+static inline void  //
+wuffs_base__poke_u16be__no_bounds_check(uint8_t* p, uint16_t x) {
+  p[0] = (uint8_t)(x >> 8);
+  p[1] = (uint8_t)(x >> 0);
+}
+
+static inline void  //
+wuffs_base__poke_u16le__no_bounds_check(uint8_t* p, uint16_t x) {
+#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
+    (defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
+  // This seems to perform better on gcc 10 (but not clang 9). Clang also
+  // defines "__GNUC__".
+  memcpy(p, &x, 2);
+#else
+  p[0] = (uint8_t)(x >> 0);
+  p[1] = (uint8_t)(x >> 8);
+#endif
+}
+
+static inline void  //
+wuffs_base__poke_u24be__no_bounds_check(uint8_t* p, uint32_t x) {
+  p[0] = (uint8_t)(x >> 16);
+  p[1] = (uint8_t)(x >> 8);
+  p[2] = (uint8_t)(x >> 0);
+}
+
+static inline void  //
+wuffs_base__poke_u24le__no_bounds_check(uint8_t* p, uint32_t x) {
+  p[0] = (uint8_t)(x >> 0);
+  p[1] = (uint8_t)(x >> 8);
+  p[2] = (uint8_t)(x >> 16);
+}
+
+static inline void  //
+wuffs_base__poke_u32be__no_bounds_check(uint8_t* p, uint32_t x) {
+  p[0] = (uint8_t)(x >> 24);
+  p[1] = (uint8_t)(x >> 16);
+  p[2] = (uint8_t)(x >> 8);
+  p[3] = (uint8_t)(x >> 0);
+}
+
+static inline void  //
+wuffs_base__poke_u32le__no_bounds_check(uint8_t* p, uint32_t x) {
+#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
+    (defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
+  // This seems to perform better on gcc 10 (but not clang 9). Clang also
+  // defines "__GNUC__".
+  memcpy(p, &x, 4);
+#else
+  p[0] = (uint8_t)(x >> 0);
+  p[1] = (uint8_t)(x >> 8);
+  p[2] = (uint8_t)(x >> 16);
+  p[3] = (uint8_t)(x >> 24);
+#endif
+}
+
+static inline void  //
+wuffs_base__poke_u40be__no_bounds_check(uint8_t* p, uint64_t x) {
+  p[0] = (uint8_t)(x >> 32);
+  p[1] = (uint8_t)(x >> 24);
+  p[2] = (uint8_t)(x >> 16);
+  p[3] = (uint8_t)(x >> 8);
+  p[4] = (uint8_t)(x >> 0);
+}
+
+static inline void  //
+wuffs_base__poke_u40le__no_bounds_check(uint8_t* p, uint64_t x) {
+  p[0] = (uint8_t)(x >> 0);
+  p[1] = (uint8_t)(x >> 8);
+  p[2] = (uint8_t)(x >> 16);
+  p[3] = (uint8_t)(x >> 24);
+  p[4] = (uint8_t)(x >> 32);
+}
+
+static inline void  //
+wuffs_base__poke_u48be__no_bounds_check(uint8_t* p, uint64_t x) {
+  p[0] = (uint8_t)(x >> 40);
+  p[1] = (uint8_t)(x >> 32);
+  p[2] = (uint8_t)(x >> 24);
+  p[3] = (uint8_t)(x >> 16);
+  p[4] = (uint8_t)(x >> 8);
+  p[5] = (uint8_t)(x >> 0);
+}
+
+static inline void  //
+wuffs_base__poke_u48le__no_bounds_check(uint8_t* p, uint64_t x) {
+  p[0] = (uint8_t)(x >> 0);
+  p[1] = (uint8_t)(x >> 8);
+  p[2] = (uint8_t)(x >> 16);
+  p[3] = (uint8_t)(x >> 24);
+  p[4] = (uint8_t)(x >> 32);
+  p[5] = (uint8_t)(x >> 40);
+}
+
+static inline void  //
+wuffs_base__poke_u56be__no_bounds_check(uint8_t* p, uint64_t x) {
+  p[0] = (uint8_t)(x >> 48);
+  p[1] = (uint8_t)(x >> 40);
+  p[2] = (uint8_t)(x >> 32);
+  p[3] = (uint8_t)(x >> 24);
+  p[4] = (uint8_t)(x >> 16);
+  p[5] = (uint8_t)(x >> 8);
+  p[6] = (uint8_t)(x >> 0);
+}
+
+static inline void  //
+wuffs_base__poke_u56le__no_bounds_check(uint8_t* p, uint64_t x) {
+  p[0] = (uint8_t)(x >> 0);
+  p[1] = (uint8_t)(x >> 8);
+  p[2] = (uint8_t)(x >> 16);
+  p[3] = (uint8_t)(x >> 24);
+  p[4] = (uint8_t)(x >> 32);
+  p[5] = (uint8_t)(x >> 40);
+  p[6] = (uint8_t)(x >> 48);
+}
+
+static inline void  //
+wuffs_base__poke_u64be__no_bounds_check(uint8_t* p, uint64_t x) {
+  p[0] = (uint8_t)(x >> 56);
+  p[1] = (uint8_t)(x >> 48);
+  p[2] = (uint8_t)(x >> 40);
+  p[3] = (uint8_t)(x >> 32);
+  p[4] = (uint8_t)(x >> 24);
+  p[5] = (uint8_t)(x >> 16);
+  p[6] = (uint8_t)(x >> 8);
+  p[7] = (uint8_t)(x >> 0);
+}
+
+static inline void  //
+wuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {
+#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
+    (defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
+  // This seems to perform better on gcc 10 (but not clang 9). Clang also
+  // defines "__GNUC__".
+  memcpy(p, &x, 8);
+#else
+  p[0] = (uint8_t)(x >> 0);
+  p[1] = (uint8_t)(x >> 8);
+  p[2] = (uint8_t)(x >> 16);
+  p[3] = (uint8_t)(x >> 24);
+  p[4] = (uint8_t)(x >> 32);
+  p[5] = (uint8_t)(x >> 40);
+  p[6] = (uint8_t)(x >> 48);
+  p[7] = (uint8_t)(x >> 56);
+#endif
+}
+
+// ---------------- Slices and Tables
+
+// WUFFS_BASE__SLICE is a 1-dimensional buffer.
+//
+// len measures a number of elements, not necessarily a size in bytes.
+//
+// A value with all fields NULL or zero is a valid, empty slice.
+#define WUFFS_BASE__SLICE(T) \
+  struct {                   \
+    T* ptr;                  \
+    size_t len;              \
+  }
+
+// WUFFS_BASE__TABLE is a 2-dimensional buffer.
+//
+// width, height and stride measure a number of elements, not necessarily a
+// size in bytes.
+//
+// A value with all fields NULL or zero is a valid, empty table.
+#define WUFFS_BASE__TABLE(T) \
+  struct {                   \
+    T* ptr;                  \
+    size_t width;            \
+    size_t height;           \
+    size_t stride;           \
+  }
+
+typedef WUFFS_BASE__SLICE(uint8_t) wuffs_base__slice_u8;
+typedef WUFFS_BASE__SLICE(uint16_t) wuffs_base__slice_u16;
+typedef WUFFS_BASE__SLICE(uint32_t) wuffs_base__slice_u32;
+typedef WUFFS_BASE__SLICE(uint64_t) wuffs_base__slice_u64;
+
+typedef WUFFS_BASE__TABLE(uint8_t) wuffs_base__table_u8;
+typedef WUFFS_BASE__TABLE(uint16_t) wuffs_base__table_u16;
+typedef WUFFS_BASE__TABLE(uint32_t) wuffs_base__table_u32;
+typedef WUFFS_BASE__TABLE(uint64_t) wuffs_base__table_u64;
+
+static inline wuffs_base__slice_u8  //
+wuffs_base__make_slice_u8(uint8_t* ptr, size_t len) {
+  wuffs_base__slice_u8 ret;
+  ret.ptr = ptr;
+  ret.len = len;
+  return ret;
+}
+
+static inline wuffs_base__slice_u16  //
+wuffs_base__make_slice_u16(uint16_t* ptr, size_t len) {
+  wuffs_base__slice_u16 ret;
+  ret.ptr = ptr;
+  ret.len = len;
+  return ret;
+}
+
+static inline wuffs_base__slice_u32  //
+wuffs_base__make_slice_u32(uint32_t* ptr, size_t len) {
+  wuffs_base__slice_u32 ret;
+  ret.ptr = ptr;
+  ret.len = len;
+  return ret;
+}
+
+static inline wuffs_base__slice_u64  //
+wuffs_base__make_slice_u64(uint64_t* ptr, size_t len) {
+  wuffs_base__slice_u64 ret;
+  ret.ptr = ptr;
+  ret.len = len;
+  return ret;
+}
+
+static inline wuffs_base__slice_u8  //
+wuffs_base__make_slice_u8_ij(uint8_t* ptr, size_t i, size_t j) {
+  wuffs_base__slice_u8 ret;
+  ret.ptr = ptr + i;
+  ret.len = (j >= i) ? (j - i) : 0;
+  return ret;
+}
+
+static inline wuffs_base__slice_u16  //
+wuffs_base__make_slice_u16_ij(uint16_t* ptr, size_t i, size_t j) {
+  wuffs_base__slice_u16 ret;
+  ret.ptr = ptr + i;
+  ret.len = (j >= i) ? (j - i) : 0;
+  return ret;
+}
+
+static inline wuffs_base__slice_u32  //
+wuffs_base__make_slice_u32_ij(uint32_t* ptr, size_t i, size_t j) {
+  wuffs_base__slice_u32 ret;
+  ret.ptr = ptr + i;
+  ret.len = (j >= i) ? (j - i) : 0;
+  return ret;
+}
+
+static inline wuffs_base__slice_u64  //
+wuffs_base__make_slice_u64_ij(uint64_t* ptr, size_t i, size_t j) {
+  wuffs_base__slice_u64 ret;
+  ret.ptr = ptr + i;
+  ret.len = (j >= i) ? (j - i) : 0;
+  return ret;
+}
+
+static inline wuffs_base__slice_u8  //
+wuffs_base__empty_slice_u8() {
+  wuffs_base__slice_u8 ret;
+  ret.ptr = NULL;
+  ret.len = 0;
+  return ret;
+}
+
+static inline wuffs_base__slice_u16  //
+wuffs_base__empty_slice_u16() {
+  wuffs_base__slice_u16 ret;
+  ret.ptr = NULL;
+  ret.len = 0;
+  return ret;
+}
+
+static inline wuffs_base__slice_u32  //
+wuffs_base__empty_slice_u32() {
+  wuffs_base__slice_u32 ret;
+  ret.ptr = NULL;
+  ret.len = 0;
+  return ret;
+}
+
+static inline wuffs_base__slice_u64  //
+wuffs_base__empty_slice_u64() {
+  wuffs_base__slice_u64 ret;
+  ret.ptr = NULL;
+  ret.len = 0;
+  return ret;
+}
+
+static inline wuffs_base__table_u8  //
+wuffs_base__make_table_u8(uint8_t* ptr,
+                          size_t width,
+                          size_t height,
+                          size_t stride) {
+  wuffs_base__table_u8 ret;
+  ret.ptr = ptr;
+  ret.width = width;
+  ret.height = height;
+  ret.stride = stride;
+  return ret;
+}
+
+static inline wuffs_base__table_u16  //
+wuffs_base__make_table_u16(uint16_t* ptr,
+                           size_t width,
+                           size_t height,
+                           size_t stride) {
+  wuffs_base__table_u16 ret;
+  ret.ptr = ptr;
+  ret.width = width;
+  ret.height = height;
+  ret.stride = stride;
+  return ret;
+}
+
+static inline wuffs_base__table_u32  //
+wuffs_base__make_table_u32(uint32_t* ptr,
+                           size_t width,
+                           size_t height,
+                           size_t stride) {
+  wuffs_base__table_u32 ret;
+  ret.ptr = ptr;
+  ret.width = width;
+  ret.height = height;
+  ret.stride = stride;
+  return ret;
+}
+
+static inline wuffs_base__table_u64  //
+wuffs_base__make_table_u64(uint64_t* ptr,
+                           size_t width,
+                           size_t height,
+                           size_t stride) {
+  wuffs_base__table_u64 ret;
+  ret.ptr = ptr;
+  ret.width = width;
+  ret.height = height;
+  ret.stride = stride;
+  return ret;
+}
+
+static inline wuffs_base__table_u8  //
+wuffs_base__empty_table_u8() {
+  wuffs_base__table_u8 ret;
+  ret.ptr = NULL;
+  ret.width = 0;
+  ret.height = 0;
+  ret.stride = 0;
+  return ret;
+}
+
+static inline wuffs_base__table_u16  //
+wuffs_base__empty_table_u16() {
+  wuffs_base__table_u16 ret;
+  ret.ptr = NULL;
+  ret.width = 0;
+  ret.height = 0;
+  ret.stride = 0;
+  return ret;
+}
+
+static inline wuffs_base__table_u32  //
+wuffs_base__empty_table_u32() {
+  wuffs_base__table_u32 ret;
+  ret.ptr = NULL;
+  ret.width = 0;
+  ret.height = 0;
+  ret.stride = 0;
+  return ret;
+}
+
+static inline wuffs_base__table_u64  //
+wuffs_base__empty_table_u64() {
+  wuffs_base__table_u64 ret;
+  ret.ptr = NULL;
+  ret.width = 0;
+  ret.height = 0;
+  ret.stride = 0;
+  return ret;
+}
+
+static inline bool  //
+wuffs_base__slice_u8__overlaps(wuffs_base__slice_u8 s, wuffs_base__slice_u8 t) {
+  return ((s.ptr <= t.ptr) && (t.ptr < (s.ptr + s.len))) ||
+         ((t.ptr <= s.ptr) && (s.ptr < (t.ptr + t.len)));
+}
+
+// wuffs_base__slice_u8__subslice_i returns s[i:].
+//
+// It returns an empty slice if i is out of bounds.
+static inline wuffs_base__slice_u8  //
+wuffs_base__slice_u8__subslice_i(wuffs_base__slice_u8 s, uint64_t i) {
+  if ((i <= SIZE_MAX) && (i <= s.len)) {
+    return wuffs_base__make_slice_u8(s.ptr + i, ((size_t)(s.len - i)));
+  }
+  return wuffs_base__make_slice_u8(NULL, 0);
+}
+
+// wuffs_base__slice_u8__subslice_j returns s[:j].
+//
+// It returns an empty slice if j is out of bounds.
+static inline wuffs_base__slice_u8  //
+wuffs_base__slice_u8__subslice_j(wuffs_base__slice_u8 s, uint64_t j) {
+  if ((j <= SIZE_MAX) && (j <= s.len)) {
+    return wuffs_base__make_slice_u8(s.ptr, ((size_t)j));
+  }
+  return wuffs_base__make_slice_u8(NULL, 0);
+}
+
+// wuffs_base__slice_u8__subslice_ij returns s[i:j].
+//
+// It returns an empty slice if i or j is out of bounds.
+static inline wuffs_base__slice_u8  //
+wuffs_base__slice_u8__subslice_ij(wuffs_base__slice_u8 s,
+                                  uint64_t i,
+                                  uint64_t j) {
+  if ((i <= j) && (j <= SIZE_MAX) && (j <= s.len)) {
+    return wuffs_base__make_slice_u8(s.ptr + i, ((size_t)(j - i)));
+  }
+  return wuffs_base__make_slice_u8(NULL, 0);
+}
+
+// wuffs_base__table_u8__subtable_ij returns t[ix:jx, iy:jy].
+//
+// It returns an empty table if i or j is out of bounds.
+static inline wuffs_base__table_u8  //
+wuffs_base__table_u8__subtable_ij(wuffs_base__table_u8 t,
+                                  uint64_t ix,
+                                  uint64_t iy,
+                                  uint64_t jx,
+                                  uint64_t jy) {
+  if ((ix <= jx) && (jx <= SIZE_MAX) && (jx <= t.width) &&  //
+      (iy <= jy) && (jy <= SIZE_MAX) && (jy <= t.height)) {
+    return wuffs_base__make_table_u8(t.ptr + ix + (iy * t.stride),  //
+                                     ((size_t)(jx - ix)),           //
+                                     ((size_t)(jy - iy)),           //
+                                     t.stride);                     //
+  }
+  return wuffs_base__make_table_u8(NULL, 0, 0, 0);
+}
+
+// wuffs_base__table__flattened_length returns the number of elements covered
+// by the 1-dimensional span that backs a 2-dimensional table. This counts the
+// elements inside the table and, when width != stride, the elements outside
+// the table but between its rows.
+//
+// For example, consider a width 10, height 4, stride 10 table. Mark its first
+// and last (inclusive) elements with 'a' and 'z'. This function returns 40.
+//
+//    a123456789
+//    0123456789
+//    0123456789
+//    012345678z
+//
+// Now consider the sub-table of that from (2, 1) inclusive to (8, 4) exclusive.
+//
+//    a123456789
+//    01iiiiiioo
+//    ooiiiiiioo
+//    ooiiiiii8z
+//
+// This function (called with width 6, height 3, stride 10) returns 26: 18 'i'
+// inside elements plus 8 'o' outside elements. Note that 26 is less than a
+// naive (height * stride = 30) computation. Indeed, advancing 29 elements from
+// the first 'i' would venture past 'z', out of bounds of the original table.
+//
+// It does not check for overflow, but if the arguments come from a table that
+// exists in memory and each element occupies a positive number of bytes then
+// the result should be bounded by the amount of allocatable memory (which
+// shouldn't overflow SIZE_MAX).
+static inline size_t  //
+wuffs_base__table__flattened_length(size_t width,
+                                    size_t height,
+                                    size_t stride) {
+  if (height == 0) {
+    return 0;
+  }
+  return ((height - 1) * stride) + width;
+}
+
+// ---------------- Magic Numbers
+
+// wuffs_base__magic_number_guess_fourcc guesses the file format of some data,
+// given its starting bytes (the prefix_data argument) and whether or not there
+// may be further bytes (the prefix_closed argument; true means that
+// prefix_data is the entire data).
+//
+// It returns a positive FourCC value on success.
+//
+// It returns zero if nothing matches its hard-coded list of 'magic numbers'.
+//
+// It returns a negative value if prefix_closed is false and a longer prefix is
+// required for a conclusive result. For example, a single 'B' byte (without
+// further data) is not enough to discriminate the BMP and BPG image file
+// formats. Similarly, a single '\xFF' byte might be the start of JPEG data or
+// it might be the start of some other binary data.
+//
+// It does not do a full validity check. Like any guess made from a short
+// prefix of the data, it may return false positives. Data that starts with 99
+// bytes of valid JPEG followed by corruption or truncation is an invalid JPEG
+// image overall, but this function will still return WUFFS_BASE__FOURCC__JPEG.
+//
+// Another source of false positives is that some 'magic numbers' are valid
+// ASCII data. A file starting with "GIF87a and GIF89a are the two versions of
+// GIF" will match GIF's 'magic number' even if it's plain text, not an image.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__MAGIC sub-module, not just
+// WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC int32_t  //
+wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix_data,
+                                      bool prefix_closed);
+
+// ---------------- Ranges and Rects
+
+// See https://github.com/google/wuffs/blob/main/doc/note/ranges-and-rects.md
+
+typedef struct wuffs_base__range_ii_u32__struct {
+  uint32_t min_incl;
+  uint32_t max_incl;
+
+#ifdef __cplusplus
+  inline bool is_empty() const;
+  inline bool equals(wuffs_base__range_ii_u32__struct s) const;
+  inline wuffs_base__range_ii_u32__struct intersect(
+      wuffs_base__range_ii_u32__struct s) const;
+  inline wuffs_base__range_ii_u32__struct unite(
+      wuffs_base__range_ii_u32__struct s) const;
+  inline bool contains(uint32_t x) const;
+  inline bool contains_range(wuffs_base__range_ii_u32__struct s) const;
+#endif  // __cplusplus
+
+} wuffs_base__range_ii_u32;
+
+static inline wuffs_base__range_ii_u32  //
+wuffs_base__empty_range_ii_u32() {
+  wuffs_base__range_ii_u32 ret;
+  ret.min_incl = 0;
+  ret.max_incl = 0;
+  return ret;
+}
+
+static inline wuffs_base__range_ii_u32  //
+wuffs_base__make_range_ii_u32(uint32_t min_incl, uint32_t max_incl) {
+  wuffs_base__range_ii_u32 ret;
+  ret.min_incl = min_incl;
+  ret.max_incl = max_incl;
+  return ret;
+}
+
+static inline bool  //
+wuffs_base__range_ii_u32__is_empty(const wuffs_base__range_ii_u32* r) {
+  return r->min_incl > r->max_incl;
+}
+
+static inline bool  //
+wuffs_base__range_ii_u32__equals(const wuffs_base__range_ii_u32* r,
+                                 wuffs_base__range_ii_u32 s) {
+  return (r->min_incl == s.min_incl && r->max_incl == s.max_incl) ||
+         (wuffs_base__range_ii_u32__is_empty(r) &&
+          wuffs_base__range_ii_u32__is_empty(&s));
+}
+
+static inline wuffs_base__range_ii_u32  //
+wuffs_base__range_ii_u32__intersect(const wuffs_base__range_ii_u32* r,
+                                    wuffs_base__range_ii_u32 s) {
+  wuffs_base__range_ii_u32 t;
+  t.min_incl = wuffs_base__u32__max(r->min_incl, s.min_incl);
+  t.max_incl = wuffs_base__u32__min(r->max_incl, s.max_incl);
+  return t;
+}
+
+static inline wuffs_base__range_ii_u32  //
+wuffs_base__range_ii_u32__unite(const wuffs_base__range_ii_u32* r,
+                                wuffs_base__range_ii_u32 s) {
+  if (wuffs_base__range_ii_u32__is_empty(r)) {
+    return s;
+  }
+  if (wuffs_base__range_ii_u32__is_empty(&s)) {
+    return *r;
+  }
+  wuffs_base__range_ii_u32 t;
+  t.min_incl = wuffs_base__u32__min(r->min_incl, s.min_incl);
+  t.max_incl = wuffs_base__u32__max(r->max_incl, s.max_incl);
+  return t;
+}
+
+static inline bool  //
+wuffs_base__range_ii_u32__contains(const wuffs_base__range_ii_u32* r,
+                                   uint32_t x) {
+  return (r->min_incl <= x) && (x <= r->max_incl);
+}
+
+static inline bool  //
+wuffs_base__range_ii_u32__contains_range(const wuffs_base__range_ii_u32* r,
+                                         wuffs_base__range_ii_u32 s) {
+  return wuffs_base__range_ii_u32__equals(
+      &s, wuffs_base__range_ii_u32__intersect(r, s));
+}
+
+#ifdef __cplusplus
+
+inline bool  //
+wuffs_base__range_ii_u32::is_empty() const {
+  return wuffs_base__range_ii_u32__is_empty(this);
+}
+
+inline bool  //
+wuffs_base__range_ii_u32::equals(wuffs_base__range_ii_u32 s) const {
+  return wuffs_base__range_ii_u32__equals(this, s);
+}
+
+inline wuffs_base__range_ii_u32  //
+wuffs_base__range_ii_u32::intersect(wuffs_base__range_ii_u32 s) const {
+  return wuffs_base__range_ii_u32__intersect(this, s);
+}
+
+inline wuffs_base__range_ii_u32  //
+wuffs_base__range_ii_u32::unite(wuffs_base__range_ii_u32 s) const {
+  return wuffs_base__range_ii_u32__unite(this, s);
+}
+
+inline bool  //
+wuffs_base__range_ii_u32::contains(uint32_t x) const {
+  return wuffs_base__range_ii_u32__contains(this, x);
+}
+
+inline bool  //
+wuffs_base__range_ii_u32::contains_range(wuffs_base__range_ii_u32 s) const {
+  return wuffs_base__range_ii_u32__contains_range(this, s);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+typedef struct wuffs_base__range_ie_u32__struct {
+  uint32_t min_incl;
+  uint32_t max_excl;
+
+#ifdef __cplusplus
+  inline bool is_empty() const;
+  inline bool equals(wuffs_base__range_ie_u32__struct s) const;
+  inline wuffs_base__range_ie_u32__struct intersect(
+      wuffs_base__range_ie_u32__struct s) const;
+  inline wuffs_base__range_ie_u32__struct unite(
+      wuffs_base__range_ie_u32__struct s) const;
+  inline bool contains(uint32_t x) const;
+  inline bool contains_range(wuffs_base__range_ie_u32__struct s) const;
+  inline uint32_t length() const;
+#endif  // __cplusplus
+
+} wuffs_base__range_ie_u32;
+
+static inline wuffs_base__range_ie_u32  //
+wuffs_base__empty_range_ie_u32() {
+  wuffs_base__range_ie_u32 ret;
+  ret.min_incl = 0;
+  ret.max_excl = 0;
+  return ret;
+}
+
+static inline wuffs_base__range_ie_u32  //
+wuffs_base__make_range_ie_u32(uint32_t min_incl, uint32_t max_excl) {
+  wuffs_base__range_ie_u32 ret;
+  ret.min_incl = min_incl;
+  ret.max_excl = max_excl;
+  return ret;
+}
+
+static inline bool  //
+wuffs_base__range_ie_u32__is_empty(const wuffs_base__range_ie_u32* r) {
+  return r->min_incl >= r->max_excl;
+}
+
+static inline bool  //
+wuffs_base__range_ie_u32__equals(const wuffs_base__range_ie_u32* r,
+                                 wuffs_base__range_ie_u32 s) {
+  return (r->min_incl == s.min_incl && r->max_excl == s.max_excl) ||
+         (wuffs_base__range_ie_u32__is_empty(r) &&
+          wuffs_base__range_ie_u32__is_empty(&s));
+}
+
+static inline wuffs_base__range_ie_u32  //
+wuffs_base__range_ie_u32__intersect(const wuffs_base__range_ie_u32* r,
+                                    wuffs_base__range_ie_u32 s) {
+  wuffs_base__range_ie_u32 t;
+  t.min_incl = wuffs_base__u32__max(r->min_incl, s.min_incl);
+  t.max_excl = wuffs_base__u32__min(r->max_excl, s.max_excl);
+  return t;
+}
+
+static inline wuffs_base__range_ie_u32  //
+wuffs_base__range_ie_u32__unite(const wuffs_base__range_ie_u32* r,
+                                wuffs_base__range_ie_u32 s) {
+  if (wuffs_base__range_ie_u32__is_empty(r)) {
+    return s;
+  }
+  if (wuffs_base__range_ie_u32__is_empty(&s)) {
+    return *r;
+  }
+  wuffs_base__range_ie_u32 t;
+  t.min_incl = wuffs_base__u32__min(r->min_incl, s.min_incl);
+  t.max_excl = wuffs_base__u32__max(r->max_excl, s.max_excl);
+  return t;
+}
+
+static inline bool  //
+wuffs_base__range_ie_u32__contains(const wuffs_base__range_ie_u32* r,
+                                   uint32_t x) {
+  return (r->min_incl <= x) && (x < r->max_excl);
+}
+
+static inline bool  //
+wuffs_base__range_ie_u32__contains_range(const wuffs_base__range_ie_u32* r,
+                                         wuffs_base__range_ie_u32 s) {
+  return wuffs_base__range_ie_u32__equals(
+      &s, wuffs_base__range_ie_u32__intersect(r, s));
+}
+
+static inline uint32_t  //
+wuffs_base__range_ie_u32__length(const wuffs_base__range_ie_u32* r) {
+  return wuffs_base__u32__sat_sub(r->max_excl, r->min_incl);
+}
+
+#ifdef __cplusplus
+
+inline bool  //
+wuffs_base__range_ie_u32::is_empty() const {
+  return wuffs_base__range_ie_u32__is_empty(this);
+}
+
+inline bool  //
+wuffs_base__range_ie_u32::equals(wuffs_base__range_ie_u32 s) const {
+  return wuffs_base__range_ie_u32__equals(this, s);
+}
+
+inline wuffs_base__range_ie_u32  //
+wuffs_base__range_ie_u32::intersect(wuffs_base__range_ie_u32 s) const {
+  return wuffs_base__range_ie_u32__intersect(this, s);
+}
+
+inline wuffs_base__range_ie_u32  //
+wuffs_base__range_ie_u32::unite(wuffs_base__range_ie_u32 s) const {
+  return wuffs_base__range_ie_u32__unite(this, s);
+}
+
+inline bool  //
+wuffs_base__range_ie_u32::contains(uint32_t x) const {
+  return wuffs_base__range_ie_u32__contains(this, x);
+}
+
+inline bool  //
+wuffs_base__range_ie_u32::contains_range(wuffs_base__range_ie_u32 s) const {
+  return wuffs_base__range_ie_u32__contains_range(this, s);
+}
+
+inline uint32_t  //
+wuffs_base__range_ie_u32::length() const {
+  return wuffs_base__range_ie_u32__length(this);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+typedef struct wuffs_base__range_ii_u64__struct {
+  uint64_t min_incl;
+  uint64_t max_incl;
+
+#ifdef __cplusplus
+  inline bool is_empty() const;
+  inline bool equals(wuffs_base__range_ii_u64__struct s) const;
+  inline wuffs_base__range_ii_u64__struct intersect(
+      wuffs_base__range_ii_u64__struct s) const;
+  inline wuffs_base__range_ii_u64__struct unite(
+      wuffs_base__range_ii_u64__struct s) const;
+  inline bool contains(uint64_t x) const;
+  inline bool contains_range(wuffs_base__range_ii_u64__struct s) const;
+#endif  // __cplusplus
+
+} wuffs_base__range_ii_u64;
+
+static inline wuffs_base__range_ii_u64  //
+wuffs_base__empty_range_ii_u64() {
+  wuffs_base__range_ii_u64 ret;
+  ret.min_incl = 0;
+  ret.max_incl = 0;
+  return ret;
+}
+
+static inline wuffs_base__range_ii_u64  //
+wuffs_base__make_range_ii_u64(uint64_t min_incl, uint64_t max_incl) {
+  wuffs_base__range_ii_u64 ret;
+  ret.min_incl = min_incl;
+  ret.max_incl = max_incl;
+  return ret;
+}
+
+static inline bool  //
+wuffs_base__range_ii_u64__is_empty(const wuffs_base__range_ii_u64* r) {
+  return r->min_incl > r->max_incl;
+}
+
+static inline bool  //
+wuffs_base__range_ii_u64__equals(const wuffs_base__range_ii_u64* r,
+                                 wuffs_base__range_ii_u64 s) {
+  return (r->min_incl == s.min_incl && r->max_incl == s.max_incl) ||
+         (wuffs_base__range_ii_u64__is_empty(r) &&
+          wuffs_base__range_ii_u64__is_empty(&s));
+}
+
+static inline wuffs_base__range_ii_u64  //
+wuffs_base__range_ii_u64__intersect(const wuffs_base__range_ii_u64* r,
+                                    wuffs_base__range_ii_u64 s) {
+  wuffs_base__range_ii_u64 t;
+  t.min_incl = wuffs_base__u64__max(r->min_incl, s.min_incl);
+  t.max_incl = wuffs_base__u64__min(r->max_incl, s.max_incl);
+  return t;
+}
+
+static inline wuffs_base__range_ii_u64  //
+wuffs_base__range_ii_u64__unite(const wuffs_base__range_ii_u64* r,
+                                wuffs_base__range_ii_u64 s) {
+  if (wuffs_base__range_ii_u64__is_empty(r)) {
+    return s;
+  }
+  if (wuffs_base__range_ii_u64__is_empty(&s)) {
+    return *r;
+  }
+  wuffs_base__range_ii_u64 t;
+  t.min_incl = wuffs_base__u64__min(r->min_incl, s.min_incl);
+  t.max_incl = wuffs_base__u64__max(r->max_incl, s.max_incl);
+  return t;
+}
+
+static inline bool  //
+wuffs_base__range_ii_u64__contains(const wuffs_base__range_ii_u64* r,
+                                   uint64_t x) {
+  return (r->min_incl <= x) && (x <= r->max_incl);
+}
+
+static inline bool  //
+wuffs_base__range_ii_u64__contains_range(const wuffs_base__range_ii_u64* r,
+                                         wuffs_base__range_ii_u64 s) {
+  return wuffs_base__range_ii_u64__equals(
+      &s, wuffs_base__range_ii_u64__intersect(r, s));
+}
+
+#ifdef __cplusplus
+
+inline bool  //
+wuffs_base__range_ii_u64::is_empty() const {
+  return wuffs_base__range_ii_u64__is_empty(this);
+}
+
+inline bool  //
+wuffs_base__range_ii_u64::equals(wuffs_base__range_ii_u64 s) const {
+  return wuffs_base__range_ii_u64__equals(this, s);
+}
+
+inline wuffs_base__range_ii_u64  //
+wuffs_base__range_ii_u64::intersect(wuffs_base__range_ii_u64 s) const {
+  return wuffs_base__range_ii_u64__intersect(this, s);
+}
+
+inline wuffs_base__range_ii_u64  //
+wuffs_base__range_ii_u64::unite(wuffs_base__range_ii_u64 s) const {
+  return wuffs_base__range_ii_u64__unite(this, s);
+}
+
+inline bool  //
+wuffs_base__range_ii_u64::contains(uint64_t x) const {
+  return wuffs_base__range_ii_u64__contains(this, x);
+}
+
+inline bool  //
+wuffs_base__range_ii_u64::contains_range(wuffs_base__range_ii_u64 s) const {
+  return wuffs_base__range_ii_u64__contains_range(this, s);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+typedef struct wuffs_base__range_ie_u64__struct {
+  uint64_t min_incl;
+  uint64_t max_excl;
+
+#ifdef __cplusplus
+  inline bool is_empty() const;
+  inline bool equals(wuffs_base__range_ie_u64__struct s) const;
+  inline wuffs_base__range_ie_u64__struct intersect(
+      wuffs_base__range_ie_u64__struct s) const;
+  inline wuffs_base__range_ie_u64__struct unite(
+      wuffs_base__range_ie_u64__struct s) const;
+  inline bool contains(uint64_t x) const;
+  inline bool contains_range(wuffs_base__range_ie_u64__struct s) const;
+  inline uint64_t length() const;
+#endif  // __cplusplus
+
+} wuffs_base__range_ie_u64;
+
+static inline wuffs_base__range_ie_u64  //
+wuffs_base__empty_range_ie_u64() {
+  wuffs_base__range_ie_u64 ret;
+  ret.min_incl = 0;
+  ret.max_excl = 0;
+  return ret;
+}
+
+static inline wuffs_base__range_ie_u64  //
+wuffs_base__make_range_ie_u64(uint64_t min_incl, uint64_t max_excl) {
+  wuffs_base__range_ie_u64 ret;
+  ret.min_incl = min_incl;
+  ret.max_excl = max_excl;
+  return ret;
+}
+
+static inline bool  //
+wuffs_base__range_ie_u64__is_empty(const wuffs_base__range_ie_u64* r) {
+  return r->min_incl >= r->max_excl;
+}
+
+static inline bool  //
+wuffs_base__range_ie_u64__equals(const wuffs_base__range_ie_u64* r,
+                                 wuffs_base__range_ie_u64 s) {
+  return (r->min_incl == s.min_incl && r->max_excl == s.max_excl) ||
+         (wuffs_base__range_ie_u64__is_empty(r) &&
+          wuffs_base__range_ie_u64__is_empty(&s));
+}
+
+static inline wuffs_base__range_ie_u64  //
+wuffs_base__range_ie_u64__intersect(const wuffs_base__range_ie_u64* r,
+                                    wuffs_base__range_ie_u64 s) {
+  wuffs_base__range_ie_u64 t;
+  t.min_incl = wuffs_base__u64__max(r->min_incl, s.min_incl);
+  t.max_excl = wuffs_base__u64__min(r->max_excl, s.max_excl);
+  return t;
+}
+
+static inline wuffs_base__range_ie_u64  //
+wuffs_base__range_ie_u64__unite(const wuffs_base__range_ie_u64* r,
+                                wuffs_base__range_ie_u64 s) {
+  if (wuffs_base__range_ie_u64__is_empty(r)) {
+    return s;
+  }
+  if (wuffs_base__range_ie_u64__is_empty(&s)) {
+    return *r;
+  }
+  wuffs_base__range_ie_u64 t;
+  t.min_incl = wuffs_base__u64__min(r->min_incl, s.min_incl);
+  t.max_excl = wuffs_base__u64__max(r->max_excl, s.max_excl);
+  return t;
+}
+
+static inline bool  //
+wuffs_base__range_ie_u64__contains(const wuffs_base__range_ie_u64* r,
+                                   uint64_t x) {
+  return (r->min_incl <= x) && (x < r->max_excl);
+}
+
+static inline bool  //
+wuffs_base__range_ie_u64__contains_range(const wuffs_base__range_ie_u64* r,
+                                         wuffs_base__range_ie_u64 s) {
+  return wuffs_base__range_ie_u64__equals(
+      &s, wuffs_base__range_ie_u64__intersect(r, s));
+}
+
+static inline uint64_t  //
+wuffs_base__range_ie_u64__length(const wuffs_base__range_ie_u64* r) {
+  return wuffs_base__u64__sat_sub(r->max_excl, r->min_incl);
+}
+
+#ifdef __cplusplus
+
+inline bool  //
+wuffs_base__range_ie_u64::is_empty() const {
+  return wuffs_base__range_ie_u64__is_empty(this);
+}
+
+inline bool  //
+wuffs_base__range_ie_u64::equals(wuffs_base__range_ie_u64 s) const {
+  return wuffs_base__range_ie_u64__equals(this, s);
+}
+
+inline wuffs_base__range_ie_u64  //
+wuffs_base__range_ie_u64::intersect(wuffs_base__range_ie_u64 s) const {
+  return wuffs_base__range_ie_u64__intersect(this, s);
+}
+
+inline wuffs_base__range_ie_u64  //
+wuffs_base__range_ie_u64::unite(wuffs_base__range_ie_u64 s) const {
+  return wuffs_base__range_ie_u64__unite(this, s);
+}
+
+inline bool  //
+wuffs_base__range_ie_u64::contains(uint64_t x) const {
+  return wuffs_base__range_ie_u64__contains(this, x);
+}
+
+inline bool  //
+wuffs_base__range_ie_u64::contains_range(wuffs_base__range_ie_u64 s) const {
+  return wuffs_base__range_ie_u64__contains_range(this, s);
+}
+
+inline uint64_t  //
+wuffs_base__range_ie_u64::length() const {
+  return wuffs_base__range_ie_u64__length(this);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+typedef struct wuffs_base__rect_ii_u32__struct {
+  uint32_t min_incl_x;
+  uint32_t min_incl_y;
+  uint32_t max_incl_x;
+  uint32_t max_incl_y;
+
+#ifdef __cplusplus
+  inline bool is_empty() const;
+  inline bool equals(wuffs_base__rect_ii_u32__struct s) const;
+  inline wuffs_base__rect_ii_u32__struct intersect(
+      wuffs_base__rect_ii_u32__struct s) const;
+  inline wuffs_base__rect_ii_u32__struct unite(
+      wuffs_base__rect_ii_u32__struct s) const;
+  inline bool contains(uint32_t x, uint32_t y) const;
+  inline bool contains_rect(wuffs_base__rect_ii_u32__struct s) const;
+#endif  // __cplusplus
+
+} wuffs_base__rect_ii_u32;
+
+static inline wuffs_base__rect_ii_u32  //
+wuffs_base__empty_rect_ii_u32() {
+  wuffs_base__rect_ii_u32 ret;
+  ret.min_incl_x = 0;
+  ret.min_incl_y = 0;
+  ret.max_incl_x = 0;
+  ret.max_incl_y = 0;
+  return ret;
+}
+
+static inline wuffs_base__rect_ii_u32  //
+wuffs_base__make_rect_ii_u32(uint32_t min_incl_x,
+                             uint32_t min_incl_y,
+                             uint32_t max_incl_x,
+                             uint32_t max_incl_y) {
+  wuffs_base__rect_ii_u32 ret;
+  ret.min_incl_x = min_incl_x;
+  ret.min_incl_y = min_incl_y;
+  ret.max_incl_x = max_incl_x;
+  ret.max_incl_y = max_incl_y;
+  return ret;
+}
+
+static inline bool  //
+wuffs_base__rect_ii_u32__is_empty(const wuffs_base__rect_ii_u32* r) {
+  return (r->min_incl_x > r->max_incl_x) || (r->min_incl_y > r->max_incl_y);
+}
+
+static inline bool  //
+wuffs_base__rect_ii_u32__equals(const wuffs_base__rect_ii_u32* r,
+                                wuffs_base__rect_ii_u32 s) {
+  return (r->min_incl_x == s.min_incl_x && r->min_incl_y == s.min_incl_y &&
+          r->max_incl_x == s.max_incl_x && r->max_incl_y == s.max_incl_y) ||
+         (wuffs_base__rect_ii_u32__is_empty(r) &&
+          wuffs_base__rect_ii_u32__is_empty(&s));
+}
+
+static inline wuffs_base__rect_ii_u32  //
+wuffs_base__rect_ii_u32__intersect(const wuffs_base__rect_ii_u32* r,
+                                   wuffs_base__rect_ii_u32 s) {
+  wuffs_base__rect_ii_u32 t;
+  t.min_incl_x = wuffs_base__u32__max(r->min_incl_x, s.min_incl_x);
+  t.min_incl_y = wuffs_base__u32__max(r->min_incl_y, s.min_incl_y);
+  t.max_incl_x = wuffs_base__u32__min(r->max_incl_x, s.max_incl_x);
+  t.max_incl_y = wuffs_base__u32__min(r->max_incl_y, s.max_incl_y);
+  return t;
+}
+
+static inline wuffs_base__rect_ii_u32  //
+wuffs_base__rect_ii_u32__unite(const wuffs_base__rect_ii_u32* r,
+                               wuffs_base__rect_ii_u32 s) {
+  if (wuffs_base__rect_ii_u32__is_empty(r)) {
+    return s;
+  }
+  if (wuffs_base__rect_ii_u32__is_empty(&s)) {
+    return *r;
+  }
+  wuffs_base__rect_ii_u32 t;
+  t.min_incl_x = wuffs_base__u32__min(r->min_incl_x, s.min_incl_x);
+  t.min_incl_y = wuffs_base__u32__min(r->min_incl_y, s.min_incl_y);
+  t.max_incl_x = wuffs_base__u32__max(r->max_incl_x, s.max_incl_x);
+  t.max_incl_y = wuffs_base__u32__max(r->max_incl_y, s.max_incl_y);
+  return t;
+}
+
+static inline bool  //
+wuffs_base__rect_ii_u32__contains(const wuffs_base__rect_ii_u32* r,
+                                  uint32_t x,
+                                  uint32_t y) {
+  return (r->min_incl_x <= x) && (x <= r->max_incl_x) && (r->min_incl_y <= y) &&
+         (y <= r->max_incl_y);
+}
+
+static inline bool  //
+wuffs_base__rect_ii_u32__contains_rect(const wuffs_base__rect_ii_u32* r,
+                                       wuffs_base__rect_ii_u32 s) {
+  return wuffs_base__rect_ii_u32__equals(
+      &s, wuffs_base__rect_ii_u32__intersect(r, s));
+}
+
+#ifdef __cplusplus
+
+inline bool  //
+wuffs_base__rect_ii_u32::is_empty() const {
+  return wuffs_base__rect_ii_u32__is_empty(this);
+}
+
+inline bool  //
+wuffs_base__rect_ii_u32::equals(wuffs_base__rect_ii_u32 s) const {
+  return wuffs_base__rect_ii_u32__equals(this, s);
+}
+
+inline wuffs_base__rect_ii_u32  //
+wuffs_base__rect_ii_u32::intersect(wuffs_base__rect_ii_u32 s) const {
+  return wuffs_base__rect_ii_u32__intersect(this, s);
+}
+
+inline wuffs_base__rect_ii_u32  //
+wuffs_base__rect_ii_u32::unite(wuffs_base__rect_ii_u32 s) const {
+  return wuffs_base__rect_ii_u32__unite(this, s);
+}
+
+inline bool  //
+wuffs_base__rect_ii_u32::contains(uint32_t x, uint32_t y) const {
+  return wuffs_base__rect_ii_u32__contains(this, x, y);
+}
+
+inline bool  //
+wuffs_base__rect_ii_u32::contains_rect(wuffs_base__rect_ii_u32 s) const {
+  return wuffs_base__rect_ii_u32__contains_rect(this, s);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+typedef struct wuffs_base__rect_ie_u32__struct {
+  uint32_t min_incl_x;
+  uint32_t min_incl_y;
+  uint32_t max_excl_x;
+  uint32_t max_excl_y;
+
+#ifdef __cplusplus
+  inline bool is_empty() const;
+  inline bool equals(wuffs_base__rect_ie_u32__struct s) const;
+  inline wuffs_base__rect_ie_u32__struct intersect(
+      wuffs_base__rect_ie_u32__struct s) const;
+  inline wuffs_base__rect_ie_u32__struct unite(
+      wuffs_base__rect_ie_u32__struct s) const;
+  inline bool contains(uint32_t x, uint32_t y) const;
+  inline bool contains_rect(wuffs_base__rect_ie_u32__struct s) const;
+  inline uint32_t width() const;
+  inline uint32_t height() const;
+#endif  // __cplusplus
+
+} wuffs_base__rect_ie_u32;
+
+static inline wuffs_base__rect_ie_u32  //
+wuffs_base__empty_rect_ie_u32() {
+  wuffs_base__rect_ie_u32 ret;
+  ret.min_incl_x = 0;
+  ret.min_incl_y = 0;
+  ret.max_excl_x = 0;
+  ret.max_excl_y = 0;
+  return ret;
+}
+
+static inline wuffs_base__rect_ie_u32  //
+wuffs_base__make_rect_ie_u32(uint32_t min_incl_x,
+                             uint32_t min_incl_y,
+                             uint32_t max_excl_x,
+                             uint32_t max_excl_y) {
+  wuffs_base__rect_ie_u32 ret;
+  ret.min_incl_x = min_incl_x;
+  ret.min_incl_y = min_incl_y;
+  ret.max_excl_x = max_excl_x;
+  ret.max_excl_y = max_excl_y;
+  return ret;
+}
+
+static inline bool  //
+wuffs_base__rect_ie_u32__is_empty(const wuffs_base__rect_ie_u32* r) {
+  return (r->min_incl_x >= r->max_excl_x) || (r->min_incl_y >= r->max_excl_y);
+}
+
+static inline bool  //
+wuffs_base__rect_ie_u32__equals(const wuffs_base__rect_ie_u32* r,
+                                wuffs_base__rect_ie_u32 s) {
+  return (r->min_incl_x == s.min_incl_x && r->min_incl_y == s.min_incl_y &&
+          r->max_excl_x == s.max_excl_x && r->max_excl_y == s.max_excl_y) ||
+         (wuffs_base__rect_ie_u32__is_empty(r) &&
+          wuffs_base__rect_ie_u32__is_empty(&s));
+}
+
+static inline wuffs_base__rect_ie_u32  //
+wuffs_base__rect_ie_u32__intersect(const wuffs_base__rect_ie_u32* r,
+                                   wuffs_base__rect_ie_u32 s) {
+  wuffs_base__rect_ie_u32 t;
+  t.min_incl_x = wuffs_base__u32__max(r->min_incl_x, s.min_incl_x);
+  t.min_incl_y = wuffs_base__u32__max(r->min_incl_y, s.min_incl_y);
+  t.max_excl_x = wuffs_base__u32__min(r->max_excl_x, s.max_excl_x);
+  t.max_excl_y = wuffs_base__u32__min(r->max_excl_y, s.max_excl_y);
+  return t;
+}
+
+static inline wuffs_base__rect_ie_u32  //
+wuffs_base__rect_ie_u32__unite(const wuffs_base__rect_ie_u32* r,
+                               wuffs_base__rect_ie_u32 s) {
+  if (wuffs_base__rect_ie_u32__is_empty(r)) {
+    return s;
+  }
+  if (wuffs_base__rect_ie_u32__is_empty(&s)) {
+    return *r;
+  }
+  wuffs_base__rect_ie_u32 t;
+  t.min_incl_x = wuffs_base__u32__min(r->min_incl_x, s.min_incl_x);
+  t.min_incl_y = wuffs_base__u32__min(r->min_incl_y, s.min_incl_y);
+  t.max_excl_x = wuffs_base__u32__max(r->max_excl_x, s.max_excl_x);
+  t.max_excl_y = wuffs_base__u32__max(r->max_excl_y, s.max_excl_y);
+  return t;
+}
+
+static inline bool  //
+wuffs_base__rect_ie_u32__contains(const wuffs_base__rect_ie_u32* r,
+                                  uint32_t x,
+                                  uint32_t y) {
+  return (r->min_incl_x <= x) && (x < r->max_excl_x) && (r->min_incl_y <= y) &&
+         (y < r->max_excl_y);
+}
+
+static inline bool  //
+wuffs_base__rect_ie_u32__contains_rect(const wuffs_base__rect_ie_u32* r,
+                                       wuffs_base__rect_ie_u32 s) {
+  return wuffs_base__rect_ie_u32__equals(
+      &s, wuffs_base__rect_ie_u32__intersect(r, s));
+}
+
+static inline uint32_t  //
+wuffs_base__rect_ie_u32__width(const wuffs_base__rect_ie_u32* r) {
+  return wuffs_base__u32__sat_sub(r->max_excl_x, r->min_incl_x);
+}
+
+static inline uint32_t  //
+wuffs_base__rect_ie_u32__height(const wuffs_base__rect_ie_u32* r) {
+  return wuffs_base__u32__sat_sub(r->max_excl_y, r->min_incl_y);
+}
+
+#ifdef __cplusplus
+
+inline bool  //
+wuffs_base__rect_ie_u32::is_empty() const {
+  return wuffs_base__rect_ie_u32__is_empty(this);
+}
+
+inline bool  //
+wuffs_base__rect_ie_u32::equals(wuffs_base__rect_ie_u32 s) const {
+  return wuffs_base__rect_ie_u32__equals(this, s);
+}
+
+inline wuffs_base__rect_ie_u32  //
+wuffs_base__rect_ie_u32::intersect(wuffs_base__rect_ie_u32 s) const {
+  return wuffs_base__rect_ie_u32__intersect(this, s);
+}
+
+inline wuffs_base__rect_ie_u32  //
+wuffs_base__rect_ie_u32::unite(wuffs_base__rect_ie_u32 s) const {
+  return wuffs_base__rect_ie_u32__unite(this, s);
+}
+
+inline bool  //
+wuffs_base__rect_ie_u32::contains(uint32_t x, uint32_t y) const {
+  return wuffs_base__rect_ie_u32__contains(this, x, y);
+}
+
+inline bool  //
+wuffs_base__rect_ie_u32::contains_rect(wuffs_base__rect_ie_u32 s) const {
+  return wuffs_base__rect_ie_u32__contains_rect(this, s);
+}
+
+inline uint32_t  //
+wuffs_base__rect_ie_u32::width() const {
+  return wuffs_base__rect_ie_u32__width(this);
+}
+
+inline uint32_t  //
+wuffs_base__rect_ie_u32::height() const {
+  return wuffs_base__rect_ie_u32__height(this);
+}
+
+#endif  // __cplusplus
+
+// ---------------- More Information
+
+// wuffs_base__more_information holds additional fields, typically when a Wuffs
+// method returns a [note status](/doc/note/statuses.md).
+//
+// The flavor field follows the base38 namespace
+// convention](/doc/note/base38-and-fourcc.md). The other fields' semantics
+// depends on the flavor.
+typedef struct wuffs_base__more_information__struct {
+  uint32_t flavor;
+  uint32_t w;
+  uint64_t x;
+  uint64_t y;
+  uint64_t z;
+
+#ifdef __cplusplus
+  inline void set(uint32_t flavor_arg,
+                  uint32_t w_arg,
+                  uint64_t x_arg,
+                  uint64_t y_arg,
+                  uint64_t z_arg);
+  inline uint32_t io_redirect__fourcc() const;
+  inline wuffs_base__range_ie_u64 io_redirect__range() const;
+  inline uint64_t io_seek__position() const;
+  inline uint32_t metadata__fourcc() const;
+  inline wuffs_base__range_ie_u64 metadata_raw_passthrough__range() const;
+  inline int32_t metadata_parsed__chrm(uint32_t component) const;
+  inline uint32_t metadata_parsed__gama() const;
+  inline uint32_t metadata_parsed__srgb() const;
+#endif  // __cplusplus
+
+} wuffs_base__more_information;
+
+#define WUFFS_BASE__MORE_INFORMATION__FLAVOR__IO_REDIRECT 1
+#define WUFFS_BASE__MORE_INFORMATION__FLAVOR__IO_SEEK 2
+#define WUFFS_BASE__MORE_INFORMATION__FLAVOR__METADATA_RAW_PASSTHROUGH 3
+#define WUFFS_BASE__MORE_INFORMATION__FLAVOR__METADATA_RAW_TRANSFORM 4
+#define WUFFS_BASE__MORE_INFORMATION__FLAVOR__METADATA_PARSED 5
+
+static inline wuffs_base__more_information  //
+wuffs_base__empty_more_information() {
+  wuffs_base__more_information ret;
+  ret.flavor = 0;
+  ret.w = 0;
+  ret.x = 0;
+  ret.y = 0;
+  ret.z = 0;
+  return ret;
+}
+
+static inline void  //
+wuffs_base__more_information__set(wuffs_base__more_information* m,
+                                  uint32_t flavor,
+                                  uint32_t w,
+                                  uint64_t x,
+                                  uint64_t y,
+                                  uint64_t z) {
+  if (!m) {
+    return;
+  }
+  m->flavor = flavor;
+  m->w = w;
+  m->x = x;
+  m->y = y;
+  m->z = z;
+}
+
+static inline uint32_t  //
+wuffs_base__more_information__io_redirect__fourcc(
+    const wuffs_base__more_information* m) {
+  return m->w;
+}
+
+static inline wuffs_base__range_ie_u64  //
+wuffs_base__more_information__io_redirect__range(
+    const wuffs_base__more_information* m) {
+  wuffs_base__range_ie_u64 ret;
+  ret.min_incl = m->y;
+  ret.max_excl = m->z;
+  return ret;
+}
+
+static inline uint64_t  //
+wuffs_base__more_information__io_seek__position(
+    const wuffs_base__more_information* m) {
+  return m->x;
+}
+
+static inline uint32_t  //
+wuffs_base__more_information__metadata__fourcc(
+    const wuffs_base__more_information* m) {
+  return m->w;
+}
+
+static inline wuffs_base__range_ie_u64  //
+wuffs_base__more_information__metadata_raw_passthrough__range(
+    const wuffs_base__more_information* m) {
+  wuffs_base__range_ie_u64 ret;
+  ret.min_incl = m->y;
+  ret.max_excl = m->z;
+  return ret;
+}
+
+#define WUFFS_BASE__MORE_INFORMATION__METADATA_PARSED__CHRM__WHITE_X 0
+#define WUFFS_BASE__MORE_INFORMATION__METADATA_PARSED__CHRM__WHITE_Y 1
+#define WUFFS_BASE__MORE_INFORMATION__METADATA_PARSED__CHRM__RED_X 2
+#define WUFFS_BASE__MORE_INFORMATION__METADATA_PARSED__CHRM__RED_Y 3
+#define WUFFS_BASE__MORE_INFORMATION__METADATA_PARSED__CHRM__GREEN_X 4
+#define WUFFS_BASE__MORE_INFORMATION__METADATA_PARSED__CHRM__GREEN_Y 5
+#define WUFFS_BASE__MORE_INFORMATION__METADATA_PARSED__CHRM__BLUE_X 6
+#define WUFFS_BASE__MORE_INFORMATION__METADATA_PARSED__CHRM__BLUE_Y 7
+
+// wuffs_base__more_information__metadata_parsed__chrm returns chromaticity
+// values (scaled by 100000) like the PNG "cHRM" chunk. For example, the sRGB
+// color space corresponds to:
+//  - ETC__CHRM__WHITE_X 31270
+//  - ETC__CHRM__WHITE_Y 32900
+//  - ETC__CHRM__RED_X   64000
+//  - ETC__CHRM__RED_Y   33000
+//  - ETC__CHRM__GREEN_X 30000
+//  - ETC__CHRM__GREEN_Y 60000
+//  - ETC__CHRM__BLUE_X  15000
+//  - ETC__CHRM__BLUE_Y   6000
+//
+// See
+// https://ciechanow.ski/color-spaces/#chromaticity-and-white-point-coordinates
+static inline int32_t  //
+wuffs_base__more_information__metadata_parsed__chrm(
+    const wuffs_base__more_information* m,
+    uint32_t component) {
+  // After the flavor and the w field (holding a FourCC), a
+  // wuffs_base__more_information holds 24 bytes of data in three uint64_t
+  // typed fields (x, y and z). We pack the eight chromaticity values (wx, wy,
+  // rx, ..., by), basically int24_t values, into 24 bytes like this:
+  //  -    LSB                 MSB
+  //  - x: wx wx wx wy wy wy rx rx
+  //  - y: rx ry ry ry gx gx gx gy
+  //  - z: gy gy bx bx bx by by by
+  uint32_t u = 0;
+  switch (component & 7) {
+    case 0:
+      u = ((uint32_t)(m->x >> 0));
+      break;
+    case 1:
+      u = ((uint32_t)(m->x >> 24));
+      break;
+    case 2:
+      u = ((uint32_t)((m->x >> 48) | (m->y << 16)));
+      break;
+    case 3:
+      u = ((uint32_t)(m->y >> 8));
+      break;
+    case 4:
+      u = ((uint32_t)(m->y >> 32));
+      break;
+    case 5:
+      u = ((uint32_t)((m->y >> 56) | (m->z << 8)));
+      break;
+    case 6:
+      u = ((uint32_t)(m->z >> 16));
+      break;
+    case 7:
+      u = ((uint32_t)(m->z >> 40));
+      break;
+  }
+  // The left-right shifts sign-extend from 24-bit to 32-bit integers.
+  return ((int32_t)(u << 8)) >> 8;
+}
+
+// wuffs_base__more_information__metadata_parsed__gama returns inverse gamma
+// correction values (scaled by 100000) like the PNG "gAMA" chunk. For example,
+// for gamma = 2.2, this returns 45455 (approximating 100000 / 2.2).
+static inline uint32_t  //
+wuffs_base__more_information__metadata_parsed__gama(
+    const wuffs_base__more_information* m) {
+  return ((uint32_t)(m->x));
+}
+
+#define WUFFS_BASE__SRGB_RENDERING_INTENT__PERCEPTUAL 0
+#define WUFFS_BASE__SRGB_RENDERING_INTENT__RELATIVE_COLORIMETRIC 1
+#define WUFFS_BASE__SRGB_RENDERING_INTENT__SATURATION 2
+#define WUFFS_BASE__SRGB_RENDERING_INTENT__ABSOLUTE_COLORIMETRIC 3
+
+// wuffs_base__more_information__metadata_parsed__srgb returns the sRGB
+// rendering intent like the PNG "sRGB" chunk.
+static inline uint32_t  //
+wuffs_base__more_information__metadata_parsed__srgb(
+    const wuffs_base__more_information* m) {
+  return m->x & 3;
+}
+
+#ifdef __cplusplus
+
+inline void  //
+wuffs_base__more_information::set(uint32_t flavor_arg,
+                                  uint32_t w_arg,
+                                  uint64_t x_arg,
+                                  uint64_t y_arg,
+                                  uint64_t z_arg) {
+  wuffs_base__more_information__set(this, flavor_arg, w_arg, x_arg, y_arg,
+                                    z_arg);
+}
+
+inline uint32_t  //
+wuffs_base__more_information::io_redirect__fourcc() const {
+  return wuffs_base__more_information__io_redirect__fourcc(this);
+}
+
+inline wuffs_base__range_ie_u64  //
+wuffs_base__more_information::io_redirect__range() const {
+  return wuffs_base__more_information__io_redirect__range(this);
+}
+
+inline uint64_t  //
+wuffs_base__more_information::io_seek__position() const {
+  return wuffs_base__more_information__io_seek__position(this);
+}
+
+inline uint32_t  //
+wuffs_base__more_information::metadata__fourcc() const {
+  return wuffs_base__more_information__metadata__fourcc(this);
+}
+
+inline wuffs_base__range_ie_u64  //
+wuffs_base__more_information::metadata_raw_passthrough__range() const {
+  return wuffs_base__more_information__metadata_raw_passthrough__range(this);
+}
+
+inline int32_t  //
+wuffs_base__more_information::metadata_parsed__chrm(uint32_t component) const {
+  return wuffs_base__more_information__metadata_parsed__chrm(this, component);
+}
+
+inline uint32_t  //
+wuffs_base__more_information::metadata_parsed__gama() const {
+  return wuffs_base__more_information__metadata_parsed__gama(this);
+}
+
+inline uint32_t  //
+wuffs_base__more_information::metadata_parsed__srgb() const {
+  return wuffs_base__more_information__metadata_parsed__srgb(this);
+}
+
+#endif  // __cplusplus
+
+// ---------------- I/O
+//
+// See (/doc/note/io-input-output.md).
+
+// wuffs_base__io_buffer_meta is the metadata for a wuffs_base__io_buffer's
+// data.
+typedef struct wuffs_base__io_buffer_meta__struct {
+  size_t wi;     // Write index. Invariant: wi <= len.
+  size_t ri;     // Read  index. Invariant: ri <= wi.
+  uint64_t pos;  // Buffer position (relative to the start of stream).
+  bool closed;   // No further writes are expected.
+} wuffs_base__io_buffer_meta;
+
+// wuffs_base__io_buffer is a 1-dimensional buffer (a pointer and length) plus
+// additional metadata.
+//
+// A value with all fields zero is a valid, empty buffer.
+typedef struct wuffs_base__io_buffer__struct {
+  wuffs_base__slice_u8 data;
+  wuffs_base__io_buffer_meta meta;
+
+#ifdef __cplusplus
+  inline bool is_valid() const;
+  inline void compact();
+  inline void compact_retaining(uint64_t history_retain_length);
+  inline size_t reader_length() const;
+  inline uint8_t* reader_pointer() const;
+  inline uint64_t reader_position() const;
+  inline wuffs_base__slice_u8 reader_slice() const;
+  inline size_t writer_length() const;
+  inline uint8_t* writer_pointer() const;
+  inline uint64_t writer_position() const;
+  inline wuffs_base__slice_u8 writer_slice() const;
+#endif  // __cplusplus
+
+} wuffs_base__io_buffer;
+
+static inline wuffs_base__io_buffer  //
+wuffs_base__make_io_buffer(wuffs_base__slice_u8 data,
+                           wuffs_base__io_buffer_meta meta) {
+  wuffs_base__io_buffer ret;
+  ret.data = data;
+  ret.meta = meta;
+  return ret;
+}
+
+static inline wuffs_base__io_buffer_meta  //
+wuffs_base__make_io_buffer_meta(size_t wi,
+                                size_t ri,
+                                uint64_t pos,
+                                bool closed) {
+  wuffs_base__io_buffer_meta ret;
+  ret.wi = wi;
+  ret.ri = ri;
+  ret.pos = pos;
+  ret.closed = closed;
+  return ret;
+}
+
+static inline wuffs_base__io_buffer  //
+wuffs_base__ptr_u8__reader(uint8_t* ptr, size_t len, bool closed) {
+  wuffs_base__io_buffer ret;
+  ret.data.ptr = ptr;
+  ret.data.len = len;
+  ret.meta.wi = len;
+  ret.meta.ri = 0;
+  ret.meta.pos = 0;
+  ret.meta.closed = closed;
+  return ret;
+}
+
+static inline wuffs_base__io_buffer  //
+wuffs_base__ptr_u8__writer(uint8_t* ptr, size_t len) {
+  wuffs_base__io_buffer ret;
+  ret.data.ptr = ptr;
+  ret.data.len = len;
+  ret.meta.wi = 0;
+  ret.meta.ri = 0;
+  ret.meta.pos = 0;
+  ret.meta.closed = false;
+  return ret;
+}
+
+static inline wuffs_base__io_buffer  //
+wuffs_base__slice_u8__reader(wuffs_base__slice_u8 s, bool closed) {
+  wuffs_base__io_buffer ret;
+  ret.data.ptr = s.ptr;
+  ret.data.len = s.len;
+  ret.meta.wi = s.len;
+  ret.meta.ri = 0;
+  ret.meta.pos = 0;
+  ret.meta.closed = closed;
+  return ret;
+}
+
+static inline wuffs_base__io_buffer  //
+wuffs_base__slice_u8__writer(wuffs_base__slice_u8 s) {
+  wuffs_base__io_buffer ret;
+  ret.data.ptr = s.ptr;
+  ret.data.len = s.len;
+  ret.meta.wi = 0;
+  ret.meta.ri = 0;
+  ret.meta.pos = 0;
+  ret.meta.closed = false;
+  return ret;
+}
+
+static inline wuffs_base__io_buffer  //
+wuffs_base__empty_io_buffer() {
+  wuffs_base__io_buffer ret;
+  ret.data.ptr = NULL;
+  ret.data.len = 0;
+  ret.meta.wi = 0;
+  ret.meta.ri = 0;
+  ret.meta.pos = 0;
+  ret.meta.closed = false;
+  return ret;
+}
+
+static inline wuffs_base__io_buffer_meta  //
+wuffs_base__empty_io_buffer_meta() {
+  wuffs_base__io_buffer_meta ret;
+  ret.wi = 0;
+  ret.ri = 0;
+  ret.pos = 0;
+  ret.closed = false;
+  return ret;
+}
+
+static inline bool  //
+wuffs_base__io_buffer__is_valid(const wuffs_base__io_buffer* buf) {
+  if (buf) {
+    if (buf->data.ptr) {
+      return (buf->meta.ri <= buf->meta.wi) && (buf->meta.wi <= buf->data.len);
+    } else {
+      return (buf->meta.ri == 0) && (buf->meta.wi == 0) && (buf->data.len == 0);
+    }
+  }
+  return false;
+}
+
+// wuffs_base__io_buffer__compact moves any written but unread bytes to the
+// start of the buffer.
+static inline void  //
+wuffs_base__io_buffer__compact(wuffs_base__io_buffer* buf) {
+  if (!buf || (buf->meta.ri == 0)) {
+    return;
+  }
+  buf->meta.pos = wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri);
+  size_t new_wi = buf->meta.wi - buf->meta.ri;
+  if (new_wi != 0) {
+    memmove(buf->data.ptr, buf->data.ptr + buf->meta.ri, new_wi);
+  }
+  buf->meta.wi = new_wi;
+  buf->meta.ri = 0;
+}
+
+// wuffs_base__io_buffer__compact_retaining moves any written but unread bytes
+// closer to the start of the buffer. It retains H bytes of history (the most
+// recently read bytes), where H is min(buf->meta.ri, history_retain_length).
+// A postcondition is that buf->meta.ri == H.
+//
+// wuffs_base__io_buffer__compact_retaining(0) is equivalent to
+// wuffs_base__io_buffer__compact().
+//
+// For example, if buf started like this:
+//
+//        +--- ri = 3
+//        v
+//     abcdefgh??    len = 10, pos = 900
+//             ^
+//             +--- wi = 8
+//
+// Then, depending on history_retain_length, the resultant buf would be:
+//
+// HRL = 0     defgh?????    ri = 0    wi = 5    pos = 903
+// HRL = 1     cdefgh????    ri = 1    wi = 6    pos = 902
+// HRL = 2     bcdefgh???    ri = 2    wi = 7    pos = 901
+// HRL = 3     abcdefgh??    ri = 3    wi = 8    pos = 900
+// HRL = 4+    abcdefgh??    ri = 3    wi = 8    pos = 900
+static inline void  //
+wuffs_base__io_buffer__compact_retaining(wuffs_base__io_buffer* buf,
+                                         uint64_t history_retain_length) {
+  if (!buf || (buf->meta.ri == 0)) {
+    return;
+  }
+  size_t old_ri = buf->meta.ri;
+  size_t new_ri = (size_t)(wuffs_base__u64__min(old_ri, history_retain_length));
+  size_t memmove_start = old_ri - new_ri;
+  buf->meta.pos = wuffs_base__u64__sat_add(buf->meta.pos, memmove_start);
+  size_t new_wi = buf->meta.wi - memmove_start;
+  if ((new_wi != 0) && (memmove_start != 0)) {
+    memmove(buf->data.ptr, buf->data.ptr + memmove_start, new_wi);
+  }
+  buf->meta.wi = new_wi;
+  buf->meta.ri = new_ri;
+}
+
+static inline size_t  //
+wuffs_base__io_buffer__reader_length(const wuffs_base__io_buffer* buf) {
+  return buf ? buf->meta.wi - buf->meta.ri : 0;
+}
+
+static inline uint8_t*  //
+wuffs_base__io_buffer__reader_pointer(const wuffs_base__io_buffer* buf) {
+  return buf ? (buf->data.ptr + buf->meta.ri) : NULL;
+}
+
+static inline uint64_t  //
+wuffs_base__io_buffer__reader_position(const wuffs_base__io_buffer* buf) {
+  return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri) : 0;
+}
+
+static inline wuffs_base__slice_u8  //
+wuffs_base__io_buffer__reader_slice(const wuffs_base__io_buffer* buf) {
+  return buf ? wuffs_base__make_slice_u8(buf->data.ptr + buf->meta.ri,
+                                         buf->meta.wi - buf->meta.ri)
+             : wuffs_base__empty_slice_u8();
+}
+
+static inline size_t  //
+wuffs_base__io_buffer__writer_length(const wuffs_base__io_buffer* buf) {
+  return buf ? buf->data.len - buf->meta.wi : 0;
+}
+
+static inline uint8_t*  //
+wuffs_base__io_buffer__writer_pointer(const wuffs_base__io_buffer* buf) {
+  return buf ? (buf->data.ptr + buf->meta.wi) : NULL;
+}
+
+static inline uint64_t  //
+wuffs_base__io_buffer__writer_position(const wuffs_base__io_buffer* buf) {
+  return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.wi) : 0;
+}
+
+static inline wuffs_base__slice_u8  //
+wuffs_base__io_buffer__writer_slice(const wuffs_base__io_buffer* buf) {
+  return buf ? wuffs_base__make_slice_u8(buf->data.ptr + buf->meta.wi,
+                                         buf->data.len - buf->meta.wi)
+             : wuffs_base__empty_slice_u8();
+}
+
+#ifdef __cplusplus
+
+inline bool  //
+wuffs_base__io_buffer::is_valid() const {
+  return wuffs_base__io_buffer__is_valid(this);
+}
+
+inline void  //
+wuffs_base__io_buffer::compact() {
+  wuffs_base__io_buffer__compact(this);
+}
+
+inline void  //
+wuffs_base__io_buffer::compact_retaining(uint64_t history_retain_length) {
+  wuffs_base__io_buffer__compact_retaining(this, history_retain_length);
+}
+
+inline size_t  //
+wuffs_base__io_buffer::reader_length() const {
+  return wuffs_base__io_buffer__reader_length(this);
+}
+
+inline uint8_t*  //
+wuffs_base__io_buffer::reader_pointer() const {
+  return wuffs_base__io_buffer__reader_pointer(this);
+}
+
+inline uint64_t  //
+wuffs_base__io_buffer::reader_position() const {
+  return wuffs_base__io_buffer__reader_position(this);
+}
+
+inline wuffs_base__slice_u8  //
+wuffs_base__io_buffer::reader_slice() const {
+  return wuffs_base__io_buffer__reader_slice(this);
+}
+
+inline size_t  //
+wuffs_base__io_buffer::writer_length() const {
+  return wuffs_base__io_buffer__writer_length(this);
+}
+
+inline uint8_t*  //
+wuffs_base__io_buffer::writer_pointer() const {
+  return wuffs_base__io_buffer__writer_pointer(this);
+}
+
+inline uint64_t  //
+wuffs_base__io_buffer::writer_position() const {
+  return wuffs_base__io_buffer__writer_position(this);
+}
+
+inline wuffs_base__slice_u8  //
+wuffs_base__io_buffer::writer_slice() const {
+  return wuffs_base__io_buffer__writer_slice(this);
+}
+
+#endif  // __cplusplus
+
+// ---------------- Tokens
+
+// wuffs_base__token is an element of a byte stream's tokenization.
+//
+// See https://github.com/google/wuffs/blob/main/doc/note/tokens.md
+typedef struct wuffs_base__token__struct {
+  uint64_t repr;
+
+#ifdef __cplusplus
+  inline int64_t value() const;
+  inline int64_t value_extension() const;
+  inline int64_t value_major() const;
+  inline int64_t value_base_category() const;
+  inline uint64_t value_minor() const;
+  inline uint64_t value_base_detail() const;
+  inline int64_t value_base_detail__sign_extended() const;
+  inline bool continued() const;
+  inline uint64_t length() const;
+#endif  // __cplusplus
+
+} wuffs_base__token;
+
+static inline wuffs_base__token  //
+wuffs_base__make_token(uint64_t repr) {
+  wuffs_base__token ret;
+  ret.repr = repr;
+  return ret;
+}
+
+// --------
+
+#define WUFFS_BASE__TOKEN__LENGTH__MAX_INCL 0xFFFF
+
+#define WUFFS_BASE__TOKEN__VALUE__SHIFT 17
+#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__SHIFT 17
+#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 42
+#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 17
+#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 38
+#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 17
+#define WUFFS_BASE__TOKEN__CONTINUED__SHIFT 16
+#define WUFFS_BASE__TOKEN__LENGTH__SHIFT 0
+
+#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__NUM_BITS 46
+
+// --------
+
+#define WUFFS_BASE__TOKEN__VBC__FILLER 0
+#define WUFFS_BASE__TOKEN__VBC__STRUCTURE 1
+#define WUFFS_BASE__TOKEN__VBC__STRING 2
+#define WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT 3
+#define WUFFS_BASE__TOKEN__VBC__LITERAL 4
+#define WUFFS_BASE__TOKEN__VBC__NUMBER 5
+#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_SIGNED 6
+#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_UNSIGNED 7
+
+// --------
+
+#define WUFFS_BASE__TOKEN__VBD__FILLER__PUNCTUATION 0x00001
+#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK 0x00002
+#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00004
+
+// COMMENT_ANY is a bit-wise or of COMMENT_BLOCK AND COMMENT_LINE.
+#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_ANY 0x00006
+
+// --------
+
+#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__PUSH 0x00001
+#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__POP 0x00002
+#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_NONE 0x00010
+#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_LIST 0x00020
+#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_DICT 0x00040
+#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE 0x01000
+#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST 0x02000
+#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT 0x04000
+
+// --------
+
+// DEFINITELY_FOO means that the destination bytes (and also the source bytes,
+// for 1_DST_1_SRC_COPY) are in the FOO format. Definitely means that the lack
+// of the bit means "maybe FOO". It does not necessarily mean "not FOO".
+//
+// CHAIN_ETC means that decoding the entire token chain forms a UTF-8 or ASCII
+// string, not just this current token. CHAIN_ETC_UTF_8 therefore distinguishes
+// Unicode (UTF-8) strings from byte strings. MUST means that the the token
+// producer (e.g. parser) must verify this. SHOULD means that the token
+// consumer (e.g. renderer) should verify this.
+//
+// When a CHAIN_ETC_UTF_8 bit is set, the parser must ensure that non-ASCII
+// code points (with multi-byte UTF-8 encodings) do not straddle token
+// boundaries. Checking UTF-8 validity can inspect each token separately.
+//
+// The lack of any particular bit is conservative: it is valid for all-ASCII
+// strings, in a single- or multi-token chain, to have none of these bits set.
+#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00001
+#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_UTF_8 0x00002
+#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_SHOULD_BE_UTF_8 0x00004
+#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00010
+#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_ASCII 0x00020
+#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_SHOULD_BE_ASCII 0x00040
+
+// CONVERT_D_DST_S_SRC means that multiples of S source bytes (possibly padded)
+// produces multiples of D destination bytes. For example,
+// CONVERT_1_DST_4_SRC_BACKSLASH_X means a source like "\\x23\\x67\\xAB", where
+// 12 src bytes encode 3 dst bytes.
+//
+// Post-processing may further transform those D destination bytes (e.g. treat
+// "\\xFF" as the Unicode code point U+00FF instead of the byte 0xFF), but that
+// is out of scope of this VBD's semantics.
+//
+// When src is the empty string, multiple conversion algorithms are applicable
+// (so these bits are not necessarily mutually exclusive), all producing the
+// same empty dst string.
+#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00100
+#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00200
+#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_2_SRC_HEXADECIMAL 0x00400
+#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_4_SRC_BACKSLASH_X 0x00800
+#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_STD 0x01000
+#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_URL 0x02000
+#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x04000
+#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_5_DST_8_SRC_BASE_32_HEX 0x08000
+#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_5_DST_8_SRC_BASE_32_STD 0x10000
+
+// --------
+
+#define WUFFS_BASE__TOKEN__VBD__LITERAL__UNDEFINED 0x00001
+#define WUFFS_BASE__TOKEN__VBD__LITERAL__NULL 0x00002
+#define WUFFS_BASE__TOKEN__VBD__LITERAL__FALSE 0x00004
+#define WUFFS_BASE__TOKEN__VBD__LITERAL__TRUE 0x00008
+
+// --------
+
+// For a source string of "123" or "0x9A", it is valid for a tokenizer to
+// return any combination of:
+//  - WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_FLOATING_POINT.
+//  - WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_SIGNED.
+//  - WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_UNSIGNED.
+//
+// For a source string of "+123" or "-0x9A", only the first two are valid.
+//
+// For a source string of "123.", only the first one is valid.
+#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_FLOATING_POINT 0x00001
+#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_SIGNED 0x00002
+#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_UNSIGNED 0x00004
+
+#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_NEG_INF 0x00010
+#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_POS_INF 0x00020
+#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_NEG_NAN 0x00040
+#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_POS_NAN 0x00080
+
+// The number 300 might be represented as "\x01\x2C", "\x2C\x01\x00\x00" or
+// "300", which are big-endian, little-endian or text. For binary formats, the
+// token length (after adjusting for FORMAT_IGNORE_ETC) discriminates
+// e.g. u16 little-endian vs u32 little-endian.
+#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_BIG_ENDIAN 0x00100
+#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_LITTLE_ENDIAN 0x00200
+#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_TEXT 0x00400
+
+#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_IGNORE_FIRST_BYTE 0x01000
+
+// --------
+
+// wuffs_base__token__value returns the token's high 46 bits, sign-extended. A
+// negative value means an extended token, non-negative means a simple token.
+static inline int64_t  //
+wuffs_base__token__value(const wuffs_base__token* t) {
+  return ((int64_t)(t->repr)) >> WUFFS_BASE__TOKEN__VALUE__SHIFT;
+}
+
+// wuffs_base__token__value_extension returns a negative value if the token was
+// not an extended token.
+static inline int64_t  //
+wuffs_base__token__value_extension(const wuffs_base__token* t) {
+  return (~(int64_t)(t->repr)) >> WUFFS_BASE__TOKEN__VALUE_EXTENSION__SHIFT;
+}
+
+// wuffs_base__token__value_major returns a negative value if the token was not
+// a simple token.
+static inline int64_t  //
+wuffs_base__token__value_major(const wuffs_base__token* t) {
+  return ((int64_t)(t->repr)) >> WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT;
+}
+
+// wuffs_base__token__value_base_category returns a negative value if the token
+// was not a simple token.
+static inline int64_t  //
+wuffs_base__token__value_base_category(const wuffs_base__token* t) {
+  return ((int64_t)(t->repr)) >> WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT;
+}
+
+static inline uint64_t  //
+wuffs_base__token__value_minor(const wuffs_base__token* t) {
+  return (t->repr >> WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) & 0x1FFFFFF;
+}
+
+static inline uint64_t  //
+wuffs_base__token__value_base_detail(const wuffs_base__token* t) {
+  return (t->repr >> WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT) & 0x1FFFFF;
+}
+
+static inline int64_t  //
+wuffs_base__token__value_base_detail__sign_extended(
+    const wuffs_base__token* t) {
+  // The VBD is 21 bits in the middle of t->repr. Left shift the high (64 - 21
+  // - ETC__SHIFT) bits off, then right shift (sign-extending) back down.
+  uint64_t u = t->repr << (43 - WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT);
+  return ((int64_t)u) >> 43;
+}
+
+static inline bool  //
+wuffs_base__token__continued(const wuffs_base__token* t) {
+  return t->repr & 0x10000;
+}
+
+static inline uint64_t  //
+wuffs_base__token__length(const wuffs_base__token* t) {
+  return (t->repr >> WUFFS_BASE__TOKEN__LENGTH__SHIFT) & 0xFFFF;
+}
+
+#ifdef __cplusplus
+
+inline int64_t  //
+wuffs_base__token::value() const {
+  return wuffs_base__token__value(this);
+}
+
+inline int64_t  //
+wuffs_base__token::value_extension() const {
+  return wuffs_base__token__value_extension(this);
+}
+
+inline int64_t  //
+wuffs_base__token::value_major() const {
+  return wuffs_base__token__value_major(this);
+}
+
+inline int64_t  //
+wuffs_base__token::value_base_category() const {
+  return wuffs_base__token__value_base_category(this);
+}
+
+inline uint64_t  //
+wuffs_base__token::value_minor() const {
+  return wuffs_base__token__value_minor(this);
+}
+
+inline uint64_t  //
+wuffs_base__token::value_base_detail() const {
+  return wuffs_base__token__value_base_detail(this);
+}
+
+inline int64_t  //
+wuffs_base__token::value_base_detail__sign_extended() const {
+  return wuffs_base__token__value_base_detail__sign_extended(this);
+}
+
+inline bool  //
+wuffs_base__token::continued() const {
+  return wuffs_base__token__continued(this);
+}
+
+inline uint64_t  //
+wuffs_base__token::length() const {
+  return wuffs_base__token__length(this);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+typedef WUFFS_BASE__SLICE(wuffs_base__token) wuffs_base__slice_token;
+
+static inline wuffs_base__slice_token  //
+wuffs_base__make_slice_token(wuffs_base__token* ptr, size_t len) {
+  wuffs_base__slice_token ret;
+  ret.ptr = ptr;
+  ret.len = len;
+  return ret;
+}
+
+static inline wuffs_base__slice_token  //
+wuffs_base__empty_slice_token() {
+  wuffs_base__slice_token ret;
+  ret.ptr = NULL;
+  ret.len = 0;
+  return ret;
+}
+
+// --------
+
+// wuffs_base__token_buffer_meta is the metadata for a
+// wuffs_base__token_buffer's data.
+typedef struct wuffs_base__token_buffer_meta__struct {
+  size_t wi;     // Write index. Invariant: wi <= len.
+  size_t ri;     // Read  index. Invariant: ri <= wi.
+  uint64_t pos;  // Position of the buffer start relative to the stream start.
+  bool closed;   // No further writes are expected.
+} wuffs_base__token_buffer_meta;
+
+// wuffs_base__token_buffer is a 1-dimensional buffer (a pointer and length)
+// plus additional metadata.
+//
+// A value with all fields zero is a valid, empty buffer.
+typedef struct wuffs_base__token_buffer__struct {
+  wuffs_base__slice_token data;
+  wuffs_base__token_buffer_meta meta;
+
+#ifdef __cplusplus
+  inline bool is_valid() const;
+  inline void compact();
+  inline void compact_retaining(uint64_t history_retain_length);
+  inline uint64_t reader_length() const;
+  inline wuffs_base__token* reader_pointer() const;
+  inline wuffs_base__slice_token reader_slice() const;
+  inline uint64_t reader_token_position() const;
+  inline uint64_t writer_length() const;
+  inline uint64_t writer_token_position() const;
+  inline wuffs_base__token* writer_pointer() const;
+  inline wuffs_base__slice_token writer_slice() const;
+#endif  // __cplusplus
+
+} wuffs_base__token_buffer;
+
+static inline wuffs_base__token_buffer  //
+wuffs_base__make_token_buffer(wuffs_base__slice_token data,
+                              wuffs_base__token_buffer_meta meta) {
+  wuffs_base__token_buffer ret;
+  ret.data = data;
+  ret.meta = meta;
+  return ret;
+}
+
+static inline wuffs_base__token_buffer_meta  //
+wuffs_base__make_token_buffer_meta(size_t wi,
+                                   size_t ri,
+                                   uint64_t pos,
+                                   bool closed) {
+  wuffs_base__token_buffer_meta ret;
+  ret.wi = wi;
+  ret.ri = ri;
+  ret.pos = pos;
+  ret.closed = closed;
+  return ret;
+}
+
+static inline wuffs_base__token_buffer  //
+wuffs_base__slice_token__reader(wuffs_base__slice_token s, bool closed) {
+  wuffs_base__token_buffer ret;
+  ret.data.ptr = s.ptr;
+  ret.data.len = s.len;
+  ret.meta.wi = s.len;
+  ret.meta.ri = 0;
+  ret.meta.pos = 0;
+  ret.meta.closed = closed;
+  return ret;
+}
+
+static inline wuffs_base__token_buffer  //
+wuffs_base__slice_token__writer(wuffs_base__slice_token s) {
+  wuffs_base__token_buffer ret;
+  ret.data.ptr = s.ptr;
+  ret.data.len = s.len;
+  ret.meta.wi = 0;
+  ret.meta.ri = 0;
+  ret.meta.pos = 0;
+  ret.meta.closed = false;
+  return ret;
+}
+
+static inline wuffs_base__token_buffer  //
+wuffs_base__empty_token_buffer() {
+  wuffs_base__token_buffer ret;
+  ret.data.ptr = NULL;
+  ret.data.len = 0;
+  ret.meta.wi = 0;
+  ret.meta.ri = 0;
+  ret.meta.pos = 0;
+  ret.meta.closed = false;
+  return ret;
+}
+
+static inline wuffs_base__token_buffer_meta  //
+wuffs_base__empty_token_buffer_meta() {
+  wuffs_base__token_buffer_meta ret;
+  ret.wi = 0;
+  ret.ri = 0;
+  ret.pos = 0;
+  ret.closed = false;
+  return ret;
+}
+
+static inline bool  //
+wuffs_base__token_buffer__is_valid(const wuffs_base__token_buffer* buf) {
+  if (buf) {
+    if (buf->data.ptr) {
+      return (buf->meta.ri <= buf->meta.wi) && (buf->meta.wi <= buf->data.len);
+    } else {
+      return (buf->meta.ri == 0) && (buf->meta.wi == 0) && (buf->data.len == 0);
+    }
+  }
+  return false;
+}
+
+// wuffs_base__token_buffer__compact moves any written but unread tokens to the
+// start of the buffer.
+static inline void  //
+wuffs_base__token_buffer__compact(wuffs_base__token_buffer* buf) {
+  if (!buf || (buf->meta.ri == 0)) {
+    return;
+  }
+  buf->meta.pos = wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri);
+  size_t new_wi = buf->meta.wi - buf->meta.ri;
+  if (new_wi != 0) {
+    memmove(buf->data.ptr, buf->data.ptr + buf->meta.ri,
+            new_wi * sizeof(wuffs_base__token));
+  }
+  buf->meta.wi = new_wi;
+  buf->meta.ri = 0;
+}
+
+// wuffs_base__token_buffer__compact_retaining moves any written but unread
+// tokens closer to the start of the buffer. It retains H tokens of history
+// (the most recently read tokens), where H is min(buf->meta.ri,
+// history_retain_length). A postcondition is that buf->meta.ri == H.
+//
+// wuffs_base__token_buffer__compact_retaining(0) is equivalent to
+// wuffs_base__token_buffer__compact().
+//
+// For example, if buf started like this:
+//
+//        +--- ri = 3
+//        v
+//     abcdefgh??    len = 10, pos = 900
+//             ^
+//             +--- wi = 8
+//
+// Then, depending on history_retain_length, the resultant buf would be:
+//
+// HRL = 0     defgh?????    ri = 0    wi = 5    pos = 903
+// HRL = 1     cdefgh????    ri = 1    wi = 6    pos = 902
+// HRL = 2     bcdefgh???    ri = 2    wi = 7    pos = 901
+// HRL = 3     abcdefgh??    ri = 3    wi = 8    pos = 900
+// HRL = 4+    abcdefgh??    ri = 3    wi = 8    pos = 900
+static inline void  //
+wuffs_base__token_buffer__compact_retaining(wuffs_base__token_buffer* buf,
+                                            uint64_t history_retain_length) {
+  if (!buf || (buf->meta.ri == 0)) {
+    return;
+  }
+  size_t old_ri = buf->meta.ri;
+  size_t new_ri = (size_t)(wuffs_base__u64__min(old_ri, history_retain_length));
+  size_t memmove_start = old_ri - new_ri;
+  buf->meta.pos = wuffs_base__u64__sat_add(buf->meta.pos, memmove_start);
+  size_t new_wi = buf->meta.wi - memmove_start;
+  if ((new_wi != 0) && (memmove_start != 0)) {
+    memmove(buf->data.ptr, buf->data.ptr + memmove_start,
+            new_wi * sizeof(wuffs_base__token));
+  }
+  buf->meta.wi = new_wi;
+  buf->meta.ri = new_ri;
+}
+
+static inline uint64_t  //
+wuffs_base__token_buffer__reader_length(const wuffs_base__token_buffer* buf) {
+  return buf ? buf->meta.wi - buf->meta.ri : 0;
+}
+
+static inline wuffs_base__token*  //
+wuffs_base__token_buffer__reader_pointer(const wuffs_base__token_buffer* buf) {
+  return buf ? (buf->data.ptr + buf->meta.ri) : NULL;
+}
+
+static inline wuffs_base__slice_token  //
+wuffs_base__token_buffer__reader_slice(const wuffs_base__token_buffer* buf) {
+  return buf ? wuffs_base__make_slice_token(buf->data.ptr + buf->meta.ri,
+                                            buf->meta.wi - buf->meta.ri)
+             : wuffs_base__empty_slice_token();
+}
+
+static inline uint64_t  //
+wuffs_base__token_buffer__reader_token_position(
+    const wuffs_base__token_buffer* buf) {
+  return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri) : 0;
+}
+
+static inline uint64_t  //
+wuffs_base__token_buffer__writer_length(const wuffs_base__token_buffer* buf) {
+  return buf ? buf->data.len - buf->meta.wi : 0;
+}
+
+static inline wuffs_base__token*  //
+wuffs_base__token_buffer__writer_pointer(const wuffs_base__token_buffer* buf) {
+  return buf ? (buf->data.ptr + buf->meta.wi) : NULL;
+}
+
+static inline wuffs_base__slice_token  //
+wuffs_base__token_buffer__writer_slice(const wuffs_base__token_buffer* buf) {
+  return buf ? wuffs_base__make_slice_token(buf->data.ptr + buf->meta.wi,
+                                            buf->data.len - buf->meta.wi)
+             : wuffs_base__empty_slice_token();
+}
+
+static inline uint64_t  //
+wuffs_base__token_buffer__writer_token_position(
+    const wuffs_base__token_buffer* buf) {
+  return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.wi) : 0;
+}
+
+#ifdef __cplusplus
+
+inline bool  //
+wuffs_base__token_buffer::is_valid() const {
+  return wuffs_base__token_buffer__is_valid(this);
+}
+
+inline void  //
+wuffs_base__token_buffer::compact() {
+  wuffs_base__token_buffer__compact(this);
+}
+
+inline void  //
+wuffs_base__token_buffer::compact_retaining(uint64_t history_retain_length) {
+  wuffs_base__token_buffer__compact_retaining(this, history_retain_length);
+}
+
+inline uint64_t  //
+wuffs_base__token_buffer::reader_length() const {
+  return wuffs_base__token_buffer__reader_length(this);
+}
+
+inline wuffs_base__token*  //
+wuffs_base__token_buffer::reader_pointer() const {
+  return wuffs_base__token_buffer__reader_pointer(this);
+}
+
+inline wuffs_base__slice_token  //
+wuffs_base__token_buffer::reader_slice() const {
+  return wuffs_base__token_buffer__reader_slice(this);
+}
+
+inline uint64_t  //
+wuffs_base__token_buffer::reader_token_position() const {
+  return wuffs_base__token_buffer__reader_token_position(this);
+}
+
+inline uint64_t  //
+wuffs_base__token_buffer::writer_length() const {
+  return wuffs_base__token_buffer__writer_length(this);
+}
+
+inline wuffs_base__token*  //
+wuffs_base__token_buffer::writer_pointer() const {
+  return wuffs_base__token_buffer__writer_pointer(this);
+}
+
+inline wuffs_base__slice_token  //
+wuffs_base__token_buffer::writer_slice() const {
+  return wuffs_base__token_buffer__writer_slice(this);
+}
+
+inline uint64_t  //
+wuffs_base__token_buffer::writer_token_position() const {
+  return wuffs_base__token_buffer__writer_token_position(this);
+}
+
+#endif  // __cplusplus
+
+// ---------------- Memory Allocation
+
+// The memory allocation related functions in this section aren't used by Wuffs
+// per se, but they may be helpful to the code that uses Wuffs.
+
+// wuffs_base__malloc_slice_uxx wraps calling a malloc-like function, except
+// that it takes a uint64_t number of elements instead of a size_t size in
+// bytes, and it returns a slice (a pointer and a length) instead of just a
+// pointer.
+//
+// You can pass the C stdlib's malloc as the malloc_func.
+//
+// It returns an empty slice (containing a NULL ptr field) if (num_uxx *
+// sizeof(uintxx_t)) would overflow SIZE_MAX.
+
+static inline wuffs_base__slice_u8  //
+wuffs_base__malloc_slice_u8(void* (*malloc_func)(size_t), uint64_t num_u8) {
+  if (malloc_func && (num_u8 <= (SIZE_MAX / sizeof(uint8_t)))) {
+    void* p = (*malloc_func)((size_t)(num_u8 * sizeof(uint8_t)));
+    if (p) {
+      return wuffs_base__make_slice_u8((uint8_t*)(p), (size_t)num_u8);
+    }
+  }
+  return wuffs_base__make_slice_u8(NULL, 0);
+}
+
+static inline wuffs_base__slice_u16  //
+wuffs_base__malloc_slice_u16(void* (*malloc_func)(size_t), uint64_t num_u16) {
+  if (malloc_func && (num_u16 <= (SIZE_MAX / sizeof(uint16_t)))) {
+    void* p = (*malloc_func)((size_t)(num_u16 * sizeof(uint16_t)));
+    if (p) {
+      return wuffs_base__make_slice_u16((uint16_t*)(p), (size_t)num_u16);
+    }
+  }
+  return wuffs_base__make_slice_u16(NULL, 0);
+}
+
+static inline wuffs_base__slice_u32  //
+wuffs_base__malloc_slice_u32(void* (*malloc_func)(size_t), uint64_t num_u32) {
+  if (malloc_func && (num_u32 <= (SIZE_MAX / sizeof(uint32_t)))) {
+    void* p = (*malloc_func)((size_t)(num_u32 * sizeof(uint32_t)));
+    if (p) {
+      return wuffs_base__make_slice_u32((uint32_t*)(p), (size_t)num_u32);
+    }
+  }
+  return wuffs_base__make_slice_u32(NULL, 0);
+}
+
+static inline wuffs_base__slice_u64  //
+wuffs_base__malloc_slice_u64(void* (*malloc_func)(size_t), uint64_t num_u64) {
+  if (malloc_func && (num_u64 <= (SIZE_MAX / sizeof(uint64_t)))) {
+    void* p = (*malloc_func)((size_t)(num_u64 * sizeof(uint64_t)));
+    if (p) {
+      return wuffs_base__make_slice_u64((uint64_t*)(p), (size_t)num_u64);
+    }
+  }
+  return wuffs_base__make_slice_u64(NULL, 0);
+}
+
+// ---------------- Images
+
+#define WUFFS_BASE__IMAGE__DIMENSION_MAX_INCL 0xFFFFFF
+
+// wuffs_base__color_u32_argb_premul is an 8 bit per channel premultiplied
+// Alpha, Red, Green, Blue color, as a uint32_t value. Its value is always
+// 0xAARRGGBB (Alpha most significant, Blue least), regardless of endianness.
+typedef uint32_t wuffs_base__color_u32_argb_premul;
+
+// wuffs_base__color_u32_argb_premul__is_valid returns whether c's Red, Green
+// and Blue channels are all less than or equal to its Alpha channel. c uses
+// premultiplied alpha, so 50% opaque 100% saturated red is 0x7F7F_0000 and a
+// value like 0x7F80_0000 is invalid.
+static inline bool  //
+wuffs_base__color_u32_argb_premul__is_valid(
+    wuffs_base__color_u32_argb_premul c) {
+  uint32_t a = 0xFF & (c >> 24);
+  uint32_t r = 0xFF & (c >> 16);
+  uint32_t g = 0xFF & (c >> 8);
+  uint32_t b = 0xFF & (c >> 0);
+  return (a >= r) && (a >= g) && (a >= b);
+}
+
+static inline uint16_t  //
+wuffs_base__color_u32_argb_premul__as__color_u16_rgb_565(
+    wuffs_base__color_u32_argb_premul c) {
+  uint32_t r5 = 0xF800 & (c >> 8);
+  uint32_t g6 = 0x07E0 & (c >> 5);
+  uint32_t b5 = 0x001F & (c >> 3);
+  return (uint16_t)(r5 | g6 | b5);
+}
+
+static inline wuffs_base__color_u32_argb_premul  //
+wuffs_base__color_u16_rgb_565__as__color_u32_argb_premul(uint16_t rgb_565) {
+  uint32_t b5 = 0x1F & (rgb_565 >> 0);
+  uint32_t b = (b5 << 3) | (b5 >> 2);
+  uint32_t g6 = 0x3F & (rgb_565 >> 5);
+  uint32_t g = (g6 << 2) | (g6 >> 4);
+  uint32_t r5 = 0x1F & (rgb_565 >> 11);
+  uint32_t r = (r5 << 3) | (r5 >> 2);
+  return 0xFF000000 | (r << 16) | (g << 8) | (b << 0);
+}
+
+static inline uint8_t  //
+wuffs_base__color_u32_argb_premul__as__color_u8_gray(
+    wuffs_base__color_u32_argb_premul c) {
+  // Work in 16-bit color.
+  uint32_t cr = 0x101 * (0xFF & (c >> 16));
+  uint32_t cg = 0x101 * (0xFF & (c >> 8));
+  uint32_t cb = 0x101 * (0xFF & (c >> 0));
+
+  // These coefficients (the fractions 0.299, 0.587 and 0.114) are the same
+  // as those given by the JFIF specification.
+  //
+  // Note that 19595 + 38470 + 7471 equals 65536, also known as (1 << 16). We
+  // shift by 24, not just by 16, because the return value is 8-bit color, not
+  // 16-bit color.
+  uint32_t weighted_average = (19595 * cr) + (38470 * cg) + (7471 * cb) + 32768;
+  return (uint8_t)(weighted_average >> 24);
+}
+
+static inline uint16_t  //
+wuffs_base__color_u32_argb_premul__as__color_u16_gray(
+    wuffs_base__color_u32_argb_premul c) {
+  // Work in 16-bit color.
+  uint32_t cr = 0x101 * (0xFF & (c >> 16));
+  uint32_t cg = 0x101 * (0xFF & (c >> 8));
+  uint32_t cb = 0x101 * (0xFF & (c >> 0));
+
+  // These coefficients (the fractions 0.299, 0.587 and 0.114) are the same
+  // as those given by the JFIF specification.
+  //
+  // Note that 19595 + 38470 + 7471 equals 65536, also known as (1 << 16).
+  uint32_t weighted_average = (19595 * cr) + (38470 * cg) + (7471 * cb) + 32768;
+  return (uint16_t)(weighted_average >> 16);
+}
+
+// wuffs_base__color_u32_argb_nonpremul__as__color_u32_argb_premul converts
+// from non-premultiplied alpha to premultiplied alpha.
+static inline wuffs_base__color_u32_argb_premul  //
+wuffs_base__color_u32_argb_nonpremul__as__color_u32_argb_premul(
+    uint32_t argb_nonpremul) {
+  // Multiplying by 0x101 (twice, once for alpha and once for color) converts
+  // from 8-bit to 16-bit color. Shifting right by 8 undoes that.
+  //
+  // Working in the higher bit depth can produce slightly different (and
+  // arguably slightly more accurate) results. For example, given 8-bit blue
+  // and alpha of 0x80 and 0x81:
+  //
+  //  - ((0x80   * 0x81  ) / 0xFF  )      = 0x40        = 0x40
+  //  - ((0x8080 * 0x8181) / 0xFFFF) >> 8 = 0x4101 >> 8 = 0x41
+  uint32_t a = 0xFF & (argb_nonpremul >> 24);
+  uint32_t a16 = a * (0x101 * 0x101);
+
+  uint32_t r = 0xFF & (argb_nonpremul >> 16);
+  r = ((r * a16) / 0xFFFF) >> 8;
+  uint32_t g = 0xFF & (argb_nonpremul >> 8);
+  g = ((g * a16) / 0xFFFF) >> 8;
+  uint32_t b = 0xFF & (argb_nonpremul >> 0);
+  b = ((b * a16) / 0xFFFF) >> 8;
+
+  return (a << 24) | (r << 16) | (g << 8) | (b << 0);
+}
+
+// wuffs_base__color_u32_argb_premul__as__color_u32_argb_nonpremul converts
+// from premultiplied alpha to non-premultiplied alpha.
+static inline uint32_t  //
+wuffs_base__color_u32_argb_premul__as__color_u32_argb_nonpremul(
+    wuffs_base__color_u32_argb_premul c) {
+  uint32_t a = 0xFF & (c >> 24);
+  if (a == 0xFF) {
+    return c;
+  } else if (a == 0) {
+    return 0;
+  }
+  uint32_t a16 = a * 0x101;
+
+  uint32_t r = 0xFF & (c >> 16);
+  r = ((r * (0x101 * 0xFFFF)) / a16) >> 8;
+  uint32_t g = 0xFF & (c >> 8);
+  g = ((g * (0x101 * 0xFFFF)) / a16) >> 8;
+  uint32_t b = 0xFF & (c >> 0);
+  b = ((b * (0x101 * 0xFFFF)) / a16) >> 8;
+
+  return (a << 24) | (r << 16) | (g << 8) | (b << 0);
+}
+
+// wuffs_base__color_u64_argb_nonpremul__as__color_u32_argb_premul converts
+// from 4x16LE non-premultiplied alpha to 4x8 premultiplied alpha.
+static inline wuffs_base__color_u32_argb_premul  //
+wuffs_base__color_u64_argb_nonpremul__as__color_u32_argb_premul(
+    uint64_t argb_nonpremul) {
+  uint32_t a16 = ((uint32_t)(0xFFFF & (argb_nonpremul >> 48)));
+
+  uint32_t r16 = ((uint32_t)(0xFFFF & (argb_nonpremul >> 32)));
+  r16 = (r16 * a16) / 0xFFFF;
+  uint32_t g16 = ((uint32_t)(0xFFFF & (argb_nonpremul >> 16)));
+  g16 = (g16 * a16) / 0xFFFF;
+  uint32_t b16 = ((uint32_t)(0xFFFF & (argb_nonpremul >> 0)));
+  b16 = (b16 * a16) / 0xFFFF;
+
+  return ((a16 >> 8) << 24) | ((r16 >> 8) << 16) | ((g16 >> 8) << 8) |
+         ((b16 >> 8) << 0);
+}
+
+// wuffs_base__color_u32_argb_premul__as__color_u64_argb_nonpremul converts
+// from 4x8 premultiplied alpha to 4x16LE non-premultiplied alpha.
+static inline uint64_t  //
+wuffs_base__color_u32_argb_premul__as__color_u64_argb_nonpremul(
+    wuffs_base__color_u32_argb_premul c) {
+  uint32_t a = 0xFF & (c >> 24);
+  if (a == 0xFF) {
+    uint64_t r16 = 0x101 * (0xFF & (c >> 16));
+    uint64_t g16 = 0x101 * (0xFF & (c >> 8));
+    uint64_t b16 = 0x101 * (0xFF & (c >> 0));
+    return 0xFFFF000000000000u | (r16 << 32) | (g16 << 16) | (b16 << 0);
+  } else if (a == 0) {
+    return 0;
+  }
+  uint64_t a16 = a * 0x101;
+
+  uint64_t r = 0xFF & (c >> 16);
+  uint64_t r16 = (r * (0x101 * 0xFFFF)) / a16;
+  uint64_t g = 0xFF & (c >> 8);
+  uint64_t g16 = (g * (0x101 * 0xFFFF)) / a16;
+  uint64_t b = 0xFF & (c >> 0);
+  uint64_t b16 = (b * (0x101 * 0xFFFF)) / a16;
+
+  return (a16 << 48) | (r16 << 32) | (g16 << 16) | (b16 << 0);
+}
+
+static inline uint64_t  //
+wuffs_base__color_u32__as__color_u64(uint32_t c) {
+  uint64_t a16 = 0x101 * (0xFF & (c >> 24));
+  uint64_t r16 = 0x101 * (0xFF & (c >> 16));
+  uint64_t g16 = 0x101 * (0xFF & (c >> 8));
+  uint64_t b16 = 0x101 * (0xFF & (c >> 0));
+  return (a16 << 48) | (r16 << 32) | (g16 << 16) | (b16 << 0);
+}
+
+static inline uint32_t  //
+wuffs_base__color_u64__as__color_u32(uint64_t c) {
+  uint32_t a = ((uint32_t)(0xFF & (c >> 56)));
+  uint32_t r = ((uint32_t)(0xFF & (c >> 40)));
+  uint32_t g = ((uint32_t)(0xFF & (c >> 24)));
+  uint32_t b = ((uint32_t)(0xFF & (c >> 8)));
+  return (a << 24) | (r << 16) | (g << 8) | (b << 0);
+}
+
+// wuffs_base__color_ycc__as__color_u32 converts from YCbCr to 0xAARRGGBB. The
+// alpha bits are always 0xFF.
+static inline wuffs_base__color_u32_argb_premul  //
+wuffs_base__color_ycc__as__color_u32(uint8_t yy, uint8_t cb, uint8_t cr) {
+  // Work in 16.16 fixed point arithmetic (so that 'one half' is (1 << 15)) and
+  // bias the chroma values by 0x80.
+  uint32_t yy32 = (((uint32_t)yy) << 16) | (1 << 15);
+  uint32_t cb32 = (((uint32_t)cb) - 0x80);
+  uint32_t cr32 = (((uint32_t)cr) - 0x80);
+
+  // The formulae:
+  //
+  //  R = Y                + 1.40200 * Cr
+  //  G = Y - 0.34414 * Cb - 0.71414 * Cr
+  //  B = Y + 1.77200 * Cb
+  //
+  // When scaled by 1<<16:
+  //
+  //  0.34414 becomes 0x0581A =  22554.
+  //  0.71414 becomes 0x0B6D2 =  46802.
+  //  1.40200 becomes 0x166E9 =  91881.
+  //  1.77200 becomes 0x1C5A2 = 116130.
+  //
+  // Since we're working in 16.16 fixed point arithmetic, masking by 0x00FF0000
+  // (possibly followed by a shift) gives the relevant 8 bits per channel.
+  //
+  // However, we need to saturate for overflow (above 0x00FFFFFF, but not so
+  // high that the MSB Most Significant Bit is set) or for underflow (below
+  // 0x00000000 as int32_t, which means that the MSB is set as uint32_t). In
+  // both cases, some of the high 8 bits (bits 24 ..= 31) will be set.
+  //
+  // "((uint32_t)(((int32_t)x) >> 31))" just replicates x's MSB across all 32
+  // bits. Prepending that with "~" inverts those bits. Thus, "~(etc)" is
+  // either 0xFFFFFFFF (for overflow) or 0x00000000 (for underflow).
+  uint32_t rr32 = yy32 + (0x166E9 * cr32);
+  uint32_t gg32 = yy32 - (0x0581A * cb32) - (0x0B6D2 * cr32);
+  uint32_t bb32 = yy32 + (0x1C5A2 * cb32);
+  if (rr32 >> 24) {
+    rr32 = ~((uint32_t)(((int32_t)rr32) >> 31));
+  }
+  if (gg32 >> 24) {
+    gg32 = ~((uint32_t)(((int32_t)gg32) >> 31));
+  }
+  if (bb32 >> 24) {
+    bb32 = ~((uint32_t)(((int32_t)bb32) >> 31));
+  }
+  return 0xFF000000 |                  //
+         ((0x00FF0000 & rr32) >> 0) |  //
+         ((0x00FF0000 & gg32) >> 8) |  //
+         ((0x00FF0000 & bb32) >> 16);
+}
+
+// wuffs_base__color_ycc__as__color_u32_abgr is like
+// wuffs_base__color_ycc__as__color_u32 but the uint32_t returned is in
+// 0xAABBGGRR order, not 0xAARRGGBB.
+static inline uint32_t  //
+wuffs_base__color_ycc__as__color_u32_abgr(uint8_t yy, uint8_t cb, uint8_t cr) {
+  uint32_t yy32 = (((uint32_t)yy) << 16) | (1 << 15);
+  uint32_t cb32 = (((uint32_t)cb) - 0x80);
+  uint32_t cr32 = (((uint32_t)cr) - 0x80);
+  uint32_t rr32 = yy32 + (0x166E9 * cr32);
+  uint32_t gg32 = yy32 - (0x0581A * cb32) - (0x0B6D2 * cr32);
+  uint32_t bb32 = yy32 + (0x1C5A2 * cb32);
+  if (rr32 >> 24) {
+    rr32 = ~((uint32_t)(((int32_t)rr32) >> 31));
+  }
+  if (gg32 >> 24) {
+    gg32 = ~((uint32_t)(((int32_t)gg32) >> 31));
+  }
+  if (bb32 >> 24) {
+    bb32 = ~((uint32_t)(((int32_t)bb32) >> 31));
+  }
+  return 0xFF000000 |                  //
+         ((0x00FF0000 & bb32) >> 0) |  //
+         ((0x00FF0000 & gg32) >> 8) |  //
+         ((0x00FF0000 & rr32) >> 16);
+}
+
+// --------
+
+typedef uint8_t wuffs_base__pixel_blend;
+
+// wuffs_base__pixel_blend encodes how to blend source and destination pixels,
+// accounting for transparency. It encompasses the Porter-Duff compositing
+// operators as well as the other blending modes defined by PDF.
+//
+// TODO: implement the other modes.
+#define WUFFS_BASE__PIXEL_BLEND__SRC ((wuffs_base__pixel_blend)0)
+#define WUFFS_BASE__PIXEL_BLEND__SRC_OVER ((wuffs_base__pixel_blend)1)
+
+// --------
+
+// wuffs_base__pixel_alpha_transparency is a pixel format's alpha channel
+// model. It is a property of the pixel format in general, not of a specific
+// pixel. An RGBA pixel format (with alpha) can still have fully opaque pixels.
+typedef uint32_t wuffs_base__pixel_alpha_transparency;
+
+#define WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__OPAQUE 0
+#define WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__NONPREMULTIPLIED_ALPHA 1
+#define WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__PREMULTIPLIED_ALPHA 2
+#define WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__BINARY_ALPHA 3
+
+// --------
+
+// Deprecated: use WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX_INCL.
+#define WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX 4
+
+#define WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX_INCL 4
+
+#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__INDEX_PLANE 0
+#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE 3
+
+// A palette is 256 entries × 4 bytes per entry (e.g. BGRA).
+#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH 1024
+
+// wuffs_base__pixel_format encodes the format of the bytes that constitute an
+// image frame's pixel data.
+//
+// See https://github.com/google/wuffs/blob/main/doc/note/pixel-formats.md
+//
+// Do not manipulate its bits directly; they are private implementation
+// details. Use methods such as wuffs_base__pixel_format__num_planes instead.
+typedef struct wuffs_base__pixel_format__struct {
+  uint32_t repr;
+
+#ifdef __cplusplus
+  inline bool is_valid() const;
+  inline uint32_t bits_per_pixel() const;
+  inline bool is_direct() const;
+  inline bool is_indexed() const;
+  inline bool is_interleaved() const;
+  inline bool is_planar() const;
+  inline uint32_t num_planes() const;
+  inline wuffs_base__pixel_alpha_transparency transparency() const;
+#endif  // __cplusplus
+
+} wuffs_base__pixel_format;
+
+static inline wuffs_base__pixel_format  //
+wuffs_base__make_pixel_format(uint32_t repr) {
+  wuffs_base__pixel_format f;
+  f.repr = repr;
+  return f;
+}
+
+// Common 8-bit-depth pixel formats. This list is not exhaustive; not all valid
+// wuffs_base__pixel_format values are present.
+
+#define WUFFS_BASE__PIXEL_FORMAT__INVALID 0x00000000
+
+#define WUFFS_BASE__PIXEL_FORMAT__A 0x02000008
+
+#define WUFFS_BASE__PIXEL_FORMAT__Y 0x20000008
+#define WUFFS_BASE__PIXEL_FORMAT__Y_16LE 0x2000000B
+#define WUFFS_BASE__PIXEL_FORMAT__Y_16BE 0x2010000B
+#define WUFFS_BASE__PIXEL_FORMAT__YA_NONPREMUL 0x21000008
+#define WUFFS_BASE__PIXEL_FORMAT__YA_PREMUL 0x22000008
+
+#define WUFFS_BASE__PIXEL_FORMAT__YCBCR 0x40020888
+#define WUFFS_BASE__PIXEL_FORMAT__YCBCRA_NONPREMUL 0x41038888
+#define WUFFS_BASE__PIXEL_FORMAT__YCBCRK 0x50038888
+
+#define WUFFS_BASE__PIXEL_FORMAT__YCOCG 0x60020888
+#define WUFFS_BASE__PIXEL_FORMAT__YCOCGA_NONPREMUL 0x61038888
+#define WUFFS_BASE__PIXEL_FORMAT__YCOCGK 0x70038888
+
+#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_NONPREMUL 0x81040008
+#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_PREMUL 0x82040008
+#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY 0x83040008
+
+#define WUFFS_BASE__PIXEL_FORMAT__BGR_565 0x80000565
+#define WUFFS_BASE__PIXEL_FORMAT__BGR 0x80000888
+#define WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL 0x81008888
+#define WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE 0x8100BBBB
+#define WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL 0x82008888
+#define WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL_4X16LE 0x8200BBBB
+#define WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY 0x83008888
+#define WUFFS_BASE__PIXEL_FORMAT__BGRX 0x90008888
+
+#define WUFFS_BASE__PIXEL_FORMAT__RGB 0xA0000888
+#define WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL 0xA1008888
+#define WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL_4X16LE 0xA100BBBB
+#define WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL 0xA2008888
+#define WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL_4X16LE 0xA200BBBB
+#define WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY 0xA3008888
+#define WUFFS_BASE__PIXEL_FORMAT__RGBX 0xB0008888
+
+#define WUFFS_BASE__PIXEL_FORMAT__CMY 0xC0020888
+#define WUFFS_BASE__PIXEL_FORMAT__CMYK 0xD0038888
+
+extern const uint32_t wuffs_base__pixel_format__bits_per_channel[16];
+
+static inline bool  //
+wuffs_base__pixel_format__is_valid(const wuffs_base__pixel_format* f) {
+  return f->repr != 0;
+}
+
+// wuffs_base__pixel_format__bits_per_pixel returns the number of bits per
+// pixel for interleaved pixel formats, and returns 0 for planar pixel formats.
+static inline uint32_t  //
+wuffs_base__pixel_format__bits_per_pixel(const wuffs_base__pixel_format* f) {
+  if (((f->repr >> 16) & 0x03) != 0) {
+    return 0;
+  }
+  return wuffs_base__pixel_format__bits_per_channel[0x0F & (f->repr >> 0)] +
+         wuffs_base__pixel_format__bits_per_channel[0x0F & (f->repr >> 4)] +
+         wuffs_base__pixel_format__bits_per_channel[0x0F & (f->repr >> 8)] +
+         wuffs_base__pixel_format__bits_per_channel[0x0F & (f->repr >> 12)];
+}
+
+static inline bool  //
+wuffs_base__pixel_format__is_direct(const wuffs_base__pixel_format* f) {
+  return ((f->repr >> 18) & 0x01) == 0;
+}
+
+static inline bool  //
+wuffs_base__pixel_format__is_indexed(const wuffs_base__pixel_format* f) {
+  return ((f->repr >> 18) & 0x01) != 0;
+}
+
+static inline bool  //
+wuffs_base__pixel_format__is_interleaved(const wuffs_base__pixel_format* f) {
+  return ((f->repr >> 16) & 0x03) == 0;
+}
+
+static inline bool  //
+wuffs_base__pixel_format__is_planar(const wuffs_base__pixel_format* f) {
+  return ((f->repr >> 16) & 0x03) != 0;
+}
+
+static inline uint32_t  //
+wuffs_base__pixel_format__num_planes(const wuffs_base__pixel_format* f) {
+  return ((f->repr >> 16) & 0x03) + 1;
+}
+
+static inline wuffs_base__pixel_alpha_transparency  //
+wuffs_base__pixel_format__transparency(const wuffs_base__pixel_format* f) {
+  return (wuffs_base__pixel_alpha_transparency)((f->repr >> 24) & 0x03);
+}
+
+#ifdef __cplusplus
+
+inline bool  //
+wuffs_base__pixel_format::is_valid() const {
+  return wuffs_base__pixel_format__is_valid(this);
+}
+
+inline uint32_t  //
+wuffs_base__pixel_format::bits_per_pixel() const {
+  return wuffs_base__pixel_format__bits_per_pixel(this);
+}
+
+inline bool  //
+wuffs_base__pixel_format::is_direct() const {
+  return wuffs_base__pixel_format__is_direct(this);
+}
+
+inline bool  //
+wuffs_base__pixel_format::is_indexed() const {
+  return wuffs_base__pixel_format__is_indexed(this);
+}
+
+inline bool  //
+wuffs_base__pixel_format::is_interleaved() const {
+  return wuffs_base__pixel_format__is_interleaved(this);
+}
+
+inline bool  //
+wuffs_base__pixel_format::is_planar() const {
+  return wuffs_base__pixel_format__is_planar(this);
+}
+
+inline uint32_t  //
+wuffs_base__pixel_format::num_planes() const {
+  return wuffs_base__pixel_format__num_planes(this);
+}
+
+inline wuffs_base__pixel_alpha_transparency  //
+wuffs_base__pixel_format::transparency() const {
+  return wuffs_base__pixel_format__transparency(this);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+// wuffs_base__pixel_subsampling encodes whether sample values cover one pixel
+// or cover multiple pixels.
+//
+// See https://github.com/google/wuffs/blob/main/doc/note/pixel-subsampling.md
+//
+// Do not manipulate its bits directly; they are private implementation
+// details. Use methods such as wuffs_base__pixel_subsampling__bias_x instead.
+typedef struct wuffs_base__pixel_subsampling__struct {
+  uint32_t repr;
+
+#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
+
+} 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->repr >> shift) & 0x03;
+}
+
+static inline uint32_t  //
+wuffs_base__pixel_subsampling__denominator_x(
+    const wuffs_base__pixel_subsampling* s,
+    uint32_t plane) {
+  uint32_t shift = ((plane & 0x03) * 8) + 4;
+  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->repr >> shift) & 0x03;
+}
+
+static inline uint32_t  //
+wuffs_base__pixel_subsampling__denominator_y(
+    const wuffs_base__pixel_subsampling* s,
+    uint32_t plane) {
+  uint32_t shift = ((plane & 0x03) * 8) + 0;
+  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 wuffs_base__pixel_config__struct {
+  // Do not access the private_impl's fields directly. There is no API/ABI
+  // compatibility or safety guarantee if you do so.
+  struct {
+    wuffs_base__pixel_format pixfmt;
+    wuffs_base__pixel_subsampling pixsub;
+    uint32_t width;
+    uint32_t height;
+  } private_impl;
+
+#ifdef __cplusplus
+  inline void set(uint32_t pixfmt_repr,
+                  uint32_t pixsub_repr,
+                  uint32_t width,
+                  uint32_t height);
+  inline void invalidate();
+  inline bool is_valid() const;
+  inline wuffs_base__pixel_format pixel_format() const;
+  inline wuffs_base__pixel_subsampling pixel_subsampling() const;
+  inline wuffs_base__rect_ie_u32 bounds() const;
+  inline uint32_t width() const;
+  inline uint32_t height() const;
+  inline uint64_t pixbuf_len() const;
+#endif  // __cplusplus
+
+} wuffs_base__pixel_config;
+
+static inline wuffs_base__pixel_config  //
+wuffs_base__null_pixel_config() {
+  wuffs_base__pixel_config ret;
+  ret.private_impl.pixfmt.repr = 0;
+  ret.private_impl.pixsub.repr = 0;
+  ret.private_impl.width = 0;
+  ret.private_impl.height = 0;
+  return ret;
+}
+
+// TODO: Should this function return bool? An error type?
+static inline void  //
+wuffs_base__pixel_config__set(wuffs_base__pixel_config* c,
+                              uint32_t pixfmt_repr,
+                              uint32_t pixsub_repr,
+                              uint32_t width,
+                              uint32_t height) {
+  if (!c) {
+    return;
+  }
+  if (pixfmt_repr) {
+    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.repr = pixfmt_repr;
+      c->private_impl.pixsub.repr = pixsub_repr;
+      c->private_impl.width = width;
+      c->private_impl.height = height;
+      return;
+    }
+  }
+
+  c->private_impl.pixfmt.repr = 0;
+  c->private_impl.pixsub.repr = 0;
+  c->private_impl.width = 0;
+  c->private_impl.height = 0;
+}
+
+static inline void  //
+wuffs_base__pixel_config__invalidate(wuffs_base__pixel_config* c) {
+  if (c) {
+    c->private_impl.pixfmt.repr = 0;
+    c->private_impl.pixsub.repr = 0;
+    c->private_impl.width = 0;
+    c->private_impl.height = 0;
+  }
+}
+
+static inline bool  //
+wuffs_base__pixel_config__is_valid(const wuffs_base__pixel_config* c) {
+  return c && c->private_impl.pixfmt.repr;
+}
+
+static inline wuffs_base__pixel_format  //
+wuffs_base__pixel_config__pixel_format(const wuffs_base__pixel_config* c) {
+  return c ? c->private_impl.pixfmt : wuffs_base__make_pixel_format(0);
+}
+
+static inline wuffs_base__pixel_subsampling  //
+wuffs_base__pixel_config__pixel_subsampling(const wuffs_base__pixel_config* c) {
+  return c ? c->private_impl.pixsub : wuffs_base__make_pixel_subsampling(0);
+}
+
+static inline wuffs_base__rect_ie_u32  //
+wuffs_base__pixel_config__bounds(const wuffs_base__pixel_config* c) {
+  if (c) {
+    wuffs_base__rect_ie_u32 ret;
+    ret.min_incl_x = 0;
+    ret.min_incl_y = 0;
+    ret.max_excl_x = c->private_impl.width;
+    ret.max_excl_y = c->private_impl.height;
+    return ret;
+  }
+
+  wuffs_base__rect_ie_u32 ret;
+  ret.min_incl_x = 0;
+  ret.min_incl_y = 0;
+  ret.max_excl_x = 0;
+  ret.max_excl_y = 0;
+  return ret;
+}
+
+static inline uint32_t  //
+wuffs_base__pixel_config__width(const wuffs_base__pixel_config* c) {
+  return c ? c->private_impl.width : 0;
+}
+
+static inline uint32_t  //
+wuffs_base__pixel_config__height(const wuffs_base__pixel_config* c) {
+  return c ? c->private_impl.height : 0;
+}
+
+// TODO: this is the right API for planar (not interleaved) pixbufs? Should it
+// allow decoding into a color model different from the format's intrinsic one?
+// For example, decoding a JPEG image straight to RGBA instead of to YCbCr?
+static inline uint64_t  //
+wuffs_base__pixel_config__pixbuf_len(const wuffs_base__pixel_config* c) {
+  if (!c) {
+    return 0;
+  }
+  if (wuffs_base__pixel_format__is_planar(&c->private_impl.pixfmt)) {
+    // TODO: support planar pixel formats, concious of pixel subsampling.
+    return 0;
+  }
+  uint32_t bits_per_pixel =
+      wuffs_base__pixel_format__bits_per_pixel(&c->private_impl.pixfmt);
+  if ((bits_per_pixel == 0) || ((bits_per_pixel % 8) != 0)) {
+    // TODO: support fraction-of-byte pixels, e.g. 1 bit per pixel?
+    return 0;
+  }
+  uint64_t bytes_per_pixel = bits_per_pixel / 8;
+
+  uint64_t n =
+      ((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);
+  if (n > (UINT64_MAX / bytes_per_pixel)) {
+    return 0;
+  }
+  n *= bytes_per_pixel;
+
+  if (wuffs_base__pixel_format__is_indexed(&c->private_impl.pixfmt)) {
+    if (n >
+        (UINT64_MAX - WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH)) {
+      return 0;
+    }
+    n += WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;
+  }
+
+  return n;
+}
+
+#ifdef __cplusplus
+
+inline void  //
+wuffs_base__pixel_config::set(uint32_t pixfmt_repr,
+                              uint32_t pixsub_repr,
+                              uint32_t width,
+                              uint32_t height) {
+  wuffs_base__pixel_config__set(this, pixfmt_repr, pixsub_repr, width, height);
+}
+
+inline void  //
+wuffs_base__pixel_config::invalidate() {
+  wuffs_base__pixel_config__invalidate(this);
+}
+
+inline bool  //
+wuffs_base__pixel_config::is_valid() const {
+  return wuffs_base__pixel_config__is_valid(this);
+}
+
+inline wuffs_base__pixel_format  //
+wuffs_base__pixel_config::pixel_format() const {
+  return wuffs_base__pixel_config__pixel_format(this);
+}
+
+inline wuffs_base__pixel_subsampling  //
+wuffs_base__pixel_config::pixel_subsampling() const {
+  return wuffs_base__pixel_config__pixel_subsampling(this);
+}
+
+inline wuffs_base__rect_ie_u32  //
+wuffs_base__pixel_config::bounds() const {
+  return wuffs_base__pixel_config__bounds(this);
+}
+
+inline uint32_t  //
+wuffs_base__pixel_config::width() const {
+  return wuffs_base__pixel_config__width(this);
+}
+
+inline uint32_t  //
+wuffs_base__pixel_config::height() const {
+  return wuffs_base__pixel_config__height(this);
+}
+
+inline uint64_t  //
+wuffs_base__pixel_config::pixbuf_len() const {
+  return wuffs_base__pixel_config__pixbuf_len(this);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+typedef struct wuffs_base__image_config__struct {
+  wuffs_base__pixel_config pixcfg;
+
+  // Do not access the private_impl's fields directly. There is no API/ABI
+  // compatibility or safety guarantee if you do so.
+  struct {
+    uint64_t first_frame_io_position;
+    bool first_frame_is_opaque;
+  } private_impl;
+
+#ifdef __cplusplus
+  inline void set(uint32_t pixfmt_repr,
+                  uint32_t pixsub_repr,
+                  uint32_t width,
+                  uint32_t height,
+                  uint64_t first_frame_io_position,
+                  bool first_frame_is_opaque);
+  inline void invalidate();
+  inline bool is_valid() const;
+  inline uint64_t first_frame_io_position() const;
+  inline bool first_frame_is_opaque() const;
+#endif  // __cplusplus
+
+} wuffs_base__image_config;
+
+static inline wuffs_base__image_config  //
+wuffs_base__null_image_config() {
+  wuffs_base__image_config ret;
+  ret.pixcfg = wuffs_base__null_pixel_config();
+  ret.private_impl.first_frame_io_position = 0;
+  ret.private_impl.first_frame_is_opaque = false;
+  return ret;
+}
+
+// TODO: Should this function return bool? An error type?
+static inline void  //
+wuffs_base__image_config__set(wuffs_base__image_config* c,
+                              uint32_t pixfmt_repr,
+                              uint32_t pixsub_repr,
+                              uint32_t width,
+                              uint32_t height,
+                              uint64_t first_frame_io_position,
+                              bool first_frame_is_opaque) {
+  if (!c) {
+    return;
+  }
+  if (pixfmt_repr) {
+    c->pixcfg.private_impl.pixfmt.repr = pixfmt_repr;
+    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;
+    c->private_impl.first_frame_is_opaque = first_frame_is_opaque;
+    return;
+  }
+
+  c->pixcfg.private_impl.pixfmt.repr = 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;
+  c->private_impl.first_frame_is_opaque = 0;
+}
+
+static inline void  //
+wuffs_base__image_config__invalidate(wuffs_base__image_config* c) {
+  if (c) {
+    c->pixcfg.private_impl.pixfmt.repr = 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;
+    c->private_impl.first_frame_is_opaque = 0;
+  }
+}
+
+static inline bool  //
+wuffs_base__image_config__is_valid(const wuffs_base__image_config* c) {
+  return c && wuffs_base__pixel_config__is_valid(&(c->pixcfg));
+}
+
+static inline uint64_t  //
+wuffs_base__image_config__first_frame_io_position(
+    const wuffs_base__image_config* c) {
+  return c ? c->private_impl.first_frame_io_position : 0;
+}
+
+static inline bool  //
+wuffs_base__image_config__first_frame_is_opaque(
+    const wuffs_base__image_config* c) {
+  return c ? c->private_impl.first_frame_is_opaque : false;
+}
+
+#ifdef __cplusplus
+
+inline void  //
+wuffs_base__image_config::set(uint32_t pixfmt_repr,
+                              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_repr, width, height,
+                                first_frame_io_position, first_frame_is_opaque);
+}
+
+inline void  //
+wuffs_base__image_config::invalidate() {
+  wuffs_base__image_config__invalidate(this);
+}
+
+inline bool  //
+wuffs_base__image_config::is_valid() const {
+  return wuffs_base__image_config__is_valid(this);
+}
+
+inline uint64_t  //
+wuffs_base__image_config::first_frame_io_position() const {
+  return wuffs_base__image_config__first_frame_io_position(this);
+}
+
+inline bool  //
+wuffs_base__image_config::first_frame_is_opaque() const {
+  return wuffs_base__image_config__first_frame_is_opaque(this);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+// wuffs_base__animation_disposal encodes, for an animated image, how to
+// dispose of a frame after displaying it:
+//  - None means to draw the next frame on top of this one.
+//  - Restore Background means to clear the frame's dirty rectangle to "the
+//    background color" (in practice, this means transparent black) before
+//    drawing the next frame.
+//  - Restore Previous means to undo the current frame, so that the next frame
+//    is drawn on top of the previous one.
+typedef uint8_t wuffs_base__animation_disposal;
+
+#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)
+#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \
+  ((wuffs_base__animation_disposal)1)
+#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \
+  ((wuffs_base__animation_disposal)2)
+
+// --------
+
+typedef struct wuffs_base__frame_config__struct {
+  // Do not access the private_impl's fields directly. There is no API/ABI
+  // compatibility or safety guarantee if you do so.
+  struct {
+    wuffs_base__rect_ie_u32 bounds;
+    wuffs_base__flicks duration;
+    uint64_t index;
+    uint64_t io_position;
+    wuffs_base__animation_disposal disposal;
+    bool opaque_within_bounds;
+    bool overwrite_instead_of_blend;
+    wuffs_base__color_u32_argb_premul background_color;
+  } private_impl;
+
+#ifdef __cplusplus
+  inline void set(wuffs_base__rect_ie_u32 bounds,
+                  wuffs_base__flicks duration,
+                  uint64_t index,
+                  uint64_t io_position,
+                  wuffs_base__animation_disposal disposal,
+                  bool opaque_within_bounds,
+                  bool overwrite_instead_of_blend,
+                  wuffs_base__color_u32_argb_premul background_color);
+  inline wuffs_base__rect_ie_u32 bounds() const;
+  inline uint32_t width() const;
+  inline uint32_t height() const;
+  inline wuffs_base__flicks duration() const;
+  inline uint64_t index() const;
+  inline uint64_t io_position() const;
+  inline wuffs_base__animation_disposal disposal() const;
+  inline bool opaque_within_bounds() const;
+  inline bool overwrite_instead_of_blend() const;
+  inline wuffs_base__color_u32_argb_premul background_color() const;
+#endif  // __cplusplus
+
+} wuffs_base__frame_config;
+
+static inline wuffs_base__frame_config  //
+wuffs_base__null_frame_config() {
+  wuffs_base__frame_config ret;
+  ret.private_impl.bounds = wuffs_base__make_rect_ie_u32(0, 0, 0, 0);
+  ret.private_impl.duration = 0;
+  ret.private_impl.index = 0;
+  ret.private_impl.io_position = 0;
+  ret.private_impl.disposal = 0;
+  ret.private_impl.opaque_within_bounds = false;
+  ret.private_impl.overwrite_instead_of_blend = false;
+  return ret;
+}
+
+static inline void  //
+wuffs_base__frame_config__set(
+    wuffs_base__frame_config* c,
+    wuffs_base__rect_ie_u32 bounds,
+    wuffs_base__flicks duration,
+    uint64_t index,
+    uint64_t io_position,
+    wuffs_base__animation_disposal disposal,
+    bool opaque_within_bounds,
+    bool overwrite_instead_of_blend,
+    wuffs_base__color_u32_argb_premul background_color) {
+  if (!c) {
+    return;
+  }
+
+  c->private_impl.bounds = bounds;
+  c->private_impl.duration = duration;
+  c->private_impl.index = index;
+  c->private_impl.io_position = io_position;
+  c->private_impl.disposal = disposal;
+  c->private_impl.opaque_within_bounds = opaque_within_bounds;
+  c->private_impl.overwrite_instead_of_blend = overwrite_instead_of_blend;
+  c->private_impl.background_color = background_color;
+}
+
+static inline wuffs_base__rect_ie_u32  //
+wuffs_base__frame_config__bounds(const wuffs_base__frame_config* c) {
+  if (c) {
+    return c->private_impl.bounds;
+  }
+
+  wuffs_base__rect_ie_u32 ret;
+  ret.min_incl_x = 0;
+  ret.min_incl_y = 0;
+  ret.max_excl_x = 0;
+  ret.max_excl_y = 0;
+  return ret;
+}
+
+static inline uint32_t  //
+wuffs_base__frame_config__width(const wuffs_base__frame_config* c) {
+  return c ? wuffs_base__rect_ie_u32__width(&c->private_impl.bounds) : 0;
+}
+
+static inline uint32_t  //
+wuffs_base__frame_config__height(const wuffs_base__frame_config* c) {
+  return c ? wuffs_base__rect_ie_u32__height(&c->private_impl.bounds) : 0;
+}
+
+// wuffs_base__frame_config__duration returns the amount of time to display
+// this frame. Zero means to display forever - a still (non-animated) image.
+static inline wuffs_base__flicks  //
+wuffs_base__frame_config__duration(const wuffs_base__frame_config* c) {
+  return c ? c->private_impl.duration : 0;
+}
+
+// wuffs_base__frame_config__index returns the index of this frame. The first
+// frame in an image has index 0, the second frame has index 1, and so on.
+static inline uint64_t  //
+wuffs_base__frame_config__index(const wuffs_base__frame_config* c) {
+  return c ? c->private_impl.index : 0;
+}
+
+// wuffs_base__frame_config__io_position returns the I/O stream position before
+// the frame config.
+static inline uint64_t  //
+wuffs_base__frame_config__io_position(const wuffs_base__frame_config* c) {
+  return c ? c->private_impl.io_position : 0;
+}
+
+// wuffs_base__frame_config__disposal returns, for an animated image, how to
+// dispose of this frame after displaying it.
+static inline wuffs_base__animation_disposal  //
+wuffs_base__frame_config__disposal(const wuffs_base__frame_config* c) {
+  return c ? c->private_impl.disposal : 0;
+}
+
+// wuffs_base__frame_config__opaque_within_bounds returns whether all pixels
+// within the frame's bounds are fully opaque. It makes no claim about pixels
+// outside the frame bounds but still inside the overall image. The two
+// bounding rectangles can differ for animated images.
+//
+// Its semantics are conservative. It is valid for a fully opaque frame to have
+// this value be false: a false negative.
+//
+// If true, drawing the frame with WUFFS_BASE__PIXEL_BLEND__SRC and
+// WUFFS_BASE__PIXEL_BLEND__SRC_OVER should be equivalent, in terms of
+// resultant pixels, but the former may be faster.
+static inline bool  //
+wuffs_base__frame_config__opaque_within_bounds(
+    const wuffs_base__frame_config* c) {
+  return c && c->private_impl.opaque_within_bounds;
+}
+
+// wuffs_base__frame_config__overwrite_instead_of_blend returns, for an
+// animated image, whether to ignore the previous image state (within the frame
+// bounds) when drawing this incremental frame. Equivalently, whether to use
+// WUFFS_BASE__PIXEL_BLEND__SRC instead of WUFFS_BASE__PIXEL_BLEND__SRC_OVER.
+//
+// The WebP spec (https://developers.google.com/speed/webp/docs/riff_container)
+// calls this the "Blending method" bit. WebP's "Do not blend" corresponds to
+// Wuffs' "overwrite_instead_of_blend".
+static inline bool  //
+wuffs_base__frame_config__overwrite_instead_of_blend(
+    const wuffs_base__frame_config* c) {
+  return c && c->private_impl.overwrite_instead_of_blend;
+}
+
+static inline wuffs_base__color_u32_argb_premul  //
+wuffs_base__frame_config__background_color(const wuffs_base__frame_config* c) {
+  return c ? c->private_impl.background_color : 0;
+}
+
+#ifdef __cplusplus
+
+inline void  //
+wuffs_base__frame_config::set(
+    wuffs_base__rect_ie_u32 bounds,
+    wuffs_base__flicks duration,
+    uint64_t index,
+    uint64_t io_position,
+    wuffs_base__animation_disposal disposal,
+    bool opaque_within_bounds,
+    bool overwrite_instead_of_blend,
+    wuffs_base__color_u32_argb_premul background_color) {
+  wuffs_base__frame_config__set(this, bounds, duration, index, io_position,
+                                disposal, opaque_within_bounds,
+                                overwrite_instead_of_blend, background_color);
+}
+
+inline wuffs_base__rect_ie_u32  //
+wuffs_base__frame_config::bounds() const {
+  return wuffs_base__frame_config__bounds(this);
+}
+
+inline uint32_t  //
+wuffs_base__frame_config::width() const {
+  return wuffs_base__frame_config__width(this);
+}
+
+inline uint32_t  //
+wuffs_base__frame_config::height() const {
+  return wuffs_base__frame_config__height(this);
+}
+
+inline wuffs_base__flicks  //
+wuffs_base__frame_config::duration() const {
+  return wuffs_base__frame_config__duration(this);
+}
+
+inline uint64_t  //
+wuffs_base__frame_config::index() const {
+  return wuffs_base__frame_config__index(this);
+}
+
+inline uint64_t  //
+wuffs_base__frame_config::io_position() const {
+  return wuffs_base__frame_config__io_position(this);
+}
+
+inline wuffs_base__animation_disposal  //
+wuffs_base__frame_config::disposal() const {
+  return wuffs_base__frame_config__disposal(this);
+}
+
+inline bool  //
+wuffs_base__frame_config::opaque_within_bounds() const {
+  return wuffs_base__frame_config__opaque_within_bounds(this);
+}
+
+inline bool  //
+wuffs_base__frame_config::overwrite_instead_of_blend() const {
+  return wuffs_base__frame_config__overwrite_instead_of_blend(this);
+}
+
+inline wuffs_base__color_u32_argb_premul  //
+wuffs_base__frame_config::background_color() const {
+  return wuffs_base__frame_config__background_color(this);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+typedef struct wuffs_base__pixel_buffer__struct {
+  wuffs_base__pixel_config pixcfg;
+
+  // Do not access the private_impl's fields directly. There is no API/ABI
+  // compatibility or safety guarantee if you do so.
+  struct {
+    wuffs_base__table_u8 planes[WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX_INCL];
+    // TODO: color spaces.
+  } private_impl;
+
+#ifdef __cplusplus
+  inline wuffs_base__status set_interleaved(
+      const wuffs_base__pixel_config* pixcfg,
+      wuffs_base__table_u8 primary_memory,
+      wuffs_base__slice_u8 palette_memory);
+  inline wuffs_base__status set_from_slice(
+      const wuffs_base__pixel_config* pixcfg,
+      wuffs_base__slice_u8 pixbuf_memory);
+  inline wuffs_base__slice_u8 palette();
+  inline wuffs_base__slice_u8 palette_or_else(wuffs_base__slice_u8 fallback);
+  inline wuffs_base__pixel_format pixel_format() const;
+  inline wuffs_base__table_u8 plane(uint32_t p);
+  inline wuffs_base__color_u32_argb_premul color_u32_at(uint32_t x,
+                                                        uint32_t y) const;
+  inline wuffs_base__status set_color_u32_at(
+      uint32_t x,
+      uint32_t y,
+      wuffs_base__color_u32_argb_premul color);
+  inline wuffs_base__status set_color_u32_fill_rect(
+      wuffs_base__rect_ie_u32 rect,
+      wuffs_base__color_u32_argb_premul color);
+#endif  // __cplusplus
+
+} wuffs_base__pixel_buffer;
+
+static inline wuffs_base__pixel_buffer  //
+wuffs_base__null_pixel_buffer() {
+  wuffs_base__pixel_buffer ret;
+  ret.pixcfg = wuffs_base__null_pixel_config();
+  ret.private_impl.planes[0] = wuffs_base__empty_table_u8();
+  ret.private_impl.planes[1] = wuffs_base__empty_table_u8();
+  ret.private_impl.planes[2] = wuffs_base__empty_table_u8();
+  ret.private_impl.planes[3] = wuffs_base__empty_table_u8();
+  return ret;
+}
+
+static inline wuffs_base__status  //
+wuffs_base__pixel_buffer__set_interleaved(
+    wuffs_base__pixel_buffer* pb,
+    const wuffs_base__pixel_config* pixcfg,
+    wuffs_base__table_u8 primary_memory,
+    wuffs_base__slice_u8 palette_memory) {
+  if (!pb) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  memset(pb, 0, sizeof(*pb));
+  if (!pixcfg ||
+      wuffs_base__pixel_format__is_planar(&pixcfg->private_impl.pixfmt)) {
+    return wuffs_base__make_status(wuffs_base__error__bad_argument);
+  }
+  if (wuffs_base__pixel_format__is_indexed(&pixcfg->private_impl.pixfmt) &&
+      (palette_memory.len <
+       WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH)) {
+    return wuffs_base__make_status(
+        wuffs_base__error__bad_argument_length_too_short);
+  }
+  uint32_t bits_per_pixel =
+      wuffs_base__pixel_format__bits_per_pixel(&pixcfg->private_impl.pixfmt);
+  if ((bits_per_pixel == 0) || ((bits_per_pixel % 8) != 0)) {
+    // TODO: support fraction-of-byte pixels, e.g. 1 bit per pixel?
+    return wuffs_base__make_status(wuffs_base__error__unsupported_option);
+  }
+  uint64_t bytes_per_pixel = bits_per_pixel / 8;
+
+  uint64_t width_in_bytes =
+      ((uint64_t)pixcfg->private_impl.width) * bytes_per_pixel;
+  if ((width_in_bytes > primary_memory.width) ||
+      (pixcfg->private_impl.height > primary_memory.height)) {
+    return wuffs_base__make_status(wuffs_base__error__bad_argument);
+  }
+
+  pb->pixcfg = *pixcfg;
+  pb->private_impl.planes[0] = primary_memory;
+  if (wuffs_base__pixel_format__is_indexed(&pixcfg->private_impl.pixfmt)) {
+    wuffs_base__table_u8* tab =
+        &pb->private_impl
+             .planes[WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE];
+    tab->ptr = palette_memory.ptr;
+    tab->width = WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;
+    tab->height = 1;
+    tab->stride = WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;
+  }
+  return wuffs_base__make_status(NULL);
+}
+
+static inline wuffs_base__status  //
+wuffs_base__pixel_buffer__set_from_slice(wuffs_base__pixel_buffer* pb,
+                                         const wuffs_base__pixel_config* pixcfg,
+                                         wuffs_base__slice_u8 pixbuf_memory) {
+  if (!pb) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  memset(pb, 0, sizeof(*pb));
+  if (!pixcfg) {
+    return wuffs_base__make_status(wuffs_base__error__bad_argument);
+  }
+  if (wuffs_base__pixel_format__is_planar(&pixcfg->private_impl.pixfmt)) {
+    // TODO: support planar pixel formats, concious of pixel subsampling.
+    return wuffs_base__make_status(wuffs_base__error__unsupported_option);
+  }
+  uint32_t bits_per_pixel =
+      wuffs_base__pixel_format__bits_per_pixel(&pixcfg->private_impl.pixfmt);
+  if ((bits_per_pixel == 0) || ((bits_per_pixel % 8) != 0)) {
+    // TODO: support fraction-of-byte pixels, e.g. 1 bit per pixel?
+    return wuffs_base__make_status(wuffs_base__error__unsupported_option);
+  }
+  uint64_t bytes_per_pixel = bits_per_pixel / 8;
+
+  uint8_t* ptr = pixbuf_memory.ptr;
+  uint64_t len = pixbuf_memory.len;
+  if (wuffs_base__pixel_format__is_indexed(&pixcfg->private_impl.pixfmt)) {
+    // Split a WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH byte
+    // chunk (1024 bytes = 256 palette entries × 4 bytes per entry) from the
+    // start of pixbuf_memory. We split from the start, not the end, so that
+    // the both chunks' pointers have the same alignment as the original
+    // pointer, up to an alignment of 1024.
+    if (len < WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH) {
+      return wuffs_base__make_status(
+          wuffs_base__error__bad_argument_length_too_short);
+    }
+    wuffs_base__table_u8* tab =
+        &pb->private_impl
+             .planes[WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE];
+    tab->ptr = ptr;
+    tab->width = WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;
+    tab->height = 1;
+    tab->stride = WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;
+    ptr += WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;
+    len -= WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;
+  }
+
+  uint64_t wh = ((uint64_t)pixcfg->private_impl.width) *
+                ((uint64_t)pixcfg->private_impl.height);
+  size_t width = (size_t)(pixcfg->private_impl.width);
+  if ((wh > (UINT64_MAX / bytes_per_pixel)) ||
+      (width > (SIZE_MAX / bytes_per_pixel))) {
+    return wuffs_base__make_status(wuffs_base__error__bad_argument);
+  }
+  wh *= bytes_per_pixel;
+  width = ((size_t)(width * bytes_per_pixel));
+  if (wh > len) {
+    return wuffs_base__make_status(
+        wuffs_base__error__bad_argument_length_too_short);
+  }
+
+  pb->pixcfg = *pixcfg;
+  wuffs_base__table_u8* tab = &pb->private_impl.planes[0];
+  tab->ptr = ptr;
+  tab->width = width;
+  tab->height = pixcfg->private_impl.height;
+  tab->stride = width;
+  return wuffs_base__make_status(NULL);
+}
+
+// wuffs_base__pixel_buffer__palette returns the palette color data. If
+// non-empty, it will have length
+// WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH.
+static inline wuffs_base__slice_u8  //
+wuffs_base__pixel_buffer__palette(wuffs_base__pixel_buffer* pb) {
+  if (pb &&
+      wuffs_base__pixel_format__is_indexed(&pb->pixcfg.private_impl.pixfmt)) {
+    wuffs_base__table_u8* tab =
+        &pb->private_impl
+             .planes[WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE];
+    if ((tab->width ==
+         WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH) &&
+        (tab->height == 1)) {
+      return wuffs_base__make_slice_u8(
+          tab->ptr, WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH);
+    }
+  }
+  return wuffs_base__make_slice_u8(NULL, 0);
+}
+
+static inline wuffs_base__slice_u8  //
+wuffs_base__pixel_buffer__palette_or_else(wuffs_base__pixel_buffer* pb,
+                                          wuffs_base__slice_u8 fallback) {
+  if (pb &&
+      wuffs_base__pixel_format__is_indexed(&pb->pixcfg.private_impl.pixfmt)) {
+    wuffs_base__table_u8* tab =
+        &pb->private_impl
+             .planes[WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE];
+    if ((tab->width ==
+         WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH) &&
+        (tab->height == 1)) {
+      return wuffs_base__make_slice_u8(
+          tab->ptr, WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH);
+    }
+  }
+  return fallback;
+}
+
+static inline wuffs_base__pixel_format  //
+wuffs_base__pixel_buffer__pixel_format(const wuffs_base__pixel_buffer* pb) {
+  if (pb) {
+    return pb->pixcfg.private_impl.pixfmt;
+  }
+  return wuffs_base__make_pixel_format(WUFFS_BASE__PIXEL_FORMAT__INVALID);
+}
+
+static inline wuffs_base__table_u8  //
+wuffs_base__pixel_buffer__plane(wuffs_base__pixel_buffer* pb, uint32_t p) {
+  if (pb && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX_INCL)) {
+    return pb->private_impl.planes[p];
+  }
+
+  wuffs_base__table_u8 ret;
+  ret.ptr = NULL;
+  ret.width = 0;
+  ret.height = 0;
+  ret.stride = 0;
+  return ret;
+}
+
+WUFFS_BASE__MAYBE_STATIC wuffs_base__color_u32_argb_premul  //
+wuffs_base__pixel_buffer__color_u32_at(const wuffs_base__pixel_buffer* pb,
+                                       uint32_t x,
+                                       uint32_t y);
+
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status  //
+wuffs_base__pixel_buffer__set_color_u32_at(
+    wuffs_base__pixel_buffer* pb,
+    uint32_t x,
+    uint32_t y,
+    wuffs_base__color_u32_argb_premul color);
+
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status  //
+wuffs_base__pixel_buffer__set_color_u32_fill_rect(
+    wuffs_base__pixel_buffer* pb,
+    wuffs_base__rect_ie_u32 rect,
+    wuffs_base__color_u32_argb_premul color);
+
+#ifdef __cplusplus
+
+inline wuffs_base__status  //
+wuffs_base__pixel_buffer::set_interleaved(
+    const wuffs_base__pixel_config* pixcfg_arg,
+    wuffs_base__table_u8 primary_memory,
+    wuffs_base__slice_u8 palette_memory) {
+  return wuffs_base__pixel_buffer__set_interleaved(
+      this, pixcfg_arg, primary_memory, palette_memory);
+}
+
+inline wuffs_base__status  //
+wuffs_base__pixel_buffer::set_from_slice(
+    const wuffs_base__pixel_config* pixcfg_arg,
+    wuffs_base__slice_u8 pixbuf_memory) {
+  return wuffs_base__pixel_buffer__set_from_slice(this, pixcfg_arg,
+                                                  pixbuf_memory);
+}
+
+inline wuffs_base__slice_u8  //
+wuffs_base__pixel_buffer::palette() {
+  return wuffs_base__pixel_buffer__palette(this);
+}
+
+inline wuffs_base__slice_u8  //
+wuffs_base__pixel_buffer::palette_or_else(wuffs_base__slice_u8 fallback) {
+  return wuffs_base__pixel_buffer__palette_or_else(this, fallback);
+}
+
+inline wuffs_base__pixel_format  //
+wuffs_base__pixel_buffer::pixel_format() const {
+  return wuffs_base__pixel_buffer__pixel_format(this);
+}
+
+inline wuffs_base__table_u8  //
+wuffs_base__pixel_buffer::plane(uint32_t p) {
+  return wuffs_base__pixel_buffer__plane(this, p);
+}
+
+inline wuffs_base__color_u32_argb_premul  //
+wuffs_base__pixel_buffer::color_u32_at(uint32_t x, uint32_t y) const {
+  return wuffs_base__pixel_buffer__color_u32_at(this, x, y);
+}
+
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status  //
+wuffs_base__pixel_buffer__set_color_u32_fill_rect(
+    wuffs_base__pixel_buffer* pb,
+    wuffs_base__rect_ie_u32 rect,
+    wuffs_base__color_u32_argb_premul color);
+
+inline wuffs_base__status  //
+wuffs_base__pixel_buffer::set_color_u32_at(
+    uint32_t x,
+    uint32_t y,
+    wuffs_base__color_u32_argb_premul color) {
+  return wuffs_base__pixel_buffer__set_color_u32_at(this, x, y, color);
+}
+
+inline wuffs_base__status  //
+wuffs_base__pixel_buffer::set_color_u32_fill_rect(
+    wuffs_base__rect_ie_u32 rect,
+    wuffs_base__color_u32_argb_premul color) {
+  return wuffs_base__pixel_buffer__set_color_u32_fill_rect(this, rect, color);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+typedef struct wuffs_base__decode_frame_options__struct {
+  // Do not access the private_impl's fields directly. There is no API/ABI
+  // compatibility or safety guarantee if you do so.
+  struct {
+    uint8_t TODO;
+  } private_impl;
+
+#ifdef __cplusplus
+#endif  // __cplusplus
+
+} wuffs_base__decode_frame_options;
+
+#ifdef __cplusplus
+
+#endif  // __cplusplus
+
+// --------
+
+// wuffs_base__pixel_palette__closest_element returns the index of the palette
+// element that minimizes the sum of squared differences of the four ARGB
+// channels, working in premultiplied alpha. Ties favor the smaller index.
+//
+// The palette_slice.len may equal (N*4), for N less than 256, which means that
+// only the first N palette elements are considered. It returns 0 when N is 0.
+//
+// Applying this function on a per-pixel basis will not produce whole-of-image
+// dithering.
+WUFFS_BASE__MAYBE_STATIC uint8_t  //
+wuffs_base__pixel_palette__closest_element(
+    wuffs_base__slice_u8 palette_slice,
+    wuffs_base__pixel_format palette_format,
+    wuffs_base__color_u32_argb_premul c);
+
+// --------
+
+// TODO: should the func type take restrict pointers?
+typedef uint64_t (*wuffs_base__pixel_swizzler__func)(uint8_t* dst_ptr,
+                                                     size_t dst_len,
+                                                     uint8_t* dst_palette_ptr,
+                                                     size_t dst_palette_len,
+                                                     const uint8_t* src_ptr,
+                                                     size_t src_len);
+
+typedef uint64_t (*wuffs_base__pixel_swizzler__transparent_black_func)(
+    uint8_t* dst_ptr,
+    size_t dst_len,
+    uint8_t* dst_palette_ptr,
+    size_t dst_palette_len,
+    uint64_t num_pixels,
+    uint32_t dst_pixfmt_bytes_per_pixel);
+
+typedef struct wuffs_base__pixel_swizzler__struct {
+  // Do not access the private_impl's fields directly. There is no API/ABI
+  // compatibility or safety guarantee if you do so.
+  struct {
+    wuffs_base__pixel_swizzler__func func;
+    wuffs_base__pixel_swizzler__transparent_black_func transparent_black_func;
+    uint32_t dst_pixfmt_bytes_per_pixel;
+    uint32_t src_pixfmt_bytes_per_pixel;
+  } private_impl;
+
+#ifdef __cplusplus
+  inline wuffs_base__status prepare(wuffs_base__pixel_format dst_pixfmt,
+                                    wuffs_base__slice_u8 dst_palette,
+                                    wuffs_base__pixel_format src_pixfmt,
+                                    wuffs_base__slice_u8 src_palette,
+                                    wuffs_base__pixel_blend blend);
+  inline uint64_t swizzle_interleaved_from_slice(
+      wuffs_base__slice_u8 dst,
+      wuffs_base__slice_u8 dst_palette,
+      wuffs_base__slice_u8 src) const;
+#endif  // __cplusplus
+
+} wuffs_base__pixel_swizzler;
+
+// wuffs_base__pixel_swizzler__prepare readies the pixel swizzler so that its
+// other methods may be called.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__PIXCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status  //
+wuffs_base__pixel_swizzler__prepare(wuffs_base__pixel_swizzler* p,
+                                    wuffs_base__pixel_format dst_pixfmt,
+                                    wuffs_base__slice_u8 dst_palette,
+                                    wuffs_base__pixel_format src_pixfmt,
+                                    wuffs_base__slice_u8 src_palette,
+                                    wuffs_base__pixel_blend blend);
+
+// wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice converts pixels
+// from a source format to a destination format.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__PIXCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC uint64_t  //
+wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(
+    const wuffs_base__pixel_swizzler* p,
+    wuffs_base__slice_u8 dst,
+    wuffs_base__slice_u8 dst_palette,
+    wuffs_base__slice_u8 src);
+
+#ifdef __cplusplus
+
+inline wuffs_base__status  //
+wuffs_base__pixel_swizzler::prepare(wuffs_base__pixel_format dst_pixfmt,
+                                    wuffs_base__slice_u8 dst_palette,
+                                    wuffs_base__pixel_format src_pixfmt,
+                                    wuffs_base__slice_u8 src_palette,
+                                    wuffs_base__pixel_blend blend) {
+  return wuffs_base__pixel_swizzler__prepare(this, dst_pixfmt, dst_palette,
+                                             src_pixfmt, src_palette, blend);
+}
+
+uint64_t  //
+wuffs_base__pixel_swizzler::swizzle_interleaved_from_slice(
+    wuffs_base__slice_u8 dst,
+    wuffs_base__slice_u8 dst_palette,
+    wuffs_base__slice_u8 src) const {
+  return wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(
+      this, dst, dst_palette, src);
+}
+
+#endif  // __cplusplus
+
+// ---------------- String Conversions
+
+// Options (bitwise or'ed together) for wuffs_base__parse_number_xxx
+// functions. The XXX options apply to both integer and floating point. The FXX
+// options apply only to floating point.
+
+#define WUFFS_BASE__PARSE_NUMBER_XXX__DEFAULT_OPTIONS ((uint32_t)0x00000000)
+
+// WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_MULTIPLE_LEADING_ZEROES means to accept
+// inputs like "00", "0644" and "00.7". By default, they are rejected.
+#define WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_MULTIPLE_LEADING_ZEROES \
+  ((uint32_t)0x00000001)
+
+// WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_UNDERSCORES means to accept inputs like
+// "1__2" and "_3.141_592". By default, they are rejected.
+#define WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_UNDERSCORES ((uint32_t)0x00000002)
+
+// WUFFS_BASE__PARSE_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA means to accept
+// "1,5" and not "1.5" as one-and-a-half.
+//
+// If the caller wants to accept either, it is responsible for canonicalizing
+// the input before calling wuffs_base__parse_number_fxx. The caller also has
+// more context on e.g. exactly how to treat something like "$1,234".
+#define WUFFS_BASE__PARSE_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA \
+  ((uint32_t)0x00000010)
+
+// WUFFS_BASE__PARSE_NUMBER_FXX__REJECT_INF_AND_NAN means to reject inputs that
+// would lead to infinite or Not-a-Number floating point values. By default,
+// they are accepted.
+//
+// This affects the literal "inf" as input, but also affects inputs like
+// "1e999" that would overflow double-precision floating point.
+#define WUFFS_BASE__PARSE_NUMBER_FXX__REJECT_INF_AND_NAN ((uint32_t)0x00000020)
+
+// --------
+
+// Options (bitwise or'ed together) for wuffs_base__render_number_xxx
+// functions. The XXX options apply to both integer and floating point. The FXX
+// options apply only to floating point.
+
+#define WUFFS_BASE__RENDER_NUMBER_XXX__DEFAULT_OPTIONS ((uint32_t)0x00000000)
+
+// WUFFS_BASE__RENDER_NUMBER_XXX__ALIGN_RIGHT means to render to the right side
+// (higher indexes) of the destination slice, leaving any untouched bytes on
+// the left side (lower indexes). The default is vice versa: rendering on the
+// left with slack on the right.
+#define WUFFS_BASE__RENDER_NUMBER_XXX__ALIGN_RIGHT ((uint32_t)0x00000100)
+
+// WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN means to render the leading
+// "+" for non-negative numbers: "+0" and "+12.3" instead of "0" and "12.3".
+#define WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN ((uint32_t)0x00000200)
+
+// WUFFS_BASE__RENDER_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA means to render
+// one-and-a-half as "1,5" instead of "1.5".
+#define WUFFS_BASE__RENDER_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA \
+  ((uint32_t)0x00001000)
+
+// WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ETC means whether to never
+// (EXPONENT_ABSENT, equivalent to printf's "%f") or to always
+// (EXPONENT_PRESENT, equivalent to printf's "%e") render a floating point
+// number as "1.23e+05" instead of "123000".
+//
+// Having both bits set is the same has having neither bit set, where the
+// notation used depends on whether the exponent is sufficiently large: "0.5"
+// is preferred over "5e-01" but "5e-09" is preferred over "0.000000005".
+#define WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ABSENT ((uint32_t)0x00002000)
+#define WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_PRESENT ((uint32_t)0x00004000)
+
+// WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION means to render the
+// smallest number of digits so that parsing the resultant string will recover
+// the same double-precision floating point number.
+//
+// For example, double-precision cannot distinguish between 0.3 and
+// 0.299999999999999988897769753748434595763683319091796875, so when this bit
+// is set, rendering the latter will produce "0.3" but rendering
+// 0.3000000000000000444089209850062616169452667236328125 will produce
+// "0.30000000000000004".
+#define WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION \
+  ((uint32_t)0x00008000)
+
+// ---------------- IEEE 754 Floating Point
+
+// wuffs_base__ieee_754_bit_representation__etc converts between a double
+// precision numerical value and its IEEE 754 representations:
+//  - 16-bit: 1 sign bit,  5 exponent bits, 10 explicit significand bits.
+//  - 32-bit: 1 sign bit,  8 exponent bits, 23 explicit significand bits.
+//  - 64-bit: 1 sign bit, 11 exponent bits, 52 explicit significand bits.
+//
+// For example, it converts between:
+//  - +1.0 and 0x3C00, 0x3F80_0000 or 0x3FF0_0000_0000_0000.
+//  - +5.5 and 0x4580, 0x40B0_0000 or 0x4016_0000_0000_0000.
+//  - -inf and 0xFC00, 0xFF80_0000 or 0xFFF0_0000_0000_0000.
+//
+// Converting from f64 to shorter formats (f16 or f32, represented in C as
+// uint16_t and uint32_t) may be lossy. Such functions have names that look
+// like etc_truncate, as converting finite numbers produce equal or smaller
+// (closer-to-zero) finite numbers. For example, 1048576.0 is a perfectly valid
+// f64 number, but converting it to a f16 (with truncation) produces 65504.0,
+// the largest finite f16 number. Truncating a f64-typed value d to f32 does
+// not always produce the same result as the C-style cast ((float)d), as
+// casting can convert from finite numbers to infinite ones.
+//
+// Converting infinities or NaNs produces infinities or NaNs and always report
+// no loss, even though there a multiple NaN representations so that round-
+// tripping a f64-typed NaN may produce a different 64 bits. Nonetheless, the
+// etc_truncate functions preserve a NaN's "quiet vs signaling" bit.
+//
+// See https://en.wikipedia.org/wiki/Double-precision_floating-point_format
+
+typedef struct wuffs_base__lossy_value_u16__struct {
+  uint16_t value;
+  bool lossy;
+} wuffs_base__lossy_value_u16;
+
+typedef struct wuffs_base__lossy_value_u32__struct {
+  uint32_t value;
+  bool lossy;
+} wuffs_base__lossy_value_u32;
+
+WUFFS_BASE__MAYBE_STATIC wuffs_base__lossy_value_u16  //
+wuffs_base__ieee_754_bit_representation__from_f64_to_u16_truncate(double f);
+
+WUFFS_BASE__MAYBE_STATIC wuffs_base__lossy_value_u32  //
+wuffs_base__ieee_754_bit_representation__from_f64_to_u32_truncate(double f);
+
+static inline uint64_t  //
+wuffs_base__ieee_754_bit_representation__from_f64_to_u64(double f) {
+  uint64_t u = 0;
+  if (sizeof(uint64_t) == sizeof(double)) {
+    memcpy(&u, &f, sizeof(uint64_t));
+  }
+  return u;
+}
+
+static inline double  //
+wuffs_base__ieee_754_bit_representation__from_u16_to_f64(uint16_t u) {
+  uint64_t v = ((uint64_t)(u & 0x8000)) << 48;
+
+  do {
+    uint64_t exp = (u >> 10) & 0x1F;
+    uint64_t man = u & 0x3FF;
+    if (exp == 0x1F) {  // Infinity or NaN.
+      exp = 2047;
+    } else if (exp != 0) {  // Normal.
+      exp += 1008;          // 1008 = 1023 - 15, the difference in biases.
+    } else if (man != 0) {  // Subnormal but non-zero.
+      uint32_t clz = wuffs_base__count_leading_zeroes_u64(man);
+      exp = 1062 - clz;  // 1062 = 1008 + 64 - 10.
+      man = 0x3FF & (man << (clz - 53));
+    } else {  // Zero.
+      break;
+    }
+    v |= (exp << 52) | (man << 42);
+  } while (0);
+
+  double f = 0;
+  if (sizeof(uint64_t) == sizeof(double)) {
+    memcpy(&f, &v, sizeof(uint64_t));
+  }
+  return f;
+}
+
+static inline double  //
+wuffs_base__ieee_754_bit_representation__from_u32_to_f64(uint32_t u) {
+  float f = 0;
+  if (sizeof(uint32_t) == sizeof(float)) {
+    memcpy(&f, &u, sizeof(uint32_t));
+  }
+  return (double)f;
+}
+
+static inline double  //
+wuffs_base__ieee_754_bit_representation__from_u64_to_f64(uint64_t u) {
+  double f = 0;
+  if (sizeof(uint64_t) == sizeof(double)) {
+    memcpy(&f, &u, sizeof(uint64_t));
+  }
+  return f;
+}
+
+// ---------------- Parsing and Rendering Numbers
+
+// wuffs_base__parse_number_f64 parses the floating point number in s. For
+// example, if s contains the bytes "1.5" then it will return the double 1.5.
+//
+// It returns an error if s does not contain a floating point number.
+//
+// It does not necessarily return an error if the conversion is lossy, e.g. if
+// s is "0.3", which double-precision floating point cannot represent exactly.
+//
+// Similarly, the returned value may be infinite (and no error returned) even
+// if s was not "inf", when the input is nominally finite but sufficiently
+// larger than DBL_MAX, about 1.8e+308.
+//
+// It is similar to the C standard library's strtod function, but:
+//  - Errors are returned in-band (in a result type), not out-of-band (errno).
+//  - It takes a slice (a pointer and length), not a NUL-terminated C string.
+//  - It does not take an optional endptr argument. It does not allow a partial
+//    parse: it returns an error unless all of s is consumed.
+//  - It does not allow whitespace, leading or otherwise.
+//  - It does not allow hexadecimal floating point numbers.
+//  - It is not affected by i18n / l10n settings such as environment variables.
+//
+// The options argument can change these, but by default, it:
+//  - Allows "inf", "+Infinity" and "-NAN", case insensitive. Similarly,
+//    without an explicit opt-out, it would successfully parse "1e999" as
+//    infinity, even though it overflows double-precision floating point.
+//  - Rejects underscores. With an explicit opt-in, "_3.141_592" would
+//    successfully parse as an approximation to π.
+//  - Rejects unnecessary leading zeroes: "00", "0644" and "00.7".
+//  - Uses a dot '1.5' instead of a comma '1,5' for the decimal separator.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__FLOATCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__result_f64  //
+wuffs_base__parse_number_f64(wuffs_base__slice_u8 s, uint32_t options);
+
+// wuffs_base__parse_number_i64 parses the ASCII integer in s. For example, if
+// s contains the bytes "-123" then it will return the int64_t -123.
+//
+// It returns an error if s does not contain an integer or if the integer
+// within would overflow an int64_t.
+//
+// It is similar to wuffs_base__parse_number_u64 but it returns a signed
+// integer, not an unsigned integer. It also allows a leading '+' or '-'.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__result_i64  //
+wuffs_base__parse_number_i64(wuffs_base__slice_u8 s, uint32_t options);
+
+// wuffs_base__parse_number_u64 parses the ASCII integer in s. For example, if
+// s contains the bytes "123" then it will return the uint64_t 123.
+//
+// It returns an error if s does not contain an integer or if the integer
+// within would overflow a uint64_t.
+//
+// It is similar to the C standard library's strtoull function, but:
+//  - Errors are returned in-band (in a result type), not out-of-band (errno).
+//  - It takes a slice (a pointer and length), not a NUL-terminated C string.
+//  - It does not take an optional endptr argument. It does not allow a partial
+//    parse: it returns an error unless all of s is consumed.
+//  - It does not allow whitespace, leading or otherwise.
+//  - It does not allow a leading '+' or '-'.
+//  - It does not take a base argument (e.g. base 10 vs base 16). Instead, it
+//    always accepts both decimal (e.g "1234", "0d5678") and hexadecimal (e.g.
+//    "0x9aBC"). The caller is responsible for prior filtering of e.g. hex
+//    numbers if they are unwanted. For example, Wuffs' JSON decoder will only
+//    produce a wuffs_base__token for decimal numbers, not hexadecimal.
+//  - It is not affected by i18n / l10n settings such as environment variables.
+//
+// The options argument can change these, but by default, it:
+//  - Rejects underscores. With an explicit opt-in, "__0D_1_002" would
+//    successfully parse as "one thousand and two". Underscores are still
+//    rejected inside the optional 2-byte opening "0d" or "0X" that denotes
+//    base-10 or base-16.
+//  - Rejects unnecessary leading zeroes: "00" and "0644".
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__result_u64  //
+wuffs_base__parse_number_u64(wuffs_base__slice_u8 s, uint32_t options);
+
+// --------
+
+// WUFFS_BASE__I64__BYTE_LENGTH__MAX_INCL is the string length of
+// "-9223372036854775808" and "+9223372036854775807", INT64_MIN and INT64_MAX.
+#define WUFFS_BASE__I64__BYTE_LENGTH__MAX_INCL 20
+
+// WUFFS_BASE__U64__BYTE_LENGTH__MAX_INCL is the string length of
+// "+18446744073709551615", UINT64_MAX.
+#define WUFFS_BASE__U64__BYTE_LENGTH__MAX_INCL 21
+
+// wuffs_base__render_number_f64 writes the decimal encoding of x to dst and
+// returns the number of bytes written. If dst is shorter than the entire
+// encoding, it returns 0 (and no bytes are written).
+//
+// For those familiar with C's printf or Go's fmt.Printf functions:
+//  - "%e" means the WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_PRESENT option.
+//  - "%f" means the WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ABSENT  option.
+//  - "%g" means neither or both bits are set.
+//
+// The precision argument controls the number of digits rendered, excluding the
+// exponent (the "e+05" in "1.23e+05"):
+//  - for "%e" and "%f" it is the number of digits after the decimal separator,
+//  - for "%g" it is the number of significant digits (and trailing zeroes are
+//    removed).
+//
+// A precision of 6 gives similar output to printf's defaults.
+//
+// A precision greater than 4095 is equivalent to 4095.
+//
+// The precision argument is ignored when the
+// WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION option is set. This is
+// similar to Go's strconv.FormatFloat with a negative (i.e. non-sensical)
+// precision, but there is no corresponding feature in C's printf.
+//
+// Extreme values of x will be rendered as "NaN", "Inf" (or "+Inf" if the
+// WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN option is set) or "-Inf".
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__FLOATCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC size_t  //
+wuffs_base__render_number_f64(wuffs_base__slice_u8 dst,
+                              double x,
+                              uint32_t precision,
+                              uint32_t options);
+
+// wuffs_base__render_number_i64 writes the decimal encoding of x to dst and
+// returns the number of bytes written. If dst is shorter than the entire
+// encoding, it returns 0 (and no bytes are written).
+//
+// dst will never be too short if its length is at least 20, also known as
+// WUFFS_BASE__I64__BYTE_LENGTH__MAX_INCL.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC size_t  //
+wuffs_base__render_number_i64(wuffs_base__slice_u8 dst,
+                              int64_t x,
+                              uint32_t options);
+
+// wuffs_base__render_number_u64 writes the decimal encoding of x to dst and
+// returns the number of bytes written. If dst is shorter than the entire
+// encoding, it returns 0 (and no bytes are written).
+//
+// dst will never be too short if its length is at least 21, also known as
+// WUFFS_BASE__U64__BYTE_LENGTH__MAX_INCL.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC size_t  //
+wuffs_base__render_number_u64(wuffs_base__slice_u8 dst,
+                              uint64_t x,
+                              uint32_t options);
+
+// ---------------- Base-16
+
+// Options (bitwise or'ed together) for wuffs_base__base_16__xxx functions.
+
+#define WUFFS_BASE__BASE_16__DEFAULT_OPTIONS ((uint32_t)0x00000000)
+
+// wuffs_base__base_16__decode2 converts "6A6b" to "jk", where e.g. 'j' is
+// U+006A. There are 2 src bytes for every dst byte.
+//
+// It assumes that the src bytes are two hexadecimal digits (0-9, A-F, a-f),
+// repeated. It may write nonsense bytes if not, although it will not read or
+// write out of bounds.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output  //
+wuffs_base__base_16__decode2(wuffs_base__slice_u8 dst,
+                             wuffs_base__slice_u8 src,
+                             bool src_closed,
+                             uint32_t options);
+
+// wuffs_base__base_16__decode4 converts both "\\x6A\\x6b" and "??6a??6B" to
+// "jk", where e.g. 'j' is U+006A. There are 4 src bytes for every dst byte.
+//
+// It assumes that the src bytes are two ignored bytes and then two hexadecimal
+// digits (0-9, A-F, a-f), repeated. It may write nonsense bytes if not,
+// although it will not read or write out of bounds.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output  //
+wuffs_base__base_16__decode4(wuffs_base__slice_u8 dst,
+                             wuffs_base__slice_u8 src,
+                             bool src_closed,
+                             uint32_t options);
+
+// wuffs_base__base_16__encode2 converts "jk" to "6A6B", where e.g. 'j' is
+// U+006A. There are 2 dst bytes for every src byte.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output  //
+wuffs_base__base_16__encode2(wuffs_base__slice_u8 dst,
+                             wuffs_base__slice_u8 src,
+                             bool src_closed,
+                             uint32_t options);
+
+// wuffs_base__base_16__encode4 converts "jk" to "\\x6A\\x6B", where e.g. 'j'
+// is U+006A. There are 4 dst bytes for every src byte.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output  //
+wuffs_base__base_16__encode2(wuffs_base__slice_u8 dst,
+                             wuffs_base__slice_u8 src,
+                             bool src_closed,
+                             uint32_t options);
+
+// ---------------- Base-64
+
+// Options (bitwise or'ed together) for wuffs_base__base_64__xxx functions.
+
+#define WUFFS_BASE__BASE_64__DEFAULT_OPTIONS ((uint32_t)0x00000000)
+
+// WUFFS_BASE__BASE_64__DECODE_ALLOW_PADDING means that, when decoding base-64,
+// the input may (but does not need to) be padded with '=' bytes so that the
+// overall encoded length in bytes is a multiple of 4. A successful decoding
+// will return a num_src that includes those padding bytes.
+//
+// Excess padding (e.g. three final '='s) will be rejected as bad data.
+#define WUFFS_BASE__BASE_64__DECODE_ALLOW_PADDING ((uint32_t)0x00000001)
+
+// WUFFS_BASE__BASE_64__ENCODE_EMIT_PADDING means that, when encoding base-64,
+// the output will be padded with '=' bytes so that the overall encoded length
+// in bytes is a multiple of 4.
+#define WUFFS_BASE__BASE_64__ENCODE_EMIT_PADDING ((uint32_t)0x00000002)
+
+// WUFFS_BASE__BASE_64__URL_ALPHABET means that, for base-64, the URL-friendly
+// and file-name-friendly alphabet be used, as per RFC 4648 section 5. When
+// this option bit is off, the standard alphabet from section 4 is used.
+#define WUFFS_BASE__BASE_64__URL_ALPHABET ((uint32_t)0x00000100)
+
+// wuffs_base__base_64__decode transforms base-64 encoded bytes from src to
+// arbitrary bytes in dst.
+//
+// It will not permit line breaks or other whitespace in src. Filtering those
+// out is the responsibility of the caller.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output  //
+wuffs_base__base_64__decode(wuffs_base__slice_u8 dst,
+                            wuffs_base__slice_u8 src,
+                            bool src_closed,
+                            uint32_t options);
+
+// wuffs_base__base_64__encode transforms arbitrary bytes from src to base-64
+// encoded bytes in dst.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output  //
+wuffs_base__base_64__encode(wuffs_base__slice_u8 dst,
+                            wuffs_base__slice_u8 src,
+                            bool src_closed,
+                            uint32_t options);
+
+// ---------------- Unicode and UTF-8
+
+#define WUFFS_BASE__UNICODE_CODE_POINT__MIN_INCL 0x00000000
+#define WUFFS_BASE__UNICODE_CODE_POINT__MAX_INCL 0x0010FFFF
+
+#define WUFFS_BASE__UNICODE_REPLACEMENT_CHARACTER 0x0000FFFD
+
+#define WUFFS_BASE__UNICODE_SURROGATE__MIN_INCL 0x0000D800
+#define WUFFS_BASE__UNICODE_SURROGATE__MAX_INCL 0x0000DFFF
+
+#define WUFFS_BASE__ASCII__MIN_INCL 0x00
+#define WUFFS_BASE__ASCII__MAX_INCL 0x7F
+
+#define WUFFS_BASE__UTF_8__BYTE_LENGTH__MIN_INCL 1
+#define WUFFS_BASE__UTF_8__BYTE_LENGTH__MAX_INCL 4
+
+#define WUFFS_BASE__UTF_8__BYTE_LENGTH_1__CODE_POINT__MIN_INCL 0x00000000
+#define WUFFS_BASE__UTF_8__BYTE_LENGTH_1__CODE_POINT__MAX_INCL 0x0000007F
+#define WUFFS_BASE__UTF_8__BYTE_LENGTH_2__CODE_POINT__MIN_INCL 0x00000080
+#define WUFFS_BASE__UTF_8__BYTE_LENGTH_2__CODE_POINT__MAX_INCL 0x000007FF
+#define WUFFS_BASE__UTF_8__BYTE_LENGTH_3__CODE_POINT__MIN_INCL 0x00000800
+#define WUFFS_BASE__UTF_8__BYTE_LENGTH_3__CODE_POINT__MAX_INCL 0x0000FFFF
+#define WUFFS_BASE__UTF_8__BYTE_LENGTH_4__CODE_POINT__MIN_INCL 0x00010000
+#define WUFFS_BASE__UTF_8__BYTE_LENGTH_4__CODE_POINT__MAX_INCL 0x0010FFFF
+
+// --------
+
+// wuffs_base__utf_8__next__output is the type returned by
+// wuffs_base__utf_8__next.
+typedef struct wuffs_base__utf_8__next__output__struct {
+  uint32_t code_point;
+  uint32_t byte_length;
+
+#ifdef __cplusplus
+  inline bool is_valid() const;
+#endif  // __cplusplus
+
+} wuffs_base__utf_8__next__output;
+
+static inline wuffs_base__utf_8__next__output  //
+wuffs_base__make_utf_8__next__output(uint32_t code_point,
+                                     uint32_t byte_length) {
+  wuffs_base__utf_8__next__output ret;
+  ret.code_point = code_point;
+  ret.byte_length = byte_length;
+  return ret;
+}
+
+static inline bool  //
+wuffs_base__utf_8__next__output__is_valid(
+    const wuffs_base__utf_8__next__output* o) {
+  if (o) {
+    uint32_t cp = o->code_point;
+    switch (o->byte_length) {
+      case 1:
+        return (cp <= 0x7F);
+      case 2:
+        return (0x080 <= cp) && (cp <= 0x7FF);
+      case 3:
+        // Avoid the 0xD800 ..= 0xDFFF surrogate range.
+        return ((0x0800 <= cp) && (cp <= 0xD7FF)) ||
+               ((0xE000 <= cp) && (cp <= 0xFFFF));
+      case 4:
+        return (0x00010000 <= cp) && (cp <= 0x0010FFFF);
+    }
+  }
+  return false;
+}
+
+#ifdef __cplusplus
+
+inline bool  //
+wuffs_base__utf_8__next__output::is_valid() const {
+  return wuffs_base__utf_8__next__output__is_valid(this);
+}
+
+#endif  // __cplusplus
+
+// --------
+
+// wuffs_base__utf_8__encode writes the UTF-8 encoding of code_point to s and
+// returns the number of bytes written. If code_point is invalid, or if s is
+// shorter than the entire encoding, it returns 0 (and no bytes are written).
+//
+// s will never be too short if its length is at least 4, also known as
+// WUFFS_BASE__UTF_8__BYTE_LENGTH__MAX_INCL.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__UTF8 sub-module, not just
+// WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC size_t  //
+wuffs_base__utf_8__encode(wuffs_base__slice_u8 dst, uint32_t code_point);
+
+// wuffs_base__utf_8__next returns the next UTF-8 code point (and that code
+// point's byte length) at the start of the read-only slice (s_ptr, s_len).
+//
+// There are exactly two cases in which this function returns something where
+// wuffs_base__utf_8__next__output__is_valid is false:
+//  - If s is empty then it returns {.code_point=0, .byte_length=0}.
+//  - If s is non-empty and starts with invalid UTF-8 then it returns
+//    {.code_point=WUFFS_BASE__UNICODE_REPLACEMENT_CHARACTER, .byte_length=1}.
+//
+// Otherwise, it returns something where
+// wuffs_base__utf_8__next__output__is_valid is true.
+//
+// In any case, it always returns an output that satisfies both of:
+//  - (output.code_point  <= WUFFS_BASE__UNICODE_CODE_POINT__MAX_INCL).
+//  - (output.byte_length <= s_len).
+//
+// If s is a sub-slice of a larger slice of valid UTF-8, but that sub-slice
+// boundary occurs in the middle of a multi-byte UTF-8 encoding of a single
+// code point, then this function may return something invalid. It is the
+// caller's responsibility to split on or otherwise manage UTF-8 boundaries.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__UTF8 sub-module, not just
+// WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__utf_8__next__output  //
+wuffs_base__utf_8__next(const uint8_t* s_ptr, size_t s_len);
+
+// wuffs_base__utf_8__next_from_end is like wuffs_base__utf_8__next except that
+// it looks at the end of (s_ptr, s_len) instead of the start.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__UTF8 sub-module, not just
+// WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC wuffs_base__utf_8__next__output  //
+wuffs_base__utf_8__next_from_end(const uint8_t* s_ptr, size_t s_len);
+
+// wuffs_base__utf_8__longest_valid_prefix returns the largest n such that the
+// sub-slice s[..n] is valid UTF-8, where s is the read-only slice (s_ptr,
+// s_len).
+//
+// In particular, it returns s_len if and only if all of s is valid UTF-8.
+//
+// If s is a sub-slice of a larger slice of valid UTF-8, but that sub-slice
+// boundary occurs in the middle of a multi-byte UTF-8 encoding of a single
+// code point, then this function will return less than s_len. It is the
+// caller's responsibility to split on or otherwise manage UTF-8 boundaries.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__UTF8 sub-module, not just
+// WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC size_t  //
+wuffs_base__utf_8__longest_valid_prefix(const uint8_t* s_ptr, size_t s_len);
+
+// wuffs_base__ascii__longest_valid_prefix returns the largest n such that the
+// sub-slice s[..n] is valid ASCII, where s is the read-only slice (s_ptr,
+// s_len).
+//
+// In particular, it returns s_len if and only if all of s is valid ASCII.
+// Equivalently, when none of the bytes in s have the 0x80 high bit set.
+//
+// For modular builds that divide the base module into sub-modules, using this
+// function requires the WUFFS_CONFIG__MODULE__BASE__UTF8 sub-module, not just
+// WUFFS_CONFIG__MODULE__BASE__CORE.
+WUFFS_BASE__MAYBE_STATIC size_t  //
+wuffs_base__ascii__longest_valid_prefix(const uint8_t* s_ptr, size_t s_len);
+
+// ---------------- Interface Declarations.
+
+// For modular builds that divide the base module into sub-modules, using these
+// functions require the WUFFS_CONFIG__MODULE__BASE__INTERFACES sub-module, not
+// just WUFFS_CONFIG__MODULE__BASE__CORE.
+
+// --------
+
+extern const char wuffs_base__hasher_u32__vtable_name[];
+
+typedef struct wuffs_base__hasher_u32__func_ptrs__struct {
+  uint32_t (*checksum_u32)(
+    const void* self);
+  uint64_t (*get_quirk)(
+    const void* self,
+    uint32_t a_key);
+  wuffs_base__status (*set_quirk)(
+    void* self,
+    uint32_t a_key,
+    uint64_t a_value);
+  wuffs_base__empty_struct (*update)(
+    void* self,
+    wuffs_base__slice_u8 a_x);
+  uint32_t (*update_u32)(
+    void* self,
+    wuffs_base__slice_u8 a_x);
+} wuffs_base__hasher_u32__func_ptrs;
+
+typedef struct wuffs_base__hasher_u32__struct wuffs_base__hasher_u32;
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_base__hasher_u32__checksum_u32(
+    const wuffs_base__hasher_u32* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__hasher_u32__get_quirk(
+    const wuffs_base__hasher_u32* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__hasher_u32__set_quirk(
+    wuffs_base__hasher_u32* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_base__hasher_u32__update(
+    wuffs_base__hasher_u32* self,
+    wuffs_base__slice_u8 a_x);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_base__hasher_u32__update_u32(
+    wuffs_base__hasher_u32* self,
+    wuffs_base__slice_u8 a_x);
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_base__hasher_u32__struct {
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable first_vtable;
+  } private_impl;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_base__hasher_u32, wuffs_unique_ptr_deleter>;
+#endif
+
+  inline uint32_t
+  checksum_u32() const {
+    return wuffs_base__hasher_u32__checksum_u32(this);
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_base__hasher_u32__get_quirk(
+        this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_base__hasher_u32__set_quirk(
+        this, a_key, a_value);
+  }
+
+  inline wuffs_base__empty_struct
+  update(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_base__hasher_u32__update(
+        this, a_x);
+  }
+
+  inline uint32_t
+  update_u32(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_base__hasher_u32__update_u32(
+        this, a_x);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_base__hasher_u32__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+// --------
+
+extern const char wuffs_base__hasher_u64__vtable_name[];
+
+typedef struct wuffs_base__hasher_u64__func_ptrs__struct {
+  uint64_t (*checksum_u64)(
+    const void* self);
+  uint64_t (*get_quirk)(
+    const void* self,
+    uint32_t a_key);
+  wuffs_base__status (*set_quirk)(
+    void* self,
+    uint32_t a_key,
+    uint64_t a_value);
+  wuffs_base__empty_struct (*update)(
+    void* self,
+    wuffs_base__slice_u8 a_x);
+  uint64_t (*update_u64)(
+    void* self,
+    wuffs_base__slice_u8 a_x);
+} wuffs_base__hasher_u64__func_ptrs;
+
+typedef struct wuffs_base__hasher_u64__struct wuffs_base__hasher_u64;
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__hasher_u64__checksum_u64(
+    const wuffs_base__hasher_u64* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__hasher_u64__get_quirk(
+    const wuffs_base__hasher_u64* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__hasher_u64__set_quirk(
+    wuffs_base__hasher_u64* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_base__hasher_u64__update(
+    wuffs_base__hasher_u64* self,
+    wuffs_base__slice_u8 a_x);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__hasher_u64__update_u64(
+    wuffs_base__hasher_u64* self,
+    wuffs_base__slice_u8 a_x);
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_base__hasher_u64__struct {
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable first_vtable;
+  } private_impl;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_base__hasher_u64, wuffs_unique_ptr_deleter>;
+#endif
+
+  inline uint64_t
+  checksum_u64() const {
+    return wuffs_base__hasher_u64__checksum_u64(this);
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_base__hasher_u64__get_quirk(
+        this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_base__hasher_u64__set_quirk(
+        this, a_key, a_value);
+  }
+
+  inline wuffs_base__empty_struct
+  update(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_base__hasher_u64__update(
+        this, a_x);
+  }
+
+  inline uint64_t
+  update_u64(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_base__hasher_u64__update_u64(
+        this, a_x);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_base__hasher_u64__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+// --------
+
+extern const char wuffs_base__image_decoder__vtable_name[];
+
+typedef struct wuffs_base__image_decoder__func_ptrs__struct {
+  wuffs_base__status (*decode_frame)(
+    void* self,
+    wuffs_base__pixel_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__pixel_blend a_blend,
+    wuffs_base__slice_u8 a_workbuf,
+    wuffs_base__decode_frame_options* a_opts);
+  wuffs_base__status (*decode_frame_config)(
+    void* self,
+    wuffs_base__frame_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+  wuffs_base__status (*decode_image_config)(
+    void* self,
+    wuffs_base__image_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+  wuffs_base__rect_ie_u32 (*frame_dirty_rect)(
+    const void* self);
+  uint64_t (*get_quirk)(
+    const void* self,
+    uint32_t a_key);
+  uint64_t (*history_retain_length)(
+    const void* self);
+  uint32_t (*num_animation_loops)(
+    const void* self);
+  uint64_t (*num_decoded_frame_configs)(
+    const void* self);
+  uint64_t (*num_decoded_frames)(
+    const void* self);
+  wuffs_base__status (*restart_frame)(
+    void* self,
+    uint64_t a_index,
+    uint64_t a_io_position);
+  wuffs_base__status (*set_quirk)(
+    void* self,
+    uint32_t a_key,
+    uint64_t a_value);
+  wuffs_base__empty_struct (*set_report_metadata)(
+    void* self,
+    uint32_t a_fourcc,
+    bool a_report);
+  wuffs_base__status (*tell_me_more)(
+    void* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__more_information* a_minfo,
+    wuffs_base__io_buffer* a_src);
+  wuffs_base__range_ii_u64 (*workbuf_len)(
+    const void* self);
+} wuffs_base__image_decoder__func_ptrs;
+
+typedef struct wuffs_base__image_decoder__struct wuffs_base__image_decoder;
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__decode_frame(
+    wuffs_base__image_decoder* self,
+    wuffs_base__pixel_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__pixel_blend a_blend,
+    wuffs_base__slice_u8 a_workbuf,
+    wuffs_base__decode_frame_options* a_opts);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__decode_frame_config(
+    wuffs_base__image_decoder* self,
+    wuffs_base__frame_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__decode_image_config(
+    wuffs_base__image_decoder* self,
+    wuffs_base__image_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
+wuffs_base__image_decoder__frame_dirty_rect(
+    const wuffs_base__image_decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__image_decoder__get_quirk(
+    const wuffs_base__image_decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__image_decoder__history_retain_length(
+    const wuffs_base__image_decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_base__image_decoder__num_animation_loops(
+    const wuffs_base__image_decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__image_decoder__num_decoded_frame_configs(
+    const wuffs_base__image_decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__image_decoder__num_decoded_frames(
+    const wuffs_base__image_decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__restart_frame(
+    wuffs_base__image_decoder* self,
+    uint64_t a_index,
+    uint64_t a_io_position);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__set_quirk(
+    wuffs_base__image_decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_base__image_decoder__set_report_metadata(
+    wuffs_base__image_decoder* self,
+    uint32_t a_fourcc,
+    bool a_report);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__tell_me_more(
+    wuffs_base__image_decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__more_information* a_minfo,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_base__image_decoder__workbuf_len(
+    const wuffs_base__image_decoder* self);
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_base__image_decoder__struct {
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable first_vtable;
+  } private_impl;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_base__image_decoder, wuffs_unique_ptr_deleter>;
+#endif
+
+  inline wuffs_base__status
+  decode_frame(
+      wuffs_base__pixel_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__pixel_blend a_blend,
+      wuffs_base__slice_u8 a_workbuf,
+      wuffs_base__decode_frame_options* a_opts) {
+    return wuffs_base__image_decoder__decode_frame(
+        this, a_dst, a_src, a_blend, a_workbuf, a_opts);
+  }
+
+  inline wuffs_base__status
+  decode_frame_config(
+      wuffs_base__frame_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_base__image_decoder__decode_frame_config(
+        this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_image_config(
+      wuffs_base__image_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_base__image_decoder__decode_image_config(
+        this, a_dst, a_src);
+  }
+
+  inline wuffs_base__rect_ie_u32
+  frame_dirty_rect() const {
+    return wuffs_base__image_decoder__frame_dirty_rect(this);
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_base__image_decoder__get_quirk(
+        this, a_key);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_base__image_decoder__history_retain_length(this);
+  }
+
+  inline uint32_t
+  num_animation_loops() const {
+    return wuffs_base__image_decoder__num_animation_loops(this);
+  }
+
+  inline uint64_t
+  num_decoded_frame_configs() const {
+    return wuffs_base__image_decoder__num_decoded_frame_configs(this);
+  }
+
+  inline uint64_t
+  num_decoded_frames() const {
+    return wuffs_base__image_decoder__num_decoded_frames(this);
+  }
+
+  inline wuffs_base__status
+  restart_frame(
+      uint64_t a_index,
+      uint64_t a_io_position) {
+    return wuffs_base__image_decoder__restart_frame(
+        this, a_index, a_io_position);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_base__image_decoder__set_quirk(
+        this, a_key, a_value);
+  }
+
+  inline wuffs_base__empty_struct
+  set_report_metadata(
+      uint32_t a_fourcc,
+      bool a_report) {
+    return wuffs_base__image_decoder__set_report_metadata(
+        this, a_fourcc, a_report);
+  }
+
+  inline wuffs_base__status
+  tell_me_more(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__more_information* a_minfo,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_base__image_decoder__tell_me_more(
+        this, a_dst, a_minfo, a_src);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_base__image_decoder__workbuf_len(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_base__image_decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+// --------
+
+extern const char wuffs_base__io_transformer__vtable_name[];
+
+typedef struct wuffs_base__io_transformer__func_ptrs__struct {
+  uint64_t (*get_quirk)(
+    const void* self,
+    uint32_t a_key);
+  uint64_t (*history_retain_length)(
+    const void* self);
+  wuffs_base__status (*set_quirk)(
+    void* self,
+    uint32_t a_key,
+    uint64_t a_value);
+  wuffs_base__status (*transform_io)(
+    void* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf);
+  wuffs_base__range_ii_u64 (*workbuf_len)(
+    const void* self);
+} wuffs_base__io_transformer__func_ptrs;
+
+typedef struct wuffs_base__io_transformer__struct wuffs_base__io_transformer;
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__io_transformer__get_quirk(
+    const wuffs_base__io_transformer* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__io_transformer__history_retain_length(
+    const wuffs_base__io_transformer* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__io_transformer__set_quirk(
+    wuffs_base__io_transformer* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__io_transformer__transform_io(
+    wuffs_base__io_transformer* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_base__io_transformer__workbuf_len(
+    const wuffs_base__io_transformer* self);
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_base__io_transformer__struct {
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable first_vtable;
+  } private_impl;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_base__io_transformer, wuffs_unique_ptr_deleter>;
+#endif
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_base__io_transformer__get_quirk(
+        this, a_key);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_base__io_transformer__history_retain_length(this);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_base__io_transformer__set_quirk(
+        this, a_key, a_value);
+  }
+
+  inline wuffs_base__status
+  transform_io(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__slice_u8 a_workbuf) {
+    return wuffs_base__io_transformer__transform_io(
+        this, a_dst, a_src, a_workbuf);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_base__io_transformer__workbuf_len(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_base__io_transformer__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+// --------
+
+extern const char wuffs_base__token_decoder__vtable_name[];
+
+typedef struct wuffs_base__token_decoder__func_ptrs__struct {
+  wuffs_base__status (*decode_tokens)(
+    void* self,
+    wuffs_base__token_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf);
+  uint64_t (*get_quirk)(
+    const void* self,
+    uint32_t a_key);
+  uint64_t (*history_retain_length)(
+    const void* self);
+  wuffs_base__status (*set_quirk)(
+    void* self,
+    uint32_t a_key,
+    uint64_t a_value);
+  wuffs_base__range_ii_u64 (*workbuf_len)(
+    const void* self);
+} wuffs_base__token_decoder__func_ptrs;
+
+typedef struct wuffs_base__token_decoder__struct wuffs_base__token_decoder;
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__token_decoder__decode_tokens(
+    wuffs_base__token_decoder* self,
+    wuffs_base__token_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__token_decoder__get_quirk(
+    const wuffs_base__token_decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__token_decoder__history_retain_length(
+    const wuffs_base__token_decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__token_decoder__set_quirk(
+    wuffs_base__token_decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_base__token_decoder__workbuf_len(
+    const wuffs_base__token_decoder* self);
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_base__token_decoder__struct {
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable first_vtable;
+  } private_impl;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_base__token_decoder, wuffs_unique_ptr_deleter>;
+#endif
+
+  inline wuffs_base__status
+  decode_tokens(
+      wuffs_base__token_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__slice_u8 a_workbuf) {
+    return wuffs_base__token_decoder__decode_tokens(
+        this, a_dst, a_src, a_workbuf);
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_base__token_decoder__get_quirk(
+        this, a_key);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_base__token_decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_base__token_decoder__set_quirk(
+        this, a_key, a_value);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_base__token_decoder__workbuf_len(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_base__token_decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+// ----------------
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ADLER32) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+// ---------------- Public Consts
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_adler32__hasher__struct wuffs_adler32__hasher;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_adler32__hasher__initialize(
+    wuffs_adler32__hasher* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_adler32__hasher();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_adler32__hasher*
+wuffs_adler32__hasher__alloc();
+
+static inline wuffs_base__hasher_u32*
+wuffs_adler32__hasher__alloc_as__wuffs_base__hasher_u32() {
+  return (wuffs_base__hasher_u32*)(wuffs_adler32__hasher__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__hasher_u32*
+wuffs_adler32__hasher__upcast_as__wuffs_base__hasher_u32(
+    wuffs_adler32__hasher* p) {
+  return (wuffs_base__hasher_u32*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_adler32__hasher__get_quirk(
+    const wuffs_adler32__hasher* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_adler32__hasher__set_quirk(
+    wuffs_adler32__hasher* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_adler32__hasher__update(
+    wuffs_adler32__hasher* self,
+    wuffs_base__slice_u8 a_x);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_adler32__hasher__update_u32(
+    wuffs_adler32__hasher* self,
+    wuffs_base__slice_u8 a_x);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_adler32__hasher__checksum_u32(
+    const wuffs_adler32__hasher* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_adler32__hasher__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__hasher_u32;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_state;
+    bool f_started;
+
+    wuffs_base__empty_struct (*choosy_up)(
+        wuffs_adler32__hasher* self,
+        wuffs_base__slice_u8 a_x);
+  } private_impl;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_adler32__hasher, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_adler32__hasher__alloc());
+  }
+
+  static inline wuffs_base__hasher_u32::unique_ptr
+  alloc_as__wuffs_base__hasher_u32() {
+    return wuffs_base__hasher_u32::unique_ptr(
+        wuffs_adler32__hasher__alloc_as__wuffs_base__hasher_u32());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_adler32__hasher__struct() = delete;
+  wuffs_adler32__hasher__struct(const wuffs_adler32__hasher__struct&) = delete;
+  wuffs_adler32__hasher__struct& operator=(
+      const wuffs_adler32__hasher__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_adler32__hasher__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__hasher_u32*
+  upcast_as__wuffs_base__hasher_u32() {
+    return (wuffs_base__hasher_u32*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_adler32__hasher__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_adler32__hasher__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__empty_struct
+  update(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_adler32__hasher__update(this, a_x);
+  }
+
+  inline uint32_t
+  update_u32(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_adler32__hasher__update_u32(this, a_x);
+  }
+
+  inline uint32_t
+  checksum_u32() const {
+    return wuffs_adler32__hasher__checksum_u32(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_adler32__hasher__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ADLER32) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BMP) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_bmp__error__bad_header[];
+extern const char wuffs_bmp__error__bad_rle_compression[];
+extern const char wuffs_bmp__error__truncated_input[];
+extern const char wuffs_bmp__error__unsupported_bmp_file[];
+
+// ---------------- Public Consts
+
+#define WUFFS_BMP__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_BMP__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_bmp__decoder__struct wuffs_bmp__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_bmp__decoder__initialize(
+    wuffs_bmp__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_bmp__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_bmp__decoder*
+wuffs_bmp__decoder__alloc();
+
+static inline wuffs_base__image_decoder*
+wuffs_bmp__decoder__alloc_as__wuffs_base__image_decoder() {
+  return (wuffs_base__image_decoder*)(wuffs_bmp__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__image_decoder*
+wuffs_bmp__decoder__upcast_as__wuffs_base__image_decoder(
+    wuffs_bmp__decoder* p) {
+  return (wuffs_base__image_decoder*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_bmp__decoder__get_quirk(
+    const wuffs_bmp__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_bmp__decoder__set_quirk(
+    wuffs_bmp__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_bmp__decoder__decode_image_config(
+    wuffs_bmp__decoder* self,
+    wuffs_base__image_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_bmp__decoder__decode_frame_config(
+    wuffs_bmp__decoder* self,
+    wuffs_base__frame_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_bmp__decoder__decode_frame(
+    wuffs_bmp__decoder* self,
+    wuffs_base__pixel_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__pixel_blend a_blend,
+    wuffs_base__slice_u8 a_workbuf,
+    wuffs_base__decode_frame_options* a_opts);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
+wuffs_bmp__decoder__frame_dirty_rect(
+    const wuffs_bmp__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_bmp__decoder__num_animation_loops(
+    const wuffs_bmp__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_bmp__decoder__num_decoded_frame_configs(
+    const wuffs_bmp__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_bmp__decoder__num_decoded_frames(
+    const wuffs_bmp__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_bmp__decoder__restart_frame(
+    wuffs_bmp__decoder* self,
+    uint64_t a_index,
+    uint64_t a_io_position);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_bmp__decoder__set_report_metadata(
+    wuffs_bmp__decoder* self,
+    uint32_t a_fourcc,
+    bool a_report);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_bmp__decoder__tell_me_more(
+    wuffs_bmp__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__more_information* a_minfo,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_bmp__decoder__history_retain_length(
+    const wuffs_bmp__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_bmp__decoder__workbuf_len(
+    const wuffs_bmp__decoder* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_bmp__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_width;
+    uint32_t f_height;
+    uint8_t f_call_sequence;
+    bool f_top_down;
+    uint32_t f_pad_per_row;
+    uint32_t f_src_pixfmt;
+    uint32_t f_io_redirect_fourcc;
+    uint64_t f_io_redirect_pos;
+    uint64_t f_frame_config_io_position;
+    uint32_t f_bitmap_info_len;
+    uint32_t f_padding;
+    uint32_t f_bits_per_pixel;
+    uint32_t f_compression;
+    uint32_t f_channel_masks[4];
+    uint8_t f_channel_shifts[4];
+    uint8_t f_channel_num_bits[4];
+    uint32_t f_dst_x;
+    uint32_t f_dst_y;
+    uint32_t f_dst_y_inc;
+    uint32_t f_pending_pad;
+    uint32_t f_rle_state;
+    uint32_t f_rle_length;
+    uint8_t f_rle_delta_x;
+    bool f_rle_padded;
+    wuffs_base__pixel_swizzler f_swizzler;
+
+    uint32_t p_decode_image_config[1];
+    uint32_t p_do_decode_image_config[1];
+    uint32_t p_decode_frame_config[1];
+    uint32_t p_do_decode_frame_config[1];
+    uint32_t p_decode_frame[1];
+    uint32_t p_do_decode_frame[1];
+    uint32_t p_tell_me_more[1];
+    uint32_t p_read_palette[1];
+  } private_impl;
+
+  struct {
+    uint8_t f_scratch[2048];
+    uint8_t f_src_palette[1024];
+
+    struct {
+      uint64_t scratch;
+    } s_do_decode_image_config[1];
+    struct {
+      uint64_t scratch;
+    } s_do_decode_frame[1];
+    struct {
+      uint32_t v_i;
+      uint64_t scratch;
+    } s_read_palette[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_bmp__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_bmp__decoder__alloc());
+  }
+
+  static inline wuffs_base__image_decoder::unique_ptr
+  alloc_as__wuffs_base__image_decoder() {
+    return wuffs_base__image_decoder::unique_ptr(
+        wuffs_bmp__decoder__alloc_as__wuffs_base__image_decoder());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_bmp__decoder__struct() = delete;
+  wuffs_bmp__decoder__struct(const wuffs_bmp__decoder__struct&) = delete;
+  wuffs_bmp__decoder__struct& operator=(
+      const wuffs_bmp__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_bmp__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__image_decoder*
+  upcast_as__wuffs_base__image_decoder() {
+    return (wuffs_base__image_decoder*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_bmp__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_bmp__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__status
+  decode_image_config(
+      wuffs_base__image_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_bmp__decoder__decode_image_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame_config(
+      wuffs_base__frame_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_bmp__decoder__decode_frame_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame(
+      wuffs_base__pixel_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__pixel_blend a_blend,
+      wuffs_base__slice_u8 a_workbuf,
+      wuffs_base__decode_frame_options* a_opts) {
+    return wuffs_bmp__decoder__decode_frame(this, a_dst, a_src, a_blend, a_workbuf, a_opts);
+  }
+
+  inline wuffs_base__rect_ie_u32
+  frame_dirty_rect() const {
+    return wuffs_bmp__decoder__frame_dirty_rect(this);
+  }
+
+  inline uint32_t
+  num_animation_loops() const {
+    return wuffs_bmp__decoder__num_animation_loops(this);
+  }
+
+  inline uint64_t
+  num_decoded_frame_configs() const {
+    return wuffs_bmp__decoder__num_decoded_frame_configs(this);
+  }
+
+  inline uint64_t
+  num_decoded_frames() const {
+    return wuffs_bmp__decoder__num_decoded_frames(this);
+  }
+
+  inline wuffs_base__status
+  restart_frame(
+      uint64_t a_index,
+      uint64_t a_io_position) {
+    return wuffs_bmp__decoder__restart_frame(this, a_index, a_io_position);
+  }
+
+  inline wuffs_base__empty_struct
+  set_report_metadata(
+      uint32_t a_fourcc,
+      bool a_report) {
+    return wuffs_bmp__decoder__set_report_metadata(this, a_fourcc, a_report);
+  }
+
+  inline wuffs_base__status
+  tell_me_more(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__more_information* a_minfo,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_bmp__decoder__tell_me_more(this, a_dst, a_minfo, a_src);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_bmp__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_bmp__decoder__workbuf_len(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_bmp__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BMP) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BZIP2) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_bzip2__error__bad_huffman_code_over_subscribed[];
+extern const char wuffs_bzip2__error__bad_huffman_code_under_subscribed[];
+extern const char wuffs_bzip2__error__bad_block_header[];
+extern const char wuffs_bzip2__error__bad_block_length[];
+extern const char wuffs_bzip2__error__bad_checksum[];
+extern const char wuffs_bzip2__error__bad_header[];
+extern const char wuffs_bzip2__error__bad_number_of_sections[];
+extern const char wuffs_bzip2__error__truncated_input[];
+extern const char wuffs_bzip2__error__unsupported_block_randomization[];
+
+// ---------------- Public Consts
+
+#define WUFFS_BZIP2__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_BZIP2__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_bzip2__decoder__struct wuffs_bzip2__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_bzip2__decoder__initialize(
+    wuffs_bzip2__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_bzip2__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_bzip2__decoder*
+wuffs_bzip2__decoder__alloc();
+
+static inline wuffs_base__io_transformer*
+wuffs_bzip2__decoder__alloc_as__wuffs_base__io_transformer() {
+  return (wuffs_base__io_transformer*)(wuffs_bzip2__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__io_transformer*
+wuffs_bzip2__decoder__upcast_as__wuffs_base__io_transformer(
+    wuffs_bzip2__decoder* p) {
+  return (wuffs_base__io_transformer*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_bzip2__decoder__get_quirk(
+    const wuffs_bzip2__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_bzip2__decoder__set_quirk(
+    wuffs_bzip2__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_bzip2__decoder__history_retain_length(
+    const wuffs_bzip2__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_bzip2__decoder__workbuf_len(
+    const wuffs_bzip2__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_bzip2__decoder__transform_io(
+    wuffs_bzip2__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_bzip2__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__io_transformer;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_bits;
+    uint32_t f_n_bits;
+    uint32_t f_max_incl_block_size;
+    uint32_t f_block_size;
+    bool f_decode_huffman_finished;
+    uint8_t f_decode_huffman_which;
+    uint32_t f_decode_huffman_ticks;
+    uint32_t f_decode_huffman_section;
+    uint32_t f_decode_huffman_run_shift;
+    uint32_t f_flush_pointer;
+    uint32_t f_flush_repeat_count;
+    uint8_t f_flush_prev;
+    bool f_ignore_checksum;
+    uint32_t f_final_checksum_have;
+    uint32_t f_block_checksum_have;
+    uint32_t f_block_checksum_want;
+    uint32_t f_original_pointer;
+    uint32_t f_num_symbols;
+    uint32_t f_num_huffman_codes;
+    uint32_t f_num_sections;
+    uint32_t f_code_lengths_bitmask;
+
+    uint32_t p_transform_io[1];
+    uint32_t p_do_transform_io[1];
+    uint32_t p_prepare_block[1];
+    uint32_t p_read_code_lengths[1];
+    uint32_t p_flush_slow[1];
+    uint32_t p_decode_huffman_slow[1];
+  } private_impl;
+
+  struct {
+    uint32_t f_scratch;
+    uint32_t f_letter_counts[256];
+    uint8_t f_presence[256];
+    uint8_t f_mtft[256];
+    uint8_t f_huffman_selectors[32768];
+    uint16_t f_huffman_trees[6][257][2];
+    uint16_t f_huffman_tables[6][256];
+    uint32_t f_bwt[1048576];
+
+    struct {
+      uint32_t v_i;
+      uint64_t v_tag;
+      uint32_t v_final_checksum_want;
+    } s_do_transform_io[1];
+    struct {
+      uint32_t v_i;
+      uint32_t v_selector;
+    } s_prepare_block[1];
+    struct {
+      uint32_t v_i;
+      uint32_t v_code_length;
+    } s_read_code_lengths[1];
+    struct {
+      uint32_t v_flush_pointer;
+      uint32_t v_flush_repeat_count;
+      uint8_t v_flush_prev;
+      uint32_t v_block_checksum_have;
+      uint32_t v_block_size;
+      uint8_t v_curr;
+      uint64_t scratch;
+    } s_flush_slow[1];
+    struct {
+      uint32_t v_node_index;
+    } s_decode_huffman_slow[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_bzip2__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_bzip2__decoder__alloc());
+  }
+
+  static inline wuffs_base__io_transformer::unique_ptr
+  alloc_as__wuffs_base__io_transformer() {
+    return wuffs_base__io_transformer::unique_ptr(
+        wuffs_bzip2__decoder__alloc_as__wuffs_base__io_transformer());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_bzip2__decoder__struct() = delete;
+  wuffs_bzip2__decoder__struct(const wuffs_bzip2__decoder__struct&) = delete;
+  wuffs_bzip2__decoder__struct& operator=(
+      const wuffs_bzip2__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_bzip2__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__io_transformer*
+  upcast_as__wuffs_base__io_transformer() {
+    return (wuffs_base__io_transformer*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_bzip2__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_bzip2__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_bzip2__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_bzip2__decoder__workbuf_len(this);
+  }
+
+  inline wuffs_base__status
+  transform_io(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__slice_u8 a_workbuf) {
+    return wuffs_bzip2__decoder__transform_io(this, a_dst, a_src, a_workbuf);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_bzip2__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BZIP2) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CBOR) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_cbor__error__bad_input[];
+extern const char wuffs_cbor__error__unsupported_recursion_depth[];
+
+// ---------------- Public Consts
+
+#define WUFFS_CBOR__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_CBOR__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_CBOR__DECODER_DEPTH_MAX_INCL 1024
+
+#define WUFFS_CBOR__DECODER_DST_TOKEN_BUFFER_LENGTH_MIN_INCL 2
+
+#define WUFFS_CBOR__DECODER_SRC_IO_BUFFER_LENGTH_MIN_INCL 9
+
+#define WUFFS_CBOR__TOKEN_VALUE_MAJOR 787997
+
+#define WUFFS_CBOR__TOKEN_VALUE_MINOR__DETAIL_MASK 262143
+
+#define WUFFS_CBOR__TOKEN_VALUE_MINOR__MINUS_1_MINUS_X 16777216
+
+#define WUFFS_CBOR__TOKEN_VALUE_MINOR__SIMPLE_VALUE 8388608
+
+#define WUFFS_CBOR__TOKEN_VALUE_MINOR__TAG 4194304
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_cbor__decoder__struct wuffs_cbor__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_cbor__decoder__initialize(
+    wuffs_cbor__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_cbor__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_cbor__decoder*
+wuffs_cbor__decoder__alloc();
+
+static inline wuffs_base__token_decoder*
+wuffs_cbor__decoder__alloc_as__wuffs_base__token_decoder() {
+  return (wuffs_base__token_decoder*)(wuffs_cbor__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__token_decoder*
+wuffs_cbor__decoder__upcast_as__wuffs_base__token_decoder(
+    wuffs_cbor__decoder* p) {
+  return (wuffs_base__token_decoder*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_cbor__decoder__get_quirk(
+    const wuffs_cbor__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_cbor__decoder__set_quirk(
+    wuffs_cbor__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_cbor__decoder__history_retain_length(
+    const wuffs_cbor__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_cbor__decoder__workbuf_len(
+    const wuffs_cbor__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_cbor__decoder__decode_tokens(
+    wuffs_cbor__decoder* self,
+    wuffs_base__token_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_cbor__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__token_decoder;
+    wuffs_base__vtable null_vtable;
+
+    bool f_end_of_data;
+
+    uint32_t p_decode_tokens[1];
+  } private_impl;
+
+  struct {
+    uint32_t f_stack[64];
+    uint64_t f_container_num_remaining[1024];
+
+    struct {
+      uint64_t v_string_length;
+      uint32_t v_depth;
+      bool v_tagged;
+      uint8_t v_indefinite_string_major_type;
+    } s_decode_tokens[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_cbor__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_cbor__decoder__alloc());
+  }
+
+  static inline wuffs_base__token_decoder::unique_ptr
+  alloc_as__wuffs_base__token_decoder() {
+    return wuffs_base__token_decoder::unique_ptr(
+        wuffs_cbor__decoder__alloc_as__wuffs_base__token_decoder());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_cbor__decoder__struct() = delete;
+  wuffs_cbor__decoder__struct(const wuffs_cbor__decoder__struct&) = delete;
+  wuffs_cbor__decoder__struct& operator=(
+      const wuffs_cbor__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_cbor__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__token_decoder*
+  upcast_as__wuffs_base__token_decoder() {
+    return (wuffs_base__token_decoder*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_cbor__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_cbor__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_cbor__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_cbor__decoder__workbuf_len(this);
+  }
+
+  inline wuffs_base__status
+  decode_tokens(
+      wuffs_base__token_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__slice_u8 a_workbuf) {
+    return wuffs_cbor__decoder__decode_tokens(this, a_dst, a_src, a_workbuf);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_cbor__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CBOR) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CRC32) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+// ---------------- Public Consts
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_crc32__ieee_hasher__struct wuffs_crc32__ieee_hasher;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_crc32__ieee_hasher__initialize(
+    wuffs_crc32__ieee_hasher* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_crc32__ieee_hasher();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_crc32__ieee_hasher*
+wuffs_crc32__ieee_hasher__alloc();
+
+static inline wuffs_base__hasher_u32*
+wuffs_crc32__ieee_hasher__alloc_as__wuffs_base__hasher_u32() {
+  return (wuffs_base__hasher_u32*)(wuffs_crc32__ieee_hasher__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__hasher_u32*
+wuffs_crc32__ieee_hasher__upcast_as__wuffs_base__hasher_u32(
+    wuffs_crc32__ieee_hasher* p) {
+  return (wuffs_base__hasher_u32*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_crc32__ieee_hasher__get_quirk(
+    const wuffs_crc32__ieee_hasher* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_crc32__ieee_hasher__set_quirk(
+    wuffs_crc32__ieee_hasher* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_crc32__ieee_hasher__update(
+    wuffs_crc32__ieee_hasher* self,
+    wuffs_base__slice_u8 a_x);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_crc32__ieee_hasher__update_u32(
+    wuffs_crc32__ieee_hasher* self,
+    wuffs_base__slice_u8 a_x);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_crc32__ieee_hasher__checksum_u32(
+    const wuffs_crc32__ieee_hasher* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_crc32__ieee_hasher__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__hasher_u32;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_state;
+
+    wuffs_base__empty_struct (*choosy_up)(
+        wuffs_crc32__ieee_hasher* self,
+        wuffs_base__slice_u8 a_x);
+  } private_impl;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_crc32__ieee_hasher, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_crc32__ieee_hasher__alloc());
+  }
+
+  static inline wuffs_base__hasher_u32::unique_ptr
+  alloc_as__wuffs_base__hasher_u32() {
+    return wuffs_base__hasher_u32::unique_ptr(
+        wuffs_crc32__ieee_hasher__alloc_as__wuffs_base__hasher_u32());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_crc32__ieee_hasher__struct() = delete;
+  wuffs_crc32__ieee_hasher__struct(const wuffs_crc32__ieee_hasher__struct&) = delete;
+  wuffs_crc32__ieee_hasher__struct& operator=(
+      const wuffs_crc32__ieee_hasher__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_crc32__ieee_hasher__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__hasher_u32*
+  upcast_as__wuffs_base__hasher_u32() {
+    return (wuffs_base__hasher_u32*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_crc32__ieee_hasher__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_crc32__ieee_hasher__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__empty_struct
+  update(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_crc32__ieee_hasher__update(this, a_x);
+  }
+
+  inline uint32_t
+  update_u32(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_crc32__ieee_hasher__update_u32(this, a_x);
+  }
+
+  inline uint32_t
+  checksum_u32() const {
+    return wuffs_crc32__ieee_hasher__checksum_u32(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_crc32__ieee_hasher__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CRC32) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__DEFLATE) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_deflate__error__bad_huffman_code_over_subscribed[];
+extern const char wuffs_deflate__error__bad_huffman_code_under_subscribed[];
+extern const char wuffs_deflate__error__bad_huffman_code_length_count[];
+extern const char wuffs_deflate__error__bad_huffman_code_length_repetition[];
+extern const char wuffs_deflate__error__bad_huffman_code[];
+extern const char wuffs_deflate__error__bad_huffman_minimum_code_length[];
+extern const char wuffs_deflate__error__bad_block[];
+extern const char wuffs_deflate__error__bad_distance[];
+extern const char wuffs_deflate__error__bad_distance_code_count[];
+extern const char wuffs_deflate__error__bad_literal_length_code_count[];
+extern const char wuffs_deflate__error__inconsistent_stored_block_length[];
+extern const char wuffs_deflate__error__missing_end_of_block_code[];
+extern const char wuffs_deflate__error__no_huffman_codes[];
+extern const char wuffs_deflate__error__truncated_input[];
+
+// ---------------- Public Consts
+
+#define WUFFS_DEFLATE__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_DEFLATE__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 1
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_deflate__decoder__struct wuffs_deflate__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_deflate__decoder__initialize(
+    wuffs_deflate__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_deflate__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_deflate__decoder*
+wuffs_deflate__decoder__alloc();
+
+static inline wuffs_base__io_transformer*
+wuffs_deflate__decoder__alloc_as__wuffs_base__io_transformer() {
+  return (wuffs_base__io_transformer*)(wuffs_deflate__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__io_transformer*
+wuffs_deflate__decoder__upcast_as__wuffs_base__io_transformer(
+    wuffs_deflate__decoder* p) {
+  return (wuffs_base__io_transformer*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_deflate__decoder__add_history(
+    wuffs_deflate__decoder* self,
+    wuffs_base__slice_u8 a_hist);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_deflate__decoder__get_quirk(
+    const wuffs_deflate__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_deflate__decoder__set_quirk(
+    wuffs_deflate__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_deflate__decoder__history_retain_length(
+    const wuffs_deflate__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_deflate__decoder__workbuf_len(
+    const wuffs_deflate__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_deflate__decoder__transform_io(
+    wuffs_deflate__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_deflate__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__io_transformer;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_bits;
+    uint32_t f_n_bits;
+    uint64_t f_transformed_history_count;
+    uint32_t f_history_index;
+    uint32_t f_n_huffs_bits[2];
+    bool f_end_of_block;
+
+    uint32_t p_transform_io[1];
+    uint32_t p_do_transform_io[1];
+    uint32_t p_decode_blocks[1];
+    uint32_t p_decode_uncompressed[1];
+    uint32_t p_init_dynamic_huffman[1];
+    wuffs_base__status (*choosy_decode_huffman_fast64)(
+        wuffs_deflate__decoder* self,
+        wuffs_base__io_buffer* a_dst,
+        wuffs_base__io_buffer* a_src);
+    uint32_t p_decode_huffman_slow[1];
+  } private_impl;
+
+  struct {
+    uint32_t f_huffs[2][1024];
+    uint8_t f_history[33025];
+    uint8_t f_code_lengths[320];
+
+    struct {
+      uint32_t v_final;
+    } s_decode_blocks[1];
+    struct {
+      uint32_t v_length;
+      uint64_t scratch;
+    } s_decode_uncompressed[1];
+    struct {
+      uint32_t v_bits;
+      uint32_t v_n_bits;
+      uint32_t v_n_lit;
+      uint32_t v_n_dist;
+      uint32_t v_n_clen;
+      uint32_t v_i;
+      uint32_t v_mask;
+      uint32_t v_n_extra_bits;
+      uint8_t v_rep_symbol;
+      uint32_t v_rep_count;
+    } s_init_dynamic_huffman[1];
+    struct {
+      uint32_t v_bits;
+      uint32_t v_n_bits;
+      uint32_t v_table_entry_n_bits;
+      uint32_t v_lmask;
+      uint32_t v_dmask;
+      uint32_t v_redir_top;
+      uint32_t v_redir_mask;
+      uint32_t v_length;
+      uint32_t v_dist_minus_1;
+      uint64_t scratch;
+    } s_decode_huffman_slow[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_deflate__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_deflate__decoder__alloc());
+  }
+
+  static inline wuffs_base__io_transformer::unique_ptr
+  alloc_as__wuffs_base__io_transformer() {
+    return wuffs_base__io_transformer::unique_ptr(
+        wuffs_deflate__decoder__alloc_as__wuffs_base__io_transformer());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_deflate__decoder__struct() = delete;
+  wuffs_deflate__decoder__struct(const wuffs_deflate__decoder__struct&) = delete;
+  wuffs_deflate__decoder__struct& operator=(
+      const wuffs_deflate__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_deflate__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__io_transformer*
+  upcast_as__wuffs_base__io_transformer() {
+    return (wuffs_base__io_transformer*)this;
+  }
+
+  inline wuffs_base__empty_struct
+  add_history(
+      wuffs_base__slice_u8 a_hist) {
+    return wuffs_deflate__decoder__add_history(this, a_hist);
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_deflate__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_deflate__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_deflate__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_deflate__decoder__workbuf_len(this);
+  }
+
+  inline wuffs_base__status
+  transform_io(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__slice_u8 a_workbuf) {
+    return wuffs_deflate__decoder__transform_io(this, a_dst, a_src, a_workbuf);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_deflate__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__DEFLATE) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GIF) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_gif__error__bad_lzw_code[];
+extern const char wuffs_gif__error__bad_extension_label[];
+extern const char wuffs_gif__error__bad_frame_size[];
+extern const char wuffs_gif__error__bad_graphic_control[];
+extern const char wuffs_gif__error__bad_header[];
+extern const char wuffs_gif__error__bad_literal_width[];
+extern const char wuffs_gif__error__bad_palette[];
+extern const char wuffs_gif__error__truncated_input[];
+
+// ---------------- Public Consts
+
+#define WUFFS_GIF__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_GIF__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_GIF__QUIRK_DELAY_NUM_DECODED_FRAMES 1041635328
+
+#define WUFFS_GIF__QUIRK_FIRST_FRAME_LOCAL_PALETTE_MEANS_BLACK_BACKGROUND 1041635329
+
+#define WUFFS_GIF__QUIRK_HONOR_BACKGROUND_COLOR 1041635330
+
+#define WUFFS_GIF__QUIRK_IGNORE_TOO_MUCH_PIXEL_DATA 1041635331
+
+#define WUFFS_GIF__QUIRK_IMAGE_BOUNDS_ARE_STRICT 1041635332
+
+#define WUFFS_GIF__QUIRK_REJECT_EMPTY_FRAME 1041635333
+
+#define WUFFS_GIF__QUIRK_REJECT_EMPTY_PALETTE 1041635334
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_gif__decoder__struct wuffs_gif__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_gif__decoder__initialize(
+    wuffs_gif__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_gif__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_gif__decoder*
+wuffs_gif__decoder__alloc();
+
+static inline wuffs_base__image_decoder*
+wuffs_gif__decoder__alloc_as__wuffs_base__image_decoder() {
+  return (wuffs_base__image_decoder*)(wuffs_gif__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__image_decoder*
+wuffs_gif__decoder__upcast_as__wuffs_base__image_decoder(
+    wuffs_gif__decoder* p) {
+  return (wuffs_base__image_decoder*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_gif__decoder__get_quirk(
+    const wuffs_gif__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_gif__decoder__set_quirk(
+    wuffs_gif__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_gif__decoder__decode_image_config(
+    wuffs_gif__decoder* self,
+    wuffs_base__image_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_gif__decoder__set_report_metadata(
+    wuffs_gif__decoder* self,
+    uint32_t a_fourcc,
+    bool a_report);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_gif__decoder__tell_me_more(
+    wuffs_gif__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__more_information* a_minfo,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_gif__decoder__num_animation_loops(
+    const wuffs_gif__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_gif__decoder__num_decoded_frame_configs(
+    const wuffs_gif__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_gif__decoder__num_decoded_frames(
+    const wuffs_gif__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
+wuffs_gif__decoder__frame_dirty_rect(
+    const wuffs_gif__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_gif__decoder__history_retain_length(
+    const wuffs_gif__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_gif__decoder__workbuf_len(
+    const wuffs_gif__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_gif__decoder__restart_frame(
+    wuffs_gif__decoder* self,
+    uint64_t a_index,
+    uint64_t a_io_position);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_gif__decoder__decode_frame_config(
+    wuffs_gif__decoder* self,
+    wuffs_base__frame_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_gif__decoder__decode_frame(
+    wuffs_gif__decoder* self,
+    wuffs_base__pixel_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__pixel_blend a_blend,
+    wuffs_base__slice_u8 a_workbuf,
+    wuffs_base__decode_frame_options* a_opts);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_gif__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_width;
+    uint32_t f_height;
+    uint8_t f_call_sequence;
+    bool f_report_metadata_iccp;
+    bool f_report_metadata_xmp;
+    uint32_t f_metadata_fourcc;
+    uint64_t f_metadata_io_position;
+    bool f_quirks[7];
+    bool f_delayed_num_decoded_frames;
+    bool f_seen_header;
+    bool f_ignored_but_affects_benchmarks;
+    bool f_has_global_palette;
+    uint8_t f_interlace;
+    bool f_seen_num_animation_loops_value;
+    uint32_t f_num_animation_loops_value;
+    uint32_t f_background_color_u32_argb_premul;
+    uint32_t f_black_color_u32_argb_premul;
+    bool f_gc_has_transparent_index;
+    uint8_t f_gc_transparent_index;
+    uint8_t f_gc_disposal;
+    uint64_t f_gc_duration;
+    uint64_t f_frame_config_io_position;
+    uint64_t f_num_decoded_frame_configs_value;
+    uint64_t f_num_decoded_frames_value;
+    uint32_t f_frame_rect_x0;
+    uint32_t f_frame_rect_y0;
+    uint32_t f_frame_rect_x1;
+    uint32_t f_frame_rect_y1;
+    uint32_t f_dst_x;
+    uint32_t f_dst_y;
+    uint32_t f_dirty_max_excl_y;
+    uint64_t f_compressed_ri;
+    uint64_t f_compressed_wi;
+    wuffs_base__pixel_swizzler f_swizzler;
+    uint32_t f_lzw_pending_literal_width_plus_one;
+    uint32_t f_lzw_literal_width;
+    uint32_t f_lzw_clear_code;
+    uint32_t f_lzw_end_code;
+    uint32_t f_lzw_save_code;
+    uint32_t f_lzw_prev_code;
+    uint32_t f_lzw_width;
+    uint32_t f_lzw_bits;
+    uint32_t f_lzw_n_bits;
+    uint32_t f_lzw_output_ri;
+    uint32_t f_lzw_output_wi;
+    uint32_t f_lzw_read_from_return_value;
+    uint16_t f_lzw_prefixes[4096];
+
+    uint32_t p_decode_image_config[1];
+    uint32_t p_do_decode_image_config[1];
+    uint32_t p_tell_me_more[1];
+    uint32_t p_do_tell_me_more[1];
+    uint32_t p_decode_frame_config[1];
+    uint32_t p_do_decode_frame_config[1];
+    uint32_t p_skip_frame[1];
+    uint32_t p_decode_frame[1];
+    uint32_t p_do_decode_frame[1];
+    uint32_t p_decode_up_to_id_part1[1];
+    uint32_t p_decode_header[1];
+    uint32_t p_decode_lsd[1];
+    uint32_t p_decode_extension[1];
+    uint32_t p_skip_blocks[1];
+    uint32_t p_decode_ae[1];
+    uint32_t p_decode_gc[1];
+    uint32_t p_decode_id_part0[1];
+    uint32_t p_decode_id_part1[1];
+    uint32_t p_decode_id_part2[1];
+  } private_impl;
+
+  struct {
+    uint8_t f_compressed[4096];
+    uint8_t f_palettes[2][1024];
+    uint8_t f_dst_palette[1024];
+    uint8_t f_lzw_suffixes[4096][8];
+    uint16_t f_lzw_lm1s[4096];
+    uint8_t f_lzw_output[8199];
+
+    struct {
+      uint32_t v_background_color;
+    } s_do_decode_frame_config[1];
+    struct {
+      uint64_t scratch;
+    } s_skip_frame[1];
+    struct {
+      uint8_t v_c[6];
+      uint32_t v_i;
+    } s_decode_header[1];
+    struct {
+      uint8_t v_flags;
+      uint8_t v_background_color_index;
+      uint32_t v_num_palette_entries;
+      uint32_t v_i;
+      uint64_t scratch;
+    } s_decode_lsd[1];
+    struct {
+      uint64_t scratch;
+    } s_skip_blocks[1];
+    struct {
+      uint8_t v_block_size;
+      bool v_is_animexts;
+      bool v_is_netscape;
+      bool v_is_iccp;
+      bool v_is_xmp;
+      uint64_t scratch;
+    } s_decode_ae[1];
+    struct {
+      uint64_t scratch;
+    } s_decode_gc[1];
+    struct {
+      uint64_t scratch;
+    } s_decode_id_part0[1];
+    struct {
+      uint8_t v_which_palette;
+      uint32_t v_num_palette_entries;
+      uint32_t v_i;
+      uint64_t scratch;
+    } s_decode_id_part1[1];
+    struct {
+      uint64_t v_block_size;
+      bool v_need_block_size;
+      uint64_t scratch;
+    } s_decode_id_part2[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_gif__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_gif__decoder__alloc());
+  }
+
+  static inline wuffs_base__image_decoder::unique_ptr
+  alloc_as__wuffs_base__image_decoder() {
+    return wuffs_base__image_decoder::unique_ptr(
+        wuffs_gif__decoder__alloc_as__wuffs_base__image_decoder());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_gif__decoder__struct() = delete;
+  wuffs_gif__decoder__struct(const wuffs_gif__decoder__struct&) = delete;
+  wuffs_gif__decoder__struct& operator=(
+      const wuffs_gif__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_gif__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__image_decoder*
+  upcast_as__wuffs_base__image_decoder() {
+    return (wuffs_base__image_decoder*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_gif__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_gif__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__status
+  decode_image_config(
+      wuffs_base__image_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_gif__decoder__decode_image_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__empty_struct
+  set_report_metadata(
+      uint32_t a_fourcc,
+      bool a_report) {
+    return wuffs_gif__decoder__set_report_metadata(this, a_fourcc, a_report);
+  }
+
+  inline wuffs_base__status
+  tell_me_more(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__more_information* a_minfo,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_gif__decoder__tell_me_more(this, a_dst, a_minfo, a_src);
+  }
+
+  inline uint32_t
+  num_animation_loops() const {
+    return wuffs_gif__decoder__num_animation_loops(this);
+  }
+
+  inline uint64_t
+  num_decoded_frame_configs() const {
+    return wuffs_gif__decoder__num_decoded_frame_configs(this);
+  }
+
+  inline uint64_t
+  num_decoded_frames() const {
+    return wuffs_gif__decoder__num_decoded_frames(this);
+  }
+
+  inline wuffs_base__rect_ie_u32
+  frame_dirty_rect() const {
+    return wuffs_gif__decoder__frame_dirty_rect(this);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_gif__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_gif__decoder__workbuf_len(this);
+  }
+
+  inline wuffs_base__status
+  restart_frame(
+      uint64_t a_index,
+      uint64_t a_io_position) {
+    return wuffs_gif__decoder__restart_frame(this, a_index, a_io_position);
+  }
+
+  inline wuffs_base__status
+  decode_frame_config(
+      wuffs_base__frame_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_gif__decoder__decode_frame_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame(
+      wuffs_base__pixel_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__pixel_blend a_blend,
+      wuffs_base__slice_u8 a_workbuf,
+      wuffs_base__decode_frame_options* a_opts) {
+    return wuffs_gif__decoder__decode_frame(this, a_dst, a_src, a_blend, a_workbuf, a_opts);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_gif__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GIF) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GZIP) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_gzip__error__bad_checksum[];
+extern const char wuffs_gzip__error__bad_compression_method[];
+extern const char wuffs_gzip__error__bad_encoding_flags[];
+extern const char wuffs_gzip__error__bad_header[];
+extern const char wuffs_gzip__error__truncated_input[];
+
+// ---------------- Public Consts
+
+#define WUFFS_GZIP__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_GZIP__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 1
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_gzip__decoder__struct wuffs_gzip__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_gzip__decoder__initialize(
+    wuffs_gzip__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_gzip__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_gzip__decoder*
+wuffs_gzip__decoder__alloc();
+
+static inline wuffs_base__io_transformer*
+wuffs_gzip__decoder__alloc_as__wuffs_base__io_transformer() {
+  return (wuffs_base__io_transformer*)(wuffs_gzip__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__io_transformer*
+wuffs_gzip__decoder__upcast_as__wuffs_base__io_transformer(
+    wuffs_gzip__decoder* p) {
+  return (wuffs_base__io_transformer*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_gzip__decoder__get_quirk(
+    const wuffs_gzip__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_gzip__decoder__set_quirk(
+    wuffs_gzip__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_gzip__decoder__history_retain_length(
+    const wuffs_gzip__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_gzip__decoder__workbuf_len(
+    const wuffs_gzip__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_gzip__decoder__transform_io(
+    wuffs_gzip__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_gzip__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__io_transformer;
+    wuffs_base__vtable null_vtable;
+
+    bool f_ignore_checksum;
+
+    uint32_t p_transform_io[1];
+    uint32_t p_do_transform_io[1];
+  } private_impl;
+
+  struct {
+    wuffs_crc32__ieee_hasher f_checksum;
+    wuffs_deflate__decoder f_flate;
+
+    struct {
+      uint8_t v_flags;
+      uint32_t v_checksum_got;
+      uint32_t v_decoded_length_got;
+      uint32_t v_checksum_want;
+      uint64_t scratch;
+    } s_do_transform_io[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_gzip__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_gzip__decoder__alloc());
+  }
+
+  static inline wuffs_base__io_transformer::unique_ptr
+  alloc_as__wuffs_base__io_transformer() {
+    return wuffs_base__io_transformer::unique_ptr(
+        wuffs_gzip__decoder__alloc_as__wuffs_base__io_transformer());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_gzip__decoder__struct() = delete;
+  wuffs_gzip__decoder__struct(const wuffs_gzip__decoder__struct&) = delete;
+  wuffs_gzip__decoder__struct& operator=(
+      const wuffs_gzip__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_gzip__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__io_transformer*
+  upcast_as__wuffs_base__io_transformer() {
+    return (wuffs_base__io_transformer*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_gzip__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_gzip__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_gzip__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_gzip__decoder__workbuf_len(this);
+  }
+
+  inline wuffs_base__status
+  transform_io(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__slice_u8 a_workbuf) {
+    return wuffs_gzip__decoder__transform_io(this, a_dst, a_src, a_workbuf);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_gzip__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GZIP) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__JPEG) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_jpeg__error__bad_dht_marker[];
+extern const char wuffs_jpeg__error__bad_dqt_marker[];
+extern const char wuffs_jpeg__error__bad_dri_marker[];
+extern const char wuffs_jpeg__error__bad_sof_marker[];
+extern const char wuffs_jpeg__error__bad_sos_marker[];
+extern const char wuffs_jpeg__error__bad_header[];
+extern const char wuffs_jpeg__error__bad_marker[];
+extern const char wuffs_jpeg__error__missing_huffman_table[];
+extern const char wuffs_jpeg__error__missing_quantization_table[];
+extern const char wuffs_jpeg__error__truncated_input[];
+extern const char wuffs_jpeg__error__unsupported_arithmetic_coding[];
+extern const char wuffs_jpeg__error__unsupported_color_model[];
+extern const char wuffs_jpeg__error__unsupported_fractional_sampling[];
+extern const char wuffs_jpeg__error__unsupported_hierarchical_coding[];
+extern const char wuffs_jpeg__error__unsupported_implicit_height[];
+extern const char wuffs_jpeg__error__unsupported_lossless_coding[];
+extern const char wuffs_jpeg__error__unsupported_marker[];
+extern const char wuffs_jpeg__error__unsupported_precision_12_bits[];
+extern const char wuffs_jpeg__error__unsupported_precision_16_bits[];
+extern const char wuffs_jpeg__error__unsupported_precision[];
+extern const char wuffs_jpeg__error__unsupported_scan_count[];
+
+// ---------------- Public Consts
+
+#define WUFFS_JPEG__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_JPEG__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 51552191232
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_jpeg__decoder__struct wuffs_jpeg__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_jpeg__decoder__initialize(
+    wuffs_jpeg__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_jpeg__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_jpeg__decoder*
+wuffs_jpeg__decoder__alloc();
+
+static inline wuffs_base__image_decoder*
+wuffs_jpeg__decoder__alloc_as__wuffs_base__image_decoder() {
+  return (wuffs_base__image_decoder*)(wuffs_jpeg__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__image_decoder*
+wuffs_jpeg__decoder__upcast_as__wuffs_base__image_decoder(
+    wuffs_jpeg__decoder* p) {
+  return (wuffs_base__image_decoder*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_jpeg__decoder__get_quirk(
+    const wuffs_jpeg__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_jpeg__decoder__set_quirk(
+    wuffs_jpeg__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_jpeg__decoder__decode_image_config(
+    wuffs_jpeg__decoder* self,
+    wuffs_base__image_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_jpeg__decoder__decode_frame_config(
+    wuffs_jpeg__decoder* self,
+    wuffs_base__frame_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_jpeg__decoder__decode_frame(
+    wuffs_jpeg__decoder* self,
+    wuffs_base__pixel_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__pixel_blend a_blend,
+    wuffs_base__slice_u8 a_workbuf,
+    wuffs_base__decode_frame_options* a_opts);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
+wuffs_jpeg__decoder__frame_dirty_rect(
+    const wuffs_jpeg__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_jpeg__decoder__num_animation_loops(
+    const wuffs_jpeg__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_jpeg__decoder__num_decoded_frame_configs(
+    const wuffs_jpeg__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_jpeg__decoder__num_decoded_frames(
+    const wuffs_jpeg__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_jpeg__decoder__restart_frame(
+    wuffs_jpeg__decoder* self,
+    uint64_t a_index,
+    uint64_t a_io_position);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_jpeg__decoder__set_report_metadata(
+    wuffs_jpeg__decoder* self,
+    uint32_t a_fourcc,
+    bool a_report);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_jpeg__decoder__tell_me_more(
+    wuffs_jpeg__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__more_information* a_minfo,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_jpeg__decoder__history_retain_length(
+    const wuffs_jpeg__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_jpeg__decoder__workbuf_len(
+    const wuffs_jpeg__decoder* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_jpeg__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_width;
+    uint32_t f_height;
+    uint32_t f_width_in_mcus;
+    uint32_t f_height_in_mcus;
+    uint8_t f_call_sequence;
+    bool f_test_only_interrupt_decode_mcu;
+    bool f_is_jfif;
+    uint8_t f_is_adobe;
+    bool f_is_rgb_or_cmyk;
+    uint8_t f_sof_marker;
+    uint8_t f_next_restart_marker;
+    uint8_t f_max_incl_components_h;
+    uint8_t f_max_incl_components_v;
+    uint32_t f_num_components;
+    uint8_t f_components_c[4];
+    uint8_t f_components_h[4];
+    uint8_t f_components_v[4];
+    uint8_t f_components_tq[4];
+    uint32_t f_components_workbuf_widths[4];
+    uint32_t f_components_workbuf_heights[4];
+    uint64_t f_components_workbuf_offsets[9];
+    uint32_t f_scan_count;
+    uint32_t f_scan_num_components;
+    uint8_t f_scan_comps_cselector[4];
+    uint8_t f_scan_comps_td[4];
+    uint8_t f_scan_comps_ta[4];
+    uint8_t f_scan_ss;
+    uint8_t f_scan_se;
+    uint8_t f_scan_ah;
+    uint8_t f_scan_al;
+    uint32_t f_scan_width_in_mcus;
+    uint32_t f_scan_height_in_mcus;
+    uint8_t f_scan_comps_bx_offset[16];
+    uint8_t f_scan_comps_by_offset[16];
+    uint32_t f_mcu_num_blocks;
+    uint32_t f_mcu_current_block;
+    uint32_t f_mcu_zig_index;
+    uint8_t f_mcu_blocks_sselector[16];
+    uint64_t f_mcu_blocks_offset[10];
+    uint32_t f_mcu_blocks_mx_mul[10];
+    uint32_t f_mcu_blocks_my_mul[10];
+    uint8_t f_mcu_blocks_dc_hselector[10];
+    uint8_t f_mcu_blocks_ac_hselector[10];
+    uint16_t f_mcu_previous_dc_values[4];
+    uint8_t f_block_smoothing_lowest_scan_al[4][10];
+    uint16_t f_block_smoothing_dc_values[5][5];
+    uint32_t f_block_smoothing_mx_max_incl;
+    uint32_t f_block_smoothing_my_max_incl;
+    uint16_t f_restart_interval;
+    uint16_t f_saved_restart_interval;
+    uint16_t f_restarts_remaining;
+    uint16_t f_eob_run;
+    uint64_t f_frame_config_io_position;
+    uint32_t f_payload_length;
+    bool f_seen_dqt[4];
+    bool f_saved_seen_dqt[4];
+    bool f_seen_dht[8];
+    uint64_t f_bitstream_bits;
+    uint32_t f_bitstream_n_bits;
+    uint32_t f_bitstream_ri;
+    uint32_t f_bitstream_wi;
+    bool f_bitstream_is_closed;
+    uint32_t f_bitstream_padding;
+    uint16_t f_quant_tables[4][64];
+    uint16_t f_saved_quant_tables[4][64];
+    uint8_t f_huff_tables_symbols[8][256];
+    uint32_t f_huff_tables_slow[8][16];
+    uint16_t f_huff_tables_fast[8][256];
+    wuffs_base__pixel_swizzler f_swizzler;
+
+    wuffs_base__empty_struct (*choosy_decode_idct)(
+        wuffs_jpeg__decoder* self,
+        wuffs_base__slice_u8 a_dst_buffer,
+        uint64_t a_dst_stride,
+        uint32_t a_q);
+    uint32_t p_decode_image_config[1];
+    uint32_t p_do_decode_image_config[1];
+    uint32_t p_decode_dqt[1];
+    uint32_t p_decode_dri[1];
+    uint32_t p_decode_appn[1];
+    uint32_t p_decode_sof[1];
+    uint32_t p_decode_frame_config[1];
+    uint32_t p_do_decode_frame_config[1];
+    uint32_t p_decode_frame[1];
+    uint32_t p_do_decode_frame[1];
+    uint32_t p_decode_dht[1];
+    uint32_t p_decode_sos[1];
+    uint32_t p_prepare_scan[1];
+    wuffs_base__empty_struct (*choosy_load_mcu_blocks_for_single_component)(
+        wuffs_jpeg__decoder* self,
+        uint32_t a_mx,
+        uint32_t a_my,
+        wuffs_base__slice_u8 a_workbuf,
+        uint32_t a_csel);
+    uint32_t p_skip_past_the_next_restart_marker[1];
+    uint32_t (*choosy_decode_mcu)(
+        wuffs_jpeg__decoder* self,
+        wuffs_base__slice_u8 a_workbuf,
+        uint32_t a_mx,
+        uint32_t a_my);
+  } private_impl;
+
+  struct {
+    uint8_t f_bitstream_buffer[2048];
+    uint16_t f_mcu_blocks[10][64];
+    uint8_t f_swizzle_ycck_scratch_buffer_2k[2048];
+    uint8_t f_dht_temp_counts[16];
+    uint8_t f_dht_temp_bit_lengths[256];
+    uint16_t f_dht_temp_bit_strings[256];
+    uint8_t f_dst_palette[1024];
+
+    struct {
+      uint8_t v_marker;
+      uint64_t scratch;
+    } s_do_decode_image_config[1];
+    struct {
+      uint8_t v_q;
+      uint32_t v_i;
+    } s_decode_dqt[1];
+    struct {
+      uint64_t scratch;
+    } s_decode_dri[1];
+    struct {
+      uint64_t scratch;
+    } s_decode_appn[1];
+    struct {
+      uint32_t v_i;
+      uint64_t scratch;
+    } s_decode_sof[1];
+    struct {
+      uint8_t v_marker;
+      uint64_t scratch;
+    } s_do_decode_frame[1];
+    struct {
+      uint8_t v_tc4_th;
+      uint32_t v_total_count;
+      uint32_t v_i;
+    } s_decode_dht[1];
+    struct {
+      uint32_t v_my;
+      uint32_t v_mx;
+    } s_decode_sos[1];
+    struct {
+      uint32_t v_i;
+      uint64_t scratch;
+    } s_prepare_scan[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_jpeg__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_jpeg__decoder__alloc());
+  }
+
+  static inline wuffs_base__image_decoder::unique_ptr
+  alloc_as__wuffs_base__image_decoder() {
+    return wuffs_base__image_decoder::unique_ptr(
+        wuffs_jpeg__decoder__alloc_as__wuffs_base__image_decoder());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_jpeg__decoder__struct() = delete;
+  wuffs_jpeg__decoder__struct(const wuffs_jpeg__decoder__struct&) = delete;
+  wuffs_jpeg__decoder__struct& operator=(
+      const wuffs_jpeg__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_jpeg__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__image_decoder*
+  upcast_as__wuffs_base__image_decoder() {
+    return (wuffs_base__image_decoder*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_jpeg__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_jpeg__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__status
+  decode_image_config(
+      wuffs_base__image_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_jpeg__decoder__decode_image_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame_config(
+      wuffs_base__frame_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_jpeg__decoder__decode_frame_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame(
+      wuffs_base__pixel_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__pixel_blend a_blend,
+      wuffs_base__slice_u8 a_workbuf,
+      wuffs_base__decode_frame_options* a_opts) {
+    return wuffs_jpeg__decoder__decode_frame(this, a_dst, a_src, a_blend, a_workbuf, a_opts);
+  }
+
+  inline wuffs_base__rect_ie_u32
+  frame_dirty_rect() const {
+    return wuffs_jpeg__decoder__frame_dirty_rect(this);
+  }
+
+  inline uint32_t
+  num_animation_loops() const {
+    return wuffs_jpeg__decoder__num_animation_loops(this);
+  }
+
+  inline uint64_t
+  num_decoded_frame_configs() const {
+    return wuffs_jpeg__decoder__num_decoded_frame_configs(this);
+  }
+
+  inline uint64_t
+  num_decoded_frames() const {
+    return wuffs_jpeg__decoder__num_decoded_frames(this);
+  }
+
+  inline wuffs_base__status
+  restart_frame(
+      uint64_t a_index,
+      uint64_t a_io_position) {
+    return wuffs_jpeg__decoder__restart_frame(this, a_index, a_io_position);
+  }
+
+  inline wuffs_base__empty_struct
+  set_report_metadata(
+      uint32_t a_fourcc,
+      bool a_report) {
+    return wuffs_jpeg__decoder__set_report_metadata(this, a_fourcc, a_report);
+  }
+
+  inline wuffs_base__status
+  tell_me_more(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__more_information* a_minfo,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_jpeg__decoder__tell_me_more(this, a_dst, a_minfo, a_src);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_jpeg__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_jpeg__decoder__workbuf_len(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_jpeg__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__JPEG) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__JSON) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_json__error__bad_c0_control_code[];
+extern const char wuffs_json__error__bad_utf_8[];
+extern const char wuffs_json__error__bad_backslash_escape[];
+extern const char wuffs_json__error__bad_input[];
+extern const char wuffs_json__error__bad_new_line_in_a_string[];
+extern const char wuffs_json__error__bad_quirk_combination[];
+extern const char wuffs_json__error__unsupported_number_length[];
+extern const char wuffs_json__error__unsupported_recursion_depth[];
+
+// ---------------- Public Consts
+
+#define WUFFS_JSON__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_JSON__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_JSON__DECODER_DEPTH_MAX_INCL 1024
+
+#define WUFFS_JSON__DECODER_DST_TOKEN_BUFFER_LENGTH_MIN_INCL 1
+
+#define WUFFS_JSON__DECODER_SRC_IO_BUFFER_LENGTH_MIN_INCL 100
+
+#define WUFFS_JSON__QUIRK_ALLOW_ASCII_CONTROL_CODES 1225364480
+
+#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_A 1225364481
+
+#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_CAPITAL_U 1225364482
+
+#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_E 1225364483
+
+#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_NEW_LINE 1225364484
+
+#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_QUESTION_MARK 1225364485
+
+#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_SINGLE_QUOTE 1225364486
+
+#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_V 1225364487
+
+#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_X_AS_CODE_POINTS 1225364489
+
+#define WUFFS_JSON__QUIRK_ALLOW_BACKSLASH_ZERO 1225364490
+
+#define WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK 1225364491
+
+#define WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE 1225364492
+
+#define WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA 1225364493
+
+#define WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS 1225364494
+
+#define WUFFS_JSON__QUIRK_ALLOW_LEADING_ASCII_RECORD_SEPARATOR 1225364495
+
+#define WUFFS_JSON__QUIRK_ALLOW_LEADING_UNICODE_BYTE_ORDER_MARK 1225364496
+
+#define WUFFS_JSON__QUIRK_ALLOW_TRAILING_FILLER 1225364497
+
+#define WUFFS_JSON__QUIRK_EXPECT_TRAILING_NEW_LINE_OR_EOF 1225364498
+
+#define WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T 1225364499
+
+#define WUFFS_JSON__QUIRK_REPLACE_INVALID_UNICODE 1225364500
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_json__decoder__struct wuffs_json__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_json__decoder__initialize(
+    wuffs_json__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_json__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_json__decoder*
+wuffs_json__decoder__alloc();
+
+static inline wuffs_base__token_decoder*
+wuffs_json__decoder__alloc_as__wuffs_base__token_decoder() {
+  return (wuffs_base__token_decoder*)(wuffs_json__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__token_decoder*
+wuffs_json__decoder__upcast_as__wuffs_base__token_decoder(
+    wuffs_json__decoder* p) {
+  return (wuffs_base__token_decoder*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_json__decoder__get_quirk(
+    const wuffs_json__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_json__decoder__set_quirk(
+    wuffs_json__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_json__decoder__history_retain_length(
+    const wuffs_json__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_json__decoder__workbuf_len(
+    const wuffs_json__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_json__decoder__decode_tokens(
+    wuffs_json__decoder* self,
+    wuffs_base__token_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_json__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__token_decoder;
+    wuffs_base__vtable null_vtable;
+
+    bool f_quirks[21];
+    bool f_allow_leading_ars;
+    bool f_allow_leading_ubom;
+    bool f_end_of_data;
+    uint8_t f_trailer_stop;
+    uint8_t f_comment_type;
+
+    uint32_t p_decode_tokens[1];
+    uint32_t p_decode_leading[1];
+    uint32_t p_decode_comment[1];
+    uint32_t p_decode_inf_nan[1];
+    uint32_t p_decode_trailer[1];
+  } private_impl;
+
+  struct {
+    uint32_t f_stack[32];
+
+    struct {
+      uint32_t v_depth;
+      uint32_t v_expect;
+      uint32_t v_expect_after_value;
+    } s_decode_tokens[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_json__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_json__decoder__alloc());
+  }
+
+  static inline wuffs_base__token_decoder::unique_ptr
+  alloc_as__wuffs_base__token_decoder() {
+    return wuffs_base__token_decoder::unique_ptr(
+        wuffs_json__decoder__alloc_as__wuffs_base__token_decoder());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_json__decoder__struct() = delete;
+  wuffs_json__decoder__struct(const wuffs_json__decoder__struct&) = delete;
+  wuffs_json__decoder__struct& operator=(
+      const wuffs_json__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_json__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__token_decoder*
+  upcast_as__wuffs_base__token_decoder() {
+    return (wuffs_base__token_decoder*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_json__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_json__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_json__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_json__decoder__workbuf_len(this);
+  }
+
+  inline wuffs_base__status
+  decode_tokens(
+      wuffs_base__token_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__slice_u8 a_workbuf) {
+    return wuffs_json__decoder__decode_tokens(this, a_dst, a_src, a_workbuf);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_json__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__JSON) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__LZW) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_lzw__error__bad_code[];
+extern const char wuffs_lzw__error__truncated_input[];
+
+// ---------------- Public Consts
+
+#define WUFFS_LZW__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_LZW__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_LZW__QUIRK_LITERAL_WIDTH_PLUS_ONE 1348378624
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_lzw__decoder__struct wuffs_lzw__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_lzw__decoder__initialize(
+    wuffs_lzw__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_lzw__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_lzw__decoder*
+wuffs_lzw__decoder__alloc();
+
+static inline wuffs_base__io_transformer*
+wuffs_lzw__decoder__alloc_as__wuffs_base__io_transformer() {
+  return (wuffs_base__io_transformer*)(wuffs_lzw__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__io_transformer*
+wuffs_lzw__decoder__upcast_as__wuffs_base__io_transformer(
+    wuffs_lzw__decoder* p) {
+  return (wuffs_base__io_transformer*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_lzw__decoder__get_quirk(
+    const wuffs_lzw__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_lzw__decoder__set_quirk(
+    wuffs_lzw__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_lzw__decoder__history_retain_length(
+    const wuffs_lzw__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_lzw__decoder__workbuf_len(
+    const wuffs_lzw__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_lzw__decoder__transform_io(
+    wuffs_lzw__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__slice_u8
+wuffs_lzw__decoder__flush(
+    wuffs_lzw__decoder* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_lzw__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__io_transformer;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_pending_literal_width_plus_one;
+    uint32_t f_literal_width;
+    uint32_t f_clear_code;
+    uint32_t f_end_code;
+    uint32_t f_save_code;
+    uint32_t f_prev_code;
+    uint32_t f_width;
+    uint32_t f_bits;
+    uint32_t f_n_bits;
+    uint32_t f_output_ri;
+    uint32_t f_output_wi;
+    uint32_t f_read_from_return_value;
+    uint16_t f_prefixes[4096];
+
+    uint32_t p_transform_io[1];
+    uint32_t p_write_to[1];
+  } private_impl;
+
+  struct {
+    uint8_t f_suffixes[4096][8];
+    uint16_t f_lm1s[4096];
+    uint8_t f_output[8199];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_lzw__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_lzw__decoder__alloc());
+  }
+
+  static inline wuffs_base__io_transformer::unique_ptr
+  alloc_as__wuffs_base__io_transformer() {
+    return wuffs_base__io_transformer::unique_ptr(
+        wuffs_lzw__decoder__alloc_as__wuffs_base__io_transformer());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_lzw__decoder__struct() = delete;
+  wuffs_lzw__decoder__struct(const wuffs_lzw__decoder__struct&) = delete;
+  wuffs_lzw__decoder__struct& operator=(
+      const wuffs_lzw__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_lzw__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__io_transformer*
+  upcast_as__wuffs_base__io_transformer() {
+    return (wuffs_base__io_transformer*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_lzw__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_lzw__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_lzw__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_lzw__decoder__workbuf_len(this);
+  }
+
+  inline wuffs_base__status
+  transform_io(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__slice_u8 a_workbuf) {
+    return wuffs_lzw__decoder__transform_io(this, a_dst, a_src, a_workbuf);
+  }
+
+  inline wuffs_base__slice_u8
+  flush() {
+    return wuffs_lzw__decoder__flush(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_lzw__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__LZW) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__NETPBM) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_netpbm__error__bad_header[];
+extern const char wuffs_netpbm__error__truncated_input[];
+extern const char wuffs_netpbm__error__unsupported_netpbm_file[];
+
+// ---------------- Public Consts
+
+#define WUFFS_NETPBM__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_NETPBM__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_netpbm__decoder__struct wuffs_netpbm__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_netpbm__decoder__initialize(
+    wuffs_netpbm__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_netpbm__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_netpbm__decoder*
+wuffs_netpbm__decoder__alloc();
+
+static inline wuffs_base__image_decoder*
+wuffs_netpbm__decoder__alloc_as__wuffs_base__image_decoder() {
+  return (wuffs_base__image_decoder*)(wuffs_netpbm__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__image_decoder*
+wuffs_netpbm__decoder__upcast_as__wuffs_base__image_decoder(
+    wuffs_netpbm__decoder* p) {
+  return (wuffs_base__image_decoder*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_netpbm__decoder__get_quirk(
+    const wuffs_netpbm__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_netpbm__decoder__set_quirk(
+    wuffs_netpbm__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_netpbm__decoder__decode_image_config(
+    wuffs_netpbm__decoder* self,
+    wuffs_base__image_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_netpbm__decoder__decode_frame_config(
+    wuffs_netpbm__decoder* self,
+    wuffs_base__frame_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_netpbm__decoder__decode_frame(
+    wuffs_netpbm__decoder* self,
+    wuffs_base__pixel_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__pixel_blend a_blend,
+    wuffs_base__slice_u8 a_workbuf,
+    wuffs_base__decode_frame_options* a_opts);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
+wuffs_netpbm__decoder__frame_dirty_rect(
+    const wuffs_netpbm__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_netpbm__decoder__num_animation_loops(
+    const wuffs_netpbm__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_netpbm__decoder__num_decoded_frame_configs(
+    const wuffs_netpbm__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_netpbm__decoder__num_decoded_frames(
+    const wuffs_netpbm__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_netpbm__decoder__restart_frame(
+    wuffs_netpbm__decoder* self,
+    uint64_t a_index,
+    uint64_t a_io_position);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_netpbm__decoder__set_report_metadata(
+    wuffs_netpbm__decoder* self,
+    uint32_t a_fourcc,
+    bool a_report);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_netpbm__decoder__tell_me_more(
+    wuffs_netpbm__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__more_information* a_minfo,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_netpbm__decoder__history_retain_length(
+    const wuffs_netpbm__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_netpbm__decoder__workbuf_len(
+    const wuffs_netpbm__decoder* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_netpbm__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_pixfmt;
+    uint32_t f_width;
+    uint32_t f_height;
+    uint32_t f_max_value;
+    uint8_t f_call_sequence;
+    uint64_t f_frame_config_io_position;
+    uint32_t f_dst_x;
+    uint32_t f_dst_y;
+    wuffs_base__pixel_swizzler f_swizzler;
+
+    uint32_t p_decode_image_config[1];
+    uint32_t p_do_decode_image_config[1];
+    uint32_t p_decode_frame_config[1];
+    uint32_t p_do_decode_frame_config[1];
+    uint32_t p_decode_frame[1];
+    uint32_t p_do_decode_frame[1];
+  } private_impl;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_netpbm__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_netpbm__decoder__alloc());
+  }
+
+  static inline wuffs_base__image_decoder::unique_ptr
+  alloc_as__wuffs_base__image_decoder() {
+    return wuffs_base__image_decoder::unique_ptr(
+        wuffs_netpbm__decoder__alloc_as__wuffs_base__image_decoder());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_netpbm__decoder__struct() = delete;
+  wuffs_netpbm__decoder__struct(const wuffs_netpbm__decoder__struct&) = delete;
+  wuffs_netpbm__decoder__struct& operator=(
+      const wuffs_netpbm__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_netpbm__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__image_decoder*
+  upcast_as__wuffs_base__image_decoder() {
+    return (wuffs_base__image_decoder*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_netpbm__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_netpbm__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__status
+  decode_image_config(
+      wuffs_base__image_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_netpbm__decoder__decode_image_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame_config(
+      wuffs_base__frame_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_netpbm__decoder__decode_frame_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame(
+      wuffs_base__pixel_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__pixel_blend a_blend,
+      wuffs_base__slice_u8 a_workbuf,
+      wuffs_base__decode_frame_options* a_opts) {
+    return wuffs_netpbm__decoder__decode_frame(this, a_dst, a_src, a_blend, a_workbuf, a_opts);
+  }
+
+  inline wuffs_base__rect_ie_u32
+  frame_dirty_rect() const {
+    return wuffs_netpbm__decoder__frame_dirty_rect(this);
+  }
+
+  inline uint32_t
+  num_animation_loops() const {
+    return wuffs_netpbm__decoder__num_animation_loops(this);
+  }
+
+  inline uint64_t
+  num_decoded_frame_configs() const {
+    return wuffs_netpbm__decoder__num_decoded_frame_configs(this);
+  }
+
+  inline uint64_t
+  num_decoded_frames() const {
+    return wuffs_netpbm__decoder__num_decoded_frames(this);
+  }
+
+  inline wuffs_base__status
+  restart_frame(
+      uint64_t a_index,
+      uint64_t a_io_position) {
+    return wuffs_netpbm__decoder__restart_frame(this, a_index, a_io_position);
+  }
+
+  inline wuffs_base__empty_struct
+  set_report_metadata(
+      uint32_t a_fourcc,
+      bool a_report) {
+    return wuffs_netpbm__decoder__set_report_metadata(this, a_fourcc, a_report);
+  }
+
+  inline wuffs_base__status
+  tell_me_more(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__more_information* a_minfo,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_netpbm__decoder__tell_me_more(this, a_dst, a_minfo, a_src);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_netpbm__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_netpbm__decoder__workbuf_len(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_netpbm__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__NETPBM) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__NIE) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_nie__error__bad_header[];
+extern const char wuffs_nie__error__truncated_input[];
+extern const char wuffs_nie__error__unsupported_nie_file[];
+
+// ---------------- Public Consts
+
+#define WUFFS_NIE__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_NIE__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_nie__decoder__struct wuffs_nie__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_nie__decoder__initialize(
+    wuffs_nie__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_nie__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_nie__decoder*
+wuffs_nie__decoder__alloc();
+
+static inline wuffs_base__image_decoder*
+wuffs_nie__decoder__alloc_as__wuffs_base__image_decoder() {
+  return (wuffs_base__image_decoder*)(wuffs_nie__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__image_decoder*
+wuffs_nie__decoder__upcast_as__wuffs_base__image_decoder(
+    wuffs_nie__decoder* p) {
+  return (wuffs_base__image_decoder*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_nie__decoder__get_quirk(
+    const wuffs_nie__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_nie__decoder__set_quirk(
+    wuffs_nie__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_nie__decoder__decode_image_config(
+    wuffs_nie__decoder* self,
+    wuffs_base__image_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_nie__decoder__decode_frame_config(
+    wuffs_nie__decoder* self,
+    wuffs_base__frame_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_nie__decoder__decode_frame(
+    wuffs_nie__decoder* self,
+    wuffs_base__pixel_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__pixel_blend a_blend,
+    wuffs_base__slice_u8 a_workbuf,
+    wuffs_base__decode_frame_options* a_opts);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
+wuffs_nie__decoder__frame_dirty_rect(
+    const wuffs_nie__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_nie__decoder__num_animation_loops(
+    const wuffs_nie__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_nie__decoder__num_decoded_frame_configs(
+    const wuffs_nie__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_nie__decoder__num_decoded_frames(
+    const wuffs_nie__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_nie__decoder__restart_frame(
+    wuffs_nie__decoder* self,
+    uint64_t a_index,
+    uint64_t a_io_position);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_nie__decoder__set_report_metadata(
+    wuffs_nie__decoder* self,
+    uint32_t a_fourcc,
+    bool a_report);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_nie__decoder__tell_me_more(
+    wuffs_nie__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__more_information* a_minfo,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_nie__decoder__history_retain_length(
+    const wuffs_nie__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_nie__decoder__workbuf_len(
+    const wuffs_nie__decoder* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_nie__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_pixfmt;
+    uint32_t f_width;
+    uint32_t f_height;
+    uint8_t f_call_sequence;
+    uint32_t f_dst_x;
+    uint32_t f_dst_y;
+    wuffs_base__pixel_swizzler f_swizzler;
+
+    uint32_t p_decode_image_config[1];
+    uint32_t p_do_decode_image_config[1];
+    uint32_t p_decode_frame_config[1];
+    uint32_t p_do_decode_frame_config[1];
+    uint32_t p_decode_frame[1];
+    uint32_t p_do_decode_frame[1];
+  } private_impl;
+
+  struct {
+    struct {
+      uint64_t scratch;
+    } s_do_decode_image_config[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_nie__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_nie__decoder__alloc());
+  }
+
+  static inline wuffs_base__image_decoder::unique_ptr
+  alloc_as__wuffs_base__image_decoder() {
+    return wuffs_base__image_decoder::unique_ptr(
+        wuffs_nie__decoder__alloc_as__wuffs_base__image_decoder());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_nie__decoder__struct() = delete;
+  wuffs_nie__decoder__struct(const wuffs_nie__decoder__struct&) = delete;
+  wuffs_nie__decoder__struct& operator=(
+      const wuffs_nie__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_nie__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__image_decoder*
+  upcast_as__wuffs_base__image_decoder() {
+    return (wuffs_base__image_decoder*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_nie__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_nie__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__status
+  decode_image_config(
+      wuffs_base__image_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_nie__decoder__decode_image_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame_config(
+      wuffs_base__frame_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_nie__decoder__decode_frame_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame(
+      wuffs_base__pixel_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__pixel_blend a_blend,
+      wuffs_base__slice_u8 a_workbuf,
+      wuffs_base__decode_frame_options* a_opts) {
+    return wuffs_nie__decoder__decode_frame(this, a_dst, a_src, a_blend, a_workbuf, a_opts);
+  }
+
+  inline wuffs_base__rect_ie_u32
+  frame_dirty_rect() const {
+    return wuffs_nie__decoder__frame_dirty_rect(this);
+  }
+
+  inline uint32_t
+  num_animation_loops() const {
+    return wuffs_nie__decoder__num_animation_loops(this);
+  }
+
+  inline uint64_t
+  num_decoded_frame_configs() const {
+    return wuffs_nie__decoder__num_decoded_frame_configs(this);
+  }
+
+  inline uint64_t
+  num_decoded_frames() const {
+    return wuffs_nie__decoder__num_decoded_frames(this);
+  }
+
+  inline wuffs_base__status
+  restart_frame(
+      uint64_t a_index,
+      uint64_t a_io_position) {
+    return wuffs_nie__decoder__restart_frame(this, a_index, a_io_position);
+  }
+
+  inline wuffs_base__empty_struct
+  set_report_metadata(
+      uint32_t a_fourcc,
+      bool a_report) {
+    return wuffs_nie__decoder__set_report_metadata(this, a_fourcc, a_report);
+  }
+
+  inline wuffs_base__status
+  tell_me_more(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__more_information* a_minfo,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_nie__decoder__tell_me_more(this, a_dst, a_minfo, a_src);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_nie__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_nie__decoder__workbuf_len(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_nie__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__NIE) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ZLIB) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_zlib__note__dictionary_required[];
+extern const char wuffs_zlib__error__bad_checksum[];
+extern const char wuffs_zlib__error__bad_compression_method[];
+extern const char wuffs_zlib__error__bad_compression_window_size[];
+extern const char wuffs_zlib__error__bad_parity_check[];
+extern const char wuffs_zlib__error__incorrect_dictionary[];
+extern const char wuffs_zlib__error__truncated_input[];
+
+// ---------------- Public Consts
+
+#define WUFFS_ZLIB__QUIRK_JUST_RAW_DEFLATE 2113790976
+
+#define WUFFS_ZLIB__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_ZLIB__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 1
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_zlib__decoder__struct wuffs_zlib__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_zlib__decoder__initialize(
+    wuffs_zlib__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_zlib__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_zlib__decoder*
+wuffs_zlib__decoder__alloc();
+
+static inline wuffs_base__io_transformer*
+wuffs_zlib__decoder__alloc_as__wuffs_base__io_transformer() {
+  return (wuffs_base__io_transformer*)(wuffs_zlib__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__io_transformer*
+wuffs_zlib__decoder__upcast_as__wuffs_base__io_transformer(
+    wuffs_zlib__decoder* p) {
+  return (wuffs_base__io_transformer*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_zlib__decoder__dictionary_id(
+    const wuffs_zlib__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_zlib__decoder__add_dictionary(
+    wuffs_zlib__decoder* self,
+    wuffs_base__slice_u8 a_dict);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_zlib__decoder__get_quirk(
+    const wuffs_zlib__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_zlib__decoder__set_quirk(
+    wuffs_zlib__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_zlib__decoder__history_retain_length(
+    const wuffs_zlib__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_zlib__decoder__workbuf_len(
+    const wuffs_zlib__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_zlib__decoder__transform_io(
+    wuffs_zlib__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_zlib__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__io_transformer;
+    wuffs_base__vtable null_vtable;
+
+    bool f_bad_call_sequence;
+    bool f_header_complete;
+    bool f_got_dictionary;
+    bool f_want_dictionary;
+    bool f_quirks[1];
+    bool f_ignore_checksum;
+    uint32_t f_dict_id_got;
+    uint32_t f_dict_id_want;
+
+    uint32_t p_transform_io[1];
+    uint32_t p_do_transform_io[1];
+  } private_impl;
+
+  struct {
+    wuffs_adler32__hasher f_checksum;
+    wuffs_adler32__hasher f_dict_id_hasher;
+    wuffs_deflate__decoder f_flate;
+
+    struct {
+      uint32_t v_checksum_got;
+      uint64_t scratch;
+    } s_do_transform_io[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_zlib__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_zlib__decoder__alloc());
+  }
+
+  static inline wuffs_base__io_transformer::unique_ptr
+  alloc_as__wuffs_base__io_transformer() {
+    return wuffs_base__io_transformer::unique_ptr(
+        wuffs_zlib__decoder__alloc_as__wuffs_base__io_transformer());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_zlib__decoder__struct() = delete;
+  wuffs_zlib__decoder__struct(const wuffs_zlib__decoder__struct&) = delete;
+  wuffs_zlib__decoder__struct& operator=(
+      const wuffs_zlib__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_zlib__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__io_transformer*
+  upcast_as__wuffs_base__io_transformer() {
+    return (wuffs_base__io_transformer*)this;
+  }
+
+  inline uint32_t
+  dictionary_id() const {
+    return wuffs_zlib__decoder__dictionary_id(this);
+  }
+
+  inline wuffs_base__empty_struct
+  add_dictionary(
+      wuffs_base__slice_u8 a_dict) {
+    return wuffs_zlib__decoder__add_dictionary(this, a_dict);
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_zlib__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_zlib__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_zlib__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_zlib__decoder__workbuf_len(this);
+  }
+
+  inline wuffs_base__status
+  transform_io(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__slice_u8 a_workbuf) {
+    return wuffs_zlib__decoder__transform_io(this, a_dst, a_src, a_workbuf);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_zlib__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ZLIB) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__PNG) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_png__error__bad_animation_sequence_number[];
+extern const char wuffs_png__error__bad_checksum[];
+extern const char wuffs_png__error__bad_chunk[];
+extern const char wuffs_png__error__bad_filter[];
+extern const char wuffs_png__error__bad_header[];
+extern const char wuffs_png__error__bad_text_chunk_not_latin_1[];
+extern const char wuffs_png__error__missing_palette[];
+extern const char wuffs_png__error__truncated_input[];
+extern const char wuffs_png__error__unsupported_cgbi_extension[];
+extern const char wuffs_png__error__unsupported_png_compression_method[];
+extern const char wuffs_png__error__unsupported_png_file[];
+
+// ---------------- Public Consts
+
+#define WUFFS_PNG__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_PNG__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 2251799562027015
+
+#define WUFFS_PNG__DECODER_SRC_IO_BUFFER_LENGTH_MIN_INCL 8
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_png__decoder__struct wuffs_png__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_png__decoder__initialize(
+    wuffs_png__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_png__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_png__decoder*
+wuffs_png__decoder__alloc();
+
+static inline wuffs_base__image_decoder*
+wuffs_png__decoder__alloc_as__wuffs_base__image_decoder() {
+  return (wuffs_base__image_decoder*)(wuffs_png__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__image_decoder*
+wuffs_png__decoder__upcast_as__wuffs_base__image_decoder(
+    wuffs_png__decoder* p) {
+  return (wuffs_base__image_decoder*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_png__decoder__get_quirk(
+    const wuffs_png__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_png__decoder__set_quirk(
+    wuffs_png__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_png__decoder__decode_image_config(
+    wuffs_png__decoder* self,
+    wuffs_base__image_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_png__decoder__decode_frame_config(
+    wuffs_png__decoder* self,
+    wuffs_base__frame_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_png__decoder__decode_frame(
+    wuffs_png__decoder* self,
+    wuffs_base__pixel_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__pixel_blend a_blend,
+    wuffs_base__slice_u8 a_workbuf,
+    wuffs_base__decode_frame_options* a_opts);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
+wuffs_png__decoder__frame_dirty_rect(
+    const wuffs_png__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_png__decoder__num_animation_loops(
+    const wuffs_png__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_png__decoder__num_decoded_frame_configs(
+    const wuffs_png__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_png__decoder__num_decoded_frames(
+    const wuffs_png__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_png__decoder__restart_frame(
+    wuffs_png__decoder* self,
+    uint64_t a_index,
+    uint64_t a_io_position);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_png__decoder__set_report_metadata(
+    wuffs_png__decoder* self,
+    uint32_t a_fourcc,
+    bool a_report);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_png__decoder__tell_me_more(
+    wuffs_png__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__more_information* a_minfo,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_png__decoder__history_retain_length(
+    const wuffs_png__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_png__decoder__workbuf_len(
+    const wuffs_png__decoder* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_png__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_width;
+    uint32_t f_height;
+    uint64_t f_pass_bytes_per_row;
+    uint64_t f_workbuf_wi;
+    uint64_t f_workbuf_hist_pos_base;
+    uint64_t f_overall_workbuf_length;
+    uint64_t f_pass_workbuf_length;
+    uint8_t f_call_sequence;
+    bool f_report_metadata_chrm;
+    bool f_report_metadata_exif;
+    bool f_report_metadata_gama;
+    bool f_report_metadata_iccp;
+    bool f_report_metadata_kvp;
+    bool f_report_metadata_srgb;
+    bool f_ignore_checksum;
+    uint8_t f_depth;
+    uint8_t f_color_type;
+    uint8_t f_filter_distance;
+    uint8_t f_interlace_pass;
+    bool f_seen_actl;
+    bool f_seen_chrm;
+    bool f_seen_fctl;
+    bool f_seen_exif;
+    bool f_seen_gama;
+    bool f_seen_iccp;
+    bool f_seen_idat;
+    bool f_seen_ihdr;
+    bool f_seen_plte;
+    bool f_seen_srgb;
+    bool f_seen_trns;
+    bool f_metadata_is_zlib_compressed;
+    bool f_zlib_is_dirty;
+    uint32_t f_chunk_type;
+    uint8_t f_chunk_type_array[4];
+    uint32_t f_chunk_length;
+    uint64_t f_remap_transparency;
+    uint32_t f_dst_pixfmt;
+    uint32_t f_src_pixfmt;
+    uint32_t f_num_animation_frames_value;
+    uint32_t f_num_animation_loops_value;
+    uint32_t f_num_decoded_frame_configs_value;
+    uint32_t f_num_decoded_frames_value;
+    uint32_t f_frame_rect_x0;
+    uint32_t f_frame_rect_y0;
+    uint32_t f_frame_rect_x1;
+    uint32_t f_frame_rect_y1;
+    uint32_t f_first_rect_x0;
+    uint32_t f_first_rect_y0;
+    uint32_t f_first_rect_x1;
+    uint32_t f_first_rect_y1;
+    uint64_t f_frame_config_io_position;
+    uint64_t f_first_config_io_position;
+    uint64_t f_frame_duration;
+    uint64_t f_first_duration;
+    uint8_t f_frame_disposal;
+    uint8_t f_first_disposal;
+    bool f_frame_overwrite_instead_of_blend;
+    bool f_first_overwrite_instead_of_blend;
+    uint32_t f_next_animation_seq_num;
+    uint32_t f_metadata_flavor;
+    uint32_t f_metadata_fourcc;
+    uint64_t f_metadata_x;
+    uint64_t f_metadata_y;
+    uint64_t f_metadata_z;
+    uint32_t f_ztxt_ri;
+    uint32_t f_ztxt_wi;
+    uint64_t f_ztxt_hist_pos;
+    wuffs_base__pixel_swizzler f_swizzler;
+
+    wuffs_base__empty_struct (*choosy_filter_1)(
+        wuffs_png__decoder* self,
+        wuffs_base__slice_u8 a_curr);
+    wuffs_base__empty_struct (*choosy_filter_3)(
+        wuffs_png__decoder* self,
+        wuffs_base__slice_u8 a_curr,
+        wuffs_base__slice_u8 a_prev);
+    wuffs_base__empty_struct (*choosy_filter_4)(
+        wuffs_png__decoder* self,
+        wuffs_base__slice_u8 a_curr,
+        wuffs_base__slice_u8 a_prev);
+    uint32_t p_decode_image_config[1];
+    uint32_t p_do_decode_image_config[1];
+    uint32_t p_decode_ihdr[1];
+    uint32_t p_decode_other_chunk[1];
+    uint32_t p_decode_actl[1];
+    uint32_t p_decode_chrm[1];
+    uint32_t p_decode_fctl[1];
+    uint32_t p_decode_gama[1];
+    uint32_t p_decode_iccp[1];
+    uint32_t p_decode_plte[1];
+    uint32_t p_decode_srgb[1];
+    uint32_t p_decode_trns[1];
+    uint32_t p_decode_frame_config[1];
+    uint32_t p_do_decode_frame_config[1];
+    uint32_t p_skip_frame[1];
+    uint32_t p_decode_frame[1];
+    uint32_t p_do_decode_frame[1];
+    uint32_t p_decode_pass[1];
+    uint32_t p_tell_me_more[1];
+    uint32_t p_do_tell_me_more[1];
+    wuffs_base__status (*choosy_filter_and_swizzle)(
+        wuffs_png__decoder* self,
+        wuffs_base__pixel_buffer* a_dst,
+        wuffs_base__slice_u8 a_workbuf);
+  } private_impl;
+
+  struct {
+    wuffs_crc32__ieee_hasher f_crc32;
+    wuffs_zlib__decoder f_zlib;
+    uint8_t f_dst_palette[1024];
+    uint8_t f_src_palette[1024];
+
+    struct {
+      uint32_t v_checksum_have;
+      uint64_t scratch;
+    } s_do_decode_image_config[1];
+    struct {
+      uint64_t scratch;
+    } s_decode_ihdr[1];
+    struct {
+      uint64_t scratch;
+    } s_decode_other_chunk[1];
+    struct {
+      uint64_t scratch;
+    } s_decode_actl[1];
+    struct {
+      uint64_t scratch;
+    } s_decode_chrm[1];
+    struct {
+      uint32_t v_x0;
+      uint32_t v_x1;
+      uint32_t v_y1;
+      uint64_t scratch;
+    } s_decode_fctl[1];
+    struct {
+      uint64_t scratch;
+    } s_decode_gama[1];
+    struct {
+      uint32_t v_num_entries;
+      uint32_t v_i;
+      uint64_t scratch;
+    } s_decode_plte[1];
+    struct {
+      uint32_t v_i;
+      uint32_t v_n;
+      uint64_t scratch;
+    } s_decode_trns[1];
+    struct {
+      uint64_t scratch;
+    } s_do_decode_frame_config[1];
+    struct {
+      uint64_t scratch;
+    } s_skip_frame[1];
+    struct {
+      uint64_t scratch;
+    } s_do_decode_frame[1];
+    struct {
+      uint64_t scratch;
+    } s_decode_pass[1];
+    struct {
+      wuffs_base__status v_zlib_status;
+      uint64_t scratch;
+    } s_do_tell_me_more[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_png__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_png__decoder__alloc());
+  }
+
+  static inline wuffs_base__image_decoder::unique_ptr
+  alloc_as__wuffs_base__image_decoder() {
+    return wuffs_base__image_decoder::unique_ptr(
+        wuffs_png__decoder__alloc_as__wuffs_base__image_decoder());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_png__decoder__struct() = delete;
+  wuffs_png__decoder__struct(const wuffs_png__decoder__struct&) = delete;
+  wuffs_png__decoder__struct& operator=(
+      const wuffs_png__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_png__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__image_decoder*
+  upcast_as__wuffs_base__image_decoder() {
+    return (wuffs_base__image_decoder*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_png__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_png__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__status
+  decode_image_config(
+      wuffs_base__image_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_png__decoder__decode_image_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame_config(
+      wuffs_base__frame_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_png__decoder__decode_frame_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame(
+      wuffs_base__pixel_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__pixel_blend a_blend,
+      wuffs_base__slice_u8 a_workbuf,
+      wuffs_base__decode_frame_options* a_opts) {
+    return wuffs_png__decoder__decode_frame(this, a_dst, a_src, a_blend, a_workbuf, a_opts);
+  }
+
+  inline wuffs_base__rect_ie_u32
+  frame_dirty_rect() const {
+    return wuffs_png__decoder__frame_dirty_rect(this);
+  }
+
+  inline uint32_t
+  num_animation_loops() const {
+    return wuffs_png__decoder__num_animation_loops(this);
+  }
+
+  inline uint64_t
+  num_decoded_frame_configs() const {
+    return wuffs_png__decoder__num_decoded_frame_configs(this);
+  }
+
+  inline uint64_t
+  num_decoded_frames() const {
+    return wuffs_png__decoder__num_decoded_frames(this);
+  }
+
+  inline wuffs_base__status
+  restart_frame(
+      uint64_t a_index,
+      uint64_t a_io_position) {
+    return wuffs_png__decoder__restart_frame(this, a_index, a_io_position);
+  }
+
+  inline wuffs_base__empty_struct
+  set_report_metadata(
+      uint32_t a_fourcc,
+      bool a_report) {
+    return wuffs_png__decoder__set_report_metadata(this, a_fourcc, a_report);
+  }
+
+  inline wuffs_base__status
+  tell_me_more(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__more_information* a_minfo,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_png__decoder__tell_me_more(this, a_dst, a_minfo, a_src);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_png__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_png__decoder__workbuf_len(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_png__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__PNG) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_tga__error__bad_header[];
+extern const char wuffs_tga__error__bad_run_length_encoding[];
+extern const char wuffs_tga__error__truncated_input[];
+extern const char wuffs_tga__error__unsupported_tga_file[];
+
+// ---------------- Public Consts
+
+#define WUFFS_TGA__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_TGA__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_tga__decoder__struct wuffs_tga__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_tga__decoder__initialize(
+    wuffs_tga__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_tga__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_tga__decoder*
+wuffs_tga__decoder__alloc();
+
+static inline wuffs_base__image_decoder*
+wuffs_tga__decoder__alloc_as__wuffs_base__image_decoder() {
+  return (wuffs_base__image_decoder*)(wuffs_tga__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__image_decoder*
+wuffs_tga__decoder__upcast_as__wuffs_base__image_decoder(
+    wuffs_tga__decoder* p) {
+  return (wuffs_base__image_decoder*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_tga__decoder__get_quirk(
+    const wuffs_tga__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_tga__decoder__set_quirk(
+    wuffs_tga__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_tga__decoder__decode_image_config(
+    wuffs_tga__decoder* self,
+    wuffs_base__image_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_tga__decoder__decode_frame_config(
+    wuffs_tga__decoder* self,
+    wuffs_base__frame_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_tga__decoder__decode_frame(
+    wuffs_tga__decoder* self,
+    wuffs_base__pixel_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__pixel_blend a_blend,
+    wuffs_base__slice_u8 a_workbuf,
+    wuffs_base__decode_frame_options* a_opts);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
+wuffs_tga__decoder__frame_dirty_rect(
+    const wuffs_tga__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_tga__decoder__num_animation_loops(
+    const wuffs_tga__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_tga__decoder__num_decoded_frame_configs(
+    const wuffs_tga__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_tga__decoder__num_decoded_frames(
+    const wuffs_tga__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_tga__decoder__restart_frame(
+    wuffs_tga__decoder* self,
+    uint64_t a_index,
+    uint64_t a_io_position);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_tga__decoder__set_report_metadata(
+    wuffs_tga__decoder* self,
+    uint32_t a_fourcc,
+    bool a_report);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_tga__decoder__tell_me_more(
+    wuffs_tga__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__more_information* a_minfo,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_tga__decoder__history_retain_length(
+    const wuffs_tga__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_tga__decoder__workbuf_len(
+    const wuffs_tga__decoder* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_tga__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_width;
+    uint32_t f_height;
+    uint8_t f_call_sequence;
+    uint8_t f_header_id_length;
+    uint8_t f_header_color_map_type;
+    uint8_t f_header_image_type;
+    uint16_t f_header_color_map_first_entry_index;
+    uint16_t f_header_color_map_length;
+    uint8_t f_header_color_map_entry_size;
+    uint8_t f_header_pixel_depth;
+    uint8_t f_header_image_descriptor;
+    bool f_opaque;
+    uint32_t f_scratch_bytes_per_pixel;
+    uint32_t f_src_bytes_per_pixel;
+    uint32_t f_src_pixfmt;
+    uint64_t f_frame_config_io_position;
+    wuffs_base__pixel_swizzler f_swizzler;
+
+    uint32_t p_decode_image_config[1];
+    uint32_t p_do_decode_image_config[1];
+    uint32_t p_decode_frame_config[1];
+    uint32_t p_do_decode_frame_config[1];
+    uint32_t p_decode_frame[1];
+    uint32_t p_do_decode_frame[1];
+  } private_impl;
+
+  struct {
+    uint8_t f_dst_palette[1024];
+    uint8_t f_src_palette[1024];
+    uint8_t f_scratch[4];
+
+    struct {
+      uint32_t v_i;
+      uint64_t scratch;
+    } s_do_decode_image_config[1];
+    struct {
+      uint64_t v_dst_bytes_per_pixel;
+      uint32_t v_dst_x;
+      uint32_t v_dst_y;
+      uint64_t v_mark;
+      uint32_t v_num_pixels32;
+      uint32_t v_lit_length;
+      uint32_t v_run_length;
+      uint64_t v_num_dst_bytes;
+      uint64_t scratch;
+    } s_do_decode_frame[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_tga__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_tga__decoder__alloc());
+  }
+
+  static inline wuffs_base__image_decoder::unique_ptr
+  alloc_as__wuffs_base__image_decoder() {
+    return wuffs_base__image_decoder::unique_ptr(
+        wuffs_tga__decoder__alloc_as__wuffs_base__image_decoder());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_tga__decoder__struct() = delete;
+  wuffs_tga__decoder__struct(const wuffs_tga__decoder__struct&) = delete;
+  wuffs_tga__decoder__struct& operator=(
+      const wuffs_tga__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_tga__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__image_decoder*
+  upcast_as__wuffs_base__image_decoder() {
+    return (wuffs_base__image_decoder*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_tga__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_tga__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__status
+  decode_image_config(
+      wuffs_base__image_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_tga__decoder__decode_image_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame_config(
+      wuffs_base__frame_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_tga__decoder__decode_frame_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame(
+      wuffs_base__pixel_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__pixel_blend a_blend,
+      wuffs_base__slice_u8 a_workbuf,
+      wuffs_base__decode_frame_options* a_opts) {
+    return wuffs_tga__decoder__decode_frame(this, a_dst, a_src, a_blend, a_workbuf, a_opts);
+  }
+
+  inline wuffs_base__rect_ie_u32
+  frame_dirty_rect() const {
+    return wuffs_tga__decoder__frame_dirty_rect(this);
+  }
+
+  inline uint32_t
+  num_animation_loops() const {
+    return wuffs_tga__decoder__num_animation_loops(this);
+  }
+
+  inline uint64_t
+  num_decoded_frame_configs() const {
+    return wuffs_tga__decoder__num_decoded_frame_configs(this);
+  }
+
+  inline uint64_t
+  num_decoded_frames() const {
+    return wuffs_tga__decoder__num_decoded_frames(this);
+  }
+
+  inline wuffs_base__status
+  restart_frame(
+      uint64_t a_index,
+      uint64_t a_io_position) {
+    return wuffs_tga__decoder__restart_frame(this, a_index, a_io_position);
+  }
+
+  inline wuffs_base__empty_struct
+  set_report_metadata(
+      uint32_t a_fourcc,
+      bool a_report) {
+    return wuffs_tga__decoder__set_report_metadata(this, a_fourcc, a_report);
+  }
+
+  inline wuffs_base__status
+  tell_me_more(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__more_information* a_minfo,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_tga__decoder__tell_me_more(this, a_dst, a_minfo, a_src);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_tga__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_tga__decoder__workbuf_len(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_tga__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__WBMP) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+extern const char wuffs_wbmp__error__bad_header[];
+extern const char wuffs_wbmp__error__truncated_input[];
+
+// ---------------- Public Consts
+
+#define WUFFS_WBMP__DECODER_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE 0
+
+#define WUFFS_WBMP__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_wbmp__decoder__struct wuffs_wbmp__decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_wbmp__decoder__initialize(
+    wuffs_wbmp__decoder* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_wbmp__decoder();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_wbmp__decoder*
+wuffs_wbmp__decoder__alloc();
+
+static inline wuffs_base__image_decoder*
+wuffs_wbmp__decoder__alloc_as__wuffs_base__image_decoder() {
+  return (wuffs_base__image_decoder*)(wuffs_wbmp__decoder__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__image_decoder*
+wuffs_wbmp__decoder__upcast_as__wuffs_base__image_decoder(
+    wuffs_wbmp__decoder* p) {
+  return (wuffs_base__image_decoder*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_wbmp__decoder__get_quirk(
+    const wuffs_wbmp__decoder* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_wbmp__decoder__set_quirk(
+    wuffs_wbmp__decoder* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_wbmp__decoder__decode_image_config(
+    wuffs_wbmp__decoder* self,
+    wuffs_base__image_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_wbmp__decoder__decode_frame_config(
+    wuffs_wbmp__decoder* self,
+    wuffs_base__frame_config* a_dst,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_wbmp__decoder__decode_frame(
+    wuffs_wbmp__decoder* self,
+    wuffs_base__pixel_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__pixel_blend a_blend,
+    wuffs_base__slice_u8 a_workbuf,
+    wuffs_base__decode_frame_options* a_opts);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
+wuffs_wbmp__decoder__frame_dirty_rect(
+    const wuffs_wbmp__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_wbmp__decoder__num_animation_loops(
+    const wuffs_wbmp__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_wbmp__decoder__num_decoded_frame_configs(
+    const wuffs_wbmp__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_wbmp__decoder__num_decoded_frames(
+    const wuffs_wbmp__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_wbmp__decoder__restart_frame(
+    wuffs_wbmp__decoder* self,
+    uint64_t a_index,
+    uint64_t a_io_position);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_wbmp__decoder__set_report_metadata(
+    wuffs_wbmp__decoder* self,
+    uint32_t a_fourcc,
+    bool a_report);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_wbmp__decoder__tell_me_more(
+    wuffs_wbmp__decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__more_information* a_minfo,
+    wuffs_base__io_buffer* a_src);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_wbmp__decoder__history_retain_length(
+    const wuffs_wbmp__decoder* self);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_wbmp__decoder__workbuf_len(
+    const wuffs_wbmp__decoder* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_wbmp__decoder__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_width;
+    uint32_t f_height;
+    uint8_t f_call_sequence;
+    uint64_t f_frame_config_io_position;
+    wuffs_base__pixel_swizzler f_swizzler;
+
+    uint32_t p_decode_image_config[1];
+    uint32_t p_do_decode_image_config[1];
+    uint32_t p_decode_frame_config[1];
+    uint32_t p_do_decode_frame_config[1];
+    uint32_t p_decode_frame[1];
+    uint32_t p_do_decode_frame[1];
+  } private_impl;
+
+  struct {
+    struct {
+      uint32_t v_i;
+      uint32_t v_p;
+    } s_do_decode_image_config[1];
+    struct {
+      uint64_t v_dst_bytes_per_pixel;
+      uint32_t v_dst_x;
+      uint32_t v_dst_y;
+      uint8_t v_src[1];
+      uint8_t v_c;
+    } s_do_decode_frame[1];
+  } private_data;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_wbmp__decoder, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_wbmp__decoder__alloc());
+  }
+
+  static inline wuffs_base__image_decoder::unique_ptr
+  alloc_as__wuffs_base__image_decoder() {
+    return wuffs_base__image_decoder::unique_ptr(
+        wuffs_wbmp__decoder__alloc_as__wuffs_base__image_decoder());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_wbmp__decoder__struct() = delete;
+  wuffs_wbmp__decoder__struct(const wuffs_wbmp__decoder__struct&) = delete;
+  wuffs_wbmp__decoder__struct& operator=(
+      const wuffs_wbmp__decoder__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_wbmp__decoder__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__image_decoder*
+  upcast_as__wuffs_base__image_decoder() {
+    return (wuffs_base__image_decoder*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_wbmp__decoder__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_wbmp__decoder__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__status
+  decode_image_config(
+      wuffs_base__image_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_wbmp__decoder__decode_image_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame_config(
+      wuffs_base__frame_config* a_dst,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_wbmp__decoder__decode_frame_config(this, a_dst, a_src);
+  }
+
+  inline wuffs_base__status
+  decode_frame(
+      wuffs_base__pixel_buffer* a_dst,
+      wuffs_base__io_buffer* a_src,
+      wuffs_base__pixel_blend a_blend,
+      wuffs_base__slice_u8 a_workbuf,
+      wuffs_base__decode_frame_options* a_opts) {
+    return wuffs_wbmp__decoder__decode_frame(this, a_dst, a_src, a_blend, a_workbuf, a_opts);
+  }
+
+  inline wuffs_base__rect_ie_u32
+  frame_dirty_rect() const {
+    return wuffs_wbmp__decoder__frame_dirty_rect(this);
+  }
+
+  inline uint32_t
+  num_animation_loops() const {
+    return wuffs_wbmp__decoder__num_animation_loops(this);
+  }
+
+  inline uint64_t
+  num_decoded_frame_configs() const {
+    return wuffs_wbmp__decoder__num_decoded_frame_configs(this);
+  }
+
+  inline uint64_t
+  num_decoded_frames() const {
+    return wuffs_wbmp__decoder__num_decoded_frames(this);
+  }
+
+  inline wuffs_base__status
+  restart_frame(
+      uint64_t a_index,
+      uint64_t a_io_position) {
+    return wuffs_wbmp__decoder__restart_frame(this, a_index, a_io_position);
+  }
+
+  inline wuffs_base__empty_struct
+  set_report_metadata(
+      uint32_t a_fourcc,
+      bool a_report) {
+    return wuffs_wbmp__decoder__set_report_metadata(this, a_fourcc, a_report);
+  }
+
+  inline wuffs_base__status
+  tell_me_more(
+      wuffs_base__io_buffer* a_dst,
+      wuffs_base__more_information* a_minfo,
+      wuffs_base__io_buffer* a_src) {
+    return wuffs_wbmp__decoder__tell_me_more(this, a_dst, a_minfo, a_src);
+  }
+
+  inline uint64_t
+  history_retain_length() const {
+    return wuffs_wbmp__decoder__history_retain_length(this);
+  }
+
+  inline wuffs_base__range_ii_u64
+  workbuf_len() const {
+    return wuffs_wbmp__decoder__workbuf_len(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_wbmp__decoder__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__WBMP) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__XXHASH32) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+// ---------------- Public Consts
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_xxhash32__hasher__struct wuffs_xxhash32__hasher;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_xxhash32__hasher__initialize(
+    wuffs_xxhash32__hasher* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_xxhash32__hasher();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_xxhash32__hasher*
+wuffs_xxhash32__hasher__alloc();
+
+static inline wuffs_base__hasher_u32*
+wuffs_xxhash32__hasher__alloc_as__wuffs_base__hasher_u32() {
+  return (wuffs_base__hasher_u32*)(wuffs_xxhash32__hasher__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__hasher_u32*
+wuffs_xxhash32__hasher__upcast_as__wuffs_base__hasher_u32(
+    wuffs_xxhash32__hasher* p) {
+  return (wuffs_base__hasher_u32*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_xxhash32__hasher__get_quirk(
+    const wuffs_xxhash32__hasher* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_xxhash32__hasher__set_quirk(
+    wuffs_xxhash32__hasher* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_xxhash32__hasher__update(
+    wuffs_xxhash32__hasher* self,
+    wuffs_base__slice_u8 a_x);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_xxhash32__hasher__update_u32(
+    wuffs_xxhash32__hasher* self,
+    wuffs_base__slice_u8 a_x);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_xxhash32__hasher__checksum_u32(
+    const wuffs_xxhash32__hasher* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_xxhash32__hasher__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__hasher_u32;
+    wuffs_base__vtable null_vtable;
+
+    uint32_t f_length_modulo_u32;
+    bool f_length_overflows_u32;
+    uint8_t f_padding0;
+    uint8_t f_padding1;
+    uint8_t f_buf_len;
+    uint8_t f_buf_data[16];
+    uint32_t f_v0;
+    uint32_t f_v1;
+    uint32_t f_v2;
+    uint32_t f_v3;
+  } private_impl;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_xxhash32__hasher, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_xxhash32__hasher__alloc());
+  }
+
+  static inline wuffs_base__hasher_u32::unique_ptr
+  alloc_as__wuffs_base__hasher_u32() {
+    return wuffs_base__hasher_u32::unique_ptr(
+        wuffs_xxhash32__hasher__alloc_as__wuffs_base__hasher_u32());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_xxhash32__hasher__struct() = delete;
+  wuffs_xxhash32__hasher__struct(const wuffs_xxhash32__hasher__struct&) = delete;
+  wuffs_xxhash32__hasher__struct& operator=(
+      const wuffs_xxhash32__hasher__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_xxhash32__hasher__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__hasher_u32*
+  upcast_as__wuffs_base__hasher_u32() {
+    return (wuffs_base__hasher_u32*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_xxhash32__hasher__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_xxhash32__hasher__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__empty_struct
+  update(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_xxhash32__hasher__update(this, a_x);
+  }
+
+  inline uint32_t
+  update_u32(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_xxhash32__hasher__update_u32(this, a_x);
+  }
+
+  inline uint32_t
+  checksum_u32() const {
+    return wuffs_xxhash32__hasher__checksum_u32(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_xxhash32__hasher__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__XXHASH32) || defined(WUFFS_NONMONOLITHIC)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__XXHASH64) || defined(WUFFS_NONMONOLITHIC)
+
+// ---------------- Status Codes
+
+// ---------------- Public Consts
+
+// ---------------- Struct Declarations
+
+typedef struct wuffs_xxhash64__hasher__struct wuffs_xxhash64__hasher;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Public Initializer Prototypes
+
+// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
+// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
+//
+// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
+// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
+
+wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+wuffs_xxhash64__hasher__initialize(
+    wuffs_xxhash64__hasher* self,
+    size_t sizeof_star_self,
+    uint64_t wuffs_version,
+    uint32_t options);
+
+size_t
+sizeof__wuffs_xxhash64__hasher();
+
+// ---------------- Allocs
+
+// These functions allocate and initialize Wuffs structs. They return NULL if
+// memory allocation fails. If they return non-NULL, there is no need to call
+// wuffs_foo__bar__initialize, but the caller is responsible for eventually
+// calling free on the returned pointer. That pointer is effectively a C++
+// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
+
+wuffs_xxhash64__hasher*
+wuffs_xxhash64__hasher__alloc();
+
+static inline wuffs_base__hasher_u64*
+wuffs_xxhash64__hasher__alloc_as__wuffs_base__hasher_u64() {
+  return (wuffs_base__hasher_u64*)(wuffs_xxhash64__hasher__alloc());
+}
+
+// ---------------- Upcasts
+
+static inline wuffs_base__hasher_u64*
+wuffs_xxhash64__hasher__upcast_as__wuffs_base__hasher_u64(
+    wuffs_xxhash64__hasher* p) {
+  return (wuffs_base__hasher_u64*)p;
+}
+
+// ---------------- Public Function Prototypes
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_xxhash64__hasher__get_quirk(
+    const wuffs_xxhash64__hasher* self,
+    uint32_t a_key);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_xxhash64__hasher__set_quirk(
+    wuffs_xxhash64__hasher* self,
+    uint32_t a_key,
+    uint64_t a_value);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_xxhash64__hasher__update(
+    wuffs_xxhash64__hasher* self,
+    wuffs_base__slice_u8 a_x);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_xxhash64__hasher__update_u64(
+    wuffs_xxhash64__hasher* self,
+    wuffs_base__slice_u8 a_x);
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_xxhash64__hasher__checksum_u64(
+    const wuffs_xxhash64__hasher* self);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+// ---------------- Struct Definitions
+
+// These structs' fields, and the sizeof them, are private implementation
+// details that aren't guaranteed to be stable across Wuffs versions.
+//
+// See https://en.wikipedia.org/wiki/Opaque_pointer#C
+
+#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+struct wuffs_xxhash64__hasher__struct {
+  // Do not access the private_impl's or private_data's fields directly. There
+  // is no API/ABI compatibility or safety guarantee if you do so. Instead, use
+  // the wuffs_foo__bar__baz functions.
+  //
+  // It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
+  // can be stack allocated when WUFFS_IMPLEMENTATION is defined.
+
+  struct {
+    uint32_t magic;
+    uint32_t active_coroutine;
+    wuffs_base__vtable vtable_for__wuffs_base__hasher_u64;
+    wuffs_base__vtable null_vtable;
+
+    uint64_t f_length_modulo_u64;
+    bool f_length_overflows_u64;
+    uint8_t f_padding0;
+    uint8_t f_padding1;
+    uint8_t f_padding2;
+    uint32_t f_buf_len;
+    uint8_t f_buf_data[32];
+    uint64_t f_v0;
+    uint64_t f_v1;
+    uint64_t f_v2;
+    uint64_t f_v3;
+  } private_impl;
+
+#ifdef __cplusplus
+#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+  using unique_ptr = std::unique_ptr<wuffs_xxhash64__hasher, wuffs_unique_ptr_deleter>;
+
+  // On failure, the alloc_etc functions return nullptr. They don't throw.
+
+  static inline unique_ptr
+  alloc() {
+    return unique_ptr(wuffs_xxhash64__hasher__alloc());
+  }
+
+  static inline wuffs_base__hasher_u64::unique_ptr
+  alloc_as__wuffs_base__hasher_u64() {
+    return wuffs_base__hasher_u64::unique_ptr(
+        wuffs_xxhash64__hasher__alloc_as__wuffs_base__hasher_u64());
+  }
+#endif  // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+  // Disallow constructing or copying an object via standard C++ mechanisms,
+  // e.g. the "new" operator, as this struct is intentionally opaque. Its total
+  // size and field layout is not part of the public, stable, memory-safe API.
+  // Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
+  // call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
+  // their first argument) rather than tweaking bar.private_impl.qux fields.
+  //
+  // In C, we can just leave wuffs_foo__bar as an incomplete type (unless
+  // WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
+  // order to provide convenience methods. These forward on "this", so that you
+  // can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
+  wuffs_xxhash64__hasher__struct() = delete;
+  wuffs_xxhash64__hasher__struct(const wuffs_xxhash64__hasher__struct&) = delete;
+  wuffs_xxhash64__hasher__struct& operator=(
+      const wuffs_xxhash64__hasher__struct&) = delete;
+#endif  // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
+
+#if !defined(WUFFS_IMPLEMENTATION)
+  // As above, the size of the struct is not part of the public API, and unless
+  // WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
+  // allocated, not stack allocated. Its size is not intended to be known at
+  // compile time, but it is unfortunately divulged as a side effect of
+  // defining C++ convenience methods. Use "sizeof__T()", calling the function,
+  // instead of "sizeof T", invoking the operator. To make the two values
+  // different, so that passing the latter will be rejected by the initialize
+  // function, we add an arbitrary amount of dead weight.
+  uint8_t dead_weight[123000000];  // 123 MB.
+#endif  // !defined(WUFFS_IMPLEMENTATION)
+
+  inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
+  initialize(
+      size_t sizeof_star_self,
+      uint64_t wuffs_version,
+      uint32_t options) {
+    return wuffs_xxhash64__hasher__initialize(
+        this, sizeof_star_self, wuffs_version, options);
+  }
+
+  inline wuffs_base__hasher_u64*
+  upcast_as__wuffs_base__hasher_u64() {
+    return (wuffs_base__hasher_u64*)this;
+  }
+
+  inline uint64_t
+  get_quirk(
+      uint32_t a_key) const {
+    return wuffs_xxhash64__hasher__get_quirk(this, a_key);
+  }
+
+  inline wuffs_base__status
+  set_quirk(
+      uint32_t a_key,
+      uint64_t a_value) {
+    return wuffs_xxhash64__hasher__set_quirk(this, a_key, a_value);
+  }
+
+  inline wuffs_base__empty_struct
+  update(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_xxhash64__hasher__update(this, a_x);
+  }
+
+  inline uint64_t
+  update_u64(
+      wuffs_base__slice_u8 a_x) {
+    return wuffs_xxhash64__hasher__update_u64(this, a_x);
+  }
+
+  inline uint64_t
+  checksum_u64() const {
+    return wuffs_xxhash64__hasher__checksum_u64(this);
+  }
+
+#endif  // __cplusplus
+};  // struct wuffs_xxhash64__hasher__struct
+
+#endif  // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__XXHASH64) || defined(WUFFS_NONMONOLITHIC)
+
+#if defined(__cplusplus) && defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+// ---------------- Auxiliary - Base
+
+// Auxiliary code is discussed at
+// https://github.com/google/wuffs/blob/main/doc/note/auxiliary-code.md
+
+#include <stdio.h>
+
+#include <string>
+
+namespace wuffs_aux {
+
+using IOBuffer = wuffs_base__io_buffer;
+
+// MemOwner represents ownership of some memory. Dynamically allocated memory
+// (e.g. from malloc or new) is typically paired with free or delete, invoked
+// when the std::unique_ptr is destroyed. Statically allocated memory might use
+// MemOwner(nullptr, &free), even if that statically allocated memory is not
+// nullptr, since calling free(nullptr) is a no-op.
+using MemOwner = std::unique_ptr<void, decltype(&free)>;
+
+namespace sync_io {
+
+// --------
+
+// DynIOBuffer is an IOBuffer that is backed by a dynamically sized byte array.
+// It owns that backing array and will free it in its destructor.
+//
+// The array size can be explicitly extended (by calling the grow method) but,
+// unlike a C++ std::vector, there is no implicit extension (e.g. by calling
+// std::vector::insert) and its maximum size is capped by the max_incl
+// constructor argument.
+//
+// It contains an IOBuffer-typed field whose reader side provides access to
+// previously written bytes and whose writer side provides access to the
+// allocated but not-yet-written-to slack space. For Go programmers, this slack
+// space is roughly analogous to the s[len(s):cap(s)] space of a slice s.
+class DynIOBuffer {
+ public:
+  enum GrowResult {
+    OK = 0,
+    FailedMaxInclExceeded = 1,
+    FailedOutOfMemory = 2,
+  };
+
+  // m_buf holds the dynamically sized byte array and its read/write indexes:
+  //  - m_buf.meta.wi  is roughly analogous to a Go slice's length.
+  //  - m_buf.data.len is roughly analogous to a Go slice's capacity. It is
+  //    also equal to the m_buf.data.ptr malloc/realloc size.
+  //
+  // Users should not modify the m_buf.data.ptr or m_buf.data.len fields (as
+  // they are conceptually private to this class), but they can modify the
+  // bytes referenced by that pointer-length pair (e.g. compactions).
+  IOBuffer m_buf;
+
+  // m_max_incl is an inclusive upper bound on the backing array size.
+  const uint64_t m_max_incl;
+
+  // Constructor and destructor.
+  explicit DynIOBuffer(uint64_t max_incl);
+  ~DynIOBuffer();
+
+  // Drop frees the byte array and resets m_buf. The DynIOBuffer can still be
+  // used after a drop call. It just restarts from zero.
+  void drop();
+
+  // grow ensures that the byte array size is at least min_incl and at most
+  // max_incl. It returns FailedMaxInclExceeded if that would require
+  // allocating more than max_incl bytes, including the case where (min_incl >
+  // max_incl). It returns FailedOutOfMemory if memory allocation failed.
+  GrowResult grow(uint64_t min_incl);
+
+ private:
+  // Delete the copy and assign constructors.
+  DynIOBuffer(const DynIOBuffer&) = delete;
+  DynIOBuffer& operator=(const DynIOBuffer&) = delete;
+
+  static uint64_t round_up(uint64_t min_incl, uint64_t max_incl);
+};
+
+// --------
+
+class Input {
+ public:
+  virtual ~Input();
+
+  virtual IOBuffer* BringsItsOwnIOBuffer();
+  virtual std::string CopyIn(IOBuffer* dst, uint64_t history_retain_length) = 0;
+};
+
+// --------
+
+// FileInput is an Input that reads from a file source.
+//
+// It does not take responsibility for closing the file when done.
+class FileInput : public Input {
+ public:
+  FileInput(FILE* f);
+
+  virtual std::string CopyIn(IOBuffer* dst, uint64_t history_retain_length);
+
+ private:
+  FILE* m_f;
+
+  // Delete the copy and assign constructors.
+  FileInput(const FileInput&) = delete;
+  FileInput& operator=(const FileInput&) = delete;
+};
+
+// --------
+
+// MemoryInput is an Input that reads from an in-memory source.
+//
+// It does not take responsibility for freeing the memory when done.
+class MemoryInput : public Input {
+ public:
+  MemoryInput(const char* ptr, size_t len);
+  MemoryInput(const uint8_t* ptr, size_t len);
+
+  virtual IOBuffer* BringsItsOwnIOBuffer();
+  virtual std::string CopyIn(IOBuffer* dst, uint64_t history_retain_length);
+
+ private:
+  IOBuffer m_io;
+
+  // Delete the copy and assign constructors.
+  MemoryInput(const MemoryInput&) = delete;
+  MemoryInput& operator=(const MemoryInput&) = delete;
+};
+
+// --------
+
+}  // namespace sync_io
+
+}  // namespace wuffs_aux
+
+// ---------------- Auxiliary - CBOR
+
+namespace wuffs_aux {
+
+struct DecodeCborResult {
+  DecodeCborResult(std::string&& error_message0, uint64_t cursor_position0);
+
+  std::string error_message;
+  uint64_t cursor_position;
+};
+
+class DecodeCborCallbacks {
+ public:
+  virtual ~DecodeCborCallbacks();
+
+  // AppendXxx are called for leaf nodes: literals, numbers, strings, etc.
+
+  virtual std::string AppendNull() = 0;
+  virtual std::string AppendUndefined() = 0;
+  virtual std::string AppendBool(bool val) = 0;
+  virtual std::string AppendF64(double val) = 0;
+  virtual std::string AppendI64(int64_t val) = 0;
+  virtual std::string AppendU64(uint64_t val) = 0;
+  virtual std::string AppendByteString(std::string&& val) = 0;
+  virtual std::string AppendTextString(std::string&& val) = 0;
+  virtual std::string AppendMinus1MinusX(uint64_t val) = 0;
+  virtual std::string AppendCborSimpleValue(uint8_t val) = 0;
+  virtual std::string AppendCborTag(uint64_t val) = 0;
+
+  // Push and Pop are called for container nodes: CBOR arrays (lists) and CBOR
+  // maps (dictionaries).
+  //
+  // The flags bits combine exactly one of:
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_NONE
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_LIST
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_DICT
+  // and exactly one of:
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT
+
+  virtual std::string Push(uint32_t flags) = 0;
+  virtual std::string Pop(uint32_t flags) = 0;
+
+  // Done is always the last Callback method called by DecodeCbor, whether or
+  // not parsing the input as CBOR encountered an error. Even when successful,
+  // trailing data may remain in input and buffer.
+  //
+  // Do not keep a reference to buffer or buffer.data.ptr after Done returns,
+  // as DecodeCbor may then de-allocate the backing array.
+  //
+  // The default Done implementation is a no-op.
+  virtual void  //
+  Done(DecodeCborResult& result, sync_io::Input& input, IOBuffer& buffer);
+};
+
+// The FooArgBar types add structure to Foo's optional arguments. They wrap
+// inner representations for several reasons:
+//  - It provides a home for the DefaultValue static method, for Foo callers
+//    that want to override some but not all optional arguments.
+//  - It provides the "Bar" name at Foo call sites, which can help self-
+//    document Foo calls with many arguemnts.
+//  - It provides some type safety against accidentally transposing or omitting
+//    adjacent fundamentally-numeric-typed optional arguments.
+
+// DecodeCborArgQuirks wraps an optional argument to DecodeCbor.
+struct DecodeCborArgQuirks {
+  explicit DecodeCborArgQuirks(wuffs_base__slice_u32 repr0);
+  explicit DecodeCborArgQuirks(uint32_t* ptr, size_t len);
+
+  // DefaultValue returns an empty slice.
+  static DecodeCborArgQuirks DefaultValue();
+
+  wuffs_base__slice_u32 repr;
+};
+
+// DecodeCbor calls callbacks based on the CBOR-formatted data in input.
+//
+// On success, the returned error_message is empty and cursor_position counts
+// the number of bytes consumed. On failure, error_message is non-empty and
+// cursor_position is the location of the error. That error may be a content
+// error (invalid CBOR) or an input error (e.g. network failure).
+DecodeCborResult  //
+DecodeCbor(DecodeCborCallbacks& callbacks,
+           sync_io::Input& input,
+           DecodeCborArgQuirks quirks = DecodeCborArgQuirks::DefaultValue());
+
+}  // namespace wuffs_aux
+
+// ---------------- Auxiliary - Image
+
+namespace wuffs_aux {
+
+struct DecodeImageResult {
+  DecodeImageResult(MemOwner&& pixbuf_mem_owner0,
+                    wuffs_base__pixel_buffer pixbuf0,
+                    std::string&& error_message0);
+  DecodeImageResult(std::string&& error_message0);
+
+  MemOwner pixbuf_mem_owner;
+  wuffs_base__pixel_buffer pixbuf;
+  std::string error_message;
+};
+
+// DecodeImageCallbacks are the callbacks given to DecodeImage. They are always
+// called in this order:
+//  1. SelectDecoder
+//  2. HandleMetadata
+//  3. SelectPixfmt
+//  4. AllocPixbuf
+//  5. AllocWorkbuf
+//  6. Done
+//
+// It may return early - the third callback might not be invoked if the second
+// one fails - but the final callback (Done) is always invoked.
+class DecodeImageCallbacks {
+ public:
+  // AllocPixbufResult holds a memory allocation (the result of malloc or new,
+  // a statically allocated pointer, etc), or an error message. The memory is
+  // de-allocated when mem_owner goes out of scope and is destroyed.
+  struct AllocPixbufResult {
+    AllocPixbufResult(MemOwner&& mem_owner0, wuffs_base__pixel_buffer pixbuf0);
+    AllocPixbufResult(std::string&& error_message0);
+
+    MemOwner mem_owner;
+    wuffs_base__pixel_buffer pixbuf;
+    std::string error_message;
+  };
+
+  // AllocWorkbufResult holds a memory allocation (the result of malloc or new,
+  // a statically allocated pointer, etc), or an error message. The memory is
+  // de-allocated when mem_owner goes out of scope and is destroyed.
+  struct AllocWorkbufResult {
+    AllocWorkbufResult(MemOwner&& mem_owner0, wuffs_base__slice_u8 workbuf0);
+    AllocWorkbufResult(std::string&& error_message0);
+
+    MemOwner mem_owner;
+    wuffs_base__slice_u8 workbuf;
+    std::string error_message;
+  };
+
+  virtual ~DecodeImageCallbacks();
+
+  // SelectDecoder returns the image decoder for the input data's file format.
+  // Returning a nullptr means failure (DecodeImage_UnsupportedImageFormat).
+  //
+  // Common formats will have a FourCC value in the range [1 ..= 0x7FFF_FFFF],
+  // such as WUFFS_BASE__FOURCC__JPEG. A zero FourCC value means that Wuffs'
+  // standard library did not recognize the image format but if SelectDecoder
+  // was overridden, it may examine the input data's starting bytes and still
+  // provide its own image decoder, e.g. for an exotic image file format that's
+  // not in Wuffs' standard library. The prefix_etc fields have the same
+  // meaning as wuffs_base__magic_number_guess_fourcc arguments. SelectDecoder
+  // implementations should not modify prefix_data's contents.
+  //
+  // SelectDecoder might be called more than once, since some image file
+  // formats can wrap others. For example, a nominal BMP file can actually
+  // contain a JPEG or a PNG.
+  //
+  // The default SelectDecoder accepts the FOURCC codes listed below. For
+  // modular builds (i.e. when #define'ing WUFFS_CONFIG__MODULES), acceptance
+  // of the ETC file format is optional (for each value of ETC) and depends on
+  // the corresponding module to be enabled at compile time (i.e. #define'ing
+  // WUFFS_CONFIG__MODULE__ETC).
+  //  - WUFFS_BASE__FOURCC__BMP
+  //  - WUFFS_BASE__FOURCC__GIF
+  //  - WUFFS_BASE__FOURCC__JPEG
+  //  - WUFFS_BASE__FOURCC__NIE
+  //  - WUFFS_BASE__FOURCC__NPBM
+  //  - WUFFS_BASE__FOURCC__PNG
+  //  - WUFFS_BASE__FOURCC__TGA
+  //  - WUFFS_BASE__FOURCC__WBMP
+  virtual wuffs_base__image_decoder::unique_ptr  //
+  SelectDecoder(uint32_t fourcc,
+                wuffs_base__slice_u8 prefix_data,
+                bool prefix_closed);
+
+  // HandleMetadata acknowledges image metadata. minfo.flavor will be one of:
+  //  - WUFFS_BASE__MORE_INFORMATION__FLAVOR__METADATA_RAW_PASSTHROUGH
+  //  - WUFFS_BASE__MORE_INFORMATION__FLAVOR__METADATA_PARSED
+  // If it is ETC__METADATA_RAW_ETC then raw contains the metadata bytes. Those
+  // bytes should not be retained beyond the the HandleMetadata call.
+  //
+  // minfo.metadata__fourcc() will typically match one of the
+  // DecodeImageArgFlags bits. For example, if (REPORT_METADATA_CHRM |
+  // REPORT_METADATA_GAMA) was passed to DecodeImage then the metadata FourCC
+  // will be either WUFFS_BASE__FOURCC__CHRM or WUFFS_BASE__FOURCC__GAMA.
+  //
+  // It returns an error message, or an empty string on success.
+  virtual std::string  //
+  HandleMetadata(const wuffs_base__more_information& minfo,
+                 wuffs_base__slice_u8 raw);
+
+  // SelectPixfmt returns the destination pixel format for AllocPixbuf. It
+  // should return wuffs_base__make_pixel_format(etc) called with one of:
+  //  - WUFFS_BASE__PIXEL_FORMAT__BGR_565
+  //  - WUFFS_BASE__PIXEL_FORMAT__BGR
+  //  - WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL
+  //  - WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE
+  //  - WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL
+  //  - WUFFS_BASE__PIXEL_FORMAT__RGB
+  //  - WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL
+  //  - WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL
+  // or return image_config.pixcfg.pixel_format(). The latter means to use the
+  // image file's natural pixel format. For example, GIF images' natural pixel
+  // format is an indexed one.
+  //
+  // Returning otherwise means failure (DecodeImage_UnsupportedPixelFormat).
+  //
+  // The default SelectPixfmt implementation returns
+  // wuffs_base__make_pixel_format(WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL) which
+  // is 4 bytes per pixel (8 bits per channel × 4 channels).
+  virtual wuffs_base__pixel_format  //
+  SelectPixfmt(const wuffs_base__image_config& image_config);
+
+  // AllocPixbuf allocates the pixel buffer.
+  //
+  // allow_uninitialized_memory will be true if a valid background_color was
+  // passed to DecodeImage, since the pixel buffer's contents will be
+  // overwritten with that color after AllocPixbuf returns.
+  //
+  // The default AllocPixbuf implementation allocates either uninitialized or
+  // zeroed memory. Zeroed memory typically corresponds to filling with opaque
+  // black or transparent black, depending on the pixel format.
+  virtual AllocPixbufResult  //
+  AllocPixbuf(const wuffs_base__image_config& image_config,
+              bool allow_uninitialized_memory);
+
+  // AllocWorkbuf allocates the work buffer. The allocated buffer's length
+  // should be at least len_range.min_incl, but larger allocations (up to
+  // len_range.max_incl) may have better performance (by using more memory).
+  //
+  // The default AllocWorkbuf implementation allocates len_range.max_incl bytes
+  // of either uninitialized or zeroed memory.
+  virtual AllocWorkbufResult  //
+  AllocWorkbuf(wuffs_base__range_ii_u64 len_range,
+               bool allow_uninitialized_memory);
+
+  // Done is always the last Callback method called by DecodeImage, whether or
+  // not parsing the input encountered an error. Even when successful, trailing
+  // data may remain in input and buffer.
+  //
+  // The image_decoder is the one returned by SelectDecoder (if SelectDecoder
+  // was successful), or a no-op unique_ptr otherwise. Like any unique_ptr,
+  // ownership moves to the Done implementation.
+  //
+  // Do not keep a reference to buffer or buffer.data.ptr after Done returns,
+  // as DecodeImage may then de-allocate the backing array.
+  //
+  // The default Done implementation is a no-op, other than running the
+  // image_decoder unique_ptr destructor.
+  virtual void  //
+  Done(DecodeImageResult& result,
+       sync_io::Input& input,
+       IOBuffer& buffer,
+       wuffs_base__image_decoder::unique_ptr image_decoder);
+};
+
+extern const char DecodeImage_BufferIsTooShort[];
+extern const char DecodeImage_MaxInclDimensionExceeded[];
+extern const char DecodeImage_MaxInclMetadataLengthExceeded[];
+extern const char DecodeImage_OutOfMemory[];
+extern const char DecodeImage_UnexpectedEndOfFile[];
+extern const char DecodeImage_UnsupportedImageFormat[];
+extern const char DecodeImage_UnsupportedMetadata[];
+extern const char DecodeImage_UnsupportedPixelBlend[];
+extern const char DecodeImage_UnsupportedPixelConfiguration[];
+extern const char DecodeImage_UnsupportedPixelFormat[];
+
+// The FooArgBar types add structure to Foo's optional arguments. They wrap
+// inner representations for several reasons:
+//  - It provides a home for the DefaultValue static method, for Foo callers
+//    that want to override some but not all optional arguments.
+//  - It provides the "Bar" name at Foo call sites, which can help self-
+//    document Foo calls with many arguemnts.
+//  - It provides some type safety against accidentally transposing or omitting
+//    adjacent fundamentally-numeric-typed optional arguments.
+
+// DecodeImageArgQuirks wraps an optional argument to DecodeImage.
+struct DecodeImageArgQuirks {
+  explicit DecodeImageArgQuirks(wuffs_base__slice_u32 repr0);
+  explicit DecodeImageArgQuirks(uint32_t* ptr, size_t len);
+
+  // DefaultValue returns an empty slice.
+  static DecodeImageArgQuirks DefaultValue();
+
+  wuffs_base__slice_u32 repr;
+};
+
+// DecodeImageArgFlags wraps an optional argument to DecodeImage.
+struct DecodeImageArgFlags {
+  explicit DecodeImageArgFlags(uint64_t repr0);
+
+  // DefaultValue returns 0.
+  static DecodeImageArgFlags DefaultValue();
+
+  // TODO: support all of the REPORT_METADATA_ETC flags, not just CHRM, EXIF,
+  // GAMA, ICCP, KVP, SRGB and XMP.
+
+  // Background Color.
+  static constexpr uint64_t REPORT_METADATA_BGCL = 0x0001;
+  // Primary Chromaticities and White Point.
+  static constexpr uint64_t REPORT_METADATA_CHRM = 0x0002;
+  // Exchangeable Image File Format.
+  static constexpr uint64_t REPORT_METADATA_EXIF = 0x0004;
+  // Gamma Correction.
+  static constexpr uint64_t REPORT_METADATA_GAMA = 0x0008;
+  // International Color Consortium Profile.
+  static constexpr uint64_t REPORT_METADATA_ICCP = 0x0010;
+  // Key-Value Pair.
+  //
+  // For PNG files, this includes iTXt, tEXt and zTXt chunks. In the
+  // HandleMetadata callback, the raw argument contains UTF-8 strings.
+  static constexpr uint64_t REPORT_METADATA_KVP = 0x0020;
+  // Modification Time.
+  static constexpr uint64_t REPORT_METADATA_MTIM = 0x0040;
+  // Offset (2-Dimensional).
+  static constexpr uint64_t REPORT_METADATA_OFS2 = 0x0080;
+  // Physical Dimensions.
+  static constexpr uint64_t REPORT_METADATA_PHYD = 0x0100;
+  // Standard Red Green Blue (Rendering Intent).
+  static constexpr uint64_t REPORT_METADATA_SRGB = 0x0200;
+  // Extensible Metadata Platform.
+  static constexpr uint64_t REPORT_METADATA_XMP = 0x0400;
+
+  uint64_t repr;
+};
+
+// DecodeImageArgPixelBlend wraps an optional argument to DecodeImage.
+struct DecodeImageArgPixelBlend {
+  explicit DecodeImageArgPixelBlend(wuffs_base__pixel_blend repr0);
+
+  // DefaultValue returns WUFFS_BASE__PIXEL_BLEND__SRC.
+  static DecodeImageArgPixelBlend DefaultValue();
+
+  wuffs_base__pixel_blend repr;
+};
+
+// DecodeImageArgBackgroundColor wraps an optional argument to DecodeImage.
+struct DecodeImageArgBackgroundColor {
+  explicit DecodeImageArgBackgroundColor(
+      wuffs_base__color_u32_argb_premul repr0);
+
+  // DefaultValue returns 1, an invalid wuffs_base__color_u32_argb_premul.
+  static DecodeImageArgBackgroundColor DefaultValue();
+
+  wuffs_base__color_u32_argb_premul repr;
+};
+
+// DecodeImageArgMaxInclDimension wraps an optional argument to DecodeImage.
+struct DecodeImageArgMaxInclDimension {
+  explicit DecodeImageArgMaxInclDimension(uint32_t repr0);
+
+  // DefaultValue returns 1048575 = 0x000F_FFFF, more than 1 million pixels.
+  static DecodeImageArgMaxInclDimension DefaultValue();
+
+  uint32_t repr;
+};
+
+// DecodeImageArgMaxInclMetadataLength wraps an optional argument to
+// DecodeImage.
+struct DecodeImageArgMaxInclMetadataLength {
+  explicit DecodeImageArgMaxInclMetadataLength(uint64_t repr0);
+
+  // DefaultValue returns 16777215 = 0x00FF_FFFF, one less than 16 MiB.
+  static DecodeImageArgMaxInclMetadataLength DefaultValue();
+
+  uint64_t repr;
+};
+
+// DecodeImage decodes the image data in input. A variety of image file formats
+// can be decoded, depending on what callbacks.SelectDecoder returns.
+//
+// For animated formats, only the first frame is returned, since the API is
+// simpler for synchronous I/O and having DecodeImage only return when
+// completely done, but rendering animation often involves handling other
+// events in between animation frames. To decode multiple frames of animated
+// images, or for asynchronous I/O (e.g. when decoding an image streamed over
+// the network), use Wuffs' lower level C API instead of its higher level,
+// simplified C++ API (the wuffs_aux API).
+//
+// The DecodeImageResult's fields depend on whether decoding succeeded:
+//  - On total success, the error_message is empty and pixbuf.pixcfg.is_valid()
+//    is true.
+//  - On partial success (e.g. the input file was truncated but we are still
+//    able to decode some of the pixels), error_message is non-empty but
+//    pixbuf.pixcfg.is_valid() is still true. It is up to the caller whether to
+//    accept or reject partial success.
+//  - On failure, the error_message is non_empty and pixbuf.pixcfg.is_valid()
+//    is false.
+//
+// The callbacks allocate the pixel buffer memory and work buffer memory. On
+// success, pixel buffer memory ownership is passed to the DecodeImage caller
+// as the returned pixbuf_mem_owner. Regardless of success or failure, the work
+// buffer memory is deleted.
+//
+// The pixel_blend (one of the constants listed below) determines how to
+// composite the decoded image over the pixel buffer's original pixels (as
+// returned by callbacks.AllocPixbuf):
+//  - WUFFS_BASE__PIXEL_BLEND__SRC
+//  - WUFFS_BASE__PIXEL_BLEND__SRC_OVER
+//
+// The background_color is used to fill the pixel buffer after
+// callbacks.AllocPixbuf returns, if it is valid in the
+// wuffs_base__color_u32_argb_premul__is_valid sense. The default value,
+// 0x0000_0001, is not valid since its Blue channel value (0x01) is greater
+// than its Alpha channel value (0x00). A valid background_color will typically
+// be overwritten when pixel_blend is WUFFS_BASE__PIXEL_BLEND__SRC, but might
+// still be visible on partial (not total) success or when pixel_blend is
+// WUFFS_BASE__PIXEL_BLEND__SRC_OVER and the decoded image is not fully opaque.
+//
+// Decoding fails (with DecodeImage_MaxInclDimensionExceeded) if the image's
+// width or height is greater than max_incl_dimension or if any opted-in (via
+// flags bits) metadata is longer than max_incl_metadata_length.
+DecodeImageResult  //
+DecodeImage(DecodeImageCallbacks& callbacks,
+            sync_io::Input& input,
+            DecodeImageArgQuirks quirks = DecodeImageArgQuirks::DefaultValue(),
+            DecodeImageArgFlags flags = DecodeImageArgFlags::DefaultValue(),
+            DecodeImageArgPixelBlend pixel_blend =
+                DecodeImageArgPixelBlend::DefaultValue(),
+            DecodeImageArgBackgroundColor background_color =
+                DecodeImageArgBackgroundColor::DefaultValue(),
+            DecodeImageArgMaxInclDimension max_incl_dimension =
+                DecodeImageArgMaxInclDimension::DefaultValue(),
+            DecodeImageArgMaxInclMetadataLength max_incl_metadata_length =
+                DecodeImageArgMaxInclMetadataLength::DefaultValue());
+
+}  // namespace wuffs_aux
+
+// ---------------- Auxiliary - JSON
+
+namespace wuffs_aux {
+
+struct DecodeJsonResult {
+  DecodeJsonResult(std::string&& error_message0, uint64_t cursor_position0);
+
+  std::string error_message;
+  uint64_t cursor_position;
+};
+
+class DecodeJsonCallbacks {
+ public:
+  virtual ~DecodeJsonCallbacks();
+
+  // AppendXxx are called for leaf nodes: literals, numbers and strings. For
+  // strings, the Callbacks implementation is responsible for tracking map keys
+  // versus other values.
+
+  virtual std::string AppendNull() = 0;
+  virtual std::string AppendBool(bool val) = 0;
+  virtual std::string AppendF64(double val) = 0;
+  virtual std::string AppendI64(int64_t val) = 0;
+  virtual std::string AppendTextString(std::string&& val) = 0;
+
+  // Push and Pop are called for container nodes: JSON arrays (lists) and JSON
+  // objects (dictionaries).
+  //
+  // The flags bits combine exactly one of:
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_NONE
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_LIST
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_DICT
+  // and exactly one of:
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST
+  //  - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT
+
+  virtual std::string Push(uint32_t flags) = 0;
+  virtual std::string Pop(uint32_t flags) = 0;
+
+  // Done is always the last Callback method called by DecodeJson, whether or
+  // not parsing the input as JSON encountered an error. Even when successful,
+  // trailing data may remain in input and buffer. See "Unintuitive JSON
+  // Parsing" (https://nullprogram.com/blog/2019/12/28/) which discusses JSON
+  // parsing and when it stops.
+  //
+  // Do not keep a reference to buffer or buffer.data.ptr after Done returns,
+  // as DecodeJson may then de-allocate the backing array.
+  //
+  // The default Done implementation is a no-op.
+  virtual void  //
+  Done(DecodeJsonResult& result, sync_io::Input& input, IOBuffer& buffer);
+};
+
+extern const char DecodeJson_BadJsonPointer[];
+extern const char DecodeJson_NoMatch[];
+
+// The FooArgBar types add structure to Foo's optional arguments. They wrap
+// inner representations for several reasons:
+//  - It provides a home for the DefaultValue static method, for Foo callers
+//    that want to override some but not all optional arguments.
+//  - It provides the "Bar" name at Foo call sites, which can help self-
+//    document Foo calls with many arguemnts.
+//  - It provides some type safety against accidentally transposing or omitting
+//    adjacent fundamentally-numeric-typed optional arguments.
+
+// DecodeJsonArgQuirks wraps an optional argument to DecodeJson.
+struct DecodeJsonArgQuirks {
+  explicit DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0);
+  explicit DecodeJsonArgQuirks(uint32_t* ptr, size_t len);
+
+  // DefaultValue returns an empty slice.
+  static DecodeJsonArgQuirks DefaultValue();
+
+  wuffs_base__slice_u32 repr;
+};
+
+// DecodeJsonArgJsonPointer wraps an optional argument to DecodeJson.
+struct DecodeJsonArgJsonPointer {
+  explicit DecodeJsonArgJsonPointer(std::string repr0);
+
+  // DefaultValue returns an empty string.
+  static DecodeJsonArgJsonPointer DefaultValue();
+
+  std::string repr;
+};
+
+// DecodeJson calls callbacks based on the JSON-formatted data in input.
+//
+// On success, the returned error_message is empty and cursor_position counts
+// the number of bytes consumed. On failure, error_message is non-empty and
+// cursor_position is the location of the error. That error may be a content
+// error (invalid JSON) or an input error (e.g. network failure).
+//
+// json_pointer is a query in the JSON Pointer (RFC 6901) syntax. The callbacks
+// run for the input's sub-node that matches the query. DecodeJson_NoMatch is
+// returned if no matching sub-node was found. The empty query matches the
+// input's root node, consistent with JSON Pointer semantics.
+//
+// The JSON Pointer implementation is greedy: duplicate keys are not rejected
+// but only the first match for each '/'-separated fragment is followed.
+DecodeJsonResult  //
+DecodeJson(DecodeJsonCallbacks& callbacks,
+           sync_io::Input& input,
+           DecodeJsonArgQuirks quirks = DecodeJsonArgQuirks::DefaultValue(),
+           DecodeJsonArgJsonPointer json_pointer =
+               DecodeJsonArgJsonPointer::DefaultValue());
+
+}  // namespace wuffs_aux
+
+#endif  // defined(__cplusplus) && defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
+
+// ‼ WUFFS C HEADER ENDS HERE.
+#ifdef WUFFS_IMPLEMENTATION
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ---------------- Fundamentals
+
+// WUFFS_BASE__MAGIC is a magic number to check that initializers are called.
+// It's not foolproof, given C doesn't automatically zero memory before use,
+// but it should catch 99.99% of cases.
+//
+// Its (non-zero) value is arbitrary, based on md5sum("wuffs").
+#define WUFFS_BASE__MAGIC ((uint32_t)0x3CCB6C71)
+
+// WUFFS_BASE__DISABLED is a magic number to indicate that a non-recoverable
+// error was previously encountered.
+//
+// Its (non-zero) value is arbitrary, based on md5sum("disabled").
+#define WUFFS_BASE__DISABLED ((uint32_t)0x075AE3D2)
+
+// Use switch cases for coroutine suspension points, similar to the technique
+// in https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
+//
+// The implicit fallthrough is intentional.
+//
+// We use trivial macros instead of an explicit assignment and case statement
+// so that clang-format doesn't get confused by the unusual "case"s.
+#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0 case 0:;
+#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT(n) \
+  coro_susp_point = n;                            \
+  case n:;
+
+#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(n) \
+  if (!status.repr) {                                           \
+    goto ok;                                                    \
+  } else if (*status.repr != '$') {                             \
+    goto exit;                                                  \
+  }                                                             \
+  coro_susp_point = n;                                          \
+  goto suspend;                                                 \
+  case n:;
+
+// The "defined(__clang__)" isn't redundant. While vanilla clang defines
+// __GNUC__, clang-cl (which mimics MSVC's cl.exe) does not.
+#if defined(__GNUC__) || defined(__clang__)
+#define WUFFS_BASE__LIKELY(expr) (__builtin_expect(!!(expr), 1))
+#define WUFFS_BASE__UNLIKELY(expr) (__builtin_expect(!!(expr), 0))
+#else
+#define WUFFS_BASE__LIKELY(expr) (expr)
+#define WUFFS_BASE__UNLIKELY(expr) (expr)
+#endif
+
+// --------
+
+#if defined(__GNUC__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
+static inline uint8_t*  //
+wuffs_base__strip_const_from_u8_ptr(const uint8_t* ptr) {
+  return (uint8_t*)ptr;
+}
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
+
+// --------
+
+static inline wuffs_base__empty_struct  //
+wuffs_base__ignore_status(wuffs_base__status z) {
+  return wuffs_base__make_empty_struct();
+}
+
+static inline wuffs_base__status  //
+wuffs_base__status__ensure_not_a_suspension(wuffs_base__status z) {
+  if (z.repr && (*z.repr == '$')) {
+    z.repr = wuffs_base__error__cannot_return_a_suspension;
+  }
+  return z;
+}
+
+// --------
+
+// wuffs_base__iterate_total_advance returns the exclusive pointer-offset at
+// which iteration should stop. The overall slice has length total_len, each
+// iteration's sub-slice has length iter_len and are placed iter_advance apart.
+//
+// The iter_advance may not be larger than iter_len. The iter_advance may be
+// smaller than iter_len, in which case the sub-slices will overlap.
+//
+// The return value r satisfies ((0 <= r) && (r <= total_len)).
+//
+// For example, if total_len = 15, iter_len = 5 and iter_advance = 3, there are
+// four iterations at offsets 0, 3, 6 and 9. This function returns 12.
+//
+// 0123456789012345
+// [....]
+//    [....]
+//       [....]
+//          [....]
+//             $
+// 0123456789012345
+//
+// For example, if total_len = 15, iter_len = 5 and iter_advance = 5, there are
+// three iterations at offsets 0, 5 and 10. This function returns 15.
+//
+// 0123456789012345
+// [....]
+//      [....]
+//           [....]
+//                $
+// 0123456789012345
+static inline size_t  //
+wuffs_base__iterate_total_advance(size_t total_len,
+                                  size_t iter_len,
+                                  size_t iter_advance) {
+  if (total_len >= iter_len) {
+    size_t n = total_len - iter_len;
+    return ((n / iter_advance) * iter_advance) + iter_advance;
+  }
+  return 0;
+}
+
+// ---------------- Numeric Types
+
+extern const uint8_t wuffs_base__low_bits_mask__u8[8];
+extern const uint16_t wuffs_base__low_bits_mask__u16[16];
+extern const uint32_t wuffs_base__low_bits_mask__u32[32];
+extern const uint64_t wuffs_base__low_bits_mask__u64[64];
+
+#define WUFFS_BASE__LOW_BITS_MASK__U8(n) (wuffs_base__low_bits_mask__u8[n])
+#define WUFFS_BASE__LOW_BITS_MASK__U16(n) (wuffs_base__low_bits_mask__u16[n])
+#define WUFFS_BASE__LOW_BITS_MASK__U32(n) (wuffs_base__low_bits_mask__u32[n])
+#define WUFFS_BASE__LOW_BITS_MASK__U64(n) (wuffs_base__low_bits_mask__u64[n])
+
+// --------
+
+static inline void  //
+wuffs_base__u8__sat_add_indirect(uint8_t* x, uint8_t y) {
+  *x = wuffs_base__u8__sat_add(*x, y);
+}
+
+static inline void  //
+wuffs_base__u8__sat_sub_indirect(uint8_t* x, uint8_t y) {
+  *x = wuffs_base__u8__sat_sub(*x, y);
+}
+
+static inline void  //
+wuffs_base__u16__sat_add_indirect(uint16_t* x, uint16_t y) {
+  *x = wuffs_base__u16__sat_add(*x, y);
+}
+
+static inline void  //
+wuffs_base__u16__sat_sub_indirect(uint16_t* x, uint16_t y) {
+  *x = wuffs_base__u16__sat_sub(*x, y);
+}
+
+static inline void  //
+wuffs_base__u32__sat_add_indirect(uint32_t* x, uint32_t y) {
+  *x = wuffs_base__u32__sat_add(*x, y);
+}
+
+static inline void  //
+wuffs_base__u32__sat_sub_indirect(uint32_t* x, uint32_t y) {
+  *x = wuffs_base__u32__sat_sub(*x, y);
+}
+
+static inline void  //
+wuffs_base__u64__sat_add_indirect(uint64_t* x, uint64_t y) {
+  *x = wuffs_base__u64__sat_add(*x, y);
+}
+
+static inline void  //
+wuffs_base__u64__sat_sub_indirect(uint64_t* x, uint64_t y) {
+  *x = wuffs_base__u64__sat_sub(*x, y);
+}
+
+// ---------------- Numeric Types (Utility)
+
+#define wuffs_base__utility__sign_extend_convert_u16_u32(a) \
+  ((uint32_t)(int32_t)(int16_t)(a))
+
+#define wuffs_base__utility__sign_extend_rshift_u32(a, n) \
+  ((uint32_t)(((int32_t)(a)) >> (n)))
+
+#define wuffs_base__utility__sign_extend_rshift_u64(a, n) \
+  ((uint64_t)(((int64_t)(a)) >> (n)))
+
+// ---------------- Slices and Tables
+
+// wuffs_base__slice_u8__prefix returns up to the first up_to bytes of s.
+static inline wuffs_base__slice_u8  //
+wuffs_base__slice_u8__prefix(wuffs_base__slice_u8 s, uint64_t up_to) {
+  if (((uint64_t)(s.len)) > up_to) {
+    s.len = ((size_t)up_to);
+  }
+  return s;
+}
+
+// wuffs_base__slice_u8__suffix returns up to the last up_to bytes of s.
+static inline wuffs_base__slice_u8  //
+wuffs_base__slice_u8__suffix(wuffs_base__slice_u8 s, uint64_t up_to) {
+  if (((uint64_t)(s.len)) > up_to) {
+    s.ptr += ((uint64_t)(s.len)) - up_to;
+    s.len = ((size_t)up_to);
+  }
+  return s;
+}
+
+// wuffs_base__slice_u8__copy_from_slice calls memmove(dst.ptr, src.ptr, len)
+// where len is the minimum of dst.len and src.len.
+//
+// Passing a wuffs_base__slice_u8 with all fields NULL or zero (a valid, empty
+// slice) is valid and results in a no-op.
+static inline uint64_t  //
+wuffs_base__slice_u8__copy_from_slice(wuffs_base__slice_u8 dst,
+                                      wuffs_base__slice_u8 src) {
+  size_t len = dst.len < src.len ? dst.len : src.len;
+  if (len > 0) {
+    memmove(dst.ptr, src.ptr, len);
+  }
+  return len;
+}
+
+static inline wuffs_base__empty_struct  //
+wuffs_base__bulk_load_host_endian(void* ptr,
+                                  size_t len,
+                                  wuffs_base__slice_u8 src) {
+  if (len && (len <= src.len)) {
+    memmove(ptr, src.ptr, len);
+  }
+  return wuffs_base__make_empty_struct();
+}
+
+static inline wuffs_base__empty_struct  //
+wuffs_base__bulk_memset(void* ptr, size_t len, uint8_t byte_value) {
+  if (len) {
+    memset(ptr, byte_value, len);
+  }
+  return wuffs_base__make_empty_struct();
+}
+
+static inline wuffs_base__empty_struct  //
+wuffs_base__bulk_save_host_endian(void* ptr,
+                                  size_t len,
+                                  wuffs_base__slice_u8 dst) {
+  if (len && (len <= dst.len)) {
+    memmove(dst.ptr, ptr, len);
+  }
+  return wuffs_base__make_empty_struct();
+}
+
+// --------
+
+static inline wuffs_base__slice_u8  //
+wuffs_base__table_u8__row_u32(wuffs_base__table_u8 t, uint32_t y) {
+  if (y < t.height) {
+    return wuffs_base__make_slice_u8(t.ptr + (t.stride * y), t.width);
+  }
+  return wuffs_base__make_slice_u8(NULL, 0);
+}
+
+// ---------------- Slices and Tables (Utility)
+
+#define wuffs_base__utility__empty_slice_u8 wuffs_base__empty_slice_u8
+
+// ---------------- Ranges and Rects
+
+static inline uint32_t  //
+wuffs_base__range_ii_u32__get_min_incl(const wuffs_base__range_ii_u32* r) {
+  return r->min_incl;
+}
+
+static inline uint32_t  //
+wuffs_base__range_ii_u32__get_max_incl(const wuffs_base__range_ii_u32* r) {
+  return r->max_incl;
+}
+
+static inline uint32_t  //
+wuffs_base__range_ie_u32__get_min_incl(const wuffs_base__range_ie_u32* r) {
+  return r->min_incl;
+}
+
+static inline uint32_t  //
+wuffs_base__range_ie_u32__get_max_excl(const wuffs_base__range_ie_u32* r) {
+  return r->max_excl;
+}
+
+static inline uint64_t  //
+wuffs_base__range_ii_u64__get_min_incl(const wuffs_base__range_ii_u64* r) {
+  return r->min_incl;
+}
+
+static inline uint64_t  //
+wuffs_base__range_ii_u64__get_max_incl(const wuffs_base__range_ii_u64* r) {
+  return r->max_incl;
+}
+
+static inline uint64_t  //
+wuffs_base__range_ie_u64__get_min_incl(const wuffs_base__range_ie_u64* r) {
+  return r->min_incl;
+}
+
+static inline uint64_t  //
+wuffs_base__range_ie_u64__get_max_excl(const wuffs_base__range_ie_u64* r) {
+  return r->max_excl;
+}
+
+// ---------------- Ranges and Rects (Utility)
+
+#define wuffs_base__utility__empty_range_ii_u32 wuffs_base__empty_range_ii_u32
+#define wuffs_base__utility__empty_range_ie_u32 wuffs_base__empty_range_ie_u32
+#define wuffs_base__utility__empty_range_ii_u64 wuffs_base__empty_range_ii_u64
+#define wuffs_base__utility__empty_range_ie_u64 wuffs_base__empty_range_ie_u64
+#define wuffs_base__utility__empty_rect_ii_u32 wuffs_base__empty_rect_ii_u32
+#define wuffs_base__utility__empty_rect_ie_u32 wuffs_base__empty_rect_ie_u32
+#define wuffs_base__utility__make_range_ii_u32 wuffs_base__make_range_ii_u32
+#define wuffs_base__utility__make_range_ie_u32 wuffs_base__make_range_ie_u32
+#define wuffs_base__utility__make_range_ii_u64 wuffs_base__make_range_ii_u64
+#define wuffs_base__utility__make_range_ie_u64 wuffs_base__make_range_ie_u64
+#define wuffs_base__utility__make_rect_ii_u32 wuffs_base__make_rect_ii_u32
+#define wuffs_base__utility__make_rect_ie_u32 wuffs_base__make_rect_ie_u32
+
+// ---------------- I/O
+
+static inline uint64_t  //
+wuffs_base__io__count_since(uint64_t mark, uint64_t index) {
+  if (index >= mark) {
+    return index - mark;
+  }
+  return 0;
+}
+
+// TODO: drop the "const" in "const uint8_t* ptr". Some though required about
+// the base.io_reader.since method returning a mutable "slice base.u8".
+#if defined(__GNUC__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
+static inline wuffs_base__slice_u8  //
+wuffs_base__io__since(uint64_t mark, uint64_t index, const uint8_t* ptr) {
+  if (index >= mark) {
+    return wuffs_base__make_slice_u8(((uint8_t*)ptr) + mark,
+                                     ((size_t)(index - mark)));
+  }
+  return wuffs_base__make_slice_u8(NULL, 0);
+}
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
+
+// --------
+
+static inline void  //
+wuffs_base__io_reader__limit(const uint8_t** ptr_io2_r,
+                             const uint8_t* iop_r,
+                             uint64_t limit) {
+  if (((uint64_t)(*ptr_io2_r - iop_r)) > limit) {
+    *ptr_io2_r = iop_r + limit;
+  }
+}
+
+static inline uint32_t  //
+wuffs_base__io_reader__limited_copy_u32_to_slice(const uint8_t** ptr_iop_r,
+                                                 const uint8_t* io2_r,
+                                                 uint32_t length,
+                                                 wuffs_base__slice_u8 dst) {
+  const uint8_t* iop_r = *ptr_iop_r;
+  size_t n = dst.len;
+  if (n > length) {
+    n = length;
+  }
+  if (n > ((size_t)(io2_r - iop_r))) {
+    n = (size_t)(io2_r - iop_r);
+  }
+  if (n > 0) {
+    memmove(dst.ptr, iop_r, n);
+    *ptr_iop_r += n;
+  }
+  return (uint32_t)(n);
+}
+
+// wuffs_base__io_reader__match7 returns whether the io_reader's upcoming bytes
+// start with the given prefix (up to 7 bytes long). It is peek-like, not
+// read-like, in that there are no side-effects.
+//
+// The low 3 bits of a hold the prefix length, n.
+//
+// The high 56 bits of a hold the prefix itself, in little-endian order. The
+// first prefix byte is in bits 8..=15, the second prefix byte is in bits
+// 16..=23, etc. The high (8 * (7 - n)) bits are ignored.
+//
+// There are three possible return values:
+//  - 0 means success.
+//  - 1 means inconclusive, equivalent to "$short read".
+//  - 2 means failure.
+static inline uint32_t  //
+wuffs_base__io_reader__match7(const uint8_t* iop_r,
+                              const uint8_t* io2_r,
+                              wuffs_base__io_buffer* r,
+                              uint64_t a) {
+  uint32_t n = a & 7;
+  a >>= 8;
+  if ((io2_r - iop_r) >= 8) {
+    uint64_t x = wuffs_base__peek_u64le__no_bounds_check(iop_r);
+    uint32_t shift = 8 * (8 - n);
+    return ((a << shift) == (x << shift)) ? 0 : 2;
+  }
+  for (; n > 0; n--) {
+    if (iop_r >= io2_r) {
+      return (r && r->meta.closed) ? 2 : 1;
+    } else if (*iop_r != ((uint8_t)(a))) {
+      return 2;
+    }
+    iop_r++;
+    a >>= 8;
+  }
+  return 0;
+}
+
+static inline wuffs_base__io_buffer*  //
+wuffs_base__io_reader__set(wuffs_base__io_buffer* b,
+                           const uint8_t** ptr_iop_r,
+                           const uint8_t** ptr_io0_r,
+                           const uint8_t** ptr_io1_r,
+                           const uint8_t** ptr_io2_r,
+                           wuffs_base__slice_u8 data,
+                           uint64_t history_position) {
+  b->data = data;
+  b->meta.wi = data.len;
+  b->meta.ri = 0;
+  b->meta.pos = history_position;
+  b->meta.closed = false;
+
+  *ptr_iop_r = data.ptr;
+  *ptr_io0_r = data.ptr;
+  *ptr_io1_r = data.ptr;
+  *ptr_io2_r = data.ptr + data.len;
+
+  return b;
+}
+
+// --------
+
+static inline uint64_t  //
+wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,
+                                       uint8_t* io2_w,
+                                       wuffs_base__slice_u8 src) {
+  uint8_t* iop_w = *ptr_iop_w;
+  size_t n = src.len;
+  if (n > ((size_t)(io2_w - iop_w))) {
+    n = (size_t)(io2_w - iop_w);
+  }
+  if (n > 0) {
+    memmove(iop_w, src.ptr, n);
+    *ptr_iop_w += n;
+  }
+  return (uint64_t)(n);
+}
+
+static inline void  //
+wuffs_base__io_writer__limit(uint8_t** ptr_io2_w,
+                             uint8_t* iop_w,
+                             uint64_t limit) {
+  if (((uint64_t)(*ptr_io2_w - iop_w)) > limit) {
+    *ptr_io2_w = iop_w + limit;
+  }
+}
+
+static inline uint32_t  //
+wuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,
+                                                     uint8_t* io0_w,
+                                                     uint8_t* io2_w,
+                                                     uint32_t length,
+                                                     uint32_t distance) {
+  if (!distance) {
+    return 0;
+  }
+  uint8_t* p = *ptr_iop_w;
+  if ((size_t)(p - io0_w) < (size_t)(distance)) {
+    return 0;
+  }
+  uint8_t* q = p - distance;
+  size_t n = (size_t)(io2_w - p);
+  if ((size_t)(length) > n) {
+    length = (uint32_t)(n);
+  } else {
+    n = (size_t)(length);
+  }
+  // TODO: unrolling by 3 seems best for the std/deflate benchmarks, but that
+  // is mostly because 3 is the minimum length for the deflate format. This
+  // function implementation shouldn't overfit to that one format. Perhaps the
+  // limited_copy_u32_from_history Wuffs method should also take an unroll hint
+  // argument, and the cgen can look if that argument is the constant
+  // expression '3'.
+  //
+  // See also wuffs_base__io_writer__limited_copy_u32_from_history_fast below.
+  for (; n >= 3; n -= 3) {
+    *p++ = *q++;
+    *p++ = *q++;
+    *p++ = *q++;
+  }
+  for (; n; n--) {
+    *p++ = *q++;
+  }
+  *ptr_iop_w = p;
+  return length;
+}
+
+// wuffs_base__io_writer__limited_copy_u32_from_history_fast is like the
+// wuffs_base__io_writer__limited_copy_u32_from_history function above, but has
+// stronger pre-conditions.
+//
+// The caller needs to prove that:
+//  - length   <= (io2_w      - *ptr_iop_w)
+//  - distance >= 1
+//  - distance <= (*ptr_iop_w - io0_w)
+static inline uint32_t  //
+wuffs_base__io_writer__limited_copy_u32_from_history_fast(uint8_t** ptr_iop_w,
+                                                          uint8_t* io0_w,
+                                                          uint8_t* io2_w,
+                                                          uint32_t length,
+                                                          uint32_t distance) {
+  uint8_t* p = *ptr_iop_w;
+  uint8_t* q = p - distance;
+  uint32_t n = length;
+  for (; n >= 3; n -= 3) {
+    *p++ = *q++;
+    *p++ = *q++;
+    *p++ = *q++;
+  }
+  for (; n; n--) {
+    *p++ = *q++;
+  }
+  *ptr_iop_w = p;
+  return length;
+}
+
+// wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_distance_1_fast
+// copies the previous byte (the one immediately before *ptr_iop_w), copying 8
+// byte chunks at a time. Each chunk contains 8 repetitions of the same byte.
+//
+// In terms of number of bytes copied, length is rounded up to a multiple of 8.
+// As a special case, a zero length rounds up to 8 (even though 0 is already a
+// multiple of 8), since there is always at least one 8 byte chunk copied.
+//
+// In terms of advancing *ptr_iop_w, length is not rounded up.
+//
+// The caller needs to prove that:
+//  - (length + 8) <= (io2_w      - *ptr_iop_w)
+//  - distance     == 1
+//  - distance     <= (*ptr_iop_w - io0_w)
+static inline uint32_t  //
+wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_distance_1_fast(
+    uint8_t** ptr_iop_w,
+    uint8_t* io0_w,
+    uint8_t* io2_w,
+    uint32_t length,
+    uint32_t distance) {
+  uint8_t* p = *ptr_iop_w;
+  uint64_t x = p[-1];
+  x |= x << 8;
+  x |= x << 16;
+  x |= x << 32;
+  uint32_t n = length;
+  while (1) {
+    wuffs_base__poke_u64le__no_bounds_check(p, x);
+    if (n <= 8) {
+      p += n;
+      break;
+    }
+    p += 8;
+    n -= 8;
+  }
+  *ptr_iop_w = p;
+  return length;
+}
+
+// wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_fast is
+// like the wuffs_base__io_writer__limited_copy_u32_from_history_fast function
+// above, but copies 8 byte chunks at a time.
+//
+// In terms of number of bytes copied, length is rounded up to a multiple of 8.
+// As a special case, a zero length rounds up to 8 (even though 0 is already a
+// multiple of 8), since there is always at least one 8 byte chunk copied.
+//
+// In terms of advancing *ptr_iop_w, length is not rounded up.
+//
+// The caller needs to prove that:
+//  - (length + 8) <= (io2_w      - *ptr_iop_w)
+//  - distance     >= 8
+//  - distance     <= (*ptr_iop_w - io0_w)
+static inline uint32_t  //
+wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_fast(
+    uint8_t** ptr_iop_w,
+    uint8_t* io0_w,
+    uint8_t* io2_w,
+    uint32_t length,
+    uint32_t distance) {
+  uint8_t* p = *ptr_iop_w;
+  uint8_t* q = p - distance;
+  uint32_t n = length;
+  while (1) {
+    memcpy(p, q, 8);
+    if (n <= 8) {
+      p += n;
+      break;
+    }
+    p += 8;
+    q += 8;
+    n -= 8;
+  }
+  *ptr_iop_w = p;
+  return length;
+}
+
+static inline uint32_t  //
+wuffs_base__io_writer__limited_copy_u32_from_reader(uint8_t** ptr_iop_w,
+                                                    uint8_t* io2_w,
+                                                    uint32_t length,
+                                                    const uint8_t** ptr_iop_r,
+                                                    const uint8_t* io2_r) {
+  uint8_t* iop_w = *ptr_iop_w;
+  size_t n = length;
+  if (n > ((size_t)(io2_w - iop_w))) {
+    n = (size_t)(io2_w - iop_w);
+  }
+  const uint8_t* iop_r = *ptr_iop_r;
+  if (n > ((size_t)(io2_r - iop_r))) {
+    n = (size_t)(io2_r - iop_r);
+  }
+  if (n > 0) {
+    memmove(iop_w, iop_r, n);
+    *ptr_iop_w += n;
+    *ptr_iop_r += n;
+  }
+  return (uint32_t)(n);
+}
+
+static inline uint32_t  //
+wuffs_base__io_writer__limited_copy_u32_from_slice(uint8_t** ptr_iop_w,
+                                                   uint8_t* io2_w,
+                                                   uint32_t length,
+                                                   wuffs_base__slice_u8 src) {
+  uint8_t* iop_w = *ptr_iop_w;
+  size_t n = src.len;
+  if (n > length) {
+    n = length;
+  }
+  if (n > ((size_t)(io2_w - iop_w))) {
+    n = (size_t)(io2_w - iop_w);
+  }
+  if (n > 0) {
+    memmove(iop_w, src.ptr, n);
+    *ptr_iop_w += n;
+  }
+  return (uint32_t)(n);
+}
+
+static inline wuffs_base__io_buffer*  //
+wuffs_base__io_writer__set(wuffs_base__io_buffer* b,
+                           uint8_t** ptr_iop_w,
+                           uint8_t** ptr_io0_w,
+                           uint8_t** ptr_io1_w,
+                           uint8_t** ptr_io2_w,
+                           wuffs_base__slice_u8 data,
+                           uint64_t history_position) {
+  b->data = data;
+  b->meta.wi = 0;
+  b->meta.ri = 0;
+  b->meta.pos = history_position;
+  b->meta.closed = false;
+
+  *ptr_iop_w = data.ptr;
+  *ptr_io0_w = data.ptr;
+  *ptr_io1_w = data.ptr;
+  *ptr_io2_w = data.ptr + data.len;
+
+  return b;
+}
+
+// ---------------- I/O (Utility)
+
+#define wuffs_base__utility__empty_io_reader wuffs_base__empty_io_reader
+#define wuffs_base__utility__empty_io_writer wuffs_base__empty_io_writer
+
+// ---------------- Tokens
+
+// ---------------- Tokens (Utility)
+
+// ---------------- Memory Allocation
+
+// ---------------- Images
+
+WUFFS_BASE__MAYBE_STATIC uint64_t  //
+wuffs_base__pixel_swizzler__limited_swizzle_u32_interleaved_from_reader(
+    const wuffs_base__pixel_swizzler* p,
+    uint32_t up_to_num_pixels,
+    wuffs_base__slice_u8 dst,
+    wuffs_base__slice_u8 dst_palette,
+    const uint8_t** ptr_iop_r,
+    const uint8_t* io2_r);
+
+WUFFS_BASE__MAYBE_STATIC uint64_t  //
+wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
+    const wuffs_base__pixel_swizzler* p,
+    wuffs_base__slice_u8 dst,
+    wuffs_base__slice_u8 dst_palette,
+    const uint8_t** ptr_iop_r,
+    const uint8_t* io2_r);
+
+WUFFS_BASE__MAYBE_STATIC uint64_t  //
+wuffs_base__pixel_swizzler__swizzle_interleaved_transparent_black(
+    const wuffs_base__pixel_swizzler* p,
+    wuffs_base__slice_u8 dst,
+    wuffs_base__slice_u8 dst_palette,
+    uint64_t num_pixels);
+
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status  //
+wuffs_base__pixel_swizzler__swizzle_ycck(
+    const wuffs_base__pixel_swizzler* p,
+    wuffs_base__pixel_buffer* dst,
+    wuffs_base__slice_u8 dst_palette,
+    uint32_t width,
+    uint32_t height,
+    wuffs_base__slice_u8 src0,
+    wuffs_base__slice_u8 src1,
+    wuffs_base__slice_u8 src2,
+    wuffs_base__slice_u8 src3,
+    uint32_t width0,
+    uint32_t width1,
+    uint32_t width2,
+    uint32_t width3,
+    uint32_t height0,
+    uint32_t height1,
+    uint32_t height2,
+    uint32_t height3,
+    uint32_t stride0,
+    uint32_t stride1,
+    uint32_t stride2,
+    uint32_t stride3,
+    uint8_t h0,
+    uint8_t h1,
+    uint8_t h2,
+    uint8_t h3,
+    uint8_t v0,
+    uint8_t v1,
+    uint8_t v2,
+    uint8_t v3,
+    bool is_rgb_or_cmyk,
+    bool triangle_filter_for_2to1,
+    wuffs_base__slice_u8 scratch_buffer_2k);
+
+// ---------------- Images (Utility)
+
+#define wuffs_base__utility__make_pixel_format wuffs_base__make_pixel_format
+
+// ---------------- String Conversions
+
+// ---------------- Unicode and UTF-8
+
+// ----------------
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BASE) || \
+    defined(WUFFS_CONFIG__MODULE__BASE__CORE)
+
+const uint8_t wuffs_base__low_bits_mask__u8[8] = {
+    0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F,
+};
+
+const uint16_t wuffs_base__low_bits_mask__u16[16] = {
+    0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F,
+    0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF,
+};
+
+const uint32_t wuffs_base__low_bits_mask__u32[32] = {
+    0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000F, 0x0000001F,
+    0x0000003F, 0x0000007F, 0x000000FF, 0x000001FF, 0x000003FF, 0x000007FF,
+    0x00000FFF, 0x00001FFF, 0x00003FFF, 0x00007FFF, 0x0000FFFF, 0x0001FFFF,
+    0x0003FFFF, 0x0007FFFF, 0x000FFFFF, 0x001FFFFF, 0x003FFFFF, 0x007FFFFF,
+    0x00FFFFFF, 0x01FFFFFF, 0x03FFFFFF, 0x07FFFFFF, 0x0FFFFFFF, 0x1FFFFFFF,
+    0x3FFFFFFF, 0x7FFFFFFF,
+};
+
+const uint64_t wuffs_base__low_bits_mask__u64[64] = {
+    0x0000000000000000, 0x0000000000000001, 0x0000000000000003,
+    0x0000000000000007, 0x000000000000000F, 0x000000000000001F,
+    0x000000000000003F, 0x000000000000007F, 0x00000000000000FF,
+    0x00000000000001FF, 0x00000000000003FF, 0x00000000000007FF,
+    0x0000000000000FFF, 0x0000000000001FFF, 0x0000000000003FFF,
+    0x0000000000007FFF, 0x000000000000FFFF, 0x000000000001FFFF,
+    0x000000000003FFFF, 0x000000000007FFFF, 0x00000000000FFFFF,
+    0x00000000001FFFFF, 0x00000000003FFFFF, 0x00000000007FFFFF,
+    0x0000000000FFFFFF, 0x0000000001FFFFFF, 0x0000000003FFFFFF,
+    0x0000000007FFFFFF, 0x000000000FFFFFFF, 0x000000001FFFFFFF,
+    0x000000003FFFFFFF, 0x000000007FFFFFFF, 0x00000000FFFFFFFF,
+    0x00000001FFFFFFFF, 0x00000003FFFFFFFF, 0x00000007FFFFFFFF,
+    0x0000000FFFFFFFFF, 0x0000001FFFFFFFFF, 0x0000003FFFFFFFFF,
+    0x0000007FFFFFFFFF, 0x000000FFFFFFFFFF, 0x000001FFFFFFFFFF,
+    0x000003FFFFFFFFFF, 0x000007FFFFFFFFFF, 0x00000FFFFFFFFFFF,
+    0x00001FFFFFFFFFFF, 0x00003FFFFFFFFFFF, 0x00007FFFFFFFFFFF,
+    0x0000FFFFFFFFFFFF, 0x0001FFFFFFFFFFFF, 0x0003FFFFFFFFFFFF,
+    0x0007FFFFFFFFFFFF, 0x000FFFFFFFFFFFFF, 0x001FFFFFFFFFFFFF,
+    0x003FFFFFFFFFFFFF, 0x007FFFFFFFFFFFFF, 0x00FFFFFFFFFFFFFF,
+    0x01FFFFFFFFFFFFFF, 0x03FFFFFFFFFFFFFF, 0x07FFFFFFFFFFFFFF,
+    0x0FFFFFFFFFFFFFFF, 0x1FFFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFFF,
+    0x7FFFFFFFFFFFFFFF,
+};
+
+const uint32_t wuffs_base__pixel_format__bits_per_channel[16] = {
+    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+    0x08, 0x0A, 0x0C, 0x10, 0x18, 0x20, 0x30, 0x40,
+};
+
+const char wuffs_base__note__i_o_redirect[] = "@base: I/O redirect";
+const char wuffs_base__note__end_of_data[] = "@base: end of data";
+const char wuffs_base__note__metadata_reported[] = "@base: metadata reported";
+const char wuffs_base__suspension__even_more_information[] = "$base: even more information";
+const char wuffs_base__suspension__mispositioned_read[] = "$base: mispositioned read";
+const char wuffs_base__suspension__mispositioned_write[] = "$base: mispositioned write";
+const char wuffs_base__suspension__short_read[] = "$base: short read";
+const char wuffs_base__suspension__short_write[] = "$base: short write";
+const char wuffs_base__error__bad_i_o_position[] = "#base: bad I/O position";
+const char wuffs_base__error__bad_argument_length_too_short[] = "#base: bad argument (length too short)";
+const char wuffs_base__error__bad_argument[] = "#base: bad argument";
+const char wuffs_base__error__bad_call_sequence[] = "#base: bad call sequence";
+const char wuffs_base__error__bad_data[] = "#base: bad data";
+const char wuffs_base__error__bad_receiver[] = "#base: bad receiver";
+const char wuffs_base__error__bad_restart[] = "#base: bad restart";
+const char wuffs_base__error__bad_sizeof_receiver[] = "#base: bad sizeof receiver";
+const char wuffs_base__error__bad_vtable[] = "#base: bad vtable";
+const char wuffs_base__error__bad_workbuf_length[] = "#base: bad workbuf length";
+const char wuffs_base__error__bad_wuffs_version[] = "#base: bad wuffs version";
+const char wuffs_base__error__cannot_return_a_suspension[] = "#base: cannot return a suspension";
+const char wuffs_base__error__disabled_by_previous_error[] = "#base: disabled by previous error";
+const char wuffs_base__error__initialize_falsely_claimed_already_zeroed[] = "#base: initialize falsely claimed already zeroed";
+const char wuffs_base__error__initialize_not_called[] = "#base: initialize not called";
+const char wuffs_base__error__interleaved_coroutine_calls[] = "#base: interleaved coroutine calls";
+const char wuffs_base__error__no_more_information[] = "#base: no more information";
+const char wuffs_base__error__not_enough_data[] = "#base: not enough data";
+const char wuffs_base__error__out_of_bounds[] = "#base: out of bounds";
+const char wuffs_base__error__unsupported_image_dimension[] = "#base: unsupported image dimension";
+const char wuffs_base__error__unsupported_method[] = "#base: unsupported method";
+const char wuffs_base__error__unsupported_option[] = "#base: unsupported option";
+const char wuffs_base__error__unsupported_pixel_swizzler_option[] = "#base: unsupported pixel swizzler option";
+const char wuffs_base__error__too_much_data[] = "#base: too much data";
+
+const char wuffs_base__hasher_u32__vtable_name[] = "{vtable}wuffs_base__hasher_u32";
+const char wuffs_base__hasher_u64__vtable_name[] = "{vtable}wuffs_base__hasher_u64";
+const char wuffs_base__image_decoder__vtable_name[] = "{vtable}wuffs_base__image_decoder";
+const char wuffs_base__io_transformer__vtable_name[] = "{vtable}wuffs_base__io_transformer";
+const char wuffs_base__token_decoder__vtable_name[] = "{vtable}wuffs_base__token_decoder";
+
+#endif  // !defined(WUFFS_CONFIG__MODULES) ||
+        // defined(WUFFS_CONFIG__MODULE__BASE)  ||
+        // defined(WUFFS_CONFIG__MODULE__BASE__CORE)
+
+#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BASE) || \
+    defined(WUFFS_CONFIG__MODULE__BASE__INTERFACES)
+
+// ---------------- Interface Definitions.
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_base__hasher_u32__checksum_u32(
+    const wuffs_base__hasher_u32* self) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__hasher_u32__vtable_name) {
+      const wuffs_base__hasher_u32__func_ptrs* func_ptrs =
+          (const wuffs_base__hasher_u32__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->checksum_u32)(self);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__hasher_u32__get_quirk(
+    const wuffs_base__hasher_u32* self,
+    uint32_t a_key) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__hasher_u32__vtable_name) {
+      const wuffs_base__hasher_u32__func_ptrs* func_ptrs =
+          (const wuffs_base__hasher_u32__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->get_quirk)(self, a_key);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__hasher_u32__set_quirk(
+    wuffs_base__hasher_u32* self,
+    uint32_t a_key,
+    uint64_t a_value) {
+  if (!self) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_status(
+        (self->private_impl.magic == WUFFS_BASE__DISABLED)
+            ? wuffs_base__error__disabled_by_previous_error
+            : wuffs_base__error__initialize_not_called);
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__hasher_u32__vtable_name) {
+      const wuffs_base__hasher_u32__func_ptrs* func_ptrs =
+          (const wuffs_base__hasher_u32__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->set_quirk)(self, a_key, a_value);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_status(wuffs_base__error__bad_vtable);
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_base__hasher_u32__update(
+    wuffs_base__hasher_u32* self,
+    wuffs_base__slice_u8 a_x) {
+  if (!self) {
+    return wuffs_base__make_empty_struct();
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_empty_struct();
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__hasher_u32__vtable_name) {
+      const wuffs_base__hasher_u32__func_ptrs* func_ptrs =
+          (const wuffs_base__hasher_u32__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->update)(self, a_x);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_empty_struct();
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_base__hasher_u32__update_u32(
+    wuffs_base__hasher_u32* self,
+    wuffs_base__slice_u8 a_x) {
+  if (!self) {
+    return 0;
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__hasher_u32__vtable_name) {
+      const wuffs_base__hasher_u32__func_ptrs* func_ptrs =
+          (const wuffs_base__hasher_u32__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->update_u32)(self, a_x);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+// --------
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__hasher_u64__checksum_u64(
+    const wuffs_base__hasher_u64* self) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__hasher_u64__vtable_name) {
+      const wuffs_base__hasher_u64__func_ptrs* func_ptrs =
+          (const wuffs_base__hasher_u64__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->checksum_u64)(self);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__hasher_u64__get_quirk(
+    const wuffs_base__hasher_u64* self,
+    uint32_t a_key) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__hasher_u64__vtable_name) {
+      const wuffs_base__hasher_u64__func_ptrs* func_ptrs =
+          (const wuffs_base__hasher_u64__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->get_quirk)(self, a_key);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__hasher_u64__set_quirk(
+    wuffs_base__hasher_u64* self,
+    uint32_t a_key,
+    uint64_t a_value) {
+  if (!self) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_status(
+        (self->private_impl.magic == WUFFS_BASE__DISABLED)
+            ? wuffs_base__error__disabled_by_previous_error
+            : wuffs_base__error__initialize_not_called);
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__hasher_u64__vtable_name) {
+      const wuffs_base__hasher_u64__func_ptrs* func_ptrs =
+          (const wuffs_base__hasher_u64__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->set_quirk)(self, a_key, a_value);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_status(wuffs_base__error__bad_vtable);
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_base__hasher_u64__update(
+    wuffs_base__hasher_u64* self,
+    wuffs_base__slice_u8 a_x) {
+  if (!self) {
+    return wuffs_base__make_empty_struct();
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_empty_struct();
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__hasher_u64__vtable_name) {
+      const wuffs_base__hasher_u64__func_ptrs* func_ptrs =
+          (const wuffs_base__hasher_u64__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->update)(self, a_x);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_empty_struct();
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__hasher_u64__update_u64(
+    wuffs_base__hasher_u64* self,
+    wuffs_base__slice_u8 a_x) {
+  if (!self) {
+    return 0;
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__hasher_u64__vtable_name) {
+      const wuffs_base__hasher_u64__func_ptrs* func_ptrs =
+          (const wuffs_base__hasher_u64__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->update_u64)(self, a_x);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+// --------
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__decode_frame(
+    wuffs_base__image_decoder* self,
+    wuffs_base__pixel_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__pixel_blend a_blend,
+    wuffs_base__slice_u8 a_workbuf,
+    wuffs_base__decode_frame_options* a_opts) {
+  if (!self) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_status(
+        (self->private_impl.magic == WUFFS_BASE__DISABLED)
+            ? wuffs_base__error__disabled_by_previous_error
+            : wuffs_base__error__initialize_not_called);
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->decode_frame)(self, a_dst, a_src, a_blend, a_workbuf, a_opts);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_status(wuffs_base__error__bad_vtable);
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__decode_frame_config(
+    wuffs_base__image_decoder* self,
+    wuffs_base__frame_config* a_dst,
+    wuffs_base__io_buffer* a_src) {
+  if (!self) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_status(
+        (self->private_impl.magic == WUFFS_BASE__DISABLED)
+            ? wuffs_base__error__disabled_by_previous_error
+            : wuffs_base__error__initialize_not_called);
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->decode_frame_config)(self, a_dst, a_src);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_status(wuffs_base__error__bad_vtable);
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__decode_image_config(
+    wuffs_base__image_decoder* self,
+    wuffs_base__image_config* a_dst,
+    wuffs_base__io_buffer* a_src) {
+  if (!self) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_status(
+        (self->private_impl.magic == WUFFS_BASE__DISABLED)
+            ? wuffs_base__error__disabled_by_previous_error
+            : wuffs_base__error__initialize_not_called);
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->decode_image_config)(self, a_dst, a_src);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_status(wuffs_base__error__bad_vtable);
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
+wuffs_base__image_decoder__frame_dirty_rect(
+    const wuffs_base__image_decoder* self) {
+  if (!self) {
+    return wuffs_base__utility__empty_rect_ie_u32();
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return wuffs_base__utility__empty_rect_ie_u32();
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->frame_dirty_rect)(self);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__utility__empty_rect_ie_u32();
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__image_decoder__get_quirk(
+    const wuffs_base__image_decoder* self,
+    uint32_t a_key) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->get_quirk)(self, a_key);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__image_decoder__history_retain_length(
+    const wuffs_base__image_decoder* self) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->history_retain_length)(self);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint32_t
+wuffs_base__image_decoder__num_animation_loops(
+    const wuffs_base__image_decoder* self) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->num_animation_loops)(self);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__image_decoder__num_decoded_frame_configs(
+    const wuffs_base__image_decoder* self) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->num_decoded_frame_configs)(self);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__image_decoder__num_decoded_frames(
+    const wuffs_base__image_decoder* self) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->num_decoded_frames)(self);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__restart_frame(
+    wuffs_base__image_decoder* self,
+    uint64_t a_index,
+    uint64_t a_io_position) {
+  if (!self) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_status(
+        (self->private_impl.magic == WUFFS_BASE__DISABLED)
+            ? wuffs_base__error__disabled_by_previous_error
+            : wuffs_base__error__initialize_not_called);
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->restart_frame)(self, a_index, a_io_position);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_status(wuffs_base__error__bad_vtable);
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__set_quirk(
+    wuffs_base__image_decoder* self,
+    uint32_t a_key,
+    uint64_t a_value) {
+  if (!self) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_status(
+        (self->private_impl.magic == WUFFS_BASE__DISABLED)
+            ? wuffs_base__error__disabled_by_previous_error
+            : wuffs_base__error__initialize_not_called);
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->set_quirk)(self, a_key, a_value);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_status(wuffs_base__error__bad_vtable);
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
+wuffs_base__image_decoder__set_report_metadata(
+    wuffs_base__image_decoder* self,
+    uint32_t a_fourcc,
+    bool a_report) {
+  if (!self) {
+    return wuffs_base__make_empty_struct();
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_empty_struct();
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->set_report_metadata)(self, a_fourcc, a_report);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_empty_struct();
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__image_decoder__tell_me_more(
+    wuffs_base__image_decoder* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__more_information* a_minfo,
+    wuffs_base__io_buffer* a_src) {
+  if (!self) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_status(
+        (self->private_impl.magic == WUFFS_BASE__DISABLED)
+            ? wuffs_base__error__disabled_by_previous_error
+            : wuffs_base__error__initialize_not_called);
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->tell_me_more)(self, a_dst, a_minfo, a_src);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_status(wuffs_base__error__bad_vtable);
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_base__image_decoder__workbuf_len(
+    const wuffs_base__image_decoder* self) {
+  if (!self) {
+    return wuffs_base__utility__empty_range_ii_u64();
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return wuffs_base__utility__empty_range_ii_u64();
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__image_decoder__vtable_name) {
+      const wuffs_base__image_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__image_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->workbuf_len)(self);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__utility__empty_range_ii_u64();
+}
+
+// --------
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__io_transformer__get_quirk(
+    const wuffs_base__io_transformer* self,
+    uint32_t a_key) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__io_transformer__vtable_name) {
+      const wuffs_base__io_transformer__func_ptrs* func_ptrs =
+          (const wuffs_base__io_transformer__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->get_quirk)(self, a_key);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__io_transformer__history_retain_length(
+    const wuffs_base__io_transformer* self) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__io_transformer__vtable_name) {
+      const wuffs_base__io_transformer__func_ptrs* func_ptrs =
+          (const wuffs_base__io_transformer__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->history_retain_length)(self);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__io_transformer__set_quirk(
+    wuffs_base__io_transformer* self,
+    uint32_t a_key,
+    uint64_t a_value) {
+  if (!self) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_status(
+        (self->private_impl.magic == WUFFS_BASE__DISABLED)
+            ? wuffs_base__error__disabled_by_previous_error
+            : wuffs_base__error__initialize_not_called);
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__io_transformer__vtable_name) {
+      const wuffs_base__io_transformer__func_ptrs* func_ptrs =
+          (const wuffs_base__io_transformer__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->set_quirk)(self, a_key, a_value);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_status(wuffs_base__error__bad_vtable);
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__io_transformer__transform_io(
+    wuffs_base__io_transformer* self,
+    wuffs_base__io_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf) {
+  if (!self) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_status(
+        (self->private_impl.magic == WUFFS_BASE__DISABLED)
+            ? wuffs_base__error__disabled_by_previous_error
+            : wuffs_base__error__initialize_not_called);
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__io_transformer__vtable_name) {
+      const wuffs_base__io_transformer__func_ptrs* func_ptrs =
+          (const wuffs_base__io_transformer__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->transform_io)(self, a_dst, a_src, a_workbuf);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_status(wuffs_base__error__bad_vtable);
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
+wuffs_base__io_transformer__workbuf_len(
+    const wuffs_base__io_transformer* self) {
+  if (!self) {
+    return wuffs_base__utility__empty_range_ii_u64();
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return wuffs_base__utility__empty_range_ii_u64();
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__io_transformer__vtable_name) {
+      const wuffs_base__io_transformer__func_ptrs* func_ptrs =
+          (const wuffs_base__io_transformer__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->workbuf_len)(self);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__utility__empty_range_ii_u64();
+}
+
+// --------
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__token_decoder__decode_tokens(
+    wuffs_base__token_decoder* self,
+    wuffs_base__token_buffer* a_dst,
+    wuffs_base__io_buffer* a_src,
+    wuffs_base__slice_u8 a_workbuf) {
+  if (!self) {
+    return wuffs_base__make_status(wuffs_base__error__bad_receiver);
+  }
+  if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
+    return wuffs_base__make_status(
+        (self->private_impl.magic == WUFFS_BASE__DISABLED)
+            ? wuffs_base__error__disabled_by_previous_error
+            : wuffs_base__error__initialize_not_called);
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__token_decoder__vtable_name) {
+      const wuffs_base__token_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__token_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->decode_tokens)(self, a_dst, a_src, a_workbuf);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return wuffs_base__make_status(wuffs_base__error__bad_vtable);
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__token_decoder__get_quirk(
+    const wuffs_base__token_decoder* self,
+    uint32_t a_key) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__token_decoder__vtable_name) {
+      const wuffs_base__token_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__token_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->get_quirk)(self, a_key);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC uint64_t
+wuffs_base__token_decoder__history_retain_length(
+    const wuffs_base__token_decoder* self) {
+  if (!self) {
+    return 0;
+  }
+  if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
+      (self->private_impl.magic != WUFFS_BASE__DISABLED)) {
+    return 0;
+  }
+
+  const wuffs_base__vtable* v = &self->private_impl.first_vtable;
+  int i;
+  for (i = 0; i < 63; i++) {
+    if (v->vtable_name == wuffs_base__token_decoder__vtable_name) {
+      const wuffs_base__token_decoder__func_ptrs* func_ptrs =
+          (const wuffs_base__token_decoder__func_ptrs*)(v->function_pointers);
+      return (*func_ptrs->history_retain_length)(self);
+    } else if (v->vtable_name == NULL) {
+      break;
+    }
+    v++;
+  }
+
+  return 0;
+}
+
+WUFFS_BASE__GENERATED_C_CODE
+WUFFS_BASE__MAYBE_STATIC wuffs_base__status
+wuffs_base__token_decoder__set_quirk(
+    wuffs_base__token_decoder* self,
+    uint32_t a_key,
+    uint64_t a_value) {