Skip to content

Commit

Permalink
enum Rav1dWarpedMotionType: From into TryFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Mar 6, 2024
1 parent abf1cf7 commit c757c8b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions include/dav1d/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,18 +304,20 @@ impl Rav1dWarpedMotionParams {
}
}

impl From<Dav1dWarpedMotionParams> for Rav1dWarpedMotionParams {
fn from(value: Dav1dWarpedMotionParams) -> Self {
impl TryFrom<Dav1dWarpedMotionParams> for Rav1dWarpedMotionParams {
type Error = ();

fn try_from(value: Dav1dWarpedMotionParams) -> Result<Self, Self::Error> {
let Dav1dWarpedMotionParams {
r#type,
matrix,
abcd,
} = value;
Self {
r#type: Rav1dWarpedMotionType::from_repr(r#type as usize).unwrap(),
Ok(Self {
r#type: Rav1dWarpedMotionType::from_repr(r#type as usize).ok_or(())?,
matrix,
abcd: Abcd::new(abcd),
}
})
}
}

Expand Down Expand Up @@ -2424,7 +2426,7 @@ impl From<Dav1dFrameHeader> for Rav1dFrameHeader {
},
warp_motion,
reduced_txtp_set,
gmv: gmv.map(|c| c.into()),
gmv: gmv.map(|c| c.try_into().unwrap()),
}
}
}
Expand Down

0 comments on commit c757c8b

Please sign in to comment.