]> git.nihav.org Git - nihav-tool.git/commitdiff
frmwriter: handle grayscale formats too
authorKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 20 May 2020 16:58:37 +0000 (18:58 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 20 May 2020 16:58:37 +0000 (18:58 +0200)
src/frmwriter.rs

index 5b50b816b20a340bca3f478c9e7f28e24f72c700..71ad491abc60e8bc008c8c6a7b874c79e166c644 100644 (file)
@@ -43,7 +43,8 @@ pub fn write_pgmyuv(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) {
     let stride2 = buf.get_stride(2);
     let u = &dta[base1..][..h2*stride1];
     let v = &dta[base2..][..h2*stride2];
-    if !full_w {
+    let has_chroma = stride1 > 0 && stride2 > 0;
+    if !full_w && has_chroma {
         if !is_flipped {
             for (uline, vline) in u.chunks(stride1).zip(v.chunks(stride2)) {
                 ofile.write_all(&uline[..w2]).unwrap();
@@ -61,7 +62,7 @@ pub fn write_pgmyuv(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) {
                 ofile.write_all(pad.as_slice()).unwrap();
             }
         }
-    } else {
+    } else if has_chroma {
         if !is_flipped {
             for uline in u.chunks(stride1) {
                 ofile.write_all(&uline[..w2]).unwrap();