X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=src%2Fframe.rs;h=4aaf27251b2be497e43bcbada9f996648b07ade4;hb=b7b96b4cabbde72f05d0464299bf7fdf74d6480c;hp=b6cc9eb3780b0fba47d0f2b40be276e2eef82ca1;hpb=5076115b9a0c4ef344802af408b0e8fe7f7d95fa;p=nihav.git diff --git a/src/frame.rs b/src/frame.rs index b6cc9eb..4aaf272 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -47,6 +47,8 @@ impl NAVideoInfo { pub fn get_height(&self) -> usize { self.height as usize } pub fn is_flipped(&self) -> bool { self.flipped } pub fn get_format(&self) -> NAPixelFormaton { self.format } + pub fn set_width(&mut self, w: usize) { self.width = w; } + pub fn set_height(&mut self, h: usize) { self.height = h; } } impl fmt::Display for NAVideoInfo { @@ -334,7 +336,7 @@ pub fn alloc_video_buffer(vinfo: NAVideoInfo, align: u8) -> Result Result { let mut offs: Vec = Vec::new(); - if ainfo.format.is_planar() { + if ainfo.format.is_planar() || (ainfo.channels == 1 && (ainfo.format.get_bits() % 8) == 0) { let len = nsamples.checked_mul(ainfo.channels as usize); if len == None { return Err(AllocatorError::TooLargeDimensions); } let length = len.unwrap(); @@ -372,7 +374,7 @@ pub fn alloc_audio_buffer(ainfo: NAAudioInfo, nsamples: usize, chmap: NAChannelM let mut data: Vec = Vec::with_capacity(length); data.resize(length, 0); let buf: NAAudioBuffer = NAAudioBuffer { data: Rc::new(RefCell::new(data)), info: ainfo, offs: offs, chmap: chmap, len: nsamples }; - Ok(NABufferType::AudioPacked(buf)) + Ok(NABufferType::AudioPacked(buf)) } }