X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-core%2Fsrc%2Fframe.rs;h=d219ee45967b180e9174b8b01d1b9c6d44d23022;hb=171860fcc4a4ba3ec28bc4b720b9f582377be4cf;hp=bc3216bd2b3a37a9247f4414caf951be723bf64e;hpb=2422d9699cd56cbb86ac32b3e8dd026e20a89db5;p=nihav.git diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index bc3216b..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 { @@ -739,6 +739,8 @@ pub struct NAStream { tb_den: u32, } +pub type NAStreamRef = Arc; + pub fn reduce_timebase(tb_num: u32, tb_den: u32) -> (u32, u32) { if tb_num == 0 { return (tb_num, tb_den); } if (tb_den % tb_num) == 0 { return (1, tb_den / tb_num); } @@ -769,6 +771,7 @@ impl NAStream { self.tb_num = n; self.tb_den = d; } + pub fn into_ref(self) -> NAStreamRef { Arc::new(self) } } impl fmt::Display for NAStream { @@ -779,7 +782,7 @@ impl fmt::Display for NAStream { #[allow(dead_code)] pub struct NAPacket { - stream: Rc, + stream: NAStreamRef, ts: NATimeInfo, buffer: NABufferRef>, keyframe: bool, @@ -787,12 +790,12 @@ pub struct NAPacket { } impl NAPacket { - pub fn new(str: Rc, ts: NATimeInfo, kf: bool, vec: Vec) -> Self { + pub fn new(str: NAStreamRef, ts: NATimeInfo, kf: bool, vec: Vec) -> Self { // let mut vec: Vec = Vec::new(); // vec.resize(size, 0); NAPacket { stream: str, ts: ts, keyframe: kf, buffer: NABufferRef::new(vec) } } - pub fn get_stream(&self) -> Rc { self.stream.clone() } + pub fn get_stream(&self) -> NAStreamRef { self.stream.clone() } pub fn get_time_information(&self) -> NATimeInfo { self.ts } pub fn get_pts(&self) -> Option { self.ts.get_pts() } pub fn get_dts(&self) -> Option { self.ts.get_dts() }