Commit 0984d76a authored by Vittorio Giovara's avatar Vittorio Giovara

Add Cs400 enum entry and use it instead of a boolean field

parent 2319c057
......@@ -26,7 +26,6 @@ const LOOKAHEAD_FRAMES: u64 = 10;
pub struct VideoDetails {
pub width: usize,
pub height: usize,
pub mono: bool,
pub bit_depth: usize,
pub chroma_sampling: ChromaSampling,
pub chroma_sample_position: ChromaSamplePosition,
......@@ -38,7 +37,6 @@ impl Default for VideoDetails {
VideoDetails {
width: 640,
height: 480,
mono: false,
bit_depth: 8,
chroma_sampling: ChromaSampling::Cs420,
chroma_sample_position: ChromaSamplePosition::Unknown,
......
......@@ -15,18 +15,14 @@ impl Decoder for y4m::Decoder<'_, Box<dyn Read>> {
let height = self.get_height();
let color_space = self.get_colorspace();
let bit_depth = color_space.get_bit_depth();
let mono = match color_space {
y4m::Colorspace::Cmono => true,
_ => false
};
let (chroma_sampling, chroma_sample_position) = map_y4m_color_space(color_space);
let framerate = self.get_framerate();
let time_base = Rational::new(framerate.den as u64, framerate.num as u64);
VideoDetails {
width,
height,
bit_depth,
mono,
chroma_sampling,
chroma_sample_position,
time_base,
......@@ -81,12 +77,11 @@ pub fn map_y4m_color_space(
use ChromaSampling::*;
use ChromaSamplePosition::*;
match color_space {
Cmono => (Cs400, Unknown),
C420jpeg | C420paldv => (Cs420, Unknown),
C420mpeg2 => (Cs420, Vertical),
C420 | C420p10 | C420p12 => (Cs420, Colocated),
C422 | C422p10 | C422p12 => (Cs422, Colocated),
C444 | C444p10 | C444p12 => (Cs444, Colocated),
_ =>
panic!("Chroma characteristics unknown for the specified color space.")
}
}
......@@ -192,7 +192,8 @@ impl Default for Tune {
pub enum ChromaSampling {
Cs420,
Cs422,
Cs444
Cs444,
Cs400,
}
impl Default for ChromaSampling {
......@@ -208,7 +209,8 @@ impl ChromaSampling {
match self {
Cs420 => (2, 2),
Cs422 => (2, 1),
Cs444 => (1, 1)
Cs444 => (1, 1),
Cs400 => (1, 1),
}
}
}
......@@ -255,7 +257,6 @@ pub struct Sequence {
// 2 - adaptive
pub still_picture: bool, // Video is a single frame still picture
pub reduced_still_picture_hdr: bool, // Use reduced header for still picture
pub monochrome: bool, // Monochrome video
pub enable_intra_edge_filter: bool, // enables/disables corner/edge/upsampling
pub enable_interintra_compound: bool, // enables/disables interintra_compound
pub enable_masked_compound: bool, // enables/disables masked compound
......@@ -337,7 +338,6 @@ impl Sequence {
force_integer_mv: 2,
still_picture: false,
reduced_still_picture_hdr: false,
monochrome: false,
enable_intra_edge_filter: false,
enable_interintra_compound: false,
enable_masked_compound: false,
......@@ -1116,11 +1116,12 @@ impl<W: io::Write> UncompressedHeader for BitWriter<W, BigEndian> {
self.write_bit(seq.bit_depth == 12)?;
}
let monochrome = seq.chroma_sampling == ChromaSampling::Cs400;
if seq.profile != 1 {
self.write_bit(seq.monochrome)?;
self.write_bit(monochrome)?;
}
if seq.monochrome {
if monochrome {
unimplemented!();
}
......
......@@ -230,6 +230,7 @@ impl BlockSize {
BLOCK_64X16 => TX_32X8,
_ => TX_32X32
}
ChromaSampling::Cs400 => unimplemented!()
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment