diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2019-04-29 13:37:08 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2019-04-29 13:37:08 +0200 |
commit | 171860fcc4a4ba3ec28bc4b720b9f582377be4cf (patch) | |
tree | 3bc96c0438c95cf25b5f2135221a108ae420d473 /nihav-core/src | |
parent | 70910ac3fdc02c7b7727a4a294f55134e9f5141d (diff) | |
download | nihav-171860fcc4a4ba3ec28bc4b720b9f582377be4cf.tar.gz |
switch NAFrame references to Arc
Diffstat (limited to 'nihav-core/src')
-rw-r--r-- | nihav-core/src/frame.rs | 6 | ||||
-rw-r--r-- | nihav-core/src/test/dec_video.rs | 18 |
2 files changed, 10 insertions, 14 deletions
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<String, NAValue>, } -pub type NAFrameRef = Rc<RefCell<NAFrame>>; +pub type NAFrameRef = Arc<NAFrame>; 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<u64>) { 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<u64>, 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<u64>, 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(); |