]> git.nihav.org Git - nihav.git/commitdiff
frame: treat single-channel audio as planar too if possible
authorKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 5 Sep 2018 11:59:24 +0000 (13:59 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 5 Sep 2018 11:59:24 +0000 (13:59 +0200)
src/frame.rs

index 6f22dafc1cdcdc4277704789ad3fbed197f00249..628efb6eb75aff1606a5ea7097a85181b7831148 100644 (file)
@@ -336,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();