From c3f9e0aa13c2a238a88a25e3fab73a7f46075ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 24 Sep 2026 19:32:51 +0300 Subject: [PATCH] fix(decode): size the stretch buffers before the resample scale_i420 asserts exact planes; the stretch buffers were empty Vecs, so the first anamorphic frame died on the destination-luma assertion instead of being stretched. Sized with the rest of the steady-state scratch, once per worker, exactly as is. --- crates/engine/src/decode.rs | 10 ++++++++++ crates/engine/src/export.rs | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/crates/engine/src/decode.rs b/crates/engine/src/decode.rs index fb9e5c3..a3107b2 100644 --- a/crates/engine/src/decode.rs +++ b/crates/engine/src/decode.rs @@ -1335,6 +1335,16 @@ impl Render { // composes on, and a height is never touched by it. let display_width = self.pixel_aspect.width_factor(width); let (sy, su, sv) = &mut self.stretched; + // Sized for `scale_i420`'s exact-planes assertion, once for the + // worker's whole range: steady-state buffers, not per-frame + // allocations ([`turned`]'s reason). + let (dcw, dch) = ( + display_width.div_ceil(2) as usize, + height.div_ceil(2) as usize, + ); + sy.resize(display_width as usize * height as usize, 0); + su.resize(dcw * dch, 0); + sv.resize(dcw * dch, 0); crate::scale::scale_i420( y, u, diff --git a/crates/engine/src/export.rs b/crates/engine/src/export.rs index e869fcb..87290e0 100644 --- a/crates/engine/src/export.rs +++ b/crates/engine/src/export.rs @@ -3308,6 +3308,13 @@ fn place_picture<'a>( (y, u, v, width, height) } else { let display_width = pixel_aspect.width_factor(width); + let (dcw, dch) = ( + display_width.div_ceil(2) as usize, + height.div_ceil(2) as usize, + ); + stretched.0.resize(display_width as usize * height as usize, 0); + stretched.1.resize(dcw * dch, 0); + stretched.2.resize(dcw * dch, 0); crate::scale::scale_i420( y, u,