euv-core 0.48.2

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::*;

/// ISO/IEC 23091-2 (CICP) color primaries identifying the video gamut.
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum ColorPrimaries {
    /// ITU-R BT.709 / sRGB primaries (`1`).
    #[default]
    Bt709,
    /// ITU-R BT.601 525/625-line standard definition primaries (`5` / `6`).
    Bt601,
    /// ITU-R BT.2020 wide color gamut primaries (`9`).
    Bt2020,
    /// DCI-P3 / Display P3 primaries (`12`).
    DisplayP3,
    /// Unrecognized CICP primary code preserved verbatim.
    Unknown(u16),
}

/// ISO/IEC 23091-2 (CICP) electro-optical transfer function identifying SDR vs HDR tone curves.
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum TransferCharacteristics {
    /// Standard sRGB piecewise transfer curve (`13`).
    Srgb,
    /// ITU-R BT.709 SDR transfer curve (`1`).
    #[default]
    Bt709,
    /// Linear light transfer curve (`8`).
    Linear,
    /// SMPTE ST 2084 Perceptual Quantizer HDR10 transfer curve (`16`).
    PqSt2084,
    /// ARIB STD-B67 Hybrid Log-Gamma HDR transfer curve (`18`).
    Hlg,
    /// Unrecognized CICP transfer code preserved verbatim.
    Unknown(u16),
}

/// ISO/IEC 23091-2 (CICP) YCbCr matrix coefficients for YUV-to-RGB conversion.
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum MatrixCoefficients {
    /// RGB identity matrix (`0`).
    Identity,
    /// ITU-R BT.709 matrix (`1`).
    #[default]
    Bt709,
    /// ITU-R BT.601 matrix (`5` / `6`).
    Bt601,
    /// ITU-R BT.2020 non-constant luminance matrix (`9`).
    Bt2020Ncl,
    /// Unrecognized CICP matrix code preserved verbatim.
    Unknown(u16),
}

/// Signal quantization range of luma/chroma samples.
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum ColorRange {
    /// Broadcast / studio limited range (`Y: 16..=235`, `Cb/Cr: 16..=240`).
    #[default]
    Limited,
    /// Full 8-bit/10-bit swing (`0..=255`).
    Full,
}

/// Surface pixel layout for GPU zero-copy surfaces and CPU pooled frames.
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum VideoPixelFormat {
    /// Packed 8-bit per channel RGBA.
    #[default]
    Rgba8,
    /// Packed 8-bit per channel BGRA.
    Bgra8,
    /// Bi-planar 8-bit 4:2:0 Y + interleaved UV (`CVPixelBuffer` / `HardwareBuffer` / DXGI).
    Nv12,
    /// Bi-planar 10-bit 4:2:0 HDR Y + interleaved UV (`P010`).
    P010,
    /// Tri-planar 8-bit 4:2:0 Y + U + V.
    Yuv420p,
}

/// Target hardware or software video decode backend identifier.
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum HardwareDecoderKind {
    /// Apple VideoToolbox (`CVPixelBuffer` -> Metal zero-copy texture).
    VideoToolbox,
    /// Android MediaCodec (`AHardwareBuffer` / SurfaceTexture -> Vulkan/GLES zero-copy).
    MediaCodec,
    /// Linux VA-API / V4L2 (`DMA-BUF` -> Vulkan/GLES zero-copy).
    Vaapi,
    /// Windows DXVA / D3D11VA (`ID3D11Texture2D` shared handle -> D3D12/Vulkan zero-copy).
    Dxva,
    /// Browser WebCodecs (`VideoFrame` -> WebGPU/WebGL zero-copy).
    WebCodecs,
    /// Pure-Rust CPU software decoder writing into a bounded reusable `VideoFramePool`.
    #[default]
    SoftwareFallback,
}

/// Storage backing for a decoded video frame: either a zero-copy GPU texture handle or a pooled CPU buffer.
#[derive(Clone, Debug, PartialEq)]
pub enum VideoFrameBacking {
    /// Zero-copy GPU surface/texture interop handle composited directly without CPU readback.
    GpuSurface(VideoGpuSurfaceHandle),
    /// Bounded reusable CPU RGBA8 frame buffer fallback.
    CpuPooled(PooledVideoFrame),
}

/// Clock source driving A/V synchronization.
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum AvSyncClockSource {
    /// Hardware audio playback timestamp serves as master clock.
    AudioMaster,
    /// Monotonic steady clock fallback when track is silent, muted, or audio-less.
    #[default]
    MonotonicFallback,
}

/// Per-VSync frame presentation decision produced by `AvSyncScheduler`.
#[derive(Clone, Debug, PartialEq)]
pub enum VideoPresentDecision {
    /// A new frame is due at the active playback clock and should replace the displayed texture.
    PresentNewFrame(DecodedVideoFrame),
    /// Display refresh cadence is faster than video frame rate; hold the current frame without forging pixels.
    HoldCurrentFrame,
    /// Pipeline is waiting for the background decoder to fill the PTS queue.
    Buffering,
    /// Timeline reached end-of-stream and all queued frames have been presented.
    Ended,
}

/// Zero-clone presentation outcome returned by `VideoPlaybackPipeline::present_vsync`.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub enum VideoPresentOutcome {
    /// A new frame replaced `pipeline.current_frame()` without cloning frame pixel storage.
    Presented {
        /// Presentation timestamp in microseconds of the newly active frame.
        pts_us: i64,
        /// Decode-order sample index of the newly active frame.
        sample_index: usize,
        /// Pipeline seek generation tag of the newly active frame.
        generation: u64,
        /// `true` when the newly active frame is backed by a zero-copy GPU surface handle.
        zero_copy_gpu: bool,
    },
    /// Display refresh cadence is faster than video frame rate; held existing frame without forging pixels.
    #[default]
    HoldCurrentFrame,
    /// Background decoder is filling the PTS queue.
    Buffering,
    /// Stream reached end-of-stream and all queued frames were presented.
    Ended,
}