core/scale: fix flipping of packed video buffer
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 5 Oct 2021 13:35:01 +0000 (15:35 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 5 Oct 2021 13:35:01 +0000 (15:35 +0200)
nihav-core/src/scale/mod.rs

index 16c69efa95013e6fc14056a57c26ed9c9c2478a7..b67a62070350eb4180c0505d3028d7127b275f9c 100644 (file)
@@ -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); },
     };