#[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,
#[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 {
#[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 {
pub fn get_dimensions(&self, idx: usize) -> (usize, usize) {
get_plane_size(&self.info, idx)
}
+ pub fn into_ref(self) -> NABufferRef<Self> {
+ NABufferRef::new(self)
+ }
}
+pub type NAVideoBufferRef<T> = NABufferRef<NAVideoBuffer<T>>;
+
#[derive(Clone)]
pub struct NAAudioBuffer<T> {
info: NAAudioInfo,
#[derive(Clone)]
pub enum NABufferType {
- Video (NAVideoBuffer<u8>),
- Video16 (NAVideoBuffer<u16>),
- Video32 (NAVideoBuffer<u32>),
- VideoPacked(NAVideoBuffer<u8>),
+ Video (NAVideoBufferRef<u8>),
+ Video16 (NAVideoBufferRef<u16>),
+ Video32 (NAVideoBufferRef<u32>),
+ VideoPacked(NAVideoBufferRef<u8>),
AudioU8 (NAAudioBuffer<u8>),
AudioI16 (NAAudioBuffer<i16>),
AudioI32 (NAAudioBuffer<i32>),
_ => None,
}
}
- pub fn get_vbuf(&self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_vbuf(&self) -> Option<NAVideoBufferRef<u8>> {
match *self {
NABufferType::Video(ref vb) => Some(vb.clone()),
NABufferType::VideoPacked(ref vb) => Some(vb.clone()),
_ => None,
}
}
- pub fn get_vbuf16(&self) -> Option<NAVideoBuffer<u16>> {
+ pub fn get_vbuf16(&self) -> Option<NAVideoBufferRef<u16>> {
match *self {
NABufferType::Video16(ref vb) => Some(vb.clone()),
_ => None,
}
}
- pub fn get_vbuf32(&self) -> Option<NAVideoBuffer<u32>> {
+ pub fn get_vbuf32(&self) -> Option<NAVideoBufferRef<u32>> {
match *self {
NABufferType::Video32(ref vb) => Some(vb.clone()),
_ => None,
let mut data: Vec<u8> = Vec::with_capacity(new_size.unwrap());
data.resize(new_size.unwrap(), 0);
let buf: NAVideoBuffer<u8> = NAVideoBuffer { data: NABufferRef::new(data), info: vinfo, offs: offs, strides: strides };
- Ok(NABufferType::Video(buf))
+ Ok(NABufferType::Video(buf.into_ref()))
} else if !all_packed {
for i in 0..fmt.get_num_comp() {
let ochr = fmt.get_chromaton(i);
let mut data: Vec<u8> = Vec::with_capacity(new_size);
data.resize(new_size, 0);
let buf: NAVideoBuffer<u8> = NAVideoBuffer { data: NABufferRef::new(data), info: vinfo, offs: offs, strides: strides };
- Ok(NABufferType::Video(buf))
+ Ok(NABufferType::Video(buf.into_ref()))
} else if max_depth <= 16 {
let mut data: Vec<u16> = Vec::with_capacity(new_size);
data.resize(new_size, 0);
let buf: NAVideoBuffer<u16> = NAVideoBuffer { data: NABufferRef::new(data), info: vinfo, offs: offs, strides: strides };
- Ok(NABufferType::Video16(buf))
+ Ok(NABufferType::Video16(buf.into_ref()))
} else {
let mut data: Vec<u32> = Vec::with_capacity(new_size);
data.resize(new_size, 0);
let buf: NAVideoBuffer<u32> = NAVideoBuffer { data: NABufferRef::new(data), info: vinfo, offs: offs, strides: strides };
- Ok(NABufferType::Video32(buf))
+ Ok(NABufferType::Video32(buf.into_ref()))
}
} else if all_bytealigned || unfit_elem_size {
let elem_sz = fmt.get_elem_size();
data.resize(new_size, 0);
strides.push(line_sz.unwrap());
let buf: NAVideoBuffer<u8> = NAVideoBuffer { data: NABufferRef::new(data), info: vinfo, offs: offs, strides: strides };
- Ok(NABufferType::VideoPacked(buf))
+ Ok(NABufferType::VideoPacked(buf.into_ref()))
} else {
let elem_sz = fmt.get_elem_size();
let new_sz = width.checked_mul(height);
data.resize(new_size, 0);
strides.push(width);
let buf: NAVideoBuffer<u16> = NAVideoBuffer { data: NABufferRef::new(data), info: vinfo, offs: offs, strides: strides };
- Ok(NABufferType::Video16(buf))
+ Ok(NABufferType::Video16(buf.into_ref()))
},
4 => {
let mut data: Vec<u32> = Vec::with_capacity(new_size);
data.resize(new_size, 0);
strides.push(width);
let buf: NAVideoBuffer<u32> = NAVideoBuffer { data: NABufferRef::new(data), info: vinfo, offs: offs, strides: strides };
- Ok(NABufferType::Video32(buf))
+ Ok(NABufferType::Video32(buf.into_ref()))
},
_ => unreachable!(),
}
}
struct FrameBuf {
- last16: Option<NAVideoBuffer<u16>>,
- last24: Option<NAVideoBuffer<u8>>,
+ last16: Option<NAVideoBufferRef<u16>>,
+ last24: Option<NAVideoBufferRef<u8>>,
}
impl FrameBuf {
- fn set16(&mut self, buf: NAVideoBuffer<u16>) { self.last16 = Some(buf); }
- fn set24(&mut self, buf: NAVideoBuffer<u8>) { self.last24 = Some(buf); }
- fn get16(&mut self) -> Option<NAVideoBuffer<u16>> {
+ fn set16(&mut self, buf: NAVideoBufferRef<u16>) { self.last16 = Some(buf); }
+ fn set24(&mut self, buf: NAVideoBufferRef<u8>) { self.last24 = Some(buf); }
+ fn get16(&mut self) -> Option<NAVideoBufferRef<u16>> {
if let Some(ref mut frm) = self.last16 {
let newfrm = frm.copy_buffer();
- *frm = newfrm.clone();
- Some(newfrm)
+ *frm = newfrm.clone().into_ref();
+ Some(newfrm.into_ref())
} else {
None
}
}
- fn get24(&mut self) -> Option<NAVideoBuffer<u8>> {
+ fn get24(&mut self) -> Option<NAVideoBufferRef<u8>> {
if let Some(ref mut frm) = self.last24 {
let newfrm = frm.copy_buffer();
- *frm = newfrm.clone();
- Some(newfrm)
+ *frm = newfrm.clone().into_ref();
+ Some(newfrm.into_ref())
} else {
None
}
use nihav_core::formats::YUV420_FORMAT;
-use nihav_core::frame::{NABufferType, NAVideoInfo, NAVideoBuffer, FrameType, alloc_video_buffer};
+use nihav_core::frame::{NABufferType, NAVideoInfo, NAVideoBuffer, NAVideoBufferRef, FrameType, alloc_video_buffer};
use nihav_core::codecs::{MV, ZERO_MV, DecoderError, DecoderResult, IPBShuffler};
use nihav_core::io::bitreader::{BitReader,BitReaderMode};
use nihav_core::io::intcode::*;
ratio2: u32,
is_b: bool,
mbinfo: Vec<RV34MBInfo>,
- avg_buf: NAVideoBuffer<u8>,
+ avg_buf: NAVideoBufferRef<u8>,
base_ts: u64,
}
dsp: RV60DSP,
ipred: IntraPredContext,
- avg_buf: NAVideoBuffer<u8>,
+ avg_buf: NAVideoBufferRef<u8>,
y_coeffs: [i16; 16 * 16],
u_coeffs: [i16; 8 * 8],