X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-realmedia%2Fsrc%2Fcodecs%2Frv30.rs;h=95e619090861b5392e7c042b39438e99d47b1d31;hb=01613464323864a655c994820d3c43df1954e3b2;hp=348209099444514646fbb611a1fe7c08e77e18e7;hpb=5641dccfbf2a70d589cf094a0d4ed5a10f919f00;p=nihav.git diff --git a/nihav-realmedia/src/codecs/rv30.rs b/nihav-realmedia/src/codecs/rv30.rs index 3482090..95e6190 100644 --- a/nihav-realmedia/src/codecs/rv30.rs +++ b/nihav-realmedia/src/codecs/rv30.rs @@ -1,5 +1,3 @@ -use std::rc::Rc; -use std::cell::RefCell; use nihav_core::formats; use nihav_core::io::bitreader::*; use nihav_core::io::intcode::*; @@ -104,7 +102,7 @@ impl RV34BitstreamDecoder for RealVideo30BR { struct RealVideo30Decoder { bd: RealVideo30BR, - info: Rc, + info: NACodecInfoRef, dec: RV34Decoder, } @@ -112,18 +110,18 @@ impl RealVideo30Decoder { fn new() -> Self { RealVideo30Decoder{ bd: RealVideo30BR::new(), - info: Rc::new(DUMMY_CODEC_INFO), + info: NACodecInfoRef::default(), dec: RV34Decoder::new(true, Box::new(RV30DSP::new())), } } } impl NADecoder for RealVideo30Decoder { - fn init(&mut self, info: Rc) -> 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)); - self.info = Rc::new(NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata())); + self.info = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref(); let edata = info.get_extradata().unwrap(); let src: &[u8] = &edata; @@ -146,7 +144,7 @@ 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, pts) = self.dec.parse_frame(src.as_slice(), &mut self.bd)?; @@ -155,7 +153,7 @@ println!("???"); frm.set_keyframe(ftype == FrameType::I); frm.set_pts(Some(pts)); frm.set_frame_type(ftype);//if ftype == FrameType::B { FrameType::Skip } else { ftype } ); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } @@ -165,11 +163,20 @@ pub fn get_decoder() -> Box { #[cfg(test)] mod test { - use crate::test::dec_video::test_file_decoding; + 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; #[test] fn test_rv30() { + let mut dmx_reg = RegisteredDemuxers::new(); + realmedia_register_all_demuxers(&mut dmx_reg); + let mut dec_reg = RegisteredDecoders::new(); + realmedia_register_all_codecs(&mut dec_reg); + // test_file_decoding("realmedia", "assets/RV/rv30_chroma_drift.rm", Some(1000), true, false, /*None*/Some("rv30")); - test_file_decoding("realmedia", "assets/RV/rv30_weighted_mc.rm", Some(400), true, false, None/*Some("rv30")*/); + test_file_decoding("realmedia", "assets/RV/rv30_weighted_mc.rm", Some(400), true, false, None/*Some("rv30")*/, &dmx_reg, &dec_reg); // test_file_decoding("realmedia", "assets/RV/simpsons-clip.rm", Some(1337)/*Some(6666)*/, true, false, /*None*/Some("rv30")); //panic!("end"); }