]> git.nihav.org Git - nihav-player.git/commitdiff
hwdec-vaapi: handle copying data into kodaed chroma planes master
authorKostya Shishkov <kostya.shiskov@gmail.com>
Fri, 27 Jun 2025 05:38:12 +0000 (07:38 +0200)
committerKostya Shishkov <kostya.shiskov@gmail.com>
Fri, 27 Jun 2025 05:38:12 +0000 (07:38 +0200)
For, say, 720x408 frame hardware decoder may report chroma plane width as 368
while destination frame chroma width is merely 360. Assuming width <= stride
leads to panic during copying.

hwdec-vaapi/src/lib.rs

index 3e23a46d7650cc4eb5c4c836ae5ef353210d1716..9dca7b17b69407b2b01d3d3fa2331647568b3dce 100644 (file)
@@ -348,10 +348,11 @@ fn copy_luma(dst: &mut [u8], dstride: usize, src: &[u8], sstride: usize, w: usiz
             );
         }
     } else {
+        let copy_len = dstride.min(w);
         for (dline, sline) in dst.chunks_mut(dstride)
                 .zip(src.chunks(sstride))
                 .take(h) {
-            dline[..w].copy_from_slice(&sline[..w]);
+            dline[..copy_len].copy_from_slice(&sline[..copy_len]);
         }
     }
 }