euv-core 0.52.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
use super::*;

/// Decoded 8-bit sRGB/linear RGBA raster image produced by pure-Rust codecs.
#[derive(Clone, Data, Debug, Default, Eq, PartialEq)]
pub struct DecodedRgbaImage {
    /// Image width in pixels.
    #[get(type(copy))]
    pub(crate) width: u32,
    /// Image height in pixels.
    #[get(type(copy))]
    pub(crate) height: u32,
    /// Packed RGBA8 pixel data (`width * height * 4` bytes).
    pub(crate) pixels: Vec<u8>,
    /// Source container format.
    #[get(type(copy))]
    pub(crate) format: DecodedImageFormat,
}

/// Decoded 32-bit floating-point linear HDR RGBA image for IBL environments and HDR textures.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct DecodedHdrImage {
    /// Image width in pixels.
    #[get(type(copy))]
    pub(crate) width: u32,
    /// Image height in pixels.
    #[get(type(copy))]
    pub(crate) height: u32,
    /// Packed linear RGBA32F pixel data (`width * height * 4` floats).
    pub(crate) pixels: Vec<f32>,
    /// Source HDR container format.
    #[get(type(copy))]
    pub(crate) format: DecodedImageFormat,
}

/// LSB-first bitstream reader used by RFC 1951 DEFLATE decompression.
#[derive(Clone, Debug)]
pub(crate) struct DeflateBitReader<'a> {
    /// Underlying compressed byte slice.
    pub(crate) data: &'a [u8],
    /// Current byte cursor position.
    pub(crate) byte_pos: usize,
    /// Buffered unread bits in LSB-first order.
    pub(crate) bit_buf: u64,
    /// Number of valid bits currently held in `bit_buf`.
    pub(crate) bit_count: u8,
}

/// Canonical Huffman decoding table for RFC 1951 DEFLATE symbols.
#[derive(Clone, Debug, Default)]
pub(crate) struct DeflateHuffmanTable {
    /// Count of codes for each bit length `1..=15`.
    pub(crate) counts: [u16; 16],
    /// Symbols ordered canonically by `(bit_length, symbol)`.
    pub(crate) symbols: Vec<u16>,
    /// Maximum active code bit length.
    pub(crate) max_bits: u8,
}

/// Canonical MSB-first Huffman decoding table for Baseline JPEG entropy coding.
#[derive(Clone, Debug, Default)]
pub(crate) struct JpegHuffmanTable {
    /// Maximum code value + 1 for each bit length `1..=16`.
    pub(crate) max_code: [i32; 17],
    /// Offset into `values` minus minimum code value for each bit length `1..=16`.
    pub(crate) val_offset: [i32; 17],
    /// Symbol byte table ordered canonically.
    pub(crate) values: Vec<u8>,
    /// Whether this table slot has been populated by a DHT marker.
    pub(crate) valid: bool,
}

/// Canonical MSB-first Huffman encoding table for Baseline JPEG output.
#[derive(Clone, Debug)]
pub(crate) struct JpegHuffmanEncodeTable {
    /// Bit code per symbol `0..=255`.
    pub(crate) codes: [u16; 256],
    /// Bit length per symbol `0..=255` (`0` = unused).
    pub(crate) lengths: [u8; 256],
}

/// Single color component descriptor parsed from a JPEG SOF0 frame header.
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct JpegComponentSpec {
    /// Component identifier from SOF0.
    pub(crate) id: u8,
    /// Horizontal sampling factor (`1..=4`).
    pub(crate) h_samp: u8,
    /// Vertical sampling factor (`1..=4`).
    pub(crate) v_samp: u8,
    /// Quantization table slot (`0..=3`).
    pub(crate) quant_id: u8,
    /// DC Huffman table slot (`0..=3`).
    pub(crate) dc_table_id: u8,
    /// AC Huffman table slot (`0..=3`).
    pub(crate) ac_table_id: u8,
    /// Running DC predictor value across MCUs.
    pub(crate) dc_pred: i32,
}

/// MSB-first entropy bitstream reader handling JPEG `0xFF 0x00` byte stuffing.
#[derive(Clone, Debug)]
pub(crate) struct JpegBitReader<'a> {
    /// Underlying JPEG file slice.
    pub(crate) data: &'a [u8],
    /// Current byte index inside `data`.
    pub(crate) pos: usize,
    /// Buffered unread bits in MSB-first alignment at the top of `bit_buf`.
    pub(crate) bit_buf: u32,
    /// Number of valid bits currently in `bit_buf`.
    pub(crate) bit_count: u8,
}

/// MSB-first entropy bitstream writer emitting JPEG `0xFF 0x00` stuffed bytes.
#[derive(Clone, Debug, Default)]
pub(crate) struct JpegBitWriter {
    /// Output byte stream.
    pub(crate) out: Vec<u8>,
    /// Pending partial bits accumulated MSB-first.
    pub(crate) bit_buf: u32,
    /// Number of valid bits accumulated in `bit_buf`.
    pub(crate) bit_count: u8,
}

/// Channel descriptor parsed from an OpenEXR `channels` header attribute.
#[derive(Clone, Debug)]
pub(crate) struct ExrChannelDesc {
    /// ASCII channel name (`"R"`, `"G"`, `"B"`, `"A"`, etc.).
    pub(crate) name: String,
    /// OpenEXR pixel data type (`0` = UINT, `1` = HALF, `2` = FLOAT).
    pub(crate) pixel_type: i32,
}