From: Kostya Shishkov Date: Wed, 20 May 2020 16:58:37 +0000 (+0200) Subject: frmwriter: handle grayscale formats too X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=70183711cc0dd3e740817a9d26f5c89cff5cb442;p=nihav-tool.git frmwriter: handle grayscale formats too --- diff --git a/src/frmwriter.rs b/src/frmwriter.rs index 5b50b81..71ad491 100644 --- a/src/frmwriter.rs +++ b/src/frmwriter.rs @@ -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();