X-Git-Url: https://git.nihav.org/?p=nihav.git;a=blobdiff_plain;f=nihav-realmedia%2Fsrc%2Fcodecs%2Frv40.rs;h=5f95f0a966fe88ab6c411923d1d7aeef5c00f5e5;hp=62fafba8056c91f0bb0fa8fca5ad96bfb857cda1;hb=e64739f87a35f29be0bbbce366876180ba3eb57e;hpb=01613464323864a655c994820d3c43df1954e3b2 diff --git a/nihav-realmedia/src/codecs/rv40.rs b/nihav-realmedia/src/codecs/rv40.rs index 62fafba..5f95f0a 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, _supp: &mut NADecoderSupport, 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, _supp: &mut NADecoderSupport, 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); @@ -348,9 +352,12 @@ println!("???"); frm.set_pts(Some(ts)); Ok(frm.into_ref()) } + fn flush(&mut self) { + self.dec.flush(); + } } -pub fn get_decoder() -> Box { +pub fn get_decoder() -> Box { Box::new(RealVideo40Decoder::new()) } @@ -359,8 +366,8 @@ mod test { use nihav_core::codecs::RegisteredDecoders; use nihav_core::demuxers::RegisteredDemuxers; use nihav_core::test::dec_video::*; - use crate::codecs::realmedia_register_all_codecs; - use crate::demuxers::realmedia_register_all_demuxers; + use crate::realmedia_register_all_codecs; + use crate::realmedia_register_all_demuxers; #[test] fn test_rv40() { let mut dmx_reg = RegisteredDemuxers::new();