Commit 18ad2b5e authored by Romain Vimont's avatar Romain Vimont Committed by Romain Vimont

Simplify BlockContext logic

Rewrite conditions to make them easier to read.
parent db58658a
......@@ -1638,17 +1638,9 @@ impl BlockContext {
}
fn skip_context(&mut self, bo: BlockOffset) -> usize {
let above_skip = if bo.y > 0 {
self.above_of(bo).skip as usize
} else {
0
};
let left_skip = if bo.x > 0 {
self.left_of(bo).skip as usize
} else {
0
};
above_skip + left_skip
let above_skip = bo.y > 0 && self.above_of(bo).skip;
let left_skip = bo.x > 0 && self.left_of(bo).skip;
above_skip as usize + left_skip as usize
}
pub fn set_skip(&mut self, bo: BlockOffset, bsize: BlockSize, skip: bool) {
......@@ -1719,13 +1711,9 @@ impl BlockContext {
(above_intra || left_intra) as usize
}
}
(true, _) | (_, true) =>
2 * if has_above {
!self.above_of(bo).is_inter() as usize
} else {
!self.left_of(bo).is_inter() as usize
},
(_, _) => 0
(true, false) => if self.above_of(bo).is_inter() { 0 } else { 2 },
(false, true) => if self.left_of(bo).is_inter() { 0 } else { 2 },
_ => 0
}
}
......
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