From 5737aac9665fb805339937e771003374ac90afb7 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Tue, 5 Oct 2021 15:35:01 +0200 Subject: [PATCH] core/scale: fix flipping of packed video buffer --- nihav-core/src/scale/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nihav-core/src/scale/mod.rs b/nihav-core/src/scale/mod.rs index 16c69ef..b67a620 100644 --- a/nihav-core/src/scale/mod.rs +++ b/nihav-core/src/scale/mod.rs @@ -387,6 +387,15 @@ pub fn flip_picture(pic: &mut NABufferType) -> ScaleResult<()> { let mut line1 = vec![0; stride]; swap_plane(&mut data[off..], stride, h, line0.as_mut_slice(), line1.as_mut_slice()); } + if ncomp == 0 && vb.get_stride(0) != 0 { + let off = vb.get_offset(0); + let stride = vb.get_stride(0); + let (_, h) = vb.get_dimensions(0); + let data = vb.get_data_mut().unwrap(); + let mut line0 = vec![0; stride]; + let mut line1 = vec![0; stride]; + swap_plane(&mut data[off..], stride, h, line0.as_mut_slice(), line1.as_mut_slice()); + } }, _ => { return Err(ScaleError::InvalidArgument); }, }; -- 2.39.5