From: Kostya Shishkov Date: Tue, 12 Oct 2021 13:41:59 +0000 (+0200) Subject: codec_support/codecs: add negation for MV X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=473c2f76c1164db245d9de89034650be998d4d7d;p=nihav.git codec_support/codecs: add negation for MV --- diff --git a/nihav-codec-support/src/codecs/mod.rs b/nihav-codec-support/src/codecs/mod.rs index 389821e..92dee91 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; @@ -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)