X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-codec-support%2Fsrc%2Fcodecs%2Fmod.rs;h=ebdbaa7e56cf97bb715eaa2fc6ad36a27ae0d107;hb=fa49f0616b3b7f6454ea5722f8a6d1ca38908df6;hp=6589e477e4e3eaab4f57d9a0a9498c06a2ed39df;hpb=03011b993dc4873b39d981f62abc01591a0544f7;p=nihav.git diff --git a/nihav-codec-support/src/codecs/mod.rs b/nihav-codec-support/src/codecs/mod.rs index 6589e47..ebdbaa7 100644 --- a/nihav-codec-support/src/codecs/mod.rs +++ b/nihav-codec-support/src/codecs/mod.rs @@ -1,6 +1,6 @@ //! Decoder support functions and definitions. use std::fmt; -use std::ops::{Add, AddAssign, Sub, SubAssign}; +use std::ops::{Add, AddAssign, Sub, SubAssign, Neg}; pub use nihav_core::frame::*; use std::mem; @@ -11,25 +11,25 @@ use std::mem; /// /// # Examples /// -/// ````norun +/// ```ignore /// let mut frame = if is_intra_frame { /// allocate_video_frame() /// } else { /// let ret = shuffler.clone_ref(); /// if ret.is_none() { -/// return Err(DecodingError::MissingReference); +/// return Err(DecoderError::MissingReference); /// } /// ret.unwrap() /// }; /// // output data into the frame /// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference -/// ```` +/// ``` #[allow(dead_code)] -pub struct HAMShuffler { - lastframe: Option>, +pub struct HAMShuffler { + lastframe: Option>, } -impl HAMShuffler { +impl HAMShuffler { /// Constructs a new instance of frame manager. #[allow(dead_code)] pub fn new() -> Self { HAMShuffler { lastframe: None } } @@ -38,12 +38,12 @@ impl HAMShuffler { pub fn clear(&mut self) { self.lastframe = None; } /// Sets a new frame reference. #[allow(dead_code)] - pub fn add_frame(&mut self, buf: NAVideoBufferRef) { + pub fn add_frame(&mut self, buf: NAVideoBufferRef) { self.lastframe = Some(buf); } /// Provides a copy of the reference frame if present or `None` if it is not. #[allow(dead_code)] - pub fn clone_ref(&mut self) -> Option> { + pub fn clone_ref(&mut self) -> Option> { if let Some(ref mut frm) = self.lastframe { let newfrm = frm.copy_buffer(); *frm = newfrm.clone().into_ref(); @@ -54,7 +54,7 @@ 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> { + pub fn get_output_frame(&mut self) -> Option> { match self.lastframe { Some(ref frm) => Some(frm.clone()), None => None, @@ -62,7 +62,7 @@ impl HAMShuffler { } } -impl Default for HAMShuffler { +impl Default for HAMShuffler { fn default() -> Self { Self { lastframe: None } } } @@ -72,18 +72,18 @@ impl Default for HAMShuffler { /// /// # Examples /// -/// ````norun +/// ```ignore /// let mut frame = allocate_video_frame(); /// if is_inter_frame { /// let ret = shuffler.get_ref(); /// if ret.is_none() { -/// return Err(DecodingError::MissingReference); +/// return Err(DecoderError::MissingReference); /// } /// let ref_frame = ret.unwrap(); /// // keep decoding using data from ref_frame /// } /// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference -/// ```` +/// ``` #[allow(dead_code)] pub struct IPShuffler { lastframe: Option>, @@ -122,7 +122,7 @@ impl Default for IPShuffler { /// /// # Examples /// -/// ````norun +/// ```ignore /// let mut frame = allocate_video_frame(); /// for mb in all_macroblocks { /// // decode macroblock type @@ -144,7 +144,7 @@ impl Default for IPShuffler { /// if is_intra_frame || is_p_frame { /// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference /// } -/// ```` +/// ``` #[allow(dead_code)] pub struct IPBShuffler { lastframe: Option>, @@ -288,6 +288,13 @@ impl SubAssign for MV { fn sub_assign(&mut self, other: MV) { self.x -= other.x; self.y -= other.y; } } +impl Neg for MV { + type Output = MV; + fn neg(self) -> Self::Output { + MV { x: -self.x, y: -self.y } + } +} + impl fmt::Display for MV { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{},{}", self.x, self.y)