Commit 9611d893 authored by Raphaël Zumer's avatar Raphaël Zumer

Add assertions during OBU header writing

parent 5deb11b3
......@@ -1091,7 +1091,9 @@ impl<W: io::Write> UncompressedHeader for BitWriter<W, BigEndian> {
}
let monochrome = seq.chroma_sampling == ChromaSampling::Cs400;
if seq.profile != 1 {
if seq.profile == 1 {
assert!(monochrome == false);
} else {
self.write_bit(monochrome)?;
}
......@@ -1120,21 +1122,29 @@ impl<W: io::Write> UncompressedHeader for BitWriter<W, BigEndian> {
if write_color_range {
self.write_bit(seq.pixel_range == PixelRange::Full)?; // full color range
if monochrome {
return Ok(());
}
let subsampling_x = seq.chroma_sampling != ChromaSampling::Cs444;
let subsampling_y = seq.chroma_sampling == ChromaSampling::Cs420;
if seq.bit_depth == 12 {
self.write_bit(subsampling_x)?;
if seq.profile == 0 {
assert!(seq.chroma_sampling == ChromaSampling::Cs420);
} else if seq.profile == 1 {
assert!(seq.chroma_sampling == ChromaSampling::Cs444);
} else {
if seq.bit_depth == 12 {
self.write_bit(subsampling_x)?;
if subsampling_x {
self.write_bit(subsampling_y)?;
if subsampling_x {
self.write_bit(subsampling_y)?;
}
} else {
assert!(seq.chroma_sampling == ChromaSampling::Cs422);
}
}
if subsampling_x && !subsampling_y {
unimplemented!(); // 4:2:2 sampling
}
if seq.chroma_sampling == ChromaSampling::Cs420 {
self.write(2, seq.chroma_sample_position as u32)?;
}
......
......@@ -892,7 +892,7 @@ pub fn get_intra_edges<'a>(
let num_avail = if y != 0 && has_tr(&bo, bsize) {
tx_size.height().min(
(MI_SIZE >> plane_cfg.xdec) * frame_w_in_b // TODO: validate for 4:2:2
(MI_SIZE >> plane_cfg.xdec) * frame_w_in_b
- x as usize
- tx_size.width()
)
......@@ -927,7 +927,7 @@ pub fn get_intra_edges<'a>(
let num_avail = if x != 0 && has_bl(&bo, bsize) {
tx_size.width().min(
(MI_SIZE >> plane_cfg.xdec) * frame_h_in_b // TODO: validate for 4:2:2
(MI_SIZE >> plane_cfg.xdec) * frame_h_in_b
- y as usize
- tx_size.height()
)
......
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