Commit 44009023 authored by David Michael Barr's avatar David Michael Barr

Implement chroma-from-luma for 4:2:2 and 4:4:4

parent 8c6ac1b5
......@@ -1320,8 +1320,8 @@ pub fn luma_ac<T: Pixel>(
) {
let PlaneConfig { xdec, ydec, .. } = fs.input.planes[1].cfg;
let plane_bsize = get_plane_block_size(bsize, xdec, ydec);
let po = if bsize.is_sub8x8() {
let offset = bsize.sub8x8_offset();
let po = if bsize.is_sub8x8(xdec, ydec) {
let offset = bsize.sub8x8_offset(xdec, ydec);
bo.with_offset(offset.0, offset.1).plane_offset(&fs.input.planes[0].cfg)
} else {
bo.plane_offset(&fs.input.planes[0].cfg)
......@@ -1334,11 +1334,16 @@ pub fn luma_ac<T: Pixel>(
for sub_x in 0..plane_bsize.width() {
let y = sub_y << ydec;
let x = sub_x << xdec;
let sample: i16 = (i16::cast_from(luma.p(x, y))
+ i16::cast_from(luma.p(x + 1, y))
+ i16::cast_from(luma.p(x, y + 1))
+ i16::cast_from(luma.p(x + 1, y + 1)))
<< 1;
let mut sample: i16 = i16::cast_from(luma.p(x, y));
if xdec != 0 {
sample += i16::cast_from(luma.p(x + 1, y));
}
if ydec != 0 {
debug_assert!(xdec != 0);
sample += i16::cast_from(luma.p(x, y + 1))
+ i16::cast_from(luma.p(x + 1, y + 1));
}
sample <<= 3 - xdec - ydec;
ac[sub_y * plane_bsize.width() + sub_x] = sample;
sum += sample as i32;
}
......
......@@ -237,13 +237,13 @@ impl BlockSize {
self.width_log2() == self.height_log2()
}
pub fn is_sub8x8(self) -> bool {
self.width_log2().min(self.height_log2()) < 3
pub fn is_sub8x8(self, xdec: usize, ydec: usize) -> bool {
xdec != 0 && self.width_log2() == 2 || ydec != 0 && self.height_log2() == 2
}
pub fn sub8x8_offset(self) -> (isize, isize) {
let offset_x: isize = if self.width_log2() == 2 { -1 } else { 0 };
let offset_y: isize = if self.height_log2() == 2 { -1 } else { 0 };
pub fn sub8x8_offset(self, xdec: usize, ydec: usize) -> (isize, isize) {
let offset_x = if xdec != 0 && self.width_log2() == 2 { -1 } else { 0 };
let offset_y = if ydec != 0 && self.height_log2() == 2 { -1 } else { 0 };
(offset_x, offset_y)
}
......
......@@ -803,8 +803,7 @@ pub fn rdo_mode_decision<T: Pixel>(
});
}
if best.mode_luma.is_intra() && is_chroma_block && bsize.cfl_allowed() &&
fi.config.chroma_sampling == ChromaSampling::Cs420 { // FIXME: 4:2:2/4:4:4 unimplemented
if best.mode_luma.is_intra() && is_chroma_block && bsize.cfl_allowed() {
let chroma_mode = PredictionMode::UV_CFL_PRED;
let cw_checkpoint = cw.checkpoint();
let wr: &mut dyn Writer = &mut WriterCounter::new();
......
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