X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-codec-support%2Fsrc%2Fcodecs%2Fmod.rs;h=63810adca15bdcca5f70e871628ddcf5cebf0c84;hb=e6aaad5c5273cd814b5748b7faf3751835a37217;hp=ebdbaa7e56cf97bb715eaa2fc6ad36a27ae0d107;hpb=fa49f0616b3b7f6454ea5722f8a6d1ca38908df6;p=nihav.git diff --git a/nihav-codec-support/src/codecs/mod.rs b/nihav-codec-support/src/codecs/mod.rs index ebdbaa7..63810ad 100644 --- a/nihav-codec-support/src/codecs/mod.rs +++ b/nihav-codec-support/src/codecs/mod.rs @@ -25,6 +25,7 @@ use std::mem; /// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference /// ``` #[allow(dead_code)] +#[derive(Default)] pub struct HAMShuffler { lastframe: Option>, } @@ -55,17 +56,10 @@ impl HAMShuffler { /// Returns the original saved reference frame or `None` if it is not present. #[allow(dead_code)] pub fn get_output_frame(&mut self) -> Option> { - match self.lastframe { - Some(ref frm) => Some(frm.clone()), - None => None, - } + self.lastframe.as_ref().cloned() } } -impl Default for HAMShuffler { - fn default() -> Self { Self { lastframe: None } } -} - /// Frame manager for codecs with intra and inter frames. /// /// This frame manager simplifies frame management for the case when codec decodes new frame using previous frame as source of some data. @@ -85,6 +79,7 @@ impl Default for HAMShuffler { /// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference /// ``` #[allow(dead_code)] +#[derive(Default)] pub struct IPShuffler { lastframe: Option>, } @@ -104,18 +99,10 @@ impl IPShuffler { /// Returns the original saved reference frame or `None` if it is not present. #[allow(dead_code)] pub fn get_ref(&mut self) -> Option> { - if let Some(ref frm) = self.lastframe { - Some(frm.clone()) - } else { - None - } + self.lastframe.as_ref().cloned() } } -impl Default for IPShuffler { - fn default() -> Self { Self { lastframe: None } } -} - /// Frame manager for codecs with I-, P- and B-frames. /// /// This frame manager simplifies frame management for the case when codec uses I/P/B frame scheme. @@ -146,6 +133,7 @@ impl Default for IPShuffler { /// } /// ``` #[allow(dead_code)] +#[derive(Default)] pub struct IPBShuffler { lastframe: Option>, nextframe: Option>, @@ -167,45 +155,25 @@ impl IPBShuffler { /// Returns the previous reference frame or `None` if it is not present. #[allow(dead_code)] pub fn get_lastref(&mut self) -> Option> { - if let Some(ref frm) = self.lastframe { - Some(frm.clone()) - } else { - None - } + self.lastframe.as_ref().cloned() } /// Returns second last reference frame or `None` if it is not present. #[allow(dead_code)] pub fn get_nextref(&mut self) -> Option> { - if let Some(ref frm) = self.nextframe { - Some(frm.clone()) - } else { - None - } + self.nextframe.as_ref().cloned() } /// Returns the temporally following reference for B-frame or `None` if it is not present. #[allow(dead_code)] pub fn get_b_fwdref(&mut self) -> Option> { - if let Some(ref frm) = self.nextframe { - Some(frm.clone()) - } else { - None - } + self.nextframe.as_ref().cloned() } /// Returns the temporally preceeding reference for B-frame or `None` if it is not present. #[allow(dead_code)] pub fn get_b_bwdref(&mut self) -> Option> { - if let Some(ref frm) = self.lastframe { - Some(frm.clone()) - } else { - None - } + self.lastframe.as_ref().cloned() } } -impl Default for IPBShuffler { - fn default() -> Self { Self { lastframe: None, nextframe: None } } -} - /// Motion vector data type. /// /// # Examples @@ -228,6 +196,7 @@ pub struct MV { #[allow(clippy::many_single_char_names)] #[allow(clippy::collapsible_if)] +#[allow(clippy::collapsible_else_if)] impl MV { /// Creates a new motion vector instance. pub fn new(x: i16, y: i16) -> Self { MV{ x, y } }