From 473c2f76c1164db245d9de89034650be998d4d7d Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Tue, 12 Oct 2021 15:41:59 +0200 Subject: [PATCH] codec_support/codecs: add negation for MV --- nihav-codec-support/src/codecs/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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) -- 2.30.2