mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Have gifplayer compose onto an ARGB buffer
This commit is contained in:
1 parent
27e0139500
commit
c1dbfdb4aa
17 files changed
+272
-174
No files matched your search
@@ -669,6 +669,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -712,11 +719,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
@@ -59,15 +59,17 @@ const baseHeader = "" +
|
||||
"// ---------------- I/O\n\n// wuffs_base__io_buffer is a 1-dimensional buffer (a pointer and length), plus\n// additional indexes into that buffer, plus an opened / closed flag.\n//\n// A value with all fields NULL or zero is a valid, empty buffer.\ntypedef struct {\n uint8_t* ptr; // Pointer.\n size_t len; // Length.\n size_t wi; // Write index. Invariant: wi <= len.\n size_t ri; // Read index. Invariant: ri <= wi.\n bool closed; // No further writes are expected.\n} wuffs_base__io_buffer;\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__io_buffer* buf;\n // The bounds values are typically NULL, when created by the Wuffs public\n // API. NULL means that the callee substitutes the implicit bounds derived\n // from buf.\n uint8_t* bounds[2];\n } private_impl;\n} wuffs_base__io_reader;\n\ntypedef struct {\n // Do not access the private_impl's fields directly. There is no API/A" +
|
||||
"BI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__io_buffer* buf;\n // The bounds values are typically NULL, when created by the Wuffs public\n // API. NULL means that the callee substitutes the implicit bounds derived\n // from buf.\n uint8_t* bounds[2];\n } private_impl;\n} wuffs_base__io_writer;\n\nstatic inline wuffs_base__io_reader wuffs_base__io_buffer__reader(\n wuffs_base__io_buffer* buf) {\n wuffs_base__io_reader ret = ((wuffs_base__io_reader){});\n ret.private_impl.buf = buf;\n return ret;\n}\n\nstatic inline wuffs_base__io_writer wuffs_base__io_buffer__writer(\n wuffs_base__io_buffer* buf) {\n wuffs_base__io_writer ret = ((wuffs_base__io_writer){});\n ret.private_impl.buf = buf;\n return ret;\n}\n\n" +
|
||||
"" +
|
||||
"// ---------------- Images\n\n// wuffs_base__pixel_format encodes the format of the bytes that constitute an\n// image frame's pixel data. Its bits:\n// - bit 31 is reserved.\n// - bits 30 .. 28 encodes color (and channel order, in terms of memory).\n// - bits 27 .. 26 are reserved.\n// - bits 25 .. 24 encodes transparency.\n// - bit 23 indicates big-endian/MSB-first (as opposed to little/LSB).\n// - bit 22 indicates floating point (as opposed to integer).\n// - bits 21 .. 20 are the number of planes, minus 1. Zero means packed.\n// - bits 19 .. 16 encodes the number of bits (depth) in an index value.\n// Zero means direct, not palette-indexed.\n// - bits 15 .. 12 encodes the number of bits (depth) in the 3rd channel.\n// - bits 11 .. 8 encodes the number of bits (depth) in the 2nd channel.\n// - bits 7 .. 4 encodes the number of bits (depth) in the 1st channel.\n// - bits 3 .. 0 encodes the number of bits (depth) in the 0th channel.\n//\n// The bit fields of a wuffs_base" +
|
||||
"__pixel_format are not independent. For\n// example, the number of planes should not be greater than the number of\n// channels. Similarly, bits 15..4 are unused (and should be zero) if bits\n// 31..24 (color and transparency) together imply only 1 channel (gray, no\n// alpha) and floating point samples should mean a bit depth of 16, 32 or 64.\n//\n// Formats hold between 1 and 4 channels. For example: Y (1 channel: gray), YA\n// (2 channels: gray and alpha), BGR (3 channels: blue, green, red) or CMYK (4\n// channels: cyan, magenta, yellow, black).\n//\n// For direct formats with N > 1 channels, those channels can be laid out in\n// either 1 (packed) or N (planar) planes. For example, RGBA data is usually\n// packed, but YUV data is usually planar, due to chroma subsampling (for\n// details, see the wuffs_base__pixel_subsampling type). For indexed formats,\n// the palette (always 256 × 4 bytes) holds up to 4 packed bytes of color data\n// per index value, and there is only 1 plane (for the index). The distance\n// between s" +
|
||||
"uccessive palette elements is always 4 bytes.\n//\n// The color field is encoded in 3 bits:\n// - 0 means A (Alpha).\n// - 1 means Y or YA (Gray, Alpha).\n// - 2 means BGR, BGRX or BGRA (Blue, Green, Red, X-padding or Alpha).\n// - 3 means RGB, RGBX or RGBA (Red, Green, Blue, X-padding or Alpha).\n// - 4 means YUV or YUVA (Luma, Chroma-blue, Chroma-red, Alpha).\n// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).\n// - all other values are reserved.\n//\n// In Wuffs, channels are given in memory order, regardless of endianness,\n// since the C type for the pixel data is an array of bytes, not an array of\n// uint32_t. For example, packed BGRA with 8 bits per channel means that the\n// bytes in memory are always Blue, Green, Red then Alpha. On big-endian\n// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.\n//\n// When the color field (3 bits) encodes multiple options, the transparency\n// field (2 bits) distinguishes them:\n// - 0 means fully opaque, no e" +
|
||||
"xtra channels\n// - 1 means fully opaque, one extra channel (X or K, padding or black).\n// - 2 means one extra alpha channel, other channels are non-premultiplied.\n// - 3 means one extra alpha channel, other channels are premultiplied.\n//\n// The zero wuffs_base__pixel_format value is an invalid pixel format, as it is\n// invalid to combine the zero color (alpha only) with the zero transparency.\n//\n// Bit depth is encoded in 4 bits:\n// - 0 means the channel or index is unused.\n// - x means a bit depth of x, for x in the range 1..8.\n// - 9 means a bit depth of 10.\n// - 10 means a bit depth of 12.\n// - 11 means a bit depth of 16.\n// - 12 means a bit depth of 24.\n// - 13 means a bit depth of 32.\n// - 14 means a bit depth of 48.\n// - 15 means a bit depth of 64.\n//\n// For example, wuffs_base__pixel_format 0x3280BBBB is a natural format for\n// decoding a PNG image - network byte order (also known as big-endian),\n// packed, non-premultiplied alpha - that happens to be 16-bit-depth truecolor\n// with " +
|
||||
"alpha (RGBA). In memory order:\n//\n// ptr+0 ptr+1 ptr+2 ptr+3 ptr+4 ptr+5 ptr+6 ptr+7\n// Rhi Rlo Ghi Glo Bhi Blo Ahi Alo\n//\n// For example, the value wuffs_base__pixel_format 0x20000565 means BGR with no\n// alpha or padding, 5/6/5 bits for blue/green/red, packed 2 bytes per pixel,\n// laid out LSB-first in memory order:\n//\n// ptr+0........... ptr+1...........\n// MSB LSB MSB LSB\n// G₂G₁G₀B₄B₃B₂B₁B₀ R₄R₃R₂R₁R₀G₅G₄G₃\n//\n// On little-endian systems (but not big-endian), this Wuffs pixel format value\n// (0x20000565) corresponds to the Cairo library's CAIRO_FORMAT_RGB16_565, the\n// SDL2 (Simple DirectMedia Layer 2) library's SDL_PIXELFORMAT_RGB565 and the\n// Skia library's kRGB_565_SkColorType. Note BGR in Wuffs versus RGB in the\n// other libraries.\n//\n// Regardless of endianness, this Wuffs pixel format value (0x20000565)\n// corresponds to the V4L2 (Video For Linux 2) library's V4L2_PIX_FMT_RGB565\n// and the Wayland-DRM library's W" +
|
||||
"L_DRM_FORMAT_RGB565.\n//\n// Different software libraries name their pixel formats (and especially their\n// channel order) either according to memory layout or as bits of a native\n// integer type like uint32_t. The two conventions differ because of a system's\n// endianness. As mentioned earlier, Wuffs pixel formats are always in memory\n// order. More detail of other software libraries' naming conventions is in the\n// Pixel Format Guide at https://afrantzis.github.io/pixel-format-guide/\n//\n// Do not manipulate these bits directly; they are private implementation\n// details. Use methods such as wuffs_base__pixel_format__num_planes instead.\ntypedef uint32_t wuffs_base__pixel_format;\n\n// Common 8-bit-depth pixel formats. This list is not exhaustive; not all valid\n// wuffs_base__pixel_format values are present.\n\n#define WUFFS_BASE__PIXEL_FORMAT__INVALID ((wuffs_base__pixel_format)0x00000000)\n\n#define WUFFS_BASE__PIXEL_FORMAT__A ((wuffs_base__pixel_format)0x02000008)\n\n#define WUFFS_BASE__PIXEL_FORMAT__Y ((wuffs_base_" +
|
||||
"_pixel_format)0x10000008)\n#define WUFFS_BASE__PIXEL_FORMAT__YA_NONPREMUL \\\n ((wuffs_base__pixel_format)0x12000008)\n#define WUFFS_BASE__PIXEL_FORMAT__YA_PREMUL \\\n ((wuffs_base__pixel_format)0x13000008)\n\n#define WUFFS_BASE__PIXEL_FORMAT__BGR ((wuffs_base__pixel_format)0x20000888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRX ((wuffs_base__pixel_format)0x21008888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRX_INDEXED \\\n ((wuffs_base__pixel_format)0x21088888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL \\\n ((wuffs_base__pixel_format)0x22008888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_INDEXED \\\n ((wuffs_base__pixel_format)0x22088888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL \\\n ((wuffs_base__pixel_format)0x23008888)\n\n#define WUFFS_BASE__PIXEL_FORMAT__RGB ((wuffs_base__pixel_format)0x30000888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBX ((wuffs_base__pixel_format)0x31008888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBX_INDEXED \\\n ((wuffs_base__pixel_format)0x31088888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL" +
|
||||
" \\\n ((wuffs_base__pixel_format)0x32008888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL_INDEXED \\\n ((wuffs_base__pixel_format)0x32088888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL \\\n ((wuffs_base__pixel_format)0x33008888)\n\n#define WUFFS_BASE__PIXEL_FORMAT__YUV ((wuffs_base__pixel_format)0x40200888)\n#define WUFFS_BASE__PIXEL_FORMAT__YUVK ((wuffs_base__pixel_format)0x41308888)\n#define WUFFS_BASE__PIXEL_FORMAT__YUVA_NONPREMUL \\\n ((wuffs_base__pixel_format)0x42308888)\n\n#define WUFFS_BASE__PIXEL_FORMAT__CMY ((wuffs_base__pixel_format)0x50200888)\n#define WUFFS_BASE__PIXEL_FORMAT__CMYK ((wuffs_base__pixel_format)0x51308888)\n\nstatic inline bool wuffs_base__pixel_format__is_valid(\n wuffs_base__pixel_format f) {\n return f != 0;\n}\n\nstatic inline bool wuffs_base__pixel_format__is_indexed(\n wuffs_base__pixel_format f) {\n return ((f >> 16) & 0x0F) != 0;\n}\n\n#define WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX 4\n\nstatic inline uint32_t wuffs_base__pixel_format__num_planes(\n wuffs_base__pixel_format f) {\n " +
|
||||
"return f ? (((f >> 20) & 0x03) + 1) : 0;\n}\n\ntypedef struct {\n wuffs_base__table_u8 planes[WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX];\n} wuffs_base__pixel_buffer;\n\n" +
|
||||
"// ---------------- Images\n\n// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue\n// color, as a uint32_t value. It is in word order, not byte order: its value\n// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.\ntypedef uint32_t wuffs_base__color_u32argb;\n\n" +
|
||||
"" +
|
||||
"// --------\n\n// wuffs_base__pixel_format encodes the format of the bytes that constitute an\n// image frame's pixel data. Its bits:\n// - bit 31 is reserved.\n// - bits 30 .. 28 encodes color (and channel order, in terms of memory).\n// - bits 27 .. 26 are reserved.\n// - bits 25 .. 24 encodes transparency.\n// - bit 23 indicates big-endian/MSB-first (as opposed to little/LSB).\n// - bit 22 indicates floating point (as opposed to integer).\n// - bits 21 .. 20 are the number of planes, minus 1. Zero means packed.\n// - bits 19 .. 16 encodes the number of bits (depth) in an index value.\n// Zero means direct, not palette-indexed.\n// - bits 15 .. 12 encodes the number of bits (depth) in the 3rd channel.\n// - bits 11 .. 8 encodes the number of bits (depth) in the 2nd channel.\n// - bits 7 .. 4 encodes the number of bits (depth) in the 1st channel.\n// - bits 3 .. 0 encodes the number of bits (depth) in the 0th channel.\n//\n// The bit fields of a wuffs_base__pixel_format " +
|
||||
"are not independent. For\n// example, the number of planes should not be greater than the number of\n// channels. Similarly, bits 15..4 are unused (and should be zero) if bits\n// 31..24 (color and transparency) together imply only 1 channel (gray, no\n// alpha) and floating point samples should mean a bit depth of 16, 32 or 64.\n//\n// Formats hold between 1 and 4 channels. For example: Y (1 channel: gray), YA\n// (2 channels: gray and alpha), BGR (3 channels: blue, green, red) or CMYK (4\n// channels: cyan, magenta, yellow, black).\n//\n// For direct formats with N > 1 channels, those channels can be laid out in\n// either 1 (packed) or N (planar) planes. For example, RGBA data is usually\n// packed, but YUV data is usually planar, due to chroma subsampling (for\n// details, see the wuffs_base__pixel_subsampling type). For indexed formats,\n// the palette (always 256 × 4 bytes) holds up to 4 packed bytes of color data\n// per index value, and there is only 1 plane (for the index). The distance\n// between successive palet" +
|
||||
"te elements is always 4 bytes.\n//\n// The color field is encoded in 3 bits:\n// - 0 means A (Alpha).\n// - 1 means Y or YA (Gray, Alpha).\n// - 2 means BGR, BGRX or BGRA (Blue, Green, Red, X-padding or Alpha).\n// - 3 means RGB, RGBX or RGBA (Red, Green, Blue, X-padding or Alpha).\n// - 4 means YUV or YUVA (Luma, Chroma-blue, Chroma-red, Alpha).\n// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).\n// - all other values are reserved.\n//\n// In Wuffs, channels are given in memory order (also known as byte order),\n// regardless of endianness, since the C type for the pixel data is an array of\n// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per\n// channel means that the bytes in memory are always Blue, Green, Red then\n// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On\n// little-endian, 0xAARRGGBB.\n//\n// When the color field (3 bits) encodes multiple options, the transparency\n// field (2 bits) distinguishes them:\n// - 0 means ful" +
|
||||
"ly opaque, no extra channels\n// - 1 means fully opaque, one extra channel (X or K, padding or black).\n// - 2 means one extra alpha channel, other channels are non-premultiplied.\n// - 3 means one extra alpha channel, other channels are premultiplied.\n//\n// The zero wuffs_base__pixel_format value is an invalid pixel format, as it is\n// invalid to combine the zero color (alpha only) with the zero transparency.\n//\n// Bit depth is encoded in 4 bits:\n// - 0 means the channel or index is unused.\n// - x means a bit depth of x, for x in the range 1..8.\n// - 9 means a bit depth of 10.\n// - 10 means a bit depth of 12.\n// - 11 means a bit depth of 16.\n// - 12 means a bit depth of 24.\n// - 13 means a bit depth of 32.\n// - 14 means a bit depth of 48.\n// - 15 means a bit depth of 64.\n//\n// For example, wuffs_base__pixel_format 0x3280BBBB is a natural format for\n// decoding a PNG image - network byte order (also known as big-endian),\n// packed, non-premultiplied alpha - that happens to be 16-bit-depth tru" +
|
||||
"ecolor\n// with alpha (RGBA). In memory order:\n//\n// ptr+0 ptr+1 ptr+2 ptr+3 ptr+4 ptr+5 ptr+6 ptr+7\n// Rhi Rlo Ghi Glo Bhi Blo Ahi Alo\n//\n// For example, the value wuffs_base__pixel_format 0x20000565 means BGR with no\n// alpha or padding, 5/6/5 bits for blue/green/red, packed 2 bytes per pixel,\n// laid out LSB-first in memory order:\n//\n// ptr+0........... ptr+1...........\n// MSB LSB MSB LSB\n// G₂G₁G₀B₄B₃B₂B₁B₀ R₄R₃R₂R₁R₀G₅G₄G₃\n//\n// On little-endian systems (but not big-endian), this Wuffs pixel format value\n// (0x20000565) corresponds to the Cairo library's CAIRO_FORMAT_RGB16_565, the\n// SDL2 (Simple DirectMedia Layer 2) library's SDL_PIXELFORMAT_RGB565 and the\n// Skia library's kRGB_565_SkColorType. Note BGR in Wuffs versus RGB in the\n// other libraries.\n//\n// Regardless of endianness, this Wuffs pixel format value (0x20000565)\n// corresponds to the V4L2 (Video For Linux 2) library's V4L2_PIX_FMT_RGB565\n// and the Wayland-" +
|
||||
"DRM library's WL_DRM_FORMAT_RGB565.\n//\n// Different software libraries name their pixel formats (and especially their\n// channel order) either according to memory layout or as bits of a native\n// integer type like uint32_t. The two conventions differ because of a system's\n// endianness. As mentioned earlier, Wuffs pixel formats are always in memory\n// order. More detail of other software libraries' naming conventions is in the\n// Pixel Format Guide at https://afrantzis.github.io/pixel-format-guide/\n//\n// Do not manipulate these bits directly; they are private implementation\n// details. Use methods such as wuffs_base__pixel_format__num_planes instead.\ntypedef uint32_t wuffs_base__pixel_format;\n\n// Common 8-bit-depth pixel formats. This list is not exhaustive; not all valid\n// wuffs_base__pixel_format values are present.\n\n#define WUFFS_BASE__PIXEL_FORMAT__INVALID ((wuffs_base__pixel_format)0x00000000)\n\n#define WUFFS_BASE__PIXEL_FORMAT__A ((wuffs_base__pixel_format)0x02000008)\n\n#define WUFFS_BASE__PIXEL_FORMAT__" +
|
||||
"Y ((wuffs_base__pixel_format)0x10000008)\n#define WUFFS_BASE__PIXEL_FORMAT__YA_NONPREMUL \\\n ((wuffs_base__pixel_format)0x12000008)\n#define WUFFS_BASE__PIXEL_FORMAT__YA_PREMUL \\\n ((wuffs_base__pixel_format)0x13000008)\n\n#define WUFFS_BASE__PIXEL_FORMAT__BGR ((wuffs_base__pixel_format)0x20000888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRX ((wuffs_base__pixel_format)0x21008888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRX_INDEXED \\\n ((wuffs_base__pixel_format)0x21088888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL \\\n ((wuffs_base__pixel_format)0x22008888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_INDEXED \\\n ((wuffs_base__pixel_format)0x22088888)\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL \\\n ((wuffs_base__pixel_format)0x23008888)\n\n#define WUFFS_BASE__PIXEL_FORMAT__RGB ((wuffs_base__pixel_format)0x30000888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBX ((wuffs_base__pixel_format)0x31008888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBX_INDEXED \\\n ((wuffs_base__pixel_format)0x31088888)\n#define WUFFS_BASE__PIXEL_FORMAT_" +
|
||||
"_RGBA_NONPREMUL \\\n ((wuffs_base__pixel_format)0x32008888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL_INDEXED \\\n ((wuffs_base__pixel_format)0x32088888)\n#define WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL \\\n ((wuffs_base__pixel_format)0x33008888)\n\n#define WUFFS_BASE__PIXEL_FORMAT__YUV ((wuffs_base__pixel_format)0x40200888)\n#define WUFFS_BASE__PIXEL_FORMAT__YUVK ((wuffs_base__pixel_format)0x41308888)\n#define WUFFS_BASE__PIXEL_FORMAT__YUVA_NONPREMUL \\\n ((wuffs_base__pixel_format)0x42308888)\n\n#define WUFFS_BASE__PIXEL_FORMAT__CMY ((wuffs_base__pixel_format)0x50200888)\n#define WUFFS_BASE__PIXEL_FORMAT__CMYK ((wuffs_base__pixel_format)0x51308888)\n\nstatic inline bool wuffs_base__pixel_format__is_valid(\n wuffs_base__pixel_format f) {\n return f != 0;\n}\n\nstatic inline bool wuffs_base__pixel_format__is_indexed(\n wuffs_base__pixel_format f) {\n return ((f >> 16) & 0x0F) != 0;\n}\n\n#define WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX 4\n\nstatic inline uint32_t wuffs_base__pixel_format__num_planes(\n wuffs_base__pixel" +
|
||||
"_format f) {\n return f ? (((f >> 20) & 0x03) + 1) : 0;\n}\n\ntypedef struct {\n wuffs_base__table_u8 planes[WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX];\n} wuffs_base__pixel_buffer;\n\n" +
|
||||
"" +
|
||||
"// --------\n\n// wuffs_base__pixel_subsampling encodes the mapping of pixel space coordinates\n// (x, y) to pixel buffer indices (i, j). That mapping can differ for each\n// plane p. For a depth of 8 bits (1 byte), the p'th plane's sample starts at\n// (planes[p].ptr + (j * planes[p].stride) + i).\n//\n// For packed pixel formats, the mapping is trivial: i = x and j = y. For\n// planar pixel formats, the mapping can differ due to chroma subsampling. For\n// example, consider a three plane YUV pixel format with 4:2:2 subsampling. For\n// the luma (Y) channel, there is one sample for every pixel, but for the\n// chroma (U, V) channels, there is one sample for every two pixels: pairs of\n// horizontally adjacent pixels form one macropixel, i = x / 2 and j == y. In\n// general, for a given p:\n// - i = (x + bias_x) >> shift_x.\n// - j = (y + bias_y) >> shift_y.\n// where biases and shifts are in the range 0..3 and 0..2 respectively.\n//\n// In general, the biases will be zero after decoding an image. However, making\n// a sub-im" +
|
||||
"age may change the bias, since the (x, y) coordinates are relative\n// to the sub-image's top-left origin, but the backing pixel buffers were\n// created relative to the original image's origin.\n//\n// For each plane p, each of those four numbers (biases and shifts) are encoded\n// in two bits, which combine to form an 8 bit unsigned integer:\n//\n// e_p = (bias_x << 6) | (shift_x << 4) | (bias_y << 2) | (shift_y << 0)\n//\n// Those e_p values (e_0 for the first plane, e_1 for the second plane, etc)\n// combine to form a wuffs_base__pixel_subsampling value:\n//\n// pixsub = (e_3 << 24) | (e_2 << 16) | (e_1 << 8) | (e_0 << 0)\n//\n// Do not manipulate these bits directly; they are private implementation\n// details. Use methods such as wuffs_base__pixel_subsampling__bias_x instead.\ntypedef uint32_t wuffs_base__pixel_subsampling;\n\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__NONE ((wuffs_base__pixel_subsampling)0)\n\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__444 \\\n ((wuffs_base__pixel_subsampling)0x000000)\n#define WUFFS_BASE__PIXEL_" +
|
||||
|
||||
@@ -70,8 +70,9 @@ uint64_t micros_since_start(struct timespec* now) {
|
||||
|
||||
uint8_t src_buffer[SRC_BUFFER_SIZE] = {0};
|
||||
size_t src_len = 0;
|
||||
uint8_t* dst_buffer = NULL;
|
||||
size_t dst_len = 0;
|
||||
wuffs_base__color_u32argb* dst_buffer = NULL;
|
||||
uint8_t* image_buffer = NULL;
|
||||
size_t image_len = 0;
|
||||
uint8_t* print_buffer = NULL;
|
||||
size_t print_len = 0;
|
||||
|
||||
@@ -102,73 +103,43 @@ const char* read_stdin() {
|
||||
|
||||
// ----
|
||||
|
||||
// BYTES_PER_COLOR_PIXEL is long enough to contain "?\x1B[38;2;255;255;255mABC"
|
||||
// plus a few bytes of slack. The first byte is the overall length - a Pascal
|
||||
// style string. After that is a true color terminal escape code. ABC is three
|
||||
// bytes for the UTF-8 representation "\xE2\x96\x88" of "█", U+2588 FULL BLOCK.
|
||||
// BYTES_PER_COLOR_PIXEL is long enough to contain "\x1B[38;2;255;255;255mABC"
|
||||
// plus a trailing NUL byte and a few bytes of slack. It starts with a true
|
||||
// color terminal escape code. ABC is three bytes for the UTF-8 representation
|
||||
// "\xE2\x96\x88" of "█", U+2588 FULL BLOCK.
|
||||
#define BYTES_PER_COLOR_PIXEL 32
|
||||
|
||||
const char* full_block_pascal_string = "\x03\xE2\x96\x88";
|
||||
const char* reset_color_pascal_string = "\x04\x1B[0m";
|
||||
|
||||
uint8_t* append_pascal_string(uint8_t* dst, const char* s) {
|
||||
uint8_t len = *s++;
|
||||
while (len--) {
|
||||
*dst++ = *s++;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
const char* reset_color = "\x1B[0m";
|
||||
|
||||
bool color_flag = false;
|
||||
const int stdout_fd = 1;
|
||||
|
||||
char palette_as_ascii_art[256];
|
||||
char palette_as_color_art[256][BYTES_PER_COLOR_PIXEL]; // Pascal style strings.
|
||||
|
||||
void reset_palette_as_ascii_art() {
|
||||
memset(palette_as_ascii_art, '-', 256);
|
||||
static inline uint32_t load_u32le(uint8_t* p) {
|
||||
return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |
|
||||
((uint32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);
|
||||
}
|
||||
|
||||
void reset_palette_as_color_art() {
|
||||
memset(palette_as_color_art, 0, 256 * BYTES_PER_COLOR_PIXEL);
|
||||
}
|
||||
void compose(wuffs_base__image_buffer* ib) {
|
||||
uint8_t* palette = wuffs_base__image_buffer__palette(ib).ptr;
|
||||
|
||||
// update_palette_as_ascii_art calculates a grayscale value and therefore an
|
||||
// ASCII art character for each (red, green, blue) palette entry.
|
||||
void update_palette_as_ascii_art(wuffs_base__slice_u8 palette) {
|
||||
if (!palette.ptr || (palette.len != 256 * 4)) {
|
||||
reset_palette_as_ascii_art();
|
||||
return;
|
||||
}
|
||||
wuffs_base__image_config* ic = wuffs_base__image_buffer__image_config(ib);
|
||||
size_t width = wuffs_base__image_config__width(ic);
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < 256; i++) {
|
||||
// Convert to grayscale via the formula
|
||||
// Y = (0.299 * R) + (0.587 * G) + (0.114 * B)
|
||||
// translated into fixed point arithmetic.
|
||||
uint32_t b = palette.ptr[4 * i + 0];
|
||||
uint32_t g = palette.ptr[4 * i + 1];
|
||||
uint32_t r = palette.ptr[4 * i + 2];
|
||||
uint32_t y = ((19595 * r) + (38470 * g) + (7471 * b) + (1 << 15)) >> 16;
|
||||
palette_as_ascii_art[i] = "-:=+IOX@"[(y & 0xFF) >> 5];
|
||||
}
|
||||
}
|
||||
|
||||
// update_palette_as_color_art calculates a terminal escape code for each (red,
|
||||
// green, blue) palette entry.
|
||||
void update_palette_as_color_art(wuffs_base__slice_u8 palette) {
|
||||
if (!palette.ptr || (palette.len != 256 * 4)) {
|
||||
reset_palette_as_color_art();
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < 256; i++) {
|
||||
int b = palette.ptr[4 * i + 0];
|
||||
int g = palette.ptr[4 * i + 1];
|
||||
int r = palette.ptr[4 * i + 2];
|
||||
palette_as_color_art[i][0] =
|
||||
sprintf(palette_as_color_art[i] + 1, "\x1B[38;2;%d;%d;%dm", r, g, b);
|
||||
wuffs_base__rect_ie_u32 bounds = wuffs_base__image_buffer__dirty_rect(ib);
|
||||
size_t y;
|
||||
for (y = bounds.min_inclusive_y; y < bounds.max_exclusive_y; y++) {
|
||||
size_t x;
|
||||
wuffs_base__color_u32argb* d =
|
||||
dst_buffer + (y * width) + bounds.min_inclusive_x;
|
||||
uint8_t* s = image_buffer + (y * width) + bounds.min_inclusive_x;
|
||||
for (x = bounds.min_inclusive_x; x < bounds.max_exclusive_x; x++) {
|
||||
uint32_t index = *s++;
|
||||
wuffs_base__color_u32argb c = load_u32le(palette + 4 * index);
|
||||
if (c) {
|
||||
*d = c;
|
||||
}
|
||||
d++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,14 +148,22 @@ size_t print_ascii_art(wuffs_base__image_buffer* ib) {
|
||||
uint32_t width = wuffs_base__image_config__width(ic);
|
||||
uint32_t height = wuffs_base__image_config__height(ic);
|
||||
|
||||
uint8_t* d = dst_buffer;
|
||||
wuffs_base__color_u32argb* d = dst_buffer;
|
||||
uint8_t* p = print_buffer;
|
||||
*p++ = '\n';
|
||||
uint32_t y;
|
||||
for (y = 0; y < height; y++) {
|
||||
uint32_t x;
|
||||
for (x = 0; x < width; x++) {
|
||||
*p++ = palette_as_ascii_art[*d++];
|
||||
wuffs_base__color_u32argb c = *d++;
|
||||
// Convert to grayscale via the formula
|
||||
// Y = (0.299 * R) + (0.587 * G) + (0.114 * B)
|
||||
// translated into fixed point arithmetic.
|
||||
uint32_t b = 0xFF & (c >> 0);
|
||||
uint32_t g = 0xFF & (c >> 8);
|
||||
uint32_t r = 0xFF & (c >> 16);
|
||||
uint32_t y = ((19595 * r) + (38470 * g) + (7471 * b) + (1 << 15)) >> 16;
|
||||
*p++ = "-:=+IOX@"[(y & 0xFF) >> 5];
|
||||
}
|
||||
*p++ = '\n';
|
||||
}
|
||||
@@ -196,37 +175,31 @@ size_t print_color_art(wuffs_base__image_buffer* ib) {
|
||||
uint32_t width = wuffs_base__image_config__width(ic);
|
||||
uint32_t height = wuffs_base__image_config__height(ic);
|
||||
|
||||
int32_t previous_palette_index = -1;
|
||||
uint8_t* d = dst_buffer;
|
||||
wuffs_base__color_u32argb* d = dst_buffer;
|
||||
uint8_t* p = print_buffer;
|
||||
*p++ = '\n';
|
||||
p = append_pascal_string(p, reset_color_pascal_string);
|
||||
p += sprintf(p, "%s", reset_color);
|
||||
uint32_t y;
|
||||
for (y = 0; y < height; y++) {
|
||||
uint32_t x;
|
||||
for (x = 0; x < width; x++) {
|
||||
uint8_t palette_index = *d++;
|
||||
if (palette_index != previous_palette_index) {
|
||||
p = append_pascal_string(p, palette_as_color_art[palette_index]);
|
||||
previous_palette_index = palette_index;
|
||||
}
|
||||
p = append_pascal_string(p, full_block_pascal_string);
|
||||
wuffs_base__color_u32argb c = *d++;
|
||||
int b = 0xFF & (c >> 0);
|
||||
int g = 0xFF & (c >> 8);
|
||||
int r = 0xFF & (c >> 16);
|
||||
// "\xE2\x96\x88" is U+2588 FULL BLOCK. Before that is a true color
|
||||
// terminal escape code.
|
||||
p += sprintf(p, "\x1B[38;2;%d;%d;%dm\xE2\x96\x88", r, g, b);
|
||||
}
|
||||
*p++ = '\n';
|
||||
}
|
||||
p = append_pascal_string(p, reset_color_pascal_string);
|
||||
p += sprintf(p, "%s", reset_color);
|
||||
return p - print_buffer;
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
const char* play() {
|
||||
if (color_flag) {
|
||||
reset_palette_as_color_art();
|
||||
} else {
|
||||
reset_palette_as_ascii_art();
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec = ((wuffs_gif__decoder){});
|
||||
wuffs_gif__decoder__check_wuffs_version(&dec, sizeof dec, WUFFS_VERSION);
|
||||
|
||||
@@ -249,12 +222,22 @@ const char* play() {
|
||||
if ((width > MAX_DIMENSION) || (height > MAX_DIMENSION)) {
|
||||
return "image dimensions are too large";
|
||||
}
|
||||
if (!dst_buffer) {
|
||||
dst_len = wuffs_base__image_config__pixbuf_size(&ic);
|
||||
dst_buffer = malloc(dst_len);
|
||||
if (!image_buffer) {
|
||||
image_len = wuffs_base__image_config__pixbuf_size(&ic);
|
||||
if (image_len > (SIZE_MAX / sizeof(wuffs_base__color_u32argb))) {
|
||||
return "could not allocate dst buffer";
|
||||
}
|
||||
dst_buffer = (wuffs_base__color_u32argb*)malloc(
|
||||
image_len * sizeof(wuffs_base__color_u32argb));
|
||||
if (!dst_buffer) {
|
||||
return "could not allocate dst buffer";
|
||||
}
|
||||
image_buffer = malloc(image_len);
|
||||
if (!image_buffer) {
|
||||
free(dst_buffer);
|
||||
dst_buffer = NULL;
|
||||
return "could not allocate image buffer";
|
||||
}
|
||||
uint64_t plen = 1 + ((uint64_t)(width) + 1) * (uint64_t)(height);
|
||||
uint64_t bytes_per_print_pixel = color_flag ? BYTES_PER_COLOR_PIXEL : 1;
|
||||
if (plen <= ((uint64_t)SIZE_MAX) / bytes_per_print_pixel) {
|
||||
@@ -267,7 +250,7 @@ const char* play() {
|
||||
}
|
||||
// TODO: check wuffs_base__image_buffer__set_from_slice errors?
|
||||
wuffs_base__image_buffer__set_from_slice(
|
||||
&ib, ic, ((wuffs_base__slice_u8){.ptr = dst_buffer, .len = dst_len}));
|
||||
&ib, ic, ((wuffs_base__slice_u8){.ptr = image_buffer, .len = image_len}));
|
||||
|
||||
if (!seen_num_loops) {
|
||||
seen_num_loops = true;
|
||||
@@ -276,8 +259,7 @@ const char* play() {
|
||||
dec.private_impl.f_seen_num_loops ? dec.private_impl.f_num_loops : 1;
|
||||
}
|
||||
|
||||
bool first_frame = true;
|
||||
for (;; first_frame = false) {
|
||||
while (1) {
|
||||
s = wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader);
|
||||
if (s) {
|
||||
if (s == WUFFS_GIF__SUSPENSION_END_OF_DATA) {
|
||||
@@ -286,13 +268,7 @@ const char* play() {
|
||||
return wuffs_gif__status__string(s);
|
||||
}
|
||||
|
||||
if (wuffs_base__image_buffer__palette_changed(&ib)) {
|
||||
if (color_flag) {
|
||||
update_palette_as_color_art(wuffs_base__image_buffer__palette(&ib));
|
||||
} else {
|
||||
update_palette_as_ascii_art(wuffs_base__image_buffer__palette(&ib));
|
||||
}
|
||||
}
|
||||
compose(&ib);
|
||||
|
||||
size_t n = color_flag ? print_color_art(&ib) : print_ascii_art(&ib);
|
||||
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
+13
-5
@@ -672,6 +672,13 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
|
||||
// ---------------- Images
|
||||
|
||||
// wuffs_base__color_u32argb is an 8 bit per channel Alpha, Red, Green, Blue
|
||||
// color, as a uint32_t value. It is in word order, not byte order: its value
|
||||
// is always 0xAARRGGBB, regardless of endianness. It uses premultiplied alpha.
|
||||
typedef uint32_t wuffs_base__color_u32argb;
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_base__pixel_format encodes the format of the bytes that constitute an
|
||||
// image frame's pixel data. Its bits:
|
||||
// - bit 31 is reserved.
|
||||
@@ -715,11 +722,12 @@ static inline wuffs_base__io_writer wuffs_base__io_buffer__writer(
|
||||
// - 5 means CMY or CMYK (Cyan, Magenta, Yellow, Black).
|
||||
// - all other values are reserved.
|
||||
//
|
||||
// In Wuffs, channels are given in memory order, regardless of endianness,
|
||||
// since the C type for the pixel data is an array of bytes, not an array of
|
||||
// uint32_t. For example, packed BGRA with 8 bits per channel means that the
|
||||
// bytes in memory are always Blue, Green, Red then Alpha. On big-endian
|
||||
// systems, that is the uint32_t 0xBBGGRRAA. On little-endian, 0xAARRGGBB.
|
||||
// In Wuffs, channels are given in memory order (also known as byte order),
|
||||
// regardless of endianness, since the C type for the pixel data is an array of
|
||||
// bytes, not an array of uint32_t. For example, packed BGRA with 8 bits per
|
||||
// channel means that the bytes in memory are always Blue, Green, Red then
|
||||
// Alpha. On big-endian systems, that is the uint32_t 0xBBGGRRAA. On
|
||||
// little-endian, 0xAARRGGBB.
|
||||
//
|
||||
// When the color field (3 bits) encodes multiple options, the transparency
|
||||
// field (2 bits) distinguishes them:
|
||||
|
||||
Reference in new issue
Block a user