use std::fmt;
use std::ops::{Add, AddAssign, Sub, SubAssign};
-use crate::frame::*;
-use std::rc::Rc;
+pub use crate::frame::*;
use std::mem;
use crate::io::byteio::ByteIOError;
use crate::io::bitreader::BitReaderError;
#[allow(dead_code)]
pub struct HAMShuffler {
- lastframe: Option<NAVideoBuffer<u8>>,
+ lastframe: Option<NAVideoBufferRef<u8>>,
}
impl HAMShuffler {
#[allow(dead_code)]
pub fn clear(&mut self) { self.lastframe = None; }
#[allow(dead_code)]
- pub fn add_frame(&mut self, buf: NAVideoBuffer<u8>) {
+ pub fn add_frame(&mut self, buf: NAVideoBufferRef<u8>) {
self.lastframe = Some(buf);
}
#[allow(dead_code)]
- pub fn clone_ref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn clone_ref(&mut self) -> Option<NAVideoBufferRef<u8>> {
if let Some(ref mut frm) = self.lastframe {
let newfrm = frm.copy_buffer();
- *frm = newfrm.clone();
- Some(newfrm)
+ *frm = newfrm.clone().into_ref();
+ Some(newfrm.into_ref())
} else {
None
}
}
#[allow(dead_code)]
- pub fn get_output_frame(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_output_frame(&mut self) -> Option<NAVideoBufferRef<u8>> {
match self.lastframe {
Some(ref frm) => Some(frm.clone()),
None => None,
}
}
+impl Default for HAMShuffler {
+ fn default() -> Self { Self { lastframe: None } }
+}
+
#[allow(dead_code)]
pub struct IPShuffler {
- lastframe: Option<NAVideoBuffer<u8>>,
+ lastframe: Option<NAVideoBufferRef<u8>>,
}
impl IPShuffler {
#[allow(dead_code)]
pub fn clear(&mut self) { self.lastframe = None; }
#[allow(dead_code)]
- pub fn add_frame(&mut self, buf: NAVideoBuffer<u8>) {
+ pub fn add_frame(&mut self, buf: NAVideoBufferRef<u8>) {
self.lastframe = Some(buf);
}
#[allow(dead_code)]
- pub fn get_ref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_ref(&mut self) -> Option<NAVideoBufferRef<u8>> {
if let Some(ref frm) = self.lastframe {
Some(frm.clone())
} else {
}
}
+impl Default for IPShuffler {
+ fn default() -> Self { Self { lastframe: None } }
+}
+
#[allow(dead_code)]
pub struct IPBShuffler {
- lastframe: Option<NAVideoBuffer<u8>>,
- nextframe: Option<NAVideoBuffer<u8>>,
+ lastframe: Option<NAVideoBufferRef<u8>>,
+ nextframe: Option<NAVideoBufferRef<u8>>,
}
impl IPBShuffler {
#[allow(dead_code)]
pub fn clear(&mut self) { self.lastframe = None; self.nextframe = None; }
#[allow(dead_code)]
- pub fn add_frame(&mut self, buf: NAVideoBuffer<u8>) {
+ pub fn add_frame(&mut self, buf: NAVideoBufferRef<u8>) {
mem::swap(&mut self.lastframe, &mut self.nextframe);
self.lastframe = Some(buf);
}
#[allow(dead_code)]
- pub fn get_lastref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_lastref(&mut self) -> Option<NAVideoBufferRef<u8>> {
if let Some(ref frm) = self.lastframe {
Some(frm.clone())
} else {
}
}
#[allow(dead_code)]
- pub fn get_nextref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_nextref(&mut self) -> Option<NAVideoBufferRef<u8>> {
if let Some(ref frm) = self.nextframe {
Some(frm.clone())
} else {
}
}
#[allow(dead_code)]
- pub fn get_b_fwdref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_b_fwdref(&mut self) -> Option<NAVideoBufferRef<u8>> {
if let Some(ref frm) = self.nextframe {
Some(frm.clone())
} else {
}
}
#[allow(dead_code)]
- pub fn get_b_bwdref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_b_bwdref(&mut self) -> Option<NAVideoBufferRef<u8>> {
if let Some(ref frm) = self.lastframe {
Some(frm.clone())
} else {
}
}
+impl Default for IPBShuffler {
+ fn default() -> Self { Self { lastframe: None, nextframe: None } }
+}
+
#[derive(Debug,Clone,Copy,PartialEq)]
pub struct MV {
pub x: i16,
pub trait NADecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()>;
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()>;
fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef>;
}
}
None
}
+ pub fn iter(&self) -> std::slice::Iter<DecoderInfo> {
+ self.decs.iter()
+ }
}