use x264::*;
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
#[repr(u32)]
pub enum Colorspace {
I420 = X264_CSP_I420,
YV12 = X264_CSP_YV12,
NV12 = X264_CSP_NV12,
NV21 = X264_CSP_NV21,
I422 = X264_CSP_I422,
YV16 = X264_CSP_YV16,
NV16 = X264_CSP_NV16,
YUYV = X264_CSP_YUYV,
UYVY = X264_CSP_UYVY,
V210 = X264_CSP_V210,
I444 = X264_CSP_I444,
YV24 = X264_CSP_YV24,
BGR = X264_CSP_BGR,
BGRA = X264_CSP_BGRA,
RGB = X264_CSP_RGB,
}
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
pub struct Encoding {
raw: i32,
}
impl Encoding {
pub fn add(mut self, modifier: Modifier) -> Self {
self.raw |= modifier as i32;
self
}
pub fn remove(mut self, modifier: Modifier) -> Self {
self.raw &= !(modifier as i32);
self
}
pub fn has(self, modifier: Modifier) -> bool {
self.raw & modifier as i32 != 0
}
pub fn colorspace(self) -> Colorspace {
use core::mem;
unsafe { mem::transmute(self.raw as u32 % X264_CSP_MAX) }
}
#[doc(hidden)]
pub fn into_raw(self) -> i32 {
self.raw
}
#[doc(hidden)]
pub unsafe fn from_raw(raw: i32) -> Self {
Self { raw }
}
}
impl From<Colorspace> for Encoding {
fn from(csp: Colorspace) -> Self {
Self { raw: csp as i32 }
}
}
#[repr(i32)]
pub enum Modifier {
HighDepth = X264_CSP_HIGH_DEPTH as i32,
VerticalFlip = X264_CSP_VFLIP as i32,
}