From 7195975811de073ec5df9ab2920f93d4251c9c73 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 6 Oct 2021 12:39:31 +0200 Subject: [PATCH] rawvideo: calculate stride for packed data properly --- nihav-commonfmt/src/codecs/rawvideo.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nihav-commonfmt/src/codecs/rawvideo.rs b/nihav-commonfmt/src/codecs/rawvideo.rs index fd1c0c3..884f7c9 100644 --- a/nihav-commonfmt/src/codecs/rawvideo.rs +++ b/nihav-commonfmt/src/codecs/rawvideo.rs @@ -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()) }; -- 2.39.5