projects
/
nihav.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
codec_support/codecs: add negation for MV
[nihav.git]
/
nihav-codec-support
/
src
/
codecs
/
mod.rs
diff --git
a/nihav-codec-support/src/codecs/mod.rs
b/nihav-codec-support/src/codecs/mod.rs
index 0d5307c01aa5f314d0a34a104c6d4438023f2ec6..92dee916db07f818611befffbb83ba400adcf75e 100644
(file)
--- 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;
//! 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;
pub use nihav_core::frame::*;
use std::mem;
@@
-25,11
+25,11
@@
use std::mem;
/// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference
/// ````
#[allow(dead_code)]
/// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference
/// ````
#[allow(dead_code)]
-pub struct HAMShuffler {
- lastframe: Option<NAVideoBufferRef<
u8
>>,
+pub struct HAMShuffler
<T: Copy>
{
+ lastframe: Option<NAVideoBufferRef<
T
>>,
}
}
-impl
HAMShuffler
{
+impl
<T: Copy> HAMShuffler<T>
{
/// Constructs a new instance of frame manager.
#[allow(dead_code)]
pub fn new() -> Self { HAMShuffler { lastframe: None } }
/// 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 clear(&mut self) { self.lastframe = None; }
/// Sets a new frame reference.
#[allow(dead_code)]
- pub fn add_frame(&mut self, buf: NAVideoBufferRef<
u8
>) {
+ pub fn add_frame(&mut self, buf: NAVideoBufferRef<
T
>) {
self.lastframe = Some(buf);
}
/// Provides a copy of the reference frame if present or `None` if it is not.
#[allow(dead_code)]
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<NAVideoBufferRef<
u8
>> {
+ pub fn clone_ref(&mut self) -> Option<NAVideoBufferRef<
T
>> {
if let Some(ref mut frm) = self.lastframe {
let newfrm = frm.copy_buffer();
*frm = newfrm.clone().into_ref();
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)]
}
/// Returns the original saved reference frame or `None` if it is not present.
#[allow(dead_code)]
- pub fn get_output_frame(&mut self) -> Option<NAVideoBufferRef<
u8
>> {
+ pub fn get_output_frame(&mut self) -> Option<NAVideoBufferRef<
T
>> {
match self.lastframe {
Some(ref frm) => Some(frm.clone()),
None => None,
match self.lastframe {
Some(ref frm) => Some(frm.clone()),
None => None,
@@
-62,7
+62,7
@@
impl HAMShuffler {
}
}
}
}
-impl
Default for HAMShuffler
{
+impl
<T: Copy> Default for HAMShuffler<T>
{
fn default() -> Self { Self { lastframe: None } }
}
fn default() -> Self { Self { lastframe: None } }
}
@@
-288,6
+288,13
@@
impl SubAssign for MV {
fn sub_assign(&mut self, other: MV) { self.x -= other.x; self.y -= other.y; }
}
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)
impl fmt::Display for MV {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{},{}", self.x, self.y)
@@
-298,6
+305,9
@@
impl fmt::Display for MV {
pub mod blockdsp;
#[cfg(feature="h263")]
pub mod blockdsp;
#[cfg(feature="h263")]
+#[allow(clippy::collapsible_if)]
+#[allow(clippy::manual_memcpy)]
+#[allow(clippy::needless_range_loop)]
pub mod h263;
/// The common 8x8 zigzag scan.
pub mod h263;
/// The common 8x8 zigzag scan.