diff --git a/src/intra_edge.rs b/src/intra_edge.rs index 7cdc40e99..f662386f0 100644 --- a/src/intra_edge.rs +++ b/src/intra_edge.rs @@ -81,16 +81,6 @@ struct ModeSelMem { pub nt: *mut EdgeTip, } -unsafe fn init_edges(node: *mut EdgeNode, bl: BlockLevel, edge_flags: EdgeFlags) { - if bl == BL_8X8 { - let nt = &mut *(node as *mut EdgeTip); - init_edges_tip(nt, edge_flags) - } else { - let nwc = &mut *(node as *mut EdgeBranch); - init_edges_branch(nwc, bl, edge_flags) - } -} - fn init_edges_tip(nt: &mut EdgeTip, edge_flags: EdgeFlags) { let node = &mut nt.node; @@ -167,20 +157,25 @@ unsafe fn init_mode_node( top_has_right: bool, left_has_bottom: bool, ) { - init_edges( - &mut nwc.node, + // this is an invariant: this function is only called with BL_128X128 and BL_64X64. + // then this function recurses, decreasing the block level at each step, until bottoming out + // at BL_16x16. + assert!(bl != BL_8X8); + + init_edges_branch( + nwc, bl, EdgeFlags::ALL_TOP_HAS_RIGHT.select(top_has_right) | EdgeFlags::ALL_LEFT_HAS_BOTTOM.select(left_has_bottom), ); + if bl == BL_16X16 { let nt = slice::from_raw_parts_mut(mem.nt, nwc.split.len()); mem.nt = mem.nt.offset(nt.len() as isize); for (n, (split, nt)) in iter::zip(&mut nwc.split, nt).enumerate() { *split = &mut nt.node; - init_edges( - &mut nt.node, - bl + 1, + init_edges_tip( + nt, EdgeFlags::ALL_TOP_HAS_RIGHT.select(!(n == 3 || (n == 1 && !top_has_right))) | EdgeFlags::ALL_LEFT_HAS_BOTTOM.select(n == 0 || (n == 2 && left_has_bottom)), );