From 2dc4b37d2a21fa8446214a1814437963357e9f59 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 7 Feb 2026 18:33:20 +0100 Subject: [PATCH] videoplayer: pass aligned dimensions to YUV texture update It should be safe since YUV formats should have aligned dimensions already. --- videoplayer/src/videodec.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/videoplayer/src/videodec.rs b/videoplayer/src/videodec.rs index ca9fa62..ea6ca72 100644 --- a/videoplayer/src/videodec.rs +++ b/videoplayer/src/videodec.rs @@ -336,14 +336,15 @@ impl Advance for FrameSkipMode { } fn output_yuv(yuv_texture: &mut Texture, buf: &NAVideoBuffer, width: usize, height: usize) { + let aheight = (height + 1) & !1; let src = buf.get_data(); let ysstride = buf.get_stride(0); - let ysrc = &src[buf.get_offset(0)..][..ysstride * height]; + let ysrc = &src[buf.get_offset(0)..][..ysstride * aheight]; let usstride = buf.get_stride(2); - let usrc = &src[buf.get_offset(2)..][..usstride * (height / 2)]; + let usrc = &src[buf.get_offset(2)..][..usstride * (aheight / 2)]; let vsstride = buf.get_stride(1); - let vsrc = &src[buf.get_offset(1)..][..vsstride * (height / 2)]; - let rect = Some(sdl2::rect::Rect::new(0, 0, width as u32, height as u32)); + let vsrc = &src[buf.get_offset(1)..][..vsstride * (aheight / 2)]; + let rect = Some(sdl2::rect::Rect::new(0, 0, (width as u32 + 1) & !1, aheight as u32)); yuv_texture.update_yuv(rect, ysrc, ysstride, vsrc, vsstride, usrc, usstride) .expect("YUV surface updated"); } -- 2.39.5