euv-core 0.53.1

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
/// Standard 8-byte PNG file signature.
pub const PNG_SIGNATURE: [u8; 8] = [0x89, b'P', b'N', b'G', 0x0D, 0x0A, 0x1A, 0x0A];

/// Standard 4-byte OpenEXR file signature.
pub const OPENEXR_SIGNATURE: [u8; 4] = [0x76, 0x2F, 0x31, 0x01];

/// Maximum decoded image dimension in pixels guarded against decompression bombs.
pub const IMAGE_MAX_DIMENSION: u32 = 16_384;

/// Maximum decompressed payload size in bytes guarded against decompression bombs.
pub const IMAGE_MAX_DECOMPRESSED_BYTES: usize = 256 * 1024 * 1024;

/// PNG critical chunk tag for image header.
pub(crate) const PNG_CHUNK_IHDR: [u8; 4] = *b"IHDR";

/// PNG critical chunk tag for indexed palette.
pub(crate) const PNG_CHUNK_PLTE: [u8; 4] = *b"PLTE";

/// PNG ancillary chunk tag for transparency table.
pub(crate) const PNG_CHUNK_TRNS: [u8; 4] = *b"tRNS";

/// PNG critical chunk tag for compressed pixel stream.
pub(crate) const PNG_CHUNK_IDAT: [u8; 4] = *b"IDAT";

/// PNG critical chunk tag for stream terminator.
pub(crate) const PNG_CHUNK_IEND: [u8; 4] = *b"IEND";

/// Two-byte gzip magic header.
pub(crate) const GZIP_SIGNATURE: [u8; 2] = [0x1F, 0x8B];

/// Radiance HDR file header prefix.
pub(crate) const HDR_MAGIC_RADIANCE: &[u8] = b"#?RADIANCE";

/// Alternate Radiance RGBE header prefix.
pub(crate) const HDR_MAGIC_RGBE: &[u8] = b"#?RGBE";

/// Format badge string for PNG assets.
pub(crate) const IMAGE_LABEL_PNG: &str = "PNG";

/// OpenEXR channels header attribute name.
pub(crate) const EXR_ATTR_CHANNELS: &str = "channels";

/// OpenEXR compression header attribute name.
pub(crate) const EXR_ATTR_COMPRESSION: &str = "compression";

/// OpenEXR dataWindow header attribute name.
pub(crate) const EXR_ATTR_DATA_WINDOW: &str = "dataWindow";

/// Error string when a Base64 stream contains invalid characters or length.
pub(crate) const ERR_BASE64_INVALID: &str = "invalid base64 payload";

/// Error string when a DEFLATE stream is truncated or malformed.
pub(crate) const ERR_DEFLATE_INVALID: &str = "invalid deflate bitstream";

/// Error string when a DEFLATE Huffman table cannot be constructed.
pub(crate) const ERR_DEFLATE_HUFFMAN: &str = "invalid deflate huffman table";

/// Error string when a DEFLATE back-reference points outside output history.
pub(crate) const ERR_DEFLATE_DISTANCE: &str = "invalid deflate lz77 back-reference";

/// Error string when decompressed output exceeds the safety ceiling.
pub(crate) const ERR_DEFLATE_OVERFLOW: &str = "decompressed payload exceeds safety limit";

/// Error string when a zlib container header or checksum is invalid.
pub(crate) const ERR_ZLIB_INVALID: &str = "invalid zlib container";

/// Error string when a gzip container header or trailer is invalid.
pub(crate) const ERR_GZIP_INVALID: &str = "invalid gzip container";

/// Error string when a PNG header or chunk sequence is invalid.
pub(crate) const ERR_PNG_INVALID: &str = "invalid png container";

/// Error string when PNG color type or bit depth combination is unsupported.
pub(crate) const ERR_PNG_UNSUPPORTED: &str = "unsupported png color type or bit depth";

/// Error string when a PNG scanline filter type is unknown.
pub(crate) const ERR_PNG_FILTER: &str = "invalid png scanline filter";

/// Error string when PNG encoder inputs do not match dimensions.
pub(crate) const ERR_PNG_ENCODE_ARGS: &str = "invalid png encode dimensions or buffer size";

/// Error string when a JPEG bitstream or marker is malformed.
pub(crate) const ERR_JPEG_INVALID: &str = "invalid jpeg bitstream";

/// Error string when a JPEG frame uses an unsupported SOF coding mode.
pub(crate) const ERR_JPEG_UNSUPPORTED: &str = "unsupported jpeg coding mode";

/// Error string when JPEG encoder inputs do not match dimensions.
pub(crate) const ERR_JPEG_ENCODE_ARGS: &str = "invalid jpeg encode dimensions or buffer size";

/// Error string when a Radiance HDR payload is malformed.
pub(crate) const ERR_HDR_INVALID: &str = "invalid radiance hdr image";

/// Error string when an OpenEXR payload is malformed or unsupported.
pub(crate) const ERR_EXR_INVALID: &str = "invalid or unsupported openexr image";

/// Error string when an image format cannot be decoded.
pub(crate) const ERR_IMAGE_UNSUPPORTED: &str = "unsupported raster image format";

/// RFC 1951 order of dynamic Huffman code-length alphabet symbols.
pub(crate) const DEFLATE_CODE_LENGTH_ORDER: [usize; 19] = [
    16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15,
];

/// RFC 1951 length base values for symbols 257..=285.
pub(crate) const DEFLATE_LENGTH_BASE: [usize; 29] = [
    3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131,
    163, 195, 227, 258,
];

/// RFC 1951 length extra bit counts for symbols 257..=285.
pub(crate) const DEFLATE_LENGTH_EXTRA: [u8; 29] = [
    0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0,
];

/// RFC 1951 distance base values for symbols 0..=29.
pub(crate) const DEFLATE_DIST_BASE: [usize; 30] = [
    1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537,
    2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577,
];

/// RFC 1951 distance extra bit counts for symbols 0..=29.
pub(crate) const DEFLATE_DIST_EXTRA: [u8; 30] = [
    0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13,
    13,
];

/// PNG Adam7 starting X column for each of the 7 interlace passes.
pub(crate) const PNG_ADAM7_START_X: [usize; 7] = [0, 4, 0, 2, 0, 1, 0];

/// PNG Adam7 starting Y row for each of the 7 interlace passes.
pub(crate) const PNG_ADAM7_START_Y: [usize; 7] = [0, 0, 4, 0, 2, 0, 1];

/// PNG Adam7 horizontal stride for each of the 7 interlace passes.
pub(crate) const PNG_ADAM7_STEP_X: [usize; 7] = [8, 8, 4, 4, 2, 2, 1];

/// PNG Adam7 vertical stride for each of the 7 interlace passes.
pub(crate) const PNG_ADAM7_STEP_Y: [usize; 7] = [8, 8, 8, 4, 4, 2, 2];

/// JPEG 8x8 zigzag index mapping from zigzag order to natural row-major order.
pub(crate) const JPEG_ZIGZAG_TO_NATURAL: [usize; 64] = [
    0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20,
    13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59,
    52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63,
];

/// Precomputed 8x8 orthogonal DCT/IDCT basis matrix `C(u) * cos((2*x + 1) * u * pi / 16) * 0.5`.
pub(crate) const JPEG_DCT_BASIS: [[f32; 8]; 8] = [
    [
        0.353_553_38,
        0.353_553_38,
        0.353_553_38,
        0.353_553_38,
        0.353_553_38,
        0.353_553_38,
        0.353_553_38,
        0.353_553_38,
    ],
    [
        0.490_392_64,
        0.415_734_8,
        0.277_785_12,
        0.097_545_16,
        -0.097_545_16,
        -0.277_785_12,
        -0.415_734_8,
        -0.490_392_64,
    ],
    [
        0.461_939_75,
        0.191_341_71,
        -0.191_341_71,
        -0.461_939_75,
        -0.461_939_75,
        -0.191_341_71,
        0.191_341_71,
        0.461_939_75,
    ],
    [
        0.415_734_8,
        -0.097_545_16,
        -0.490_392_64,
        -0.277_785_12,
        0.277_785_12,
        0.490_392_64,
        0.097_545_16,
        -0.415_734_8,
    ],
    [
        0.353_553_38,
        -0.353_553_38,
        -0.353_553_38,
        0.353_553_38,
        0.353_553_38,
        -0.353_553_38,
        -0.353_553_38,
        0.353_553_38,
    ],
    [
        0.277_785_12,
        -0.490_392_64,
        0.097_545_16,
        0.415_734_8,
        -0.415_734_8,
        -0.097_545_16,
        0.490_392_64,
        -0.277_785_12,
    ],
    [
        0.191_341_71,
        -0.461_939_75,
        0.461_939_75,
        -0.191_341_71,
        -0.191_341_71,
        0.461_939_75,
        -0.461_939_75,
        0.191_341_71,
    ],
    [
        0.097_545_16,
        -0.277_785_12,
        0.415_734_8,
        -0.490_392_64,
        0.490_392_64,
        -0.415_734_8,
        0.277_785_12,
        -0.097_545_16,
    ],
];

/// Standard Annex K JPEG luminance quantization table in natural order.
pub(crate) const JPEG_STD_LUMA_QUANT: [u8; 64] = [
    16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56,
    14, 17, 22, 29, 51, 87, 80, 62, 18, 22, 37, 56, 68, 109, 103, 77, 24, 35, 55, 64, 81, 104, 113,
    92, 49, 64, 78, 87, 103, 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99,
];

/// Standard Annex K JPEG chrominance quantization table in natural order.
pub(crate) const JPEG_STD_CHROMA_QUANT: [u8; 64] = [
    17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99,
    47, 66, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
    99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
];

/// Standard Annex K JPEG luminance DC Huffman bit counts (lengths 1..=16).
pub(crate) const JPEG_STD_DC_LUMA_BITS: [u8; 16] = [0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0];

/// Standard Annex K JPEG luminance DC Huffman values.
pub(crate) const JPEG_STD_DC_LUMA_VALS: [u8; 12] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];

/// Standard Annex K JPEG chrominance DC Huffman bit counts (lengths 1..=16).
pub(crate) const JPEG_STD_DC_CHROMA_BITS: [u8; 16] =
    [0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0];

/// Standard Annex K JPEG chrominance DC Huffman values.
pub(crate) const JPEG_STD_DC_CHROMA_VALS: [u8; 12] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];

/// Standard Annex K JPEG luminance AC Huffman bit counts (lengths 1..=16).
pub(crate) const JPEG_STD_AC_LUMA_BITS: [u8; 16] =
    [0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125];

/// Standard Annex K JPEG luminance AC Huffman values.
pub(crate) const JPEG_STD_AC_LUMA_VALS: [u8; 162] = [
    0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
    0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xA1, 0x08, 0x23, 0x42, 0xB1, 0xC1, 0x15, 0x52, 0xD1, 0xF0,
    0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0A, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x25, 0x26, 0x27, 0x28,
    0x29, 0x2A, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
    0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
    0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
    0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
    0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5,
    0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xE1, 0xE2,
    0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8,
    0xF9, 0xFA,
];

/// Standard Annex K JPEG chrominance AC Huffman bit counts (lengths 1..=16).
pub(crate) const JPEG_STD_AC_CHROMA_BITS: [u8; 16] =
    [0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119];

/// Standard Annex K JPEG chrominance AC Huffman values.
pub(crate) const JPEG_STD_AC_CHROMA_VALS: [u8; 162] = [
    0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
    0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xA1, 0xB1, 0xC1, 0x09, 0x23, 0x33, 0x52, 0xF0,
    0x15, 0x62, 0x72, 0xD1, 0x0A, 0x16, 0x24, 0x34, 0xE1, 0x25, 0xF1, 0x17, 0x18, 0x19, 0x1A, 0x26,
    0x27, 0x28, 0x29, 0x2A, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
    0x49, 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
    0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
    0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5,
    0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3,
    0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA,
    0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8,
    0xF9, 0xFA,
];