From: Kostya Shishkov Date: Mon, 29 Apr 2019 11:37:08 +0000 (+0200) Subject: switch NAFrame references to Arc X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=171860fcc4a4ba3ec28bc4b720b9f582377be4cf;p=nihav.git switch NAFrame references to Arc --- diff --git a/nihav-commonfmt/src/codecs/aac.rs b/nihav-commonfmt/src/codecs/aac.rs index 412bc9c..7b3c903 100644 --- a/nihav-commonfmt/src/codecs/aac.rs +++ b/nihav-commonfmt/src/codecs/aac.rs @@ -1251,7 +1251,7 @@ impl NADecoder for AACDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.replace_info(NACodecTypeInfo::Audio(ainfo)), abuf); frm.set_keyframe(true); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-commonfmt/src/codecs/atrac3.rs b/nihav-commonfmt/src/codecs/atrac3.rs index 42fbe8a..9cc7dd4 100644 --- a/nihav-commonfmt/src/codecs/atrac3.rs +++ b/nihav-commonfmt/src/codecs/atrac3.rs @@ -688,7 +688,7 @@ impl NADecoder for Atrac3Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.replace_info(NACodecTypeInfo::Audio(ainfo)), abuf); frm.set_keyframe(true); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-commonfmt/src/codecs/clearvideo.rs b/nihav-commonfmt/src/codecs/clearvideo.rs index d485bdb..ba23148 100644 --- a/nihav-commonfmt/src/codecs/clearvideo.rs +++ b/nihav-commonfmt/src/codecs/clearvideo.rs @@ -726,7 +726,7 @@ impl NADecoder for ClearVideoDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), NABufferType::None); frm.set_keyframe(false); frm.set_frame_type(FrameType::Skip); - return Ok(Rc::new(RefCell::new(frm))); + return Ok(frm.into_ref()); } let is_intra = (src[off] & 2) == 2; @@ -757,7 +757,7 @@ impl NADecoder for ClearVideoDecoder { } else { frm.set_frame_type(FrameType::P); } - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-commonfmt/src/codecs/pcm.rs b/nihav-commonfmt/src/codecs/pcm.rs index 132d4c3..00f5c31 100644 --- a/nihav-commonfmt/src/codecs/pcm.rs +++ b/nihav-commonfmt/src/codecs/pcm.rs @@ -51,7 +51,7 @@ impl NADecoder for PCMDecoder { let mut frm = NAFrame::new_from_pkt(pkt, info, NABufferType::AudioPacked(abuf)); frm.set_duration(Some(duration)); frm.set_keyframe(true); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } else { Err(DecoderError::InvalidData) } diff --git a/nihav-commonfmt/src/codecs/sipro.rs b/nihav-commonfmt/src/codecs/sipro.rs index 05e6816..88b525e 100644 --- a/nihav-commonfmt/src/codecs/sipro.rs +++ b/nihav-commonfmt/src/codecs/sipro.rs @@ -729,7 +729,7 @@ impl NADecoder for SiproDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), abuf); frm.set_keyframe(true); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-commonfmt/src/codecs/ts102366.rs b/nihav-commonfmt/src/codecs/ts102366.rs index f17b431..a4d4570 100644 --- a/nihav-commonfmt/src/codecs/ts102366.rs +++ b/nihav-commonfmt/src/codecs/ts102366.rs @@ -1235,7 +1235,7 @@ impl NADecoder for AudioDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.replace_info(NACodecTypeInfo::Audio(ainfo)), abuf); frm.set_keyframe(true); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index d97850b..d219ee4 100644 --- a/nihav-core/src/frame.rs +++ b/nihav-core/src/frame.rs @@ -1,8 +1,6 @@ use std::cmp::max; use std::collections::HashMap; use std::fmt; -pub use std::rc::Rc; -pub use std::cell::*; use std::sync::Arc; pub use crate::formats::*; pub use crate::refs::*; @@ -653,7 +651,7 @@ pub struct NAFrame { options: HashMap, } -pub type NAFrameRef = Rc>; +pub type NAFrameRef = Arc; fn get_plane_size(info: &NAVideoInfo, idx: usize) -> (usize, usize) { let chromaton = info.get_format().get_chromaton(idx); @@ -687,6 +685,8 @@ impl NAFrame { pub fn set_duration(&mut self, dur: Option) { self.ts.set_duration(dur); } pub fn get_buffer(&self) -> NABufferType { self.buffer.clone() } + + pub fn into_ref(self) -> NAFrameRef { Arc::new(self) } } impl fmt::Display for NAFrame { diff --git a/nihav-core/src/test/dec_video.rs b/nihav-core/src/test/dec_video.rs index 2c16b3d..538a0ef 100644 --- a/nihav-core/src/test/dec_video.rs +++ b/nihav-core/src/test/dec_video.rs @@ -6,8 +6,7 @@ use crate::demuxers::*; //use crate::io::byteio::*; use super::wavwriter::WavWriter; -fn write_pgmyuv(pfx: &str, strno: usize, num: u64, frmref: NAFrameRef) { - let frm = frmref.borrow(); +fn write_pgmyuv(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) { if let NABufferType::None = frm.get_buffer() { return; } let name = format!("assets/{}out{:02}_{:06}.pgm", pfx, strno, num); let mut ofile = File::create(name).unwrap(); @@ -90,8 +89,7 @@ fn write_pgmyuv(pfx: &str, strno: usize, num: u64, frmref: NAFrameRef) { } } -fn write_palppm(pfx: &str, strno: usize, num: u64, frmref: NAFrameRef) { - let frm = frmref.borrow(); +fn write_palppm(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) { let name = format!("assets/{}out{:02}_{:06}.ppm", pfx, strno, num); let mut ofile = File::create(name).unwrap(); let buf = frm.get_buffer().get_vbuf().unwrap(); @@ -122,8 +120,7 @@ fn write_palppm(pfx: &str, strno: usize, num: u64, frmref: NAFrameRef) { } } -fn write_ppm(pfx: &str, strno: usize, num: u64, frmref: NAFrameRef) { - let frm = frmref.borrow(); +fn write_ppm(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) { let name = format!("assets/{}out{:02}_{:06}.ppm", pfx, strno, num); let mut ofile = File::create(name).unwrap(); if let NABufferType::VideoPacked(ref buf) = frm.get_buffer() { @@ -237,10 +234,10 @@ pub fn test_file_decoding(demuxer: &str, name: &str, limit: Option, let streamno = pkt.get_stream().get_id() as usize; if let Some(ref mut dec) = decs[streamno] { let frm = dec.decode(&pkt).unwrap(); - if pkt.get_stream().get_info().is_video() && video_pfx.is_some() && frm.borrow().get_frame_type() != FrameType::Skip { + if pkt.get_stream().get_info().is_video() && video_pfx.is_some() && frm.get_frame_type() != FrameType::Skip { let pfx = video_pfx.unwrap(); - let pts = if let Some(fpts) = frm.borrow().get_pts() { fpts } else { pkt.get_pts().unwrap() }; - let vinfo = frm.borrow().get_buffer().get_video_info().unwrap(); + let pts = if let Some(fpts) = frm.get_pts() { fpts } else { pkt.get_pts().unwrap() }; + let vinfo = frm.get_buffer().get_video_info().unwrap(); if vinfo.get_format().is_paletted() { write_palppm(pfx, streamno, pts, frm); } else if vinfo.get_format().get_model().is_yuv() { @@ -300,8 +297,7 @@ pub fn test_decode_audio(demuxer: &str, name: &str, limit: Option, audio_pf } let streamno = pkt.get_stream().get_id() as usize; if let Some(ref mut dec) = decs[streamno] { - let frm_ = dec.decode(&pkt).unwrap(); - let frm = frm_.borrow(); + let frm = dec.decode(&pkt).unwrap(); if frm.get_info().is_audio() { if !wrote_header { wwr.write_header(frm.get_info().as_ref().get_properties().get_audio_info().unwrap()).unwrap(); diff --git a/nihav-duck/src/codecs/dkadpcm.rs b/nihav-duck/src/codecs/dkadpcm.rs index 0104b30..9ff5ed9 100644 --- a/nihav-duck/src/codecs/dkadpcm.rs +++ b/nihav-duck/src/codecs/dkadpcm.rs @@ -158,7 +158,7 @@ impl NADecoder for DuckADPCMDecoder { let mut frm = NAFrame::new_from_pkt(pkt, info, abuf); frm.set_duration(Some(duration as u64)); frm.set_keyframe(false); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } else { Err(DecoderError::InvalidData) } diff --git a/nihav-duck/src/codecs/truemotion1.rs b/nihav-duck/src/codecs/truemotion1.rs index 2c8e5d2..b8edd4e 100644 --- a/nihav-duck/src/codecs/truemotion1.rs +++ b/nihav-duck/src/codecs/truemotion1.rs @@ -578,7 +578,7 @@ impl NADecoder for TM1Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), NABufferType::None); frm.set_keyframe(false); frm.set_frame_type(FrameType::Skip); - return Ok(Rc::new(RefCell::new(frm))); + return Ok(frm.into_ref()); } let compr_info = cinfo.unwrap(); let is_24bit = !is_sprite && compr_info.is_24bit; @@ -656,7 +656,7 @@ impl NADecoder for TM1Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(is_intra || is_sprite); frm.set_frame_type(if is_intra { FrameType::I } else { FrameType::P }); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-duck/src/codecs/truemotion2.rs b/nihav-duck/src/codecs/truemotion2.rs index e822545..1c91640 100644 --- a/nihav-duck/src/codecs/truemotion2.rs +++ b/nihav-duck/src/codecs/truemotion2.rs @@ -585,7 +585,7 @@ impl NADecoder for TM2Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(is_intra); frm.set_frame_type(if is_intra { FrameType::I } else { FrameType::P }); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-duck/src/codecs/truemotion2x.rs b/nihav-duck/src/codecs/truemotion2x.rs index fce5fb3..560ab6a 100644 --- a/nihav-duck/src/codecs/truemotion2x.rs +++ b/nihav-duck/src/codecs/truemotion2x.rs @@ -688,7 +688,7 @@ impl NADecoder for TM2XDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(self.is_intra); frm.set_frame_type(if self.is_intra { FrameType::I } else { FrameType::P }); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-duck/src/codecs/truemotionrt.rs b/nihav-duck/src/codecs/truemotionrt.rs index 12548ef..a96d609 100644 --- a/nihav-duck/src/codecs/truemotionrt.rs +++ b/nihav-duck/src/codecs/truemotionrt.rs @@ -80,7 +80,7 @@ impl NADecoder for TMRTDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(true); frm.set_frame_type(FrameType::I); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-game/src/codecs/bmv.rs b/nihav-game/src/codecs/bmv.rs index 79b8745..6712ce2 100644 --- a/nihav-game/src/codecs/bmv.rs +++ b/nihav-game/src/codecs/bmv.rs @@ -220,7 +220,7 @@ impl NADecoder for BMVVideoDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(is_intra); frm.set_frame_type(if is_intra { FrameType::I } else { FrameType::P }); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } @@ -294,7 +294,7 @@ impl NADecoder for BMVAudioDecoder { let mut frm = NAFrame::new_from_pkt(pkt, info, abuf); frm.set_duration(Some(samples as u64)); frm.set_keyframe(false); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } else { Err(DecoderError::InvalidData) } diff --git a/nihav-game/src/codecs/bmv3.rs b/nihav-game/src/codecs/bmv3.rs index 687ca23..2cd0b2b 100644 --- a/nihav-game/src/codecs/bmv3.rs +++ b/nihav-game/src/codecs/bmv3.rs @@ -504,7 +504,7 @@ impl NADecoder for BMV3VideoDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(self.is_intra); frm.set_frame_type(if self.is_intra { FrameType::I } else { FrameType::P }); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } @@ -591,7 +591,7 @@ impl NADecoder for BMV3AudioDecoder { let mut frm = NAFrame::new_from_pkt(pkt, info, abuf); frm.set_duration(Some(samples as u64)); frm.set_keyframe(false); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } else { Err(DecoderError::InvalidData) } diff --git a/nihav-game/src/codecs/gremlinvideo.rs b/nihav-game/src/codecs/gremlinvideo.rs index cf7f7b1..c7bdaf9 100644 --- a/nihav-game/src/codecs/gremlinvideo.rs +++ b/nihav-game/src/codecs/gremlinvideo.rs @@ -429,12 +429,12 @@ impl NADecoder for GremlinVideoDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), NABufferType::None); frm.set_keyframe(false); frm.set_frame_type(FrameType::Skip); - return Ok(Rc::new(RefCell::new(frm))) + return Ok(frm.into_ref()) } else if cmethod == 3 { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), NABufferType::None); frm.set_keyframe(false); frm.set_frame_type(FrameType::Skip); - return Ok(Rc::new(RefCell::new(frm))) + return Ok(frm.into_ref()) } else if cmethod == 2 { self.decode_method2(&mut br)?; } else if cmethod == 5 { @@ -456,7 +456,7 @@ impl NADecoder for GremlinVideoDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(is_intra); frm.set_frame_type(if is_intra { FrameType::I } else { FrameType::P }); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } @@ -545,7 +545,7 @@ impl NADecoder for GremlinAudioDecoder { let mut frm = NAFrame::new_from_pkt(pkt, info, abuf); frm.set_duration(Some(samples as u64)); frm.set_keyframe(false); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } else { Err(DecoderError::InvalidData) } diff --git a/nihav-game/src/codecs/vmd.rs b/nihav-game/src/codecs/vmd.rs index dc831c4..a1e71ed 100644 --- a/nihav-game/src/codecs/vmd.rs +++ b/nihav-game/src/codecs/vmd.rs @@ -264,7 +264,7 @@ impl NADecoder for VMDVideoDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), NABufferType::Video(buf)); frm.set_keyframe(is_intra); frm.set_frame_type(if is_intra { FrameType::I } else { FrameType::P }); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } @@ -433,7 +433,7 @@ impl NADecoder for VMDAudioDecoder { let mut frm = NAFrame::new_from_pkt(pkt, info, abuf); frm.set_duration(Some(samples as u64)); frm.set_keyframe(true); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } else { Err(DecoderError::InvalidData) } diff --git a/nihav-indeo/src/codecs/imc.rs b/nihav-indeo/src/codecs/imc.rs index ceac0d1..5f1390a 100644 --- a/nihav-indeo/src/codecs/imc.rs +++ b/nihav-indeo/src/codecs/imc.rs @@ -920,7 +920,7 @@ impl NADecoder for IMCDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), abuf); frm.set_keyframe(true); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-indeo/src/codecs/indeo2.rs b/nihav-indeo/src/codecs/indeo2.rs index 5ea8b3f..d110dc8 100644 --- a/nihav-indeo/src/codecs/indeo2.rs +++ b/nihav-indeo/src/codecs/indeo2.rs @@ -343,7 +343,7 @@ impl NADecoder for Indeo2Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(true); frm.set_frame_type(FrameType::I); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } else { let bufret = self.frmmgr.clone_ref(); if let None = bufret { return Err(DecoderError::MissingReference); } @@ -356,7 +356,7 @@ impl NADecoder for Indeo2Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), NABufferType::Video(buf)); frm.set_keyframe(false); frm.set_frame_type(FrameType::P); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } } diff --git a/nihav-indeo/src/codecs/indeo3.rs b/nihav-indeo/src/codecs/indeo3.rs index ebf941c..eaef84b 100644 --- a/nihav-indeo/src/codecs/indeo3.rs +++ b/nihav-indeo/src/codecs/indeo3.rs @@ -783,7 +783,7 @@ impl NADecoder for Indeo3Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(intraframe); frm.set_frame_type(if intraframe { FrameType::I } else { FrameType::P }); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-indeo/src/codecs/indeo4.rs b/nihav-indeo/src/codecs/indeo4.rs index 07f6d67..9ee3a41 100644 --- a/nihav-indeo/src/codecs/indeo4.rs +++ b/nihav-indeo/src/codecs/indeo4.rs @@ -453,7 +453,7 @@ impl NADecoder for Indeo4Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(self.dec.is_intra()); frm.set_frame_type(self.dec.get_frame_type()); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-indeo/src/codecs/indeo5.rs b/nihav-indeo/src/codecs/indeo5.rs index 1f77081..faa3107 100644 --- a/nihav-indeo/src/codecs/indeo5.rs +++ b/nihav-indeo/src/codecs/indeo5.rs @@ -528,7 +528,7 @@ impl NADecoder for Indeo5Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(self.dec.is_intra()); frm.set_frame_type(self.dec.get_frame_type()); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-indeo/src/codecs/intel263.rs b/nihav-indeo/src/codecs/intel263.rs index 3b95c5f..7afee94 100644 --- a/nihav-indeo/src/codecs/intel263.rs +++ b/nihav-indeo/src/codecs/intel263.rs @@ -393,7 +393,7 @@ impl NADecoder for Intel263Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), buftype); frm.set_keyframe(false); frm.set_frame_type(if is_skip { FrameType::Skip } else { FrameType::B }); - return Ok(Rc::new(RefCell::new(frm))); + return Ok(frm.into_ref()); } let mut ibr = Intel263BR::new(&src, &self.tables); @@ -402,7 +402,7 @@ impl NADecoder for Intel263Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(self.dec.is_intra()); frm.set_frame_type(if self.dec.is_intra() { FrameType::I } else { FrameType::P }); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-indeo/src/codecs/ivibr.rs b/nihav-indeo/src/codecs/ivibr.rs index b5fa291..edeec46 100644 --- a/nihav-indeo/src/codecs/ivibr.rs +++ b/nihav-indeo/src/codecs/ivibr.rs @@ -1,6 +1,6 @@ use std::mem; use std::rc::Rc; -use std::cell::{Ref,RefCell}; +pub use std::cell::{Ref,RefCell}; use nihav_core::io::bitreader::*; //use io::intcode::*; use nihav_core::codecs::*; diff --git a/nihav-rad/src/codecs/bink2.rs b/nihav-rad/src/codecs/bink2.rs index 60d42a4..d57f8bd 100644 --- a/nihav-rad/src/codecs/bink2.rs +++ b/nihav-rad/src/codecs/bink2.rs @@ -1933,7 +1933,7 @@ impl NADecoder for Bink2Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_frame_type(if self.key_frame { FrameType::I } else { FrameType::P }); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-rad/src/codecs/binkaud.rs b/nihav-rad/src/codecs/binkaud.rs index 182c6c9..3d7568c 100644 --- a/nihav-rad/src/codecs/binkaud.rs +++ b/nihav-rad/src/codecs/binkaud.rs @@ -268,7 +268,7 @@ impl NADecoder for BinkAudioDecoder { let mut frm = NAFrame::new_from_pkt(pkt, info, abuf); frm.set_duration(Some(self.duration as u64)); frm.set_keyframe(false); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } else { Err(DecoderError::InvalidData) } diff --git a/nihav-rad/src/codecs/binkvid.rs b/nihav-rad/src/codecs/binkvid.rs index 2f95ed6..3a0b496 100644 --- a/nihav-rad/src/codecs/binkvid.rs +++ b/nihav-rad/src/codecs/binkvid.rs @@ -1260,7 +1260,7 @@ println!("decode frame {} b={} i={}", pkt.get_pts().unwrap(), self.is_ver_b, sel let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_frame_type(FrameType::P); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-rad/src/codecs/smacker.rs b/nihav-rad/src/codecs/smacker.rs index bc27ab0..9ed2a9f 100644 --- a/nihav-rad/src/codecs/smacker.rs +++ b/nihav-rad/src/codecs/smacker.rs @@ -465,7 +465,7 @@ impl NADecoder for SmackerVideoDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(is_intra); frm.set_frame_type(ftype); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } @@ -514,7 +514,7 @@ impl NADecoder for SmackerAudioDecoder { if !br.read_bool()? { let mut frm = NAFrame::new_from_pkt(pkt, info.clone(), NABufferType::None); frm.set_frame_type(FrameType::Skip); - return Ok(Rc::new(RefCell::new(frm))); + return Ok(frm.into_ref()); } let stereo = br.read_bool()?; let bits16 = br.read_bool()?; @@ -586,7 +586,7 @@ impl NADecoder for SmackerAudioDecoder { let mut frm = NAFrame::new_from_pkt(pkt, info, abuf); frm.set_duration(Some(samples as u64)); frm.set_keyframe(false); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } else { Err(DecoderError::InvalidData) } diff --git a/nihav-realmedia/src/codecs/cook.rs b/nihav-realmedia/src/codecs/cook.rs index 6303724..b954bd7 100644 --- a/nihav-realmedia/src/codecs/cook.rs +++ b/nihav-realmedia/src/codecs/cook.rs @@ -668,7 +668,7 @@ impl NADecoder for CookDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.replace_info(NACodecTypeInfo::Audio(ainfo)), abuf); frm.set_keyframe(true); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-realmedia/src/codecs/ra144.rs b/nihav-realmedia/src/codecs/ra144.rs index 38d76c3..07d234a 100644 --- a/nihav-realmedia/src/codecs/ra144.rs +++ b/nihav-realmedia/src/codecs/ra144.rs @@ -305,7 +305,7 @@ impl NADecoder for RA144Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), abuf); frm.set_keyframe(true); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-realmedia/src/codecs/ra288.rs b/nihav-realmedia/src/codecs/ra288.rs index 142cf2a..dbb7f90 100644 --- a/nihav-realmedia/src/codecs/ra288.rs +++ b/nihav-realmedia/src/codecs/ra288.rs @@ -195,7 +195,7 @@ impl NADecoder for RA288Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), abuf); frm.set_keyframe(true); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-realmedia/src/codecs/ralf.rs b/nihav-realmedia/src/codecs/ralf.rs index 307436c..b8a06d1 100644 --- a/nihav-realmedia/src/codecs/ralf.rs +++ b/nihav-realmedia/src/codecs/ralf.rs @@ -417,7 +417,7 @@ impl NADecoder for RALFDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.replace_info(NACodecTypeInfo::Audio(ainfo)), NABufferType::None); frm.set_frame_type(FrameType::Skip); - return Ok(Rc::new(RefCell::new(frm))); + return Ok(frm.into_ref()); } src_len = pktbuf.len(); } @@ -465,7 +465,7 @@ impl NADecoder for RALFDecoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.replace_info(NACodecTypeInfo::Audio(ainfo)), abuf); frm.set_keyframe(true); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-realmedia/src/codecs/rv10.rs b/nihav-realmedia/src/codecs/rv10.rs index 1d93a01..733b677 100644 --- a/nihav-realmedia/src/codecs/rv10.rs +++ b/nihav-realmedia/src/codecs/rv10.rs @@ -447,7 +447,7 @@ println!("???"); let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(self.dec.is_intra()); frm.set_frame_type(if self.dec.is_intra() { FrameType::I } else { FrameType::P }); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-realmedia/src/codecs/rv20.rs b/nihav-realmedia/src/codecs/rv20.rs index 36ccc67..44386f6 100644 --- a/nihav-realmedia/src/codecs/rv20.rs +++ b/nihav-realmedia/src/codecs/rv20.rs @@ -501,7 +501,7 @@ impl NADecoder for RealVideo20Decoder { let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo); frm.set_keyframe(self.dec.is_intra()); frm.set_frame_type(self.dec.get_frame_type()); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } } diff --git a/nihav-realmedia/src/codecs/rv30.rs b/nihav-realmedia/src/codecs/rv30.rs index a2d7090..7ec3cb2 100644 --- a/nihav-realmedia/src/codecs/rv30.rs +++ b/nihav-realmedia/src/codecs/rv30.rs @@ -153,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()) } } diff --git a/nihav-realmedia/src/codecs/rv40.rs b/nihav-realmedia/src/codecs/rv40.rs index eb45164..482d856 100644 --- a/nihav-realmedia/src/codecs/rv40.rs +++ b/nihav-realmedia/src/codecs/rv40.rs @@ -346,7 +346,7 @@ println!("???"); 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()) } } diff --git a/nihav-realmedia/src/codecs/rv60.rs b/nihav-realmedia/src/codecs/rv60.rs index 4adbe39..82dce04 100644 --- a/nihav-realmedia/src/codecs/rv60.rs +++ b/nihav-realmedia/src/codecs/rv60.rs @@ -1458,7 +1458,7 @@ println!("???"); frm.set_keyframe(hdr.ftype == FrameType::I); frm.set_pts(Some(hdr.ts as u64)); frm.set_frame_type(hdr.ftype); - Ok(Rc::new(RefCell::new(frm))) + Ok(frm.into_ref()) } }