zoomvtools 2.0.0

Video motion vector analysis utilities in pure Rust
Documentation
#[cfg(test)]
mod tests;

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Rational frame rate.
pub struct Framerate {
    /// Frame-rate numerator.
    pub numerator: u64,
    /// Frame-rate denominator.
    pub denominator: u64,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Supported plane families for host-neutral video descriptions.
pub enum ColorFamily {
    /// Single-plane luma or grayscale data.
    Gray,
    /// Three-plane YUV data.
    Yuv,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Supported sample storage types.
pub enum SampleType {
    /// Integer-valued samples.
    Integer,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Frame dimensions in pixels.
pub struct Resolution {
    /// Frame width.
    pub width: usize,
    /// Frame height.
    pub height: usize,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Static pixel-format metadata shared by all frames in a clip.
pub struct VideoFormat {
    /// Plane family used by the clip.
    pub color_family: ColorFamily,
    /// Sample storage type for each plane.
    pub sample_type: SampleType,
    /// Significant bits stored in each sample.
    pub bits_per_sample: std::num::NonZeroU8,
    /// Bytes used to store each sample.
    pub bytes_per_sample: std::num::NonZeroU8,
    /// Horizontal chroma subsampling shift relative to luma.
    pub sub_sampling_w: u8,
    /// Vertical chroma subsampling shift relative to luma.
    pub sub_sampling_h: u8,
}

impl VideoFormat {
    /// Returns the number of planes required by this format.
    #[must_use]
    #[inline]
    pub const fn plane_count(self) -> usize {
        match self.color_family {
            ColorFamily::Gray => 1,
            ColorFamily::Yuv => 3,
        }
    }
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Clip-wide video metadata.
pub struct VideoInfo {
    /// Pixel-format metadata shared by all frames.
    pub format: VideoFormat,
    /// Constant frame dimensions.
    pub resolution: Resolution,
    /// Total number of frames in the clip.
    pub num_frames: usize,
}