use std::mem;
pub fn extract_seq_hdr_from_mkv_codec_private(codec_private: &[u8]) -> &[u8] {
&codec_private[4..]
}
#[derive(Debug, Copy, Clone)]
pub struct ColorCharacteristics {
pub cp: ColourPrimaries,
pub mc: MatrixCoefficients,
pub tc: TransferCharacteristic,
}
impl ColorCharacteristics {
pub fn or(self, other: Self) -> Self {
Self {
cp: if matches!(self.cp, ColourPrimaries::Unspecified) {
other.cp
} else {
self.cp
},
mc: if matches!(self.mc, MatrixCoefficients::Unspecified) {
other.mc
} else {
self.mc
},
tc: if matches!(self.tc, TransferCharacteristic::Unspecified) {
other.tc
} else {
self.tc
},
}
}
}
#[derive(Debug, Copy, Clone)]
#[repr(u8)]
pub enum ColourPrimaries {
BT709 = 1,
Unspecified = 2,
BT601 = 6,
}
impl ColourPrimaries {
pub fn from_byte(byte: u8) -> Self {
assert!(byte <= ColourPrimaries::BT601 as u8);
unsafe { mem::transmute::<u8, _>(byte) }
}
}
#[derive(Debug, Copy, Clone)]
#[repr(u8)]
pub enum TransferCharacteristic {
Reserved = 0,
BT709 = 1,
Unspecified = 2,
Reserved2 = 3,
BT601 = 6,
}
impl TransferCharacteristic {
pub fn from_byte(byte: u8) -> Self {
assert!(byte <= TransferCharacteristic::BT601 as u8);
unsafe { mem::transmute::<u8, _>(byte) }
}
}
#[derive(Debug, Copy, Clone)]
#[repr(u8)]
pub enum MatrixCoefficients {
Identity = 0,
BT709 = 1,
Unspecified = 2,
Reserved = 3,
FCC = 4,
BT601 = 6,
}
impl MatrixCoefficients {
pub fn from_byte(byte: u8) -> Self {
assert!(byte <= MatrixCoefficients::BT601 as u8);
unsafe { mem::transmute::<u8, _>(byte) }
}
}