X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=src%2Fcodecs%2Fh263%2Fmod.rs;h=15ca5a95911874c9519d4a0092457cedd96c9403;hb=effbebce8a7acf0cbdd6075b523bbe0b1c33bb57;hp=9973dc7e9050e0c35037cb19b92493dac0fd8f2e;hpb=88e9abd4b69419cfa83093a1e4aee3066b90bcea;p=nihav.git diff --git a/src/codecs/h263/mod.rs b/src/codecs/h263/mod.rs index 9973dc7..15ca5a9 100644 --- a/src/codecs/h263/mod.rs +++ b/src/codecs/h263/mod.rs @@ -1,5 +1,5 @@ use std::fmt; -use std::ops::{Add, Sub}; +use std::ops::{Add, AddAssign, Sub, SubAssign}; use super::DecoderResult; use frame::NAVideoBuffer; @@ -50,14 +50,16 @@ impl Type { pub struct PBInfo { trb: u8, dbquant: u8, + improved: bool, } impl PBInfo { - pub fn new(trb: u8, dbquant: u8) -> Self { - PBInfo{ trb: trb, dbquant: dbquant } + pub fn new(trb: u8, dbquant: u8, improved: bool) -> Self { + PBInfo{ trb: trb, dbquant: dbquant, improved: improved } } pub fn get_trb(&self) -> u8 { self.trb } pub fn get_dbquant(&self) -> u8 { self.dbquant } + pub fn is_improved(&self) -> bool { self.improved } } #[allow(dead_code)] @@ -90,6 +92,13 @@ impl PicInfo { pub fn get_quant(&self) -> u8 { self.quant } pub fn get_apm(&self) -> bool { self.apm } pub fn is_pb(&self) -> bool { self.pb.is_some() } + pub fn is_ipb(&self) -> bool { + if let Some(ref pbi) = self.pb { + pbi.is_improved() + } else { + false + } + } pub fn get_ts(&self) -> u16 { self.ts } pub fn get_pbinfo(&self) -> PBInfo { self.pb.unwrap() } pub fn get_plusifo(&self) -> Option { self.plusinfo } @@ -379,11 +388,19 @@ impl Add for MV { fn add(self, other: MV) -> MV { MV { x: self.x + other.x, y: self.y + other.y } } } +impl AddAssign for MV { + fn add_assign(&mut self, other: MV) { self.x += other.x; self.y += other.y; } +} + impl Sub for MV { type Output = MV; fn sub(self, other: MV) -> MV { MV { x: self.x - other.x, y: self.y - other.y } } } +impl SubAssign for MV { + fn sub_assign(&mut self, other: MV) { self.x -= other.x; self.y -= other.y; } +} + impl fmt::Display for MV { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{},{}", self.x, self.y)