]> git.nihav.org Git - nihav.git/commitdiff
rawvideo: calculate stride for packed data properly
authorKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 6 Oct 2021 10:39:31 +0000 (12:39 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 6 Oct 2021 10:39:31 +0000 (12:39 +0200)
nihav-commonfmt/src/codecs/rawvideo.rs

index fd1c0c3c65590acafc380f7eeddb431b00383ebb..884f7c9a6f4a54fa6d663e884aabc86bfb960eee 100644 (file)
@@ -59,8 +59,12 @@ impl NADecoder for RawDecoder {
 
                     NABufferType::Video(NAVideoBuffer::from_raw_parts(vinfo.clone(), src.clone(), offs, strides).into_ref())
                 } else {
-                    let offs    = vec![0; ncomp];
-                    let strides = vec![0; ncomp];
+                    let esize = vinfo.format.elem_size as usize;
+                    let ychr = vinfo.format.get_chromaton(0).unwrap();
+                    let ystep = if ychr.next_elem != 0 { ychr.next_elem as usize } else { esize };
+                    let stride = (width * esize + ystep - 1) / ystep;
+                    let offs    = vec![0];
+                    let strides = vec![stride];
                     NABufferType::VideoPacked(NAVideoBuffer::from_raw_parts(vinfo.clone(), src.clone(), offs, strides).into_ref())
                 };