use crate::prelude::v1::*;
use bytemuck::{Pod, Zeroable};
use nalgebra as na;
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct RGBA {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
impl RGBA {
pub fn from_rgb_slice(rgb: &[u8]) -> Self {
Self {
r: rgb[0],
g: rgb[1],
b: rgb[2],
a: 255,
}
}
pub fn from_rgba_slice(rgba: &[u8]) -> Self {
Self {
r: rgba[0],
g: rgba[1],
b: rgba[2],
a: rgba[3],
}
}
}
pub type MotionEntry = (na::Point2<f32>, na::Vector2<f32>);
pub type MotionVectors = Vec<MotionEntry>;
pub trait Decoder {
fn process_frame(
&mut self,
field: &mut MotionVectors,
out_frame: Option<(&mut Vec<RGBA>, &mut usize)>,
skip_frames: usize,
) -> Result<bool>;
fn get_framerate(&self) -> Option<f64>;
fn get_aspect(&self) -> Option<(usize, usize)>;
}