Skip to content

Commit

Permalink
turn integers into bools
Browse files Browse the repository at this point in the history
  • Loading branch information
Folkert de Vries committed Feb 23, 2024
1 parent 3b5b46c commit 6be4e9e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 41 deletions.
8 changes: 8 additions & 0 deletions src/intra_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ impl EdgeFlags {
}
}

impl core::ops::Shr<u32> for EdgeFlags {
type Output = Self;

fn shr(self, rhs: u32) -> Self::Output {
Self::from_bits_retain(self.bits() >> rhs)
}
}

#[repr(C)]
pub struct EdgeNode {
pub o: EdgeFlags,
Expand Down
79 changes: 38 additions & 41 deletions src/recon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2595,20 +2595,20 @@ pub(crate) unsafe fn rav1d_recon_b_intra<BD: BitDepth>(
let intra_flags = sm_flag(&*t.a, bx4 as usize)
| sm_flag(&mut t.l, by4 as usize)
| intra_edge_filter_flag;
let sb_has_tr = (if (init_x + 16) < w4 {
1 as c_int as c_uint
let sb_has_tr = if (init_x + 16) < w4 {
true
} else if init_y != 0 {
0 as c_int as c_uint
false
} else {
(intra_edge_flags & EdgeFlags::EDGE_I444_TOP_HAS_RIGHT).bits() as c_int as c_uint
}) as c_int;
let sb_has_bl = (if init_x != 0 {
0 as c_int as c_uint
intra_edge_flags.contains(EdgeFlags::EDGE_I444_TOP_HAS_RIGHT)
};
let sb_has_bl = if init_x != 0 {
false
} else if (init_y + 16) < h4 {
1 as c_int as c_uint
true
} else {
(intra_edge_flags & EdgeFlags::EDGE_I444_LEFT_HAS_BOTTOM).bits() as c_int as c_uint
}) as c_int;
intra_edge_flags.contains(EdgeFlags::EDGE_I444_LEFT_HAS_BOTTOM)
};
let mut y;
let mut x;
let sub_w4 = cmp::min(w4, init_x + 16);
Expand All @@ -2628,19 +2628,16 @@ pub(crate) unsafe fn rav1d_recon_b_intra<BD: BitDepth>(
let m: IntraPredMode;
if !(b.c2rust_unnamed.c2rust_unnamed.pal_sz[0] != 0) {
angle = b.c2rust_unnamed.c2rust_unnamed.y_angle as c_int;
edge_flags = (if (y > init_y || sb_has_tr == 0)
&& x + (*t_dim).w as c_int >= sub_w4
{
EdgeFlags::empty()
} else {
EdgeFlags::EDGE_I444_TOP_HAS_RIGHT
}) | (if x > init_x
|| sb_has_bl == 0 && y + (*t_dim).h as c_int >= sub_h4
{
EdgeFlags::empty()
} else {
EdgeFlags::EDGE_I444_LEFT_HAS_BOTTOM
});
edge_flags =
(if (y > init_y || !sb_has_tr) && x + (*t_dim).w as c_int >= sub_w4 {
EdgeFlags::empty()
} else {
EdgeFlags::EDGE_I444_TOP_HAS_RIGHT
}) | (if x > init_x || !sb_has_bl && y + (*t_dim).h as c_int >= sub_h4 {
EdgeFlags::empty()
} else {
EdgeFlags::EDGE_I444_LEFT_HAS_BOTTOM
});
let top_sb_edge_slice = if t.by & f.sb_step - 1 == 0 {
let mut top_sb_edge: *const BD::Pixel =
f.ipred_edge[0] as *mut BD::Pixel;
Expand Down Expand Up @@ -3001,26 +2998,26 @@ pub(crate) unsafe fn rav1d_recon_b_intra<BD: BitDepth>(
}
let sm_uv_fl =
sm_uv_flag(&*t.a, cbx4 as usize) | sm_uv_flag(&mut t.l, cby4 as usize);
let uv_sb_has_tr = (if init_x + 16 >> ss_hor < cw4 {
1 as c_int as c_uint
let uv_sb_has_tr = if init_x + 16 >> ss_hor < cw4 {
true
} else if init_y != 0 {
0 as c_int as c_uint
false
} else {
intra_edge_flags.bits() as c_uint
& (EdgeFlags::EDGE_I420_TOP_HAS_RIGHT.bits() as c_int
>> (f.cur.p.layout as c_uint).wrapping_sub(1 as c_int as c_uint))
as c_uint
}) as c_int;
let uv_sb_has_bl = (if init_x != 0 {
0 as c_int as c_uint
intra_edge_flags.contains(
EdgeFlags::EDGE_I420_TOP_HAS_RIGHT
>> (f.cur.p.layout as c_uint).wrapping_sub(1),
)
};
let uv_sb_has_bl = if init_x != 0 {
false
} else if init_y + 16 >> ss_ver < ch4 {
1 as c_int as c_uint
true
} else {
intra_edge_flags.bits() as c_uint
& (EdgeFlags::EDGE_I420_LEFT_HAS_BOTTOM.bits() as c_int
>> (f.cur.p.layout as c_uint).wrapping_sub(1 as c_int as c_uint))
as c_uint
}) as c_int;
intra_edge_flags.contains(
EdgeFlags::EDGE_I420_LEFT_HAS_BOTTOM
>> (f.cur.p.layout as c_uint).wrapping_sub(1),
)
};
let sub_cw4 = cmp::min(cw4, init_x + 16 >> ss_hor);
let mut pl = 0;
while pl < 2 {
Expand Down Expand Up @@ -3052,14 +3049,14 @@ pub(crate) unsafe fn rav1d_recon_b_intra<BD: BitDepth>(
|| b.c2rust_unnamed.c2rust_unnamed.pal_sz[1] as c_int != 0)
{
angle = b.c2rust_unnamed.c2rust_unnamed.uv_angle as c_int;
edge_flags = (if (y > init_y >> ss_ver || uv_sb_has_tr == 0)
edge_flags = (if (y > init_y >> ss_ver || !uv_sb_has_tr)
&& x + (*uv_t_dim).w as c_int >= sub_cw4
{
EdgeFlags::empty()
} else {
EdgeFlags::EDGE_I444_TOP_HAS_RIGHT
}) | (if x > init_x >> ss_hor
|| uv_sb_has_bl == 0 && y + (*uv_t_dim).h as c_int >= sub_ch4
|| !uv_sb_has_bl && y + (*uv_t_dim).h as c_int >= sub_ch4
{
EdgeFlags::empty()
} else {
Expand Down

0 comments on commit 6be4e9e

Please sign in to comment.