From 70183711cc0dd3e740817a9d26f5c89cff5cb442 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 20 May 2020 18:58:37 +0200 Subject: [PATCH] frmwriter: handle grayscale formats too --- src/frmwriter.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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(); -- 2.39.5