From 61ce1f48e09824aed7a880ec65f0157f0e464601 Mon Sep 17 00:00:00 2001 From: steschu77 Date: Fri, 7 Nov 2025 16:42:41 +0800 Subject: [PATCH] Use MacroBlock::default() to initialize Vp8Decoder::top --- src/vp8.rs | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/vp8.rs b/src/vp8.rs index a8d48f7..7ed8700 100644 --- a/src/vp8.rs +++ b/src/vp8.rs @@ -529,13 +529,13 @@ impl Vp8Decoder { self.frame.width = w & 0x3FFF; self.frame.height = h & 0x3FFF; - self.top = init_top_macroblocks(self.frame.width as usize); - // Almost always the first macro block, except when non exists (i.e. `width == 0`) - self.left = self.top.first().copied().unwrap_or_default(); - self.mbwidth = self.frame.width.div_ceil(16); self.mbheight = self.frame.height.div_ceil(16); + self.top = vec![MacroBlock::default(); self.mbwidth.into()]; + // Almost always the first macro block, except when non exists (i.e. `width == 0`) + self.left = self.top.first().copied().unwrap_or_default(); + self.frame.ybuf = vec![0u8; usize::from(self.mbwidth) * 16 * usize::from(self.mbheight) * 16]; self.frame.ubuf = vec![0u8; usize::from(self.mbwidth) * 8 * usize::from(self.mbheight) * 8]; @@ -1291,19 +1291,6 @@ impl Vp8Decoder { } } -fn init_top_macroblocks(width: usize) -> Vec { - let mb_width = width.div_ceil(16); - - let mb = MacroBlock { - // Section 11.3 #3 - bpred: [IntraMode::DC; 16], - luma_mode: LumaMode::DC, - ..MacroBlock::default() - }; - - vec![mb; mb_width] -} - // set border fn set_chroma_border( left_border: &mut [u8],