Skip to content

Commit

Permalink
use Option<InterIntraType> and remove the None variant
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Mar 19, 2024
1 parent 378e27a commit 57891e3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
15 changes: 6 additions & 9 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,10 +1161,7 @@ unsafe fn splat_oneref_mv(
r#ref: refmvs_refpair {
r#ref: [
b.r#ref()[0] + 1,
match b.interintra_type() {
InterIntraType::None => -1,
_ => 0,
},
b.interintra_type().map(|_| 0).unwrap_or(-1),
],
},
bs: bs as u8,
Expand Down Expand Up @@ -2975,19 +2972,19 @@ unsafe fn decode_b_inner(
&mut ts.msac,
&mut ts.cdf.m.interintra_wedge[wedge_ctx as usize],
) {
InterIntraType::Wedge
Some(InterIntraType::Wedge)
} else {
InterIntraType::Blend
Some(InterIntraType::Blend)
};
if b.interintra_type() == InterIntraType::Wedge {
if b.interintra_type() == Some(InterIntraType::Wedge) {
*b.wedge_idx_mut() = rav1d_msac_decode_symbol_adapt16(
&mut ts.msac,
&mut ts.cdf.m.wedge_idx[wedge_ctx as usize],
15,
) as u8;
}
} else {
*b.interintra_type_mut() = InterIntraType::None;
*b.interintra_type_mut() = None;
}
if debug_block_info!(f, t)
&& seq_hdr.inter_intra != 0
Expand All @@ -3004,7 +3001,7 @@ unsafe fn decode_b_inner(

// motion variation
if frame_hdr.switchable_motion_mode != 0
&& b.interintra_type() == InterIntraType::None
&& b.interintra_type() == None
&& cmp::min(bw4, bh4) >= 2
// is not warped global motion
&& !(!frame_hdr.force_integer_mv
Expand Down
11 changes: 5 additions & 6 deletions src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,8 @@ pub const COMP_INTER_NONE: CompInterType = 0;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum InterIntraType {
None = 0,
Blend = 1,
Wedge = 2,
Blend,
Wedge,
}

/// Note that this is legitimately [`Copy`]
Expand Down Expand Up @@ -310,7 +309,7 @@ pub struct Av1Block_inter {
pub r#ref: [i8; 2],
pub max_ytx: u8,
pub filter2d: u8,
pub interintra_type: InterIntraType,
pub interintra_type: Option<InterIntraType>,
pub tx_split0: u8,
pub tx_split1: u16,
}
Expand Down Expand Up @@ -528,11 +527,11 @@ impl Av1Block {
&mut self.c2rust_unnamed.c2rust_unnamed_0.max_ytx
}

pub unsafe fn interintra_type(&self) -> InterIntraType {
pub unsafe fn interintra_type(&self) -> Option<InterIntraType> {
self.c2rust_unnamed.c2rust_unnamed_0.interintra_type
}

pub unsafe fn interintra_type_mut(&mut self) -> &mut InterIntraType {
pub unsafe fn interintra_type_mut(&mut self) -> &mut Option<InterIntraType> {
&mut self.c2rust_unnamed.c2rust_unnamed_0.interintra_type
}

Expand Down
12 changes: 6 additions & 6 deletions src/recon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3439,7 +3439,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter<BD: BitDepth>(
}
}
}
if b.c2rust_unnamed.c2rust_unnamed_0.interintra_type != InterIntraType::None {
if let Some(interintra_type) = b.c2rust_unnamed.c2rust_unnamed_0.interintra_type {
let interintra_edge = BD::select_mut(&mut t.scratch.c2rust_unnamed_0.interintra_edge);
let tl_edge_array = &mut interintra_edge.0.edge;
let tl_edge_offset = 32;
Expand Down Expand Up @@ -3510,7 +3510,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter<BD: BitDepth>(
0 as c_int,
BD::from_c(f.bitdepth_max),
);
let ii_mask = match b.c2rust_unnamed.c2rust_unnamed_0.interintra_type {
let ii_mask = match interintra_type {
InterIntraType::Blend => {
dav1d_ii_masks[bs as usize][0][b
.c2rust_unnamed
Expand All @@ -3520,7 +3520,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter<BD: BitDepth>(
.interintra_mode
as usize]
}
_ => {
InterIntraType::Wedge => {
dav1d_wedge_masks[bs as usize][0][0][b
.c2rust_unnamed
.c2rust_unnamed_0
Expand Down Expand Up @@ -3842,8 +3842,8 @@ pub(crate) unsafe fn rav1d_recon_b_inter<BD: BitDepth>(
pl += 1;
}
}
if b.c2rust_unnamed.c2rust_unnamed_0.interintra_type != InterIntraType::None {
let ii_mask = match b.c2rust_unnamed.c2rust_unnamed_0.interintra_type {
if let Some(interintra_type) = b.c2rust_unnamed.c2rust_unnamed_0.interintra_type {
let ii_mask = match interintra_type {
InterIntraType::Blend => {
dav1d_ii_masks[bs as usize][chr_layout_idx as usize][b
.c2rust_unnamed
Expand All @@ -3853,7 +3853,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter<BD: BitDepth>(
.interintra_mode
as usize]
}
_ => {
InterIntraType::Wedge => {
dav1d_wedge_masks[bs as usize][chr_layout_idx as usize][0][b
.c2rust_unnamed
.c2rust_unnamed_0
Expand Down

0 comments on commit 57891e3

Please sign in to comment.