RealVideo40BR {
width: 0,
height: 0,
- aic_top_cb: aic_top_cb,
- aic_mode1_cb: aic_mode1_cb,
- aic_mode2_cb: aic_mode2_cb,
- ptype_cb: ptype_cb,
- btype_cb: btype_cb,
+ aic_top_cb,
+ aic_mode1_cb,
+ aic_mode2_cb,
+ ptype_cb,
+ btype_cb,
had_skip_run: false,
}
}
- fn predict_b_mv_component(&self, sstate: &SState, mvi: &MVInfo, mbinfo: &Vec<RV34MBInfo>, mbtype: MBType, fwd: bool) -> MV {
+ fn predict_b_mv_component(&self, sstate: &SState, mvi: &MVInfo, mbinfo: &[RV34MBInfo], mbtype: MBType, fwd: bool) -> MV {
let mut pred_mvs: [MV; 3] = [ZERO_MV; 3];
let mut mv_count: usize = 0;
let mb_x = sstate.mb_x;
self.had_skip_run = false;
- Ok(RV34SliceHeader{ ftype: ftype, quant: q, deblock: deblock, pts: pts, width: w, height: h, start: start, end: 0, set_idx: set_idx })
+ Ok(RV34SliceHeader{ ftype, quant: q, deblock, pts, width: w, height: h, start, end: 0, set_idx })
}
fn decode_intra_pred(&mut self, br: &mut BitReader, types: &mut [i8], mut pos: usize, tstride: usize, has_top: bool) -> DecoderResult<()> {
let start;
mbtype = if ftype == FrameType::P { br.read_cb(&self.ptype_cb[idx])? }
else { br.read_cb(&self.btype_cb[idx])? };
}
- Ok(MBInfo { mbtype: mbtype, skip_run: 0, dquant: dquant })
+ Ok(MBInfo { mbtype, skip_run: 0, dquant })
}
- fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], mbinfo: &Vec<RV34MBInfo>) -> (MV, MV) {
+ fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], mbinfo: &[RV34MBInfo]) -> (MV, MV) {
let mut mv_f = self.predict_b_mv_component(sstate, mvi, mbinfo, mbtype, true);
let mut mv_b = self.predict_b_mv_component(sstate, mvi, mbinfo, mbtype, false);
}
impl NADecoder for RealVideo40Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
let fmt = formats::YUV420_FORMAT;
let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(0, 0, false, fmt));
{
println!("edata:");
-for i in 0..src.len() { print!(" {:02X}", src[i]); } println!("");
+for i in 0..src.len() { print!(" {:02X}", src[i]); } println!();
}
if src.len() < 2 { return Err(DecoderError::InvalidData); }
self.bd.width = vinfo.get_width();
self.bd.height = vinfo.get_height();
+
+ supp.pool_u8.set_dec_bufs(3);
+ supp.pool_u8.prealloc_video(NAVideoInfo::new(self.bd.width, self.bd.height, false, fmt), 4)?;
+
Ok(())
} else {
println!("???");
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let src = pkt.get_buffer();
- let (bufinfo, ftype, ts) = self.dec.parse_frame(src.as_slice(), &mut self.bd)?;
+ let (bufinfo, ftype, ts) = self.dec.parse_frame(supp, src.as_slice(), &mut self.bd)?;
let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo);
frm.set_keyframe(ftype == FrameType::I);
frm.set_frame_type(ftype);
frm.set_pts(Some(ts));
- Ok(Rc::new(RefCell::new(frm)))
+ Ok(frm.into_ref())
}
}
-pub fn get_decoder() -> Box<NADecoder> {
+pub fn get_decoder() -> Box<dyn NADecoder> {
Box::new(RealVideo40Decoder::new())
}