-use std::mem;
+//use std::mem;
use frame::*;
use super::super::*;
use super::super::blockdsp;
self.mb_start = mb_start;
self.mb_w = mb_w;
self.mb_stride = mb_w * 2;
- self.top = true;
self.mv.resize(self.mb_stride * 3, ZERO_MV);
self.mvmode = mvmode;
}
}
}
#[allow(non_snake_case)]
- fn predict(&mut self, mb_x: usize, blk_no: usize, use4: bool, diff: MV) -> MV {
+ fn predict(&mut self, mb_x: usize, blk_no: usize, use4: bool, diff: MV, first_line: bool, first_mb: bool) -> MV {
let A;
let B;
let C;
match blk_no {
0 => {
if mb_x != self.mb_start {
- A = if mb_x != 0 { self.mv[self.mb_stride + mb_x * 2 - 1] } else { ZERO_MV };
- B = if !self.top { self.mv[ mb_x * 2] } else { A };
- C = if !self.top && !last { self.mv[mb_x * 2 + 2] } else { ZERO_MV };
+ A = if !first_mb { self.mv[self.mb_stride + mb_x * 2 - 1] } else { ZERO_MV };
+ B = if !first_line { self.mv[ mb_x * 2] } else { A };
+ C = if !first_line && !last { self.mv[mb_x * 2 + 2] } else { ZERO_MV };
} else {
A = ZERO_MV; B = ZERO_MV; C = ZERO_MV;
}
},
1 => {
A = self.mv[self.mb_stride + mb_x * 2];
- B = if !self.top { self.mv[mb_x * 2 + 1] } else { A };
- C = if !self.top && !last { self.mv[mb_x * 2 + 2] } else { A };
+ B = if !first_line { self.mv[mb_x * 2 + 1] } else { A };
+ C = if !first_line && !last { self.mv[mb_x * 2 + 2] } else { A };
},
2 => {
A = if mb_x != self.mb_start { self.mv[self.mb_stride * 2 + mb_x * 2 - 1] } else { ZERO_MV };
mb_h: usize,
num_mb: usize,
ftype: Type,
- prev_frm: Option<NAVideoBuffer<u8>>,
- cur_frm: Option<NAVideoBuffer<u8>>,
- last_ts: u8,
+ ipbs: IPBShuffler,
+ next_ts: u16,
+ last_ts: u16,
+ tsdiff: u16,
has_b: bool,
b_data: Vec<BMB>,
pred_coeffs: Vec<PredCoeffs>,
is_gob: bool,
+ may_have_b_frames: bool,
+ mv_data: Vec<BlockMVInfo>,
}
#[inline]
#[allow(dead_code)]
impl H263BaseDecoder {
- pub fn new(is_gob: bool) -> Self {
+ pub fn new_with_opts(is_gob: bool, may_have_b_frames: bool) -> Self {
H263BaseDecoder{
w: 0, h: 0, mb_w: 0, mb_h: 0, num_mb: 0,
ftype: Type::Special,
- prev_frm: None, cur_frm: None,
- last_ts: 0,
+ ipbs: IPBShuffler::new(),
+ last_ts: 0, next_ts: 0, tsdiff: 0,
has_b: false, b_data: Vec::new(),
pred_coeffs: Vec::new(),
is_gob: is_gob,
+ may_have_b_frames: may_have_b_frames,
+ mv_data: Vec::new(),
}
}
+ pub fn new(is_gob: bool) -> Self {
+ Self::new_with_opts(is_gob, false)
+ }
+ pub fn new_b_frames(is_gob: bool) -> Self {
+ Self::new_with_opts(is_gob, true)
+ }
pub fn is_intra(&self) -> bool { self.ftype == Type::I }
pub fn get_frame_type(&self) -> FrameType {
self.has_b = pinfo.is_pb();
if self.has_b {
- self.b_data.truncate(0);
+ self.mv_data.truncate(0);
}
- mem::swap(&mut self.cur_frm, &mut self.prev_frm);
+ let save_b_data = pinfo.mode.is_ref() && self.may_have_b_frames;
+ if save_b_data {
+ self.mv_data.truncate(0);
+ }
- let tsdiff = pinfo.ts.wrapping_sub(self.last_ts);
- let bsdiff = if pinfo.is_pb() { pinfo.get_pbinfo().get_trb() } else { 0 };
+ let tsdiff = pinfo.ts.wrapping_sub(self.last_ts) >> 1;
+ let bsdiff = if pinfo.is_pb() { (pinfo.get_pbinfo().get_trb() as u16) << 7 }
+ else { pinfo.ts.wrapping_sub(self.next_ts) >> 1 };
let fmt = formats::YUV420_FORMAT;
let vinfo = NAVideoInfo::new(self.w, self.h, false, fmt);
if !self.is_gob {
mvi.reset(self.mb_w, mb_x, pinfo.get_mvmode());
cbpi.reset(self.mb_w);
- sstate.first_line = true;
- sstate.first_mb = true;
+ sstate.reset_slice(mb_x, mb_y);
}
}
cbpi.set_cbp(mb_x, cbp);
cbpi.set_q(mb_x, binfo.get_q());
if binfo.is_intra() {
+ if save_b_data {
+ self.mv_data.push(BlockMVInfo::Intra);
+ }
for i in 0..6 {
bd.decode_block_intra(&binfo, &sstate, binfo.get_q(), i, (cbp & (1 << (5 - i))) != 0, &mut blk[i])?;
if apply_acpred && (binfo.acpred != ACPredMode::None) {
mvi.set_zero_mv(mb_x);
} else if (binfo.mode != Type::B) && !binfo.is_skipped() {
if binfo.get_num_mvs() == 1 {
- let mv = mvi.predict(mb_x, 0, false, binfo.get_mv(0));
- if let Some(ref srcbuf) = self.prev_frm {
+ let mv = mvi.predict(mb_x, 0, false, binfo.get_mv(0), sstate.first_line, sstate.first_mb);
+ if save_b_data {
+ self.mv_data.push(BlockMVInfo::Inter_1MV(mv));
+ }
+ if let Some(ref srcbuf) = self.ipbs.get_lastref() {
bdsp.copy_blocks(&mut buf, srcbuf, mb_x * 16, mb_y * 16, 16, 16, mv);
}
} else {
+ let mut mv: [MV; 4] = [ZERO_MV, ZERO_MV, ZERO_MV, ZERO_MV];
for blk_no in 0..4 {
- let mv = mvi.predict(mb_x, blk_no, true, binfo.get_mv(blk_no));
- if let Some(ref srcbuf) = self.prev_frm {
+ mv[blk_no] = mvi.predict(mb_x, blk_no, true, binfo.get_mv(blk_no), sstate.first_line, sstate.first_mb);
+ if let Some(ref srcbuf) = self.ipbs.get_lastref() {
bdsp.copy_blocks(&mut buf, srcbuf,
mb_x * 16 + (blk_no & 1) * 8,
- mb_y * 16 + (blk_no & 2) * 4, 8, 8, mv);
+ mb_y * 16 + (blk_no & 2) * 4, 8, 8, mv[blk_no]);
}
}
+ if save_b_data {
+ self.mv_data.push(BlockMVInfo::Inter_4MV(mv));
+ }
}
for i in 0..6 {
bd.decode_block_inter(&binfo, &sstate, binfo.get_q(), i, ((cbp >> (5 - i)) & 1) != 0, &mut blk[i])?;
}
blockdsp::add_blocks(&mut buf, mb_x, mb_y, &blk);
} else if binfo.mode != Type::B {
+ self.mv_data.push(BlockMVInfo::Inter_1MV(ZERO_MV));
mvi.set_zero_mv(mb_x);
- if let Some(ref srcbuf) = self.prev_frm {
+ if let Some(ref srcbuf) = self.ipbs.get_lastref() {
bdsp.copy_blocks(&mut buf, srcbuf, mb_x * 16, mb_y * 16, 16, 16, ZERO_MV);
}
} else {
-//todo
+ let ref_mv_info = self.mv_data[mb_pos];
+ let has_fwd = binfo.get_num_mvs() > 0;
+ let has_bwd = binfo.get_num_mvs2() > 0;
+ let is_direct = has_fwd && has_bwd;
+//todo refactor
+ if let BlockMVInfo::Inter_4MV(mvs) = ref_mv_info {
+ for blk_no in 0..4 {
+ let ref_mv = mvs[blk_no];
+ let mut ref_mv_fwd = ref_mv.scale(bsdiff, tsdiff);
+ let mut ref_mv_bwd = ref_mv - ref_mv_fwd;
+ let xoff = mb_x * 16 + (blk_no & 1) * 8;
+ let yoff = mb_y * 16 + (blk_no & 2) * 4;
+ if has_fwd { ref_mv_fwd = MV::add_umv(ref_mv_fwd, binfo.get_mv(0), pinfo.get_mvmode()); }
+ if has_bwd { ref_mv_bwd = MV::add_umv(ref_mv_bwd, binfo.get_mv2(0), pinfo.get_mvmode()); }
+ if let (Some(ref bck_buf), Some(ref fwd_buf)) = (self.ipbs.get_nextref(), self.ipbs.get_lastref()) {
+ if is_direct || (!has_fwd && !has_bwd) {
+ bdsp.copy_blocks(&mut buf, fwd_buf, xoff, yoff, 8, 8, ref_mv_fwd);
+ bdsp.avg_blocks(&mut buf, bck_buf, xoff, yoff, 8, 8, ref_mv_bwd);
+ } else if has_fwd {
+ bdsp.copy_blocks(&mut buf, fwd_buf, xoff, yoff, 8, 8, ref_mv_fwd);
+ } else {
+ bdsp.copy_blocks(&mut buf, bck_buf, xoff, yoff, 8, 8, ref_mv_bwd);
+ }
+ }
+ }
+ } else {
+ let ref_mv = if let BlockMVInfo::Inter_1MV(mv_) = ref_mv_info { mv_ } else { ZERO_MV };
+ let mut ref_mv_fwd = ref_mv.scale(bsdiff, tsdiff);
+ let mut ref_mv_bwd = ref_mv - ref_mv_fwd;
+ if has_fwd { ref_mv_fwd = MV::add_umv(ref_mv_fwd, binfo.get_mv(0), pinfo.get_mvmode()); }
+ if has_bwd { ref_mv_bwd = MV::add_umv(ref_mv_bwd, binfo.get_mv2(0), pinfo.get_mvmode()); }
+ if let (Some(ref bck_buf), Some(ref fwd_buf)) = (self.ipbs.get_nextref(), self.ipbs.get_lastref()) {
+ if is_direct || (!has_fwd && !has_bwd) {
+ bdsp.copy_blocks(&mut buf, fwd_buf, mb_x * 16, mb_y * 16, 16, 16, ref_mv_fwd);
+ bdsp.avg_blocks(&mut buf, bck_buf, mb_x * 16, mb_y * 16, 16, 16, ref_mv_bwd);
+ } else if has_fwd {
+ bdsp.copy_blocks(&mut buf, fwd_buf, mb_x * 16, mb_y * 16, 16, 16, ref_mv_fwd);
+ } else {
+ bdsp.copy_blocks(&mut buf, bck_buf, mb_x * 16, mb_y * 16, 16, 16, ref_mv_bwd);
+ }
+ }
+ }
if cbp != 0 {
for i in 0..6 {
bd.decode_block_inter(&binfo, &sstate, binfo.get_q(), i, ((cbp >> (5 - i)) & 1) != 0, &mut blk[i])?;
h263_idct(&mut blk[i]);
}
+ blockdsp::add_blocks(&mut buf, mb_x, mb_y, &blk);
}
- blockdsp::add_blocks(&mut buf, mb_x, mb_y, &blk);
}
if pinfo.is_pb() {
let mut b_mb = BMB::new();
cbpi.update_row();
sstate.new_row();
}
-
- self.cur_frm = Some(buf);
- self.last_ts = pinfo.ts;
+
+ if pinfo.mode.is_ref() {
+ self.ipbs.add_frame(buf);
+ self.next_ts = self.last_ts;
+ self.last_ts = pinfo.ts;
+ self.tsdiff = tsdiff;
+ }
+
Ok(bufinfo)
}
pub fn get_bframe(&mut self, bdsp: &BlockDSP) -> DecoderResult<NABufferType> {
- if !self.has_b || !self.cur_frm.is_some() || !self.prev_frm.is_some() {
+ if !self.has_b || !self.ipbs.get_lastref().is_some() || !self.ipbs.get_nextref().is_some() {
return Err(DecoderError::MissingReference);
}
self.has_b = false;
let mut bufinfo = bufret.unwrap();
let mut b_buf = bufinfo.get_vbuf().unwrap();
- if let Some(ref bck_buf) = self.prev_frm {
- if let Some(ref fwd_buf) = self.cur_frm {
- recon_b_frame(&mut b_buf, bck_buf, fwd_buf, self.mb_w, self.mb_h, &self.b_data, bdsp);
- }
+ if let (Some(ref bck_buf), Some(ref fwd_buf)) = (self.ipbs.get_nextref(), self.ipbs.get_lastref()) {
+ recon_b_frame(&mut b_buf, bck_buf, fwd_buf, self.mb_w, self.mb_h, &self.b_data, bdsp);
}
self.b_data.truncate(0);
let mut br = &mut self.br;
let syncw = br.read(22)?;
validate!(syncw == 0x000020);
- let tr = br.read(8)? as u8;
+ let tr = (br.read(8)? << 8) as u16;
check_marker(br)?;
let id = br.read(1)?;
validate!(id == 0);
let ftype = if is_intra { Type::I } else { Type::P };
let plusinfo = if deblock { Some(PlusInfo::new(false, deblock, false, false)) } else { None };
- let picinfo = PicInfo::new(w, h, ftype, umv, apm, quant as u8, tr, pbinfo, plusinfo);
+ let mvmode = if umv { MVMode::UMV } else { MVMode::Old };
+ let picinfo = PicInfo::new(w, h, ftype, mvmode, umv, apm, quant as u8, tr, pbinfo, plusinfo);
Ok(picinfo)
}
I, P, PB, Skip, B, Special
}
+impl Type {
+ pub fn is_ref(&self) -> bool {
+ match *self {
+ Type::I | Type::P | Type::PB => true,
+ _ => false,
+ }
+ }
+}
+
#[allow(dead_code)]
#[derive(Debug,Clone,Copy)]
pub struct PBInfo {
pub w: usize,
pub h: usize,
pub mode: Type,
+ pub mvmode: MVMode,
pub umv: bool,
pub apm: bool,
pub quant: u8,
pub pb: Option<PBInfo>,
- pub ts: u8,
+ pub ts: u16,
pub plusinfo: Option<PlusInfo>,
}
#[allow(dead_code)]
impl PicInfo {
- pub fn new(w: usize, h: usize, mode: Type, umv: bool, apm: bool, quant: u8, ts: u8, pb: Option<PBInfo>, plusinfo: Option<PlusInfo>) -> Self {
+ pub fn new(w: usize, h: usize, mode: Type, mvmode: MVMode, umv: bool, apm: bool, quant: u8, ts: u16, pb: Option<PBInfo>, plusinfo: Option<PlusInfo>) -> Self {
PicInfo {
- w: w, h: h, mode: mode,
+ w: w, h: h, mode: mode, mvmode: mvmode,
umv: umv, apm: apm, quant: quant,
pb: pb, ts: ts, plusinfo: plusinfo
}
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 get_ts(&self) -> u8 { self.ts }
+ pub fn get_ts(&self) -> u16 { self.ts }
pub fn get_pbinfo(&self) -> PBInfo { self.pb.unwrap() }
pub fn get_plusifo(&self) -> Option<PlusInfo> { self.plusinfo }
- pub fn get_mvmode(&self) -> MVMode {
- if self.umv { MVMode::UMV }
- else if self.apm { MVMode::Long }
- else { MVMode::Old }
- }
+ pub fn get_mvmode(&self) -> MVMode { self.mvmode }
}
#[allow(dead_code)]
pub mb_y: usize,
pub first_line: bool,
pub first_mb: bool,
+ pub slice_mb_x: usize,
+ pub slice_mb_y: usize,
}
const SLICE_NO_END: usize = 99999999;
impl SliceState {
pub fn new(is_iframe: bool) -> Self {
- SliceState { is_iframe: is_iframe, mb_x: 0, mb_y: 0, first_line: true, first_mb: true }
+ SliceState {
+ is_iframe: is_iframe, mb_x: 0, mb_y: 0, first_line: true, first_mb: true,
+ slice_mb_x: 0, slice_mb_y: 0
+ }
+ }
+ pub fn next_mb(&mut self) {
+ self.mb_x += 1; self.first_mb = false;
+ if self.mb_x >= self.slice_mb_x && self.mb_y > self.slice_mb_y {
+ self.first_line = false;
+ }
}
- pub fn next_mb(&mut self) { self.mb_x += 1; self.first_mb = false; }
pub fn new_row(&mut self) {
self.mb_x = 0; self.mb_y += 1;
- self.first_line = false; self.first_mb = true;
+ if self.mb_x >= self.slice_mb_x && self.mb_y > self.slice_mb_y {
+ self.first_line = false;
+ }
+ self.first_mb = true;
+ }
+ pub fn reset_slice(&mut self, smb_x: usize, smb_y: usize) {
+ self.slice_mb_x = smb_x;
+ self.slice_mb_y = smb_y;
+ self.first_line = true;
+ self.first_mb = true;
}
}
fwd: bool,
}
+#[allow(non_camel_case_types)]
+#[derive(Debug,Clone,Copy)]
+pub enum BlockMVInfo {
+ Intra,
+ Inter_1MV(MV),
+ Inter_4MV([MV; 4]),
+}
+
#[allow(dead_code)]
#[derive(Debug,Clone,Copy,PartialEq)]
pub enum ACPredMode {
};
new_mv
}
- fn scale(&self, trb: u8, trd: u8) -> Self {
+ fn scale(&self, trb: u16, trd: u16) -> Self {
if (trd == 0) || (trb == 0) {
ZERO_MV
} else {
- MV { x: (self.x * (trb as i16)) / (trd as i16), y: (self.y * (trb as i16)) / (trd as i16) }
+ MV { x: (((self.x as i32) * (trb as i32)) / (trd as i32)) as i16, y: (((self.y as i32) * (trb as i32)) / (trd as i32)) as i16 }
}
}
- fn b_sub(pvec: MV, fwdvec: MV, bvec: MV, trb: u8, trd: u8) -> Self {
+ fn b_sub(pvec: MV, fwdvec: MV, bvec: MV, trb: u16, trd: u16) -> Self {
let bscale = (trb as i16) - (trd as i16);
let x = if bvec.x != 0 { fwdvec.x - pvec.x } else if trd != 0 { bscale * pvec.x / (trd as i16) } else { 0 };
let y = if bvec.y != 0 { fwdvec.y - pvec.y } else if trd != 0 { bscale * pvec.y / (trd as i16) } else { 0 };
let mb_end = shdr.mb_x + shdr.mb_y * self.mb_w + shdr.mb_c;
let ftype = if !shdr.is_p { Type::I } else { Type::P };
- let picinfo = PicInfo::new(self.w, self.h, ftype, false, false, shdr.qscale, 0, None, None);
+ let picinfo = PicInfo::new(self.w, self.h, ftype, MVMode::Old, false, false, shdr.qscale, 0, None, None);
Ok(picinfo)
}
struct RV20SliceInfo {
ftype: Type,
+ seq: u32,
qscale: u8,
mb_x: usize,
mb_y: usize,
}
impl RV20SliceInfo {
- fn new(ftype: Type, qscale: u8, mb_x: usize, mb_y: usize, mb_pos: usize, w: usize, h: usize) -> Self {
- RV20SliceInfo { ftype: ftype, qscale: qscale, mb_x: mb_x, mb_y: mb_y, mb_pos: mb_pos, w: w, h: h }
+ fn new(ftype: Type, seq: u32, qscale: u8, mb_x: usize, mb_y: usize, mb_pos: usize, w: usize, h: usize) -> Self {
+ RV20SliceInfo { ftype: ftype, seq: seq, qscale: qscale, mb_x: mb_x, mb_y: mb_y, mb_pos: mb_pos, w: w, h: h }
}
}
level = code.get_level();
last = code.is_last();
if br.read_bool()? { level = -level; }
- if (idx != 0) || !sstate.is_iframe {
- level = (level * q) + q_add;
- } else {
- level = level * (H263_DC_SCALES[quant as usize] as i16);
- }
+ level = (level * q) + q_add;
} else {
last = br.read_bool()?;
run = br.read(6)? as u8;
let top = br.read_s(6)? as i16;
level = (top << 5) | low;
}
- if (idx != 0) || !sstate.is_iframe {
- level = (level * q) + q_add;
- } else {
- level = level * (H263_DC_SCALES[quant as usize] as i16);
- }
+ level = (level * q) + q_add;
if level < -2048 { level = -2048; }
if level > 2047 { level = 2047; }
}
}*/
let plusinfo = Some(PlusInfo::new(shdr.ftype == Type::I, false, false, false));
- let picinfo = PicInfo::new(shdr.w, shdr.h, shdr.ftype, false, false, shdr.qscale, 0, None, plusinfo);
+ let picinfo = PicInfo::new(shdr.w, shdr.h, shdr.ftype, MVMode::Long, false, false, shdr.qscale, shdr.seq as u16, None, plusinfo);
Ok(picinfo)
}
if pi.aic {
let acpp = br.read_bool()?;
acpred = ACPredMode::DC;
- println!(" acp {} @ {}", acpp as u8, br.tell());
+//println!(" acp {} @ {}", acpp as u8, br.tell());
if acpp {
acpred = if br.read_bool()? { ACPredMode::Hor } else { ACPredMode::Ver };
}
}
Ok(binfo)
},
- _ => { // B
+ Type::B => { // B
let mut mbtype = br.read_cb(&self.tables.mbtype_b_cb)? as usize;
while mbtype == 14 { mbtype = br.read_cb(&self.tables.mbtype_b_cb)? as usize; }
let idx = br.read(2)? as usize;
q = ((q as i16) + (H263_DQUANT_TAB[idx] as i16)) as u8;
}
-println!(" MB B {}.{} cbp = {:X} @ {} ({} {})", sstate.mb_x, sstate.mb_y, cbp, br.tell(), mbtype, is_intra);
+//println!(" MB B {}.{} cbp = {:X} @ {} ({} {})", sstate.mb_x, sstate.mb_y, cbp, br.tell(), mbtype, is_intra);
if is_intra {
let binfo = BlockInfo::new(Type::I, cbp, q);
}
Ok(binfo)
},
+ _ => { unreachable!(); },
}
}
br.skip(1)?; // loop filter
}
let seq = if self.minor_ver <= 1 {
- br.read(8)? << 7
+ br.read(8)? << 8
} else {
- br.read(13)? << 2
+ br.read(13)? << 3
};
let w;
let h;
}
println!("slice q {} mb {},{}", qscale, mb_x, mb_y);
- Ok(RV20SliceInfo::new(ftype, qscale, mb_x, mb_y, mb_pos, w, h))
+ Ok(RV20SliceInfo::new(ftype, seq, qscale, mb_x, mb_y, mb_pos, w, h))
}
}
RealVideo20Decoder{
info: Rc::new(DUMMY_CODEC_INFO),
- dec: H263BaseDecoder::new(false),
+ dec: H263BaseDecoder::new_b_frames(false),
tables: tables,
w: 0,
h: 0,
use test::dec_video::test_file_decoding;
#[test]
fn test_rv20() {
- test_file_decoding("realmedia", "assets/RV/rv20_svt_atrc_640x352_realproducer_plus_8.51.rm", None, true, false, Some("rv20"));
+ test_file_decoding("realmedia", "assets/RV/rv20_svt_atrc_640x352_realproducer_plus_8.51.rm", /*None*/Some(7000), true, false, Some("rv20"));
// test_file_decoding("realmedia", "assets/RV/rv20_cook_640x352_realproducer_plus_8.51.rm", /*None*/Some(1000), true, false, Some("rv20"));
}
}
use frame::*;
use std::rc::Rc;
use std::cell::RefCell;
+use std::mem;
use io::byteio::ByteIOError;
use io::bitreader::BitReaderError;
use io::codebook::CodebookError;
}
}
+#[allow(dead_code)]
+struct IPBShuffler {
+ lastframe: Option<NAVideoBuffer<u8>>,
+ nextframe: Option<NAVideoBuffer<u8>>,
+}
+
+impl IPBShuffler {
+ #[allow(dead_code)]
+ fn new() -> Self { IPBShuffler { lastframe: None, nextframe: None } }
+ #[allow(dead_code)]
+ fn clear(&mut self) { self.lastframe = None; self.nextframe = None; }
+ #[allow(dead_code)]
+ fn add_frame(&mut self, buf: NAVideoBuffer<u8>) {
+ mem::swap(&mut self.lastframe, &mut self.nextframe);
+ self.lastframe = Some(buf);
+ }
+ #[allow(dead_code)]
+ fn get_lastref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ if let Some(ref frm) = self.lastframe {
+ Some(frm.clone())
+ } else {
+ None
+ }
+ }
+ #[allow(dead_code)]
+ fn get_nextref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ if let Some(ref frm) = self.nextframe {
+ Some(frm.clone())
+ } else {
+ None
+ }
+ }
+}
+
pub trait NADecoder {
fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()>;
fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef>;