X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-realmedia%2Fsrc%2Fcodecs%2Frv40.rs;h=7586aae78c3b8a000ace07942faaa9f71cedcb2b;hb=e07387c7f125550a41faf36a509b252cf71d7f9a;hp=482d85680036ee0d8134f11d3c6c7bf444e85d1d;hpb=171860fcc4a4ba3ec28bc4b720b9f582377be4cf;p=nihav.git diff --git a/nihav-realmedia/src/codecs/rv40.rs b/nihav-realmedia/src/codecs/rv40.rs index 482d856..7586aae 100644 --- a/nihav-realmedia/src/codecs/rv40.rs +++ b/nihav-realmedia/src/codecs/rv40.rs @@ -97,15 +97,15 @@ impl RealVideo40BR { 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, 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; @@ -192,7 +192,7 @@ impl RV34BitstreamDecoder for RealVideo40BR { 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; @@ -276,9 +276,9 @@ impl RV34BitstreamDecoder for RealVideo40BR { 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) -> (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); @@ -314,7 +314,7 @@ impl RealVideo40Decoder { } 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)); @@ -325,22 +325,26 @@ impl NADecoder for RealVideo40Decoder { { 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 { + fn decode(&mut self, supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult { 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); @@ -350,7 +354,7 @@ println!("???"); } } -pub fn get_decoder() -> Box { +pub fn get_decoder() -> Box { Box::new(RealVideo40Decoder::new()) }