Skip to content

Commit

Permalink
enum CompInterMode: Remove redundant as u8 casts.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkysen committed Aug 25, 2023
1 parent 4cbc11d commit 396e9bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3408,15 +3408,15 @@ unsafe fn decode_b(
by4,
bx4,
);
*b.comp_type_mut() = COMP_INTER_WEIGHTED_AVG as u8
*b.comp_type_mut() = COMP_INTER_WEIGHTED_AVG
+ dav1d_msac_decode_bool_adapt(
&mut ts.msac,
&mut ts.cdf.m.jnt_comp[jnt_ctx as usize],
) as u8;
if DEBUG_BLOCK_INFO(f, t) {
println!(
"Post-jnt_comp[{},ctx={}[ac:{},ar:{},lc:{},lr:{}]]: r={}",
b.comp_type() == COMP_INTER_AVG as u8,
b.comp_type() == COMP_INTER_AVG,
jnt_ctx,
(*t.a).comp_type[bx4 as usize],
(*t.a).r#ref[0][bx4 as usize],
Expand All @@ -3426,37 +3426,37 @@ unsafe fn decode_b(
);
}
} else {
*b.comp_type_mut() = COMP_INTER_AVG as u8;
*b.comp_type_mut() = COMP_INTER_AVG;
}
} else {
if wedge_allowed_mask & (1 << bs) != 0 {
let ctx = dav1d_wedge_ctx_lut[bs as usize] as usize;
*b.comp_type_mut() = COMP_INTER_WEDGE as u8
*b.comp_type_mut() = COMP_INTER_WEDGE
- dav1d_msac_decode_bool_adapt(&mut ts.msac, &mut ts.cdf.m.wedge_comp[ctx])
as u8;
if b.comp_type() == COMP_INTER_WEDGE as u8 {
if b.comp_type() == COMP_INTER_WEDGE {
*b.wedge_idx_mut() = dav1d_msac_decode_symbol_adapt16(
&mut ts.msac,
&mut ts.cdf.m.wedge_idx[ctx],
15,
) as u8;
}
} else {
*b.comp_type_mut() = COMP_INTER_SEG as u8;
*b.comp_type_mut() = COMP_INTER_SEG;
}
*b.mask_sign_mut() = dav1d_msac_decode_bool_equi(&mut ts.msac) as u8;
if DEBUG_BLOCK_INFO(f, t) {
println!(
"Post-seg/wedge[{},wedge_idx={},sign={}]: r={}",
b.comp_type() == COMP_INTER_WEDGE as u8,
b.comp_type() == COMP_INTER_WEDGE,
b.wedge_idx(),
b.mask_sign(),
ts.msac.rng,
);
}
}
} else {
*b.comp_type_mut() = COMP_INTER_NONE as u8;
*b.comp_type_mut() = COMP_INTER_NONE;

// ref
if let Some(seg) = seg.filter(|seg| seg.r#ref > 0) {
Expand Down Expand Up @@ -3791,7 +3791,7 @@ unsafe fn decode_b(
// subpel filter
let filter = if frame_hdr.subpel_filter_mode == DAV1D_FILTER_SWITCHABLE {
if has_subpel_filter {
let comp = b.comp_type() != COMP_INTER_NONE as u8;
let comp = b.comp_type() != COMP_INTER_NONE;
let ctx1 = get_filter_ctx(&*t.a, &t.l, comp, false, b.r#ref()[0], by4, bx4);
let filter0 = dav1d_msac_decode_symbol_adapt4(
&mut ts.msac,
Expand Down Expand Up @@ -3968,7 +3968,7 @@ unsafe fn decode_b(
let sby = t.by - ts.tiling.row_start >> f.sb_shift;
let lowest_px = &mut *ts.lowest_pixel.offset(sby as isize);
// keep track of motion vectors for each reference
if b.comp_type() == COMP_INTER_NONE as u8 {
if b.comp_type() == COMP_INTER_NONE {
// y
if std::cmp::min(bw4, bh4) > 1
&& (b.inter_mode() == GLOBALMV && f.gmv_warp_allowed[b.r#ref()[0] as usize] != 0
Expand Down
12 changes: 6 additions & 6 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,14 @@ pub fn get_comp_dir_ctx(
let edge = if a_intra { l } else { a };
let off = if a_intra { yb4 } else { xb4 };

if edge.comp_type[off as usize] == COMP_INTER_NONE as u8 {
if edge.comp_type[off as usize] == COMP_INTER_NONE {
return 2;
}
return 1 + 2 * has_uni_comp(edge, off) as u8;
}

let a_comp = a.comp_type[xb4 as usize] != COMP_INTER_NONE as u8;
let l_comp = l.comp_type[yb4 as usize] != COMP_INTER_NONE as u8;
let a_comp = a.comp_type[xb4 as usize] != COMP_INTER_NONE;
let l_comp = l.comp_type[yb4 as usize] != COMP_INTER_NONE;
let a_ref0 = a.r#ref[0][xb4 as usize];
let l_ref0 = l.r#ref[0][yb4 as usize];

Expand Down Expand Up @@ -287,7 +287,7 @@ pub fn get_comp_dir_ctx(
if edge.intra[off as usize] != 0 {
return 2;
}
if edge.comp_type[off as usize] == COMP_INTER_NONE as u8 {
if edge.comp_type[off as usize] == COMP_INTER_NONE {
return 2;
}
return 4 * has_uni_comp(edge, off) as u8;
Expand Down Expand Up @@ -335,7 +335,7 @@ pub fn get_jnt_comp_ctx(
.abs();
let offset = (d0 == d1) as u8;
let [a_ctx, l_ctx] = [(a, xb4), (l, yb4)].map(|(al, b4)| {
(al.comp_type[b4 as usize] >= COMP_INTER_AVG as u8 || al.r#ref[0][b4 as usize] == 6) as u8
(al.comp_type[b4 as usize] >= COMP_INTER_AVG || al.r#ref[0][b4 as usize] == 6) as u8
});

3 * offset + a_ctx + l_ctx
Expand All @@ -349,7 +349,7 @@ pub fn get_mask_comp_ctx(
xb4: libc::c_int,
) -> u8 {
let [a_ctx, l_ctx] = [(a, xb4), (l, yb4)].map(|(al, b4)| {
if al.comp_type[b4 as usize] >= COMP_INTER_SEG as u8 {
if al.comp_type[b4 as usize] >= COMP_INTER_SEG {
1
} else if al.r#ref[0][b4 as usize] == 6 {
3
Expand Down

0 comments on commit 396e9bd

Please sign in to comment.