From: Kostya Shishkov Date: Wed, 6 Oct 2021 10:39:31 +0000 (+0200) Subject: rawvideo: calculate stride for packed data properly X-Git-Url: https://git.nihav.org/?p=nihav.git;a=commitdiff_plain;h=7195975811de073ec5df9ab2920f93d4251c9c73 rawvideo: calculate stride for packed data properly --- 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()) };