]> git.nihav.org Git - nihav.git/blobdiff - src/frame.rs
remove panics in working tests
[nihav.git] / src / frame.rs
index b6cc9eb3780b0fba47d0f2b40be276e2eef82ca1..628efb6eb75aff1606a5ea7097a85181b7831148 100644 (file)
@@ -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<NABufferType,
 
 pub fn alloc_audio_buffer(ainfo: NAAudioInfo, nsamples: usize, chmap: NAChannelMap) -> Result<NABufferType, AllocatorError> {
     let mut offs: Vec<usize> = 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();