forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-blockmem' (43f29bb0): skipped blocks describe themselves through the static zero residual instead of allocating zero grids, the all-zero marker skips the coefficient arena copy, recon op list keeps its capacity across superblocks, prediction buffers refilled in place; byte-exact, -1.6% instructions at the composed setting

Browse files at this commit

cb9db45b4f17fcb4025f189b132c54f116d9aa41Ahmet Kaan GümüşParent: afb2b38e1f00c9
crates/ec-av1/src/decode.rsmodified+137 -101
@@ -2149,6 +2149,12 @@ impl Residual {
2149 /// A residual the parse thread already transformed, kept in the arena2149 /// A residual the parse thread already transformed, kept in the arena
2150 /// instead of its own `Vec`.2150 /// instead of its own `Vec`.
2151 fn done(residual: &[i32], fctx: &crate::decode::FrameCtx) -> Self {2151 fn done(residual: &[i32], fctx: &crate::decode::FrameCtx) -> Self {
2152+ // lane-blockmem: a skipped block hands over [`ZERO_RESIDUAL`] itself,
2153+ // which is exactly the all-zero marker -- one pointer compare instead
2154+ // of copying up to 64 KB of zeros into the arena per block.
2155+ if std::ptr::eq(residual.as_ptr(), ZERO_RESIDUAL.as_ptr()) {
2156+ return Self::Done(0, 0);
2157+ }
2152 Self::Done(push_coeffs(residual, fctx), residual.len() as u32)2158 Self::Done(push_coeffs(residual, fctx), residual.len() as u32)
2153 }2159 }
2154 2160
@@ -2269,7 +2275,11 @@ pub(crate) struct PredBuild(
2269 &mut PlaneBuf<'static>,2275 &mut PlaneBuf<'static>,
2270 &mut PlaneBuf<'static>,2276 &mut PlaneBuf<'static>,
2271 &crate::decode::FrameCtx,2277 &crate::decode::FrameCtx,
2272- ) -> [Vec<u16>; 3],2278+ // lane-blockmem: the previous block's three prediction buffers,
2279+ // refilled in place -- the build used to return three fresh
2280+ // `Vec`s per block and drop these.
2281+ &mut [Vec<u16>; 3],
2282+ ),
2273 >,2283 >,
2274 );2284 );
2275 2285
@@ -2284,6 +2294,21 @@ fn recon_deferred(fctx: &crate::decode::FrameCtx) -> bool {
2284 fctx.recon_planes.with(std::cell::Cell::get).is_none()2294 fctx.recon_planes.with(std::cell::Cell::get).is_none()
2285 }2295 }
2286 2296
2297+/// The previous block's prediction buffer, cleared and zero-filled to `n`
2298+/// (lane-blockmem): the same bytes the `vec![0u16; n]` it replaces produced,
2299+/// without the per-block allocation and free.
2300+fn refill(mut v: Vec<u16>, n: usize) -> Vec<u16> {
2301+ // A buffer that has to grow anyway is cheaper allocated zeroed (`calloc`)
2302+ // than resized element by element -- which is every block on the inline
2303+ // path, where there is no previous buffer to reuse.
2304+ if v.capacity() < n {
2305+ return vec![0u16; n];
2306+ }
2307+ v.clear();
2308+ v.resize(n, 0);
2309+ v
2310+}
2311+
2287 /// Records one block's prediction build for the worker that reconstructs it.2312 /// Records one block's prediction build for the worker that reconstructs it.
2288 #[allow(unsafe_code)]2313 #[allow(unsafe_code)]
2289 fn push_pred<'a>(2314 fn push_pred<'a>(
@@ -2293,17 +2318,16 @@ fn push_pred<'a>(
2293 &mut PlaneBuf<'static>,2318 &mut PlaneBuf<'static>,
2294 &mut PlaneBuf<'static>,2319 &mut PlaneBuf<'static>,
2295 &crate::decode::FrameCtx,2320 &crate::decode::FrameCtx,
2296- ) -> [Vec<u16>; 3]2321+ &mut [Vec<u16>; 3],
2297- + 'a,2322+ ) + 'a,
2298 ) {2323 ) {
2299- type Built = [Vec<u16>; 3];
2300 type Dyn<'x> = dyn FnOnce(2324 type Dyn<'x> = dyn FnOnce(
2301 &mut PlaneBuf<'static>,2325 &mut PlaneBuf<'static>,
2302 &mut PlaneBuf<'static>,2326 &mut PlaneBuf<'static>,
2303 &mut PlaneBuf<'static>,2327 &mut PlaneBuf<'static>,
2304 &crate::decode::FrameCtx,2328 &crate::decode::FrameCtx,
2305- ) -> Built2329+ &mut [Vec<u16>; 3],
2306- + 'x;2330+ ) + 'x;
2307 let boxed: Box<Dyn<'a>> = Box::new(f);2331 let boxed: Box<Dyn<'a>> = Box::new(f);
2308 // SAFETY: see [`PredBuild`] -- every worker is joined by [`WaveGuard`]2332 // SAFETY: see [`PredBuild`] -- every worker is joined by [`WaveGuard`]
2309 // before the borrows the closure holds go out of scope.2333 // before the borrows the closure holds go out of scope.
@@ -2717,7 +2741,15 @@ impl Drop for WaveGuard<'_> {
2717 fn wave_submit(fctx: &crate::decode::FrameCtx, r: usize, c: usize) -> bool {2741 fn wave_submit(fctx: &crate::decode::FrameCtx, r: usize, c: usize) -> bool {
2718 let st = fctx.wave.with(|w| w.borrow().clone());2742 let st = fctx.wave.with(|w| w.borrow().clone());
2719 let Some(st) = st else { return false };2743 let Some(st) = st else { return false };
2720- let ops = fctx.recon_ops.with(|c| std::mem::take(&mut *c.borrow_mut()));2744+ // lane-blockmem: the op list is replaced sized for the next superblock,
2745+ // exactly as the two arenas below are -- taking it left a zero-capacity
2746+ // `Vec` that regrew (and memmoved every recorded op) from nothing on
2747+ // every superblock.
2748+ let ops = fctx.recon_ops.with(|c| {
2749+ let mut c = c.borrow_mut();
2750+ let cap = c.len();
2751+ std::mem::replace(&mut *c, Vec::with_capacity(cap))
2752+ });
2721 // The job owns its coefficients: the arena is replaced by an empty one2753 // The job owns its coefficients: the arena is replaced by an empty one
2722 // sized for the next superblock, so parse never regrows from nothing and2754 // sized for the next superblock, so parse never regrows from nothing and
2723 // the worker frees this buffer once, instead of once per unit.2755 // the worker frees this buffer once, instead of once per unit.
@@ -3089,7 +3121,7 @@ fn exec_op(
3089 ) {3121 ) {
3090 let mut scratch = Vec::new();3122 let mut scratch = Vec::new();
3091 match op {3123 match op {
3092- ReconOp::Pred(b) => *cur = (b.0)(y, u, v, fctx),3124+ ReconOp::Pred(b) => (b.0)(y, u, v, fctx, cur),
3093 ReconOp::Intra {3125 ReconOp::Intra {
3094 plane, x, y: oy, bw, bh, rect, mode, angle_delta, reach, residual, cfl,3126 plane, x, y: oy, bw, bh, rect, mode, angle_delta, reach, residual, cfl,
3095 filter_intra, smooth_neighbor, pred,3127 filter_intra, smooth_neighbor, pred,
@@ -7345,7 +7377,7 @@ impl Neighbours {
7345 side: usize,7377 side: usize,
7346 mode: usize,7378 mode: usize,
7347 uv_mode: usize,7379 uv_mode: usize,
7348- grids: &[Vec<i32>; 3],7380+ grids: &[&[i32]; 3],
7349 ) {7381 ) {
7350 self.record_rect(at, side, side, mode, uv_mode, grids);7382 self.record_rect(at, side, side, mode, uv_mode, grids);
7351 }7383 }
@@ -7590,7 +7622,7 @@ impl Neighbours {
7590 h: usize,7622 h: usize,
7591 mode: usize,7623 mode: usize,
7592 uv_mode: usize,7624 uv_mode: usize,
7593- grids: &[Vec<i32>; 3],7625+ grids: &[&[i32]; 3],
7594 ) {7626 ) {
7595 self.record_rect_mi(sub16_to_mi(at), w, h, mode, uv_mode, grids);7627 self.record_rect_mi(sub16_to_mi(at), w, h, mode, uv_mode, grids);
7596 }7628 }
@@ -7607,7 +7639,7 @@ impl Neighbours {
7607 h: usize,7639 h: usize,
7608 mode: usize,7640 mode: usize,
7609 uv_mode: usize,7641 uv_mode: usize,
7610- grids: &[Vec<i32>; 3],7642+ grids: &[&[i32]; 3],
7611 ) {7643 ) {
7612 let (r, c) = (at_mi.0 / (SUB / MI), at_mi.1 / (SUB / MI));7644 let (r, c) = (at_mi.0 / (SUB / MI), at_mi.1 / (SUB / MI));
7613 // lane-inter4 r2: a strip whose own footprint runs past the frame's7645 // lane-inter4 r2: a strip whose own footprint runs past the frame's
@@ -7638,7 +7670,7 @@ impl Neighbours {
7638 /// position directly in 4x4 mode-info units rather than [`SUB`]-grid7670 /// position directly in 4x4 mode-info units rather than [`SUB`]-grid
7639 /// `(r, c)`: an 8x8 leaf under a straddling 16x16 (lane-av1-rect) sits at7671 /// `(r, c)`: an 8x8 leaf under a straddling 16x16 (lane-av1-rect) sits at
7640 /// a mi offset [`Self::record`]'s SUB-unit `at` cannot name.7672 /// a mi offset [`Self::record`]'s SUB-unit `at` cannot name.
7641- fn record_mi(&mut self, at_mi: (usize, usize), side: usize, grids: &[Vec<i32>; 3]) {7673+ fn record_mi(&mut self, at_mi: (usize, usize), side: usize, grids: &[&[i32]; 3]) {
7642 self.record_mi_rect(at_mi, side, side, grids);7674 self.record_mi_rect(at_mi, side, side, grids);
7643 }7675 }
7644 7676
@@ -7649,10 +7681,10 @@ impl Neighbours {
7649 at_mi: (usize, usize),7681 at_mi: (usize, usize),
7650 w: usize,7682 w: usize,
7651 h: usize,7683 h: usize,
7652- grids: &[Vec<i32>; 3],7684+ grids: &[&[i32]; 3],
7653 ) {7685 ) {
7654 let (mi_r, mi_c) = at_mi;7686 let (mi_r, mi_c) = at_mi;
7655- let states: [Neighbour; 3] = std::array::from_fn(|plane| neighbour_state(&grids[plane]));7687+ let states: [Neighbour; 3] = std::array::from_fn(|plane| neighbour_state(grids[plane]));
7656 let (w_mi, h_mi) = (w / MI, h / MI);7688 let (w_mi, h_mi) = (w / MI, h / MI);
7657 if crate::envflags::env_flag!("EC_ECPUB") {7689 if crate::envflags::env_flag!("EC_ECPUB") {
7658 eprintln!("EC_ECPUB blk mi=({mi_r},{mi_c}) wh=({w},{h}) lvl={}", states[0].level);7690 eprintln!("EC_ECPUB blk mi=({mi_r},{mi_c}) wh=({w},{h}) lvl={}", states[0].level);
@@ -10114,7 +10146,7 @@ fn decode_block_rect(
10114 mode,10146 mode,
10115 angle_delta_y,10147 angle_delta_y,
10116 reach,10148 reach,
10117- &vec![0i32; bw * bh],10149+ &ZERO_RESIDUAL[..bw * bh],
10118 None,10150 None,
10119 filter_intra,10151 filter_intra,
10120 smooth_neighbor, fctx,10152 smooth_neighbor, fctx,
@@ -10131,7 +10163,7 @@ fn decode_block_rect(
10131 uv_predict_mode,10163 uv_predict_mode,
10132 angle_delta_uv,10164 angle_delta_uv,
10133 reach,10165 reach,
10134- &vec![0i32; chroma_w * chroma_h],10166+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
10135 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),10167 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
10136 None,10168 None,
10137 smooth_neighbor_uv, fctx,10169 smooth_neighbor_uv, fctx,
@@ -10147,7 +10179,7 @@ fn decode_block_rect(
10147 uv_predict_mode,10179 uv_predict_mode,
10148 angle_delta_uv,10180 angle_delta_uv,
10149 reach,10181 reach,
10150- &vec![0i32; chroma_w * chroma_h],10182+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
10151 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),10183 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
10152 None,10184 None,
10153 smooth_neighbor_uv, fctx,10185 smooth_neighbor_uv, fctx,
@@ -10159,9 +10191,9 @@ fn decode_block_rect(
10159 mode,10191 mode,
10160 uv_predict_mode,10192 uv_predict_mode,
10161 &[10193 &[
10162- vec![0i32; bw * bh],10194+ &ZERO_RESIDUAL[..bw * bh],
10163- vec![0i32; chroma_w * chroma_h],10195+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
10164- vec![0i32; chroma_w * chroma_h],10196+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
10165 ],10197 ],
10166 );10198 );
10167 } else {10199 } else {
@@ -10336,7 +10368,7 @@ fn decode_block_rect(
10336 None,10368 None,
10337 smooth_neighbor_uv, fctx,10369 smooth_neighbor_uv, fctx,
10338 );10370 );
10339- neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[luma_levels, u_levels, v_levels]);10371+ neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);
10340 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));10372 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));
10341 }10373 }
10342 }10374 }
@@ -10675,7 +10707,7 @@ fn decode_leaf_rect(
10675 );10707 );
10676 RECT_LEAF_COEFF_HITS.with(|c| c.set(c.get() + 1));10708 RECT_LEAF_COEFF_HITS.with(|c| c.set(c.get() + 1));
10677 }10709 }
10678- neighbours.record_mi_rect(leaf_mi, bw, bh, &[luma_levels, u_levels, v_levels]);10710+ neighbours.record_mi_rect(leaf_mi, bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);
10679 neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip);10711 neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip);
10680 neighbours.fill_lf_grid_rect(leaf_mi, mi_w, mi_h, bw as u8, bh as u8, 0, fctx);10712 neighbours.fill_lf_grid_rect(leaf_mi, mi_w, mi_h, bw as u8, bh as u8, 0, fctx);
10681 // The leaf's own palette state (`0` clears, as this site always did10713 // The leaf's own palette state (`0` clears, as this site always did
@@ -11067,7 +11099,7 @@ fn decode_block_rect4(
11067 (mi_r, mi_c),11099 (mi_r, mi_c),
11068 bw,11100 bw,
11069 bh,11101 bh,
11070- &[luma_levels, u_levels, v_levels],11102+ &[&luma_levels[..], &u_levels[..], &v_levels[..]],
11071 );11103 );
11072 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);11104 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);
11073 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);11105 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);
@@ -11138,7 +11170,7 @@ fn decode_block_rect4(
11138 None,11170 None,
11139 smooth_neighbor_uv, fctx,11171 smooth_neighbor_uv, fctx,
11140 );11172 );
11141- neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[luma_levels.to_vec(), u_levels, v_levels]);11173+ neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);
11142 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);11174 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);
11143 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);11175 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);
11144 record_strip_palette(11176 record_strip_palette(
@@ -11983,7 +12015,7 @@ fn decode_block_rect64(
11983 mode,12015 mode,
11984 angle_delta_y,12016 angle_delta_y,
11985 reach,12017 reach,
11986- &vec![0i32; bw * bh],12018+ &ZERO_RESIDUAL[..bw * bh],
11987 None,12019 None,
11988 filter_intra,12020 filter_intra,
11989 smooth_neighbor, fctx,12021 smooth_neighbor, fctx,
@@ -12000,7 +12032,7 @@ fn decode_block_rect64(
12000 uv_predict_mode,12032 uv_predict_mode,
12001 angle_delta_uv,12033 angle_delta_uv,
12002 reach,12034 reach,
12003- &vec![0i32; chroma_w * chroma_h],12035+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
12004 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),12036 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
12005 None,12037 None,
12006 smooth_neighbor_uv, fctx,12038 smooth_neighbor_uv, fctx,
@@ -12016,7 +12048,7 @@ fn decode_block_rect64(
12016 uv_predict_mode,12048 uv_predict_mode,
12017 angle_delta_uv,12049 angle_delta_uv,
12018 reach,12050 reach,
12019- &vec![0i32; chroma_w * chroma_h],12051+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
12020 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),12052 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
12021 None,12053 None,
12022 smooth_neighbor_uv, fctx,12054 smooth_neighbor_uv, fctx,
@@ -12028,9 +12060,9 @@ fn decode_block_rect64(
12028 mode,12060 mode,
12029 uv_predict_mode,12061 uv_predict_mode,
12030 &[12062 &[
12031- vec![0i32; bw * bh],12063+ &ZERO_RESIDUAL[..bw * bh],
12032- vec![0i32; chroma_w * chroma_h],12064+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
12033- vec![0i32; chroma_w * chroma_h],12065+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
12034 ],12066 ],
12035 );12067 );
12036 } else {12068 } else {
@@ -12277,7 +12309,7 @@ fn decode_block_rect64(
12277 None,12309 None,
12278 smooth_neighbor_uv, fctx,12310 smooth_neighbor_uv, fctx,
12279 );12311 );
12280- neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[luma_levels, u_levels, v_levels]);12312+ neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);
12281 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));12313 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));
12282 }12314 }
12283 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));12315 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
@@ -13581,7 +13613,7 @@ fn decode_block(
13581 mode,13613 mode,
13582 angle_delta_y,13614 angle_delta_y,
13583 tu_reach,13615 tu_reach,
13584- &vec![0i32; logical_tx * logical_tx],13616+ &ZERO_RESIDUAL[..logical_tx * logical_tx],
13585 None,13617 None,
13586 filter_intra,13618 filter_intra,
13587 smooth_neighbor, fctx,13619 smooth_neighbor, fctx,
@@ -13596,7 +13628,7 @@ fn decode_block(
13596 mode,13628 mode,
13597 angle_delta_y,13629 angle_delta_y,
13598 reach,13630 reach,
13599- &vec![0i32; side * side],13631+ &ZERO_RESIDUAL[..side * side],
13600 None,13632 None,
13601 filter_intra,13633 filter_intra,
13602 smooth_neighbor, fctx,13634 smooth_neighbor, fctx,
@@ -13627,7 +13659,7 @@ fn decode_block(
13627 uv_predict_mode,13659 uv_predict_mode,
13628 angle_delta_uv,13660 angle_delta_uv,
13629 cu_r,13661 cu_r,
13630- &vec![0i32; chroma_tx * chroma_tx],13662+ &ZERO_RESIDUAL[..chroma_tx * chroma_tx],
13631 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),13663 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
13632 None,13664 None,
13633 smooth_neighbor_uv, fctx,13665 smooth_neighbor_uv, fctx,
@@ -13642,7 +13674,7 @@ fn decode_block(
13642 uv_predict_mode,13674 uv_predict_mode,
13643 angle_delta_uv,13675 angle_delta_uv,
13644 cu_r,13676 cu_r,
13645- &vec![0i32; chroma_tx * chroma_tx],13677+ &ZERO_RESIDUAL[..chroma_tx * chroma_tx],
13646 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),13678 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
13647 None,13679 None,
13648 smooth_neighbor_uv, fctx,13680 smooth_neighbor_uv, fctx,
@@ -13652,7 +13684,7 @@ fn decode_block(
13652 let luma_grid = vec![0i32; side * side];13684 let luma_grid = vec![0i32; side * side];
13653 let u_grid = vec![0i32; chroma_side * chroma_side];13685 let u_grid = vec![0i32; chroma_side * chroma_side];
13654 let v_grid = vec![0i32; chroma_side * chroma_side];13686 let v_grid = vec![0i32; chroma_side * chroma_side];
13655- neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);13687+ neighbours.record(at, side, mode, uv_predict_mode, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
13656 } else if logical_tx == side {13688 } else if logical_tx == side {
13657 // lane-sb128b r1: the test used to be `!tx_select || logical_tx == side`.13689 // lane-sb128b r1: the test used to be `!tx_select || logical_tx == side`.
13658 // Without `tx_select` `logical_tx` IS `side` at every size <= 64, so13690 // Without `tx_select` `logical_tx` IS `side` at every size <= 64, so
@@ -13749,7 +13781,7 @@ fn decode_block(
13749 smooth_neighbor_uv, fctx,13781 smooth_neighbor_uv, fctx,
13750 )?;13782 )?;
13751 fctx.intrabc_chroma_tx.with(|c| c.set(None));13783 fctx.intrabc_chroma_tx.with(|c| c.set(None));
13752- neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);13784+ neighbours.record(at, side, mode, uv_predict_mode, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
13753 } else {13785 } else {
13754 // Several luma transform units, raster order (spec13786 // Several luma transform units, raster order (spec
13755 // `transform_block`'s loop): the block's resolved transform is13787 // `transform_block`'s loop): the block's resolved transform is
@@ -14267,9 +14299,9 @@ fn decode_block_128rect(
14267 mode,14299 mode,
14268 uv_predict_mode,14300 uv_predict_mode,
14269 &[14301 &[
14270- vec![0i32; bw * bh],14302+ &ZERO_RESIDUAL[..bw * bh],
14271- vec![0i32; chroma_w * chroma_h],14303+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
14272- vec![0i32; chroma_w * chroma_h],14304+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
14273 ],14305 ],
14274 );14306 );
14275 } else {14307 } else {
@@ -14598,7 +14630,7 @@ fn decode_leaf8(
14598 mode,14630 mode,
14599 angle_delta_y,14631 angle_delta_y,
14600 tu_reach,14632 tu_reach,
14601- &vec![0i32; 16],14633+ &ZERO_RESIDUAL[..16],
14602 None,14634 None,
14603 filter_intra,14635 filter_intra,
14604 smooth_neighbor, fctx,14636 smooth_neighbor, fctx,
@@ -14616,7 +14648,7 @@ fn decode_leaf8(
14616 mode,14648 mode,
14617 angle_delta_y,14649 angle_delta_y,
14618 reach,14650 reach,
14619- &vec![0i32; 64],14651+ &ZERO_RESIDUAL[..64],
14620 None,14652 None,
14621 filter_intra,14653 filter_intra,
14622 smooth_neighbor, fctx,14654 smooth_neighbor, fctx,
@@ -14635,7 +14667,7 @@ fn decode_leaf8(
14635 uv_predict_mode,14667 uv_predict_mode,
14636 angle_delta_uv,14668 angle_delta_uv,
14637 reach,14669 reach,
14638- &vec![0i32; 16],14670+ &ZERO_RESIDUAL[..16],
14639 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),14671 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
14640 None,14672 None,
14641 smooth_neighbor_uv, fctx,14673 smooth_neighbor_uv, fctx,
@@ -14652,7 +14684,7 @@ fn decode_leaf8(
14652 uv_predict_mode,14684 uv_predict_mode,
14653 angle_delta_uv,14685 angle_delta_uv,
14654 reach,14686 reach,
14655- &vec![0i32; 16],14687+ &ZERO_RESIDUAL[..16],
14656 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),14688 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
14657 None,14689 None,
14658 smooth_neighbor_uv, fctx,14690 smooth_neighbor_uv, fctx,
@@ -14938,7 +14970,7 @@ fn decode_leaf8(
14938 record_intrabc_mi(leaf_mi.0, leaf_mi.1, 2, intrabc_dv, fctx);14970 record_intrabc_mi(leaf_mi.0, leaf_mi.1, 2, intrabc_dv, fctx);
14939 return Ok(mode);14971 return Ok(mode);
14940 }14972 }
14941- neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);14973+ neighbours.record_mi(leaf_mi, 8, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
14942 // This leaf's own palette state into the mi-granular above/left bands14974 // This leaf's own palette state into the mi-granular above/left bands
14943 // (sizes 0 when it used none, which is what clears a previous block's14975 // (sizes 0 when it used none, which is what clears a previous block's
14944 // palette out of the next block's ctx and colour cache).14976 // palette out of the next block's ctx and colour cache).
@@ -15149,8 +15181,8 @@ fn decode_leaf_split4(
15149 let (px, py) = (lmi.1 * MI, lmi.0 * MI);15181 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
15150 let reach = Reach::of(4, px, py, y.width, y.height, fctx);15182 let reach = Reach::of(4, px, py, y.width, y.height, fctx);
15151 if skip {15183 if skip {
15152- push_intra(0, px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra, smooth_neighbor, fctx);15184+ push_intra(0, px, py, 4, mode, angle_delta_y, reach, &ZERO_RESIDUAL[..16], None, filter_intra, smooth_neighbor, fctx);
15153- neighbours.record_mi_luma(lmi, 4, &vec![0i32; 16]);15185+ neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]);
15154 } else {15186 } else {
15155 let tu_around = neighbours.around_mi(lmi, 4)[0];15187 let tu_around = neighbours.around_mi(lmi, 4)[0];
15156 // A `BLOCK_4X4` leaf's luma TU *is* the whole block, so libaom's15188 // A `BLOCK_4X4` leaf's luma TU *is* the whole block, so libaom's
@@ -15211,8 +15243,8 @@ fn decode_leaf_split4(
15211 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));15243 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
15212 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));15244 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
15213 }15245 }
15214- push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);15246+ push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);
15215- push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);15247+ push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);
15216 (vec![0i32; 16], vec![0i32; 16])15248 (vec![0i32; 16], vec![0i32; 16])
15217 } else {15249 } else {
15218 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));15250 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
@@ -15583,8 +15615,8 @@ fn decode_leaf_rect8(
15583 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));15615 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
15584 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));15616 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
15585 }15617 }
15586- push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);15618+ push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);
15587- push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);15619+ push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);
15588 (vec![0i32; 16], vec![0i32; 16])15620 (vec![0i32; 16], vec![0i32; 16])
15589 } else {15621 } else {
15590 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));15622 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
@@ -24694,8 +24726,8 @@ fn decode_inter_block(
24694 let build = move |_y: &mut PlaneBuf<'static>,24726 let build = move |_y: &mut PlaneBuf<'static>,
24695 _u: &mut PlaneBuf<'static>,24727 _u: &mut PlaneBuf<'static>,
24696 _v: &mut PlaneBuf<'static>,24728 _v: &mut PlaneBuf<'static>,
24697- fctx: &crate::decode::FrameCtx|24729+ fctx: &crate::decode::FrameCtx,
24698- -> [Vec<u16>; 3] {24730+ out: &mut [Vec<u16>; 3]| {
24699 let mut inter0_y = vec![0i32; side * side];24731 let mut inter0_y = vec![0i32; side * side];
24700 mc::predict_compound_intermediate_kern(24732 mc::predict_compound_intermediate_kern(
24701 &py0.data,24733 &py0.data,
@@ -24750,7 +24782,7 @@ fn decode_inter_block(
24750 side as i32, side as i32, 0, 0, fctx,24782 side as i32, side as i32, 0, 0, fctx,
24751 );24783 );
24752 }24784 }
24753- let mut pred_y = vec![0u16; side * side];24785+ let mut pred_y = refill(std::mem::take(&mut out[0]), side * side);
24754 let mut diffwtd_mask_y;24786 let mut diffwtd_mask_y;
24755 // lane-wedge r3: `mask_y` is the DIFFWTD buffer just computed OR24787 // lane-wedge r3: `mask_y` is the DIFFWTD buffer just computed OR
24756 // the wedge codebook lookup (comp_group_idx==1's two mutually24788 // the wedge codebook lookup (comp_group_idx==1's two mutually
@@ -24830,7 +24862,7 @@ fn decode_inter_block(
24830 );24862 );
24831 }24863 }
24832 }24864 }
24833- let mut pred_u = vec![0u16; chroma_side * chroma_side];24865+ let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_side * chroma_side);
24834 if let Some(mask_y) = mask_y {24866 if let Some(mask_y) = mask_y {
24835 mc::blend_masked_compound(24867 mc::blend_masked_compound(
24836 &inter0_u,24868 &inter0_u,
@@ -24904,7 +24936,7 @@ fn decode_inter_block(
24904 );24936 );
24905 }24937 }
24906 }24938 }
24907- let mut pred_v = vec![0u16; chroma_side * chroma_side];24939+ let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_side * chroma_side);
24908 if let Some(mask_y) = mask_y {24940 if let Some(mask_y) = mask_y {
24909 mc::blend_masked_compound(24941 mc::blend_masked_compound(
24910 &inter0_v,24942 &inter0_v,
@@ -24922,7 +24954,7 @@ fn decode_inter_block(
24922 24954
24923 // lane-inter4 r2: a rectangular strip's transform tree starts from24955 // lane-inter4 r2: a rectangular strip's transform tree starts from
24924 // its own rect `max_txsize_rect_lookup` entry, not a square one.24956 // its own rect `max_txsize_rect_lookup` entry, not a square one.
24925- [pred_y, pred_u, pred_v]24957+ *out = [pred_y, pred_u, pred_v];
24926 };24958 };
24927 let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>);24959 let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>);
24928 let (sy, su, sv) = if recon_deferred(fctx) {24960 let (sy, su, sv) = if recon_deferred(fctx) {
@@ -24933,7 +24965,9 @@ fn decode_inter_block(
24933 Pred::Cur { plane: 2, stride: chroma_side, off: 0 },24965 Pred::Cur { plane: 2, stride: chroma_side, off: 0 },
24934 )24966 )
24935 } else {24967 } else {
24936- let [by, bu, bv] = build(y, u, v, fctx);24968+ let mut built: [Vec<u16>; 3] = Default::default();
24969+ build(y, u, v, fctx, &mut built);
24970+ let [by, bu, bv] = built;
24937 (pred_y, pred_u, pred_v) = (by, bu, bv);24971 (pred_y, pred_u, pred_v) = (by, bu, bv);
24938 (24972 (
24939 Pred::Inline(&pred_y, side),24973 Pred::Inline(&pred_y, side),
@@ -24974,7 +25008,7 @@ fn decode_inter_block(
24974 write_w,25008 write_w,
24975 write_h,25009 write_h,
24976 sy,25010 sy,
24977- &vec![0i32; side * side], fctx,25011+ &ZERO_RESIDUAL[..side * side], fctx,
24978 );25012 );
24979 push_mc_rect(1, 25013 push_mc_rect(1,
24980 cpx,25014 cpx,
@@ -24983,7 +25017,7 @@ fn decode_inter_block(
24983 write_chroma_w,25017 write_chroma_w,
24984 write_chroma_h,25018 write_chroma_h,
24985 su,25019 su,
24986- &vec![0i32; chroma_side * chroma_side], fctx,25020+ &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
24987 );25021 );
24988 push_mc_rect(2, 25022 push_mc_rect(2,
24989 cpx,25023 cpx,
@@ -24992,7 +25026,7 @@ fn decode_inter_block(
24992 write_chroma_w,25026 write_chroma_w,
24993 write_chroma_h,25027 write_chroma_h,
24994 sv,25028 sv,
24995- &vec![0i32; chroma_side * chroma_side], fctx,25029+ &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
24996 );25030 );
24997 luma_grid = vec![0i32; side * side];25031 luma_grid = vec![0i32; side * side];
24998 u_grid = vec![0i32; chroma_side * chroma_side];25032 u_grid = vec![0i32; chroma_side * chroma_side];
@@ -25916,11 +25950,11 @@ fn decode_inter_block(
25916 let build = move |y: &mut PlaneBuf<'static>,25950 let build = move |y: &mut PlaneBuf<'static>,
25917 u: &mut PlaneBuf<'static>,25951 u: &mut PlaneBuf<'static>,
25918 v: &mut PlaneBuf<'static>,25952 v: &mut PlaneBuf<'static>,
25919- fctx: &crate::decode::FrameCtx|25953+ fctx: &crate::decode::FrameCtx,
25920- -> [Vec<u16>; 3] {25954+ out: &mut [Vec<u16>; 3]| {
25921- let mut pred_y = vec![0u16; side * side];25955+ let mut pred_y = refill(std::mem::take(&mut out[0]), side * side);
25922- let mut pred_u = vec![0u16; chroma_side * chroma_side];25956+ let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_side * chroma_side);
25923- let mut pred_v = vec![0u16; chroma_side * chroma_side];25957+ let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_side * chroma_side);
25924 if luma_scale == mc::REF_NO_SCALE {25958 if luma_scale == mc::REF_NO_SCALE {
25925 mc::predict_with_filters_kern(25959 mc::predict_with_filters_kern(
25926 &py_ref.data,25960 &py_ref.data,
@@ -26077,7 +26111,7 @@ fn decode_inter_block(
26077 &mut pred_v, fctx,26111 &mut pred_v, fctx,
26078 );26112 );
26079 }26113 }
26080- [pred_y, pred_u, pred_v]26114+ *out = [pred_y, pred_u, pred_v];
26081 };26115 };
26082 // OBMC and interintra are mutually exclusive (`motion_mode` is26116 // OBMC and interintra are mutually exclusive (`motion_mode` is
26083 // never read for an interintra block), so blending interintra26117 // never read for an interintra block), so blending interintra
@@ -26102,7 +26136,9 @@ fn decode_inter_block(
26102 if interintra_mode.is_some() {26136 if interintra_mode.is_some() {
26103 flush_recon(fctx, y, u, v);26137 flush_recon(fctx, y, u, v);
26104 }26138 }
26105- let [by, bu, bv] = build(y, u, v, fctx);26139+ let mut built: [Vec<u16>; 3] = Default::default();
26140+ build(y, u, v, fctx, &mut built);
26141+ let [by, bu, bv] = built;
26106 (pred_y, pred_u, pred_v) = (by, bu, bv);26142 (pred_y, pred_u, pred_v) = (by, bu, bv);
26107 if obmc_selected {26143 if obmc_selected {
26108 obmc_blend(26144 obmc_blend(
@@ -26221,7 +26257,7 @@ fn decode_inter_block(
26221 write_w,26257 write_w,
26222 write_h,26258 write_h,
26223 sy,26259 sy,
26224- &vec![0i32; side * side], fctx,26260+ &ZERO_RESIDUAL[..side * side], fctx,
26225 );26261 );
26226 if has_chroma {26262 if has_chroma {
26227 push_mc_rect(1, 26263 push_mc_rect(1,
@@ -26231,7 +26267,7 @@ fn decode_inter_block(
26231 write_chroma_w,26267 write_chroma_w,
26232 write_chroma_h,26268 write_chroma_h,
26233 su,26269 su,
26234- &vec![0i32; chroma_side * chroma_side], fctx,26270+ &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
26235 );26271 );
26236 push_mc_rect(2, 26272 push_mc_rect(2,
26237 cpx,26273 cpx,
@@ -26240,7 +26276,7 @@ fn decode_inter_block(
26240 write_chroma_w,26276 write_chroma_w,
26241 write_chroma_h,26277 write_chroma_h,
26242 sv,26278 sv,
26243- &vec![0i32; chroma_side * chroma_side], fctx,26279+ &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
26244 );26280 );
26245 }26281 }
26246 luma_grid = vec![0i32; side * side];26282 luma_grid = vec![0i32; side * side];
@@ -26971,7 +27007,7 @@ fn decode_inter_block(
26971 mode,27007 mode,
26972 angle_delta_y,27008 angle_delta_y,
26973 tu_reach,27009 tu_reach,
26974- &vec![0i32; tx_px * tx_px],27010+ &ZERO_RESIDUAL[..tx_px * tx_px],
26975 None,27011 None,
26976 filter_intra,27012 filter_intra,
26977 smooth_neighbor, fctx,27013 smooth_neighbor, fctx,
@@ -27041,7 +27077,7 @@ fn decode_inter_block(
27041 uv_predict_mode,27077 uv_predict_mode,
27042 angle_delta_uv,27078 angle_delta_uv,
27043 cu_reach,27079 cu_reach,
27044- &vec![0i32; cu_tx * cu_tx],27080+ &ZERO_RESIDUAL[..cu_tx * cu_tx],
27045 None,27081 None,
27046 None,27082 None,
27047 smooth_neighbor_uv, fctx,27083 smooth_neighbor_uv, fctx,
@@ -27111,7 +27147,7 @@ fn decode_inter_block(
27111 mode,27147 mode,
27112 angle_delta_y,27148 angle_delta_y,
27113 reach,27149 reach,
27114- &vec![0i32; side * side],27150+ &ZERO_RESIDUAL[..side * side],
27115 None,27151 None,
27116 filter_intra,27152 filter_intra,
27117 smooth_neighbor, fctx,27153 smooth_neighbor, fctx,
@@ -27128,7 +27164,7 @@ fn decode_inter_block(
27128 uv_predict_mode,27164 uv_predict_mode,
27129 angle_delta_uv,27165 angle_delta_uv,
27130 reach,27166 reach,
27131- &vec![0i32; chroma_side * chroma_side],27167+ &ZERO_RESIDUAL[..chroma_side * chroma_side],
27132 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),27168 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
27133 None,27169 None,
27134 smooth_neighbor_uv, fctx,27170 smooth_neighbor_uv, fctx,
@@ -27143,7 +27179,7 @@ fn decode_inter_block(
27143 uv_predict_mode,27179 uv_predict_mode,
27144 angle_delta_uv,27180 angle_delta_uv,
27145 reach,27181 reach,
27146- &vec![0i32; chroma_side * chroma_side],27182+ &ZERO_RESIDUAL[..chroma_side * chroma_side],
27147 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),27183 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
27148 None,27184 None,
27149 smooth_neighbor_uv, fctx,27185 smooth_neighbor_uv, fctx,
@@ -27373,7 +27409,7 @@ fn decode_inter_block(
27373 write_h,27409 write_h,
27374 mode_for_tx,27410 mode_for_tx,
27375 uv_predict_mode,27411 uv_predict_mode,
27376- &[luma_grid, u_grid, v_grid],27412+ &[&luma_grid[..], &u_grid[..], &v_grid[..]],
27377 );27413 );
27378 }27414 }
27379 if let Some((left, above)) = saved_chroma_ctx {27415 if let Some((left, above)) = saved_chroma_ctx {
@@ -27842,8 +27878,8 @@ fn decode_inter_sub8_split4(
27842 // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which27878 // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which
27843 // `read_inter_plane`'s `plane_idx == 0` arm already assumes).27879 // `read_inter_plane`'s `plane_idx == 0` arm already assumes).
27844 if skip {27880 if skip {
27845- push_mc(0, px, py, B4, Pred::dense(&pred_y), &vec![0i32; B4 * B4], fctx);27881+ push_mc(0, px, py, B4, Pred::dense(&pred_y), &ZERO_RESIDUAL[..B4 * B4], fctx);
27846- neighbours.record_mi_luma_rect(lmi, B4, B4, &vec![0i32; B4 * B4]);27882+ neighbours.record_mi_luma_rect(lmi, B4, B4, &ZERO_RESIDUAL[..B4 * B4]);
27847 } else {27883 } else {
27848 let around = neighbours.around_mi(lmi, B4);27884 let around = neighbours.around_mi(lmi, B4);
27849 let (luma_grid, tx_type) = read_inter_plane(27885 let (luma_grid, tx_type) = read_inter_plane(
@@ -27957,8 +27993,8 @@ fn decode_inter_sub8_split4(
27957 }27993 }
27958 }27994 }
27959 let (u_grid, v_grid) = if last_skip {27995 let (u_grid, v_grid) = if last_skip {
27960- push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &vec![0i32; B4 * B4], fctx);27996+ push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &ZERO_RESIDUAL[..B4 * B4], fctx);
27961- push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &vec![0i32; B4 * B4], fctx);27997+ push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &ZERO_RESIDUAL[..B4 * B4], fctx);
27962 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])27998 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
27963 } else {27999 } else {
27964 let around = neighbours.around_mi(group_mi, 8);28000 let around = neighbours.around_mi(group_mi, 8);
@@ -28230,10 +28266,10 @@ fn decode_intra_sub8_leaf(
28230 // reader [`decode_leaf_split4`] uses.28266 // reader [`decode_leaf_split4`] uses.
28231 if skip {28267 if skip {
28232 push_intra(0, 28268 push_intra(0,
28233- px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra,28269+ px, py, 4, mode, angle_delta_y, reach, &ZERO_RESIDUAL[..16], None, filter_intra,
28234 smooth_neighbor, fctx,28270 smooth_neighbor, fctx,
28235 );28271 );
28236- neighbours.record_mi_luma(lmi, 4, &vec![0i32; 16]);28272+ neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]);
28237 } else {28273 } else {
28238 let tu_around = neighbours.around_mi(lmi, 4)[0];28274 let tu_around = neighbours.around_mi(lmi, 4)[0];
28239 let tu_grid = read_plane(28275 let tu_grid = read_plane(
@@ -28401,8 +28437,8 @@ fn decode_intra_sub8_leaf(
28401 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));28437 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
28402 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));28438 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
28403 }28439 }
28404- push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);28440+ push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);
28405- push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);28441+ push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);
28406 (vec![0i32; 16], vec![0i32; 16])28442 (vec![0i32; 16], vec![0i32; 16])
28407 } else {28443 } else {
28408 let chroma_around = neighbours.around_mi(group_mi, 8);28444 let chroma_around = neighbours.around_mi(group_mi, 8);
@@ -28813,8 +28849,8 @@ fn decode_inter_sub8_rect2(
28813 }28849 }
28814 }28850 }
28815 if skip {28851 if skip {
28816- push_mc_rect(0, px, py, SIDE, bw, bh, Pred::dense(&pred_y), &vec![0i32; SIDE * SIDE], fctx);28852+ push_mc_rect(0, px, py, SIDE, bw, bh, Pred::dense(&pred_y), &ZERO_RESIDUAL[..SIDE * SIDE], fctx);
28817- neighbours.record_mi_luma_rect(lmi, bw, bh, &vec![0i32; bw * bh]);28853+ neighbours.record_mi_luma_rect(lmi, bw, bh, &ZERO_RESIDUAL[..bw * bh]);
28818 neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx);28854 neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx);
28819 } else {28855 } else {
28820 let (mut last_tw, mut last_th) = (bw, bh);28856 let (mut last_tw, mut last_th) = (bw, bh);
@@ -28979,8 +29015,8 @@ fn decode_inter_sub8_rect2(
28979 }29015 }
28980 }29016 }
28981 let (u_grid, v_grid) = if last_skip {29017 let (u_grid, v_grid) = if last_skip {
28982- push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &vec![0i32; B4 * B4], fctx);29018+ push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &ZERO_RESIDUAL[..B4 * B4], fctx);
28983- push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &vec![0i32; B4 * B4], fctx);29019+ push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &ZERO_RESIDUAL[..B4 * B4], fctx);
28984 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])29020 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
28985 } else {29021 } else {
28986 let around = neighbours.around_mi(group_mi, 8);29022 let around = neighbours.around_mi(group_mi, 8);
@@ -29812,20 +29848,20 @@ fn decode_inter_block8(
29812 .129848 .1
29813 .is_some();29849 .is_some();
29814 if skip {29850 if skip {
29815- push_mc(0, px, py, SIDE, Pred::dense(&pred_y), &vec![0i32; SIDE * SIDE], fctx);29851+ push_mc(0, px, py, SIDE, Pred::dense(&pred_y), &ZERO_RESIDUAL[..SIDE * SIDE], fctx);
29816 push_mc(1, 29852 push_mc(1,
29817 cpx,29853 cpx,
29818 cpy,29854 cpy,
29819 CHROMA_SIDE,29855 CHROMA_SIDE,
29820 Pred::dense(&pred_u),29856 Pred::dense(&pred_u),
29821- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,29857+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,
29822 );29858 );
29823 push_mc(2, 29859 push_mc(2,
29824 cpx,29860 cpx,
29825 cpy,29861 cpy,
29826 CHROMA_SIDE,29862 CHROMA_SIDE,
29827 Pred::dense(&pred_v),29863 Pred::dense(&pred_v),
29828- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,29864+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,
29829 );29865 );
29830 luma_grid = vec![0i32; SIDE * SIDE];29866 luma_grid = vec![0i32; SIDE * SIDE];
29831 u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];29867 u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
@@ -29931,7 +29967,7 @@ fn decode_inter_block8(
29931 palette_record8.2,29967 palette_record8.2,
29932 palette_record8.3,29968 palette_record8.3,
29933 );29969 );
29934- neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);29970+ neighbours.record_mi(leaf_mi, 8, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
29935 if let Some((left, above)) = saved_luma_ctx {29971 if let Some((left, above)) = saved_luma_ctx {
29936 for (cell, state) in left.into_iter().enumerate() {29972 for (cell, state) in left.into_iter().enumerate() {
29937 neighbours.left[leaf_mi.0 + cell][0] = state;29973 neighbours.left[leaf_mi.0 + cell][0] = state;
@@ -30460,20 +30496,20 @@ fn decode_inter_block8(
30460 .130496 .1
30461 .is_some();30497 .is_some();
30462 if skip {30498 if skip {
30463- push_mc(0, px, py, SIDE, Pred::dense(&pred_y), &vec![0i32; SIDE * SIDE], fctx);30499+ push_mc(0, px, py, SIDE, Pred::dense(&pred_y), &ZERO_RESIDUAL[..SIDE * SIDE], fctx);
30464 push_mc(1, 30500 push_mc(1,
30465 cpx,30501 cpx,
30466 cpy,30502 cpy,
30467 CHROMA_SIDE,30503 CHROMA_SIDE,
30468 Pred::dense(&pred_u),30504 Pred::dense(&pred_u),
30469- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,30505+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,
30470 );30506 );
30471 push_mc(2, 30507 push_mc(2,
30472 cpx,30508 cpx,
30473 cpy,30509 cpy,
30474 CHROMA_SIDE,30510 CHROMA_SIDE,
30475 Pred::dense(&pred_v),30511 Pred::dense(&pred_v),
30476- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,30512+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,
30477 );30513 );
30478 luma_grid = vec![0i32; SIDE * SIDE];30514 luma_grid = vec![0i32; SIDE * SIDE];
30479 u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];30515 u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
@@ -30836,7 +30872,7 @@ fn decode_inter_block8(
30836 mode,30872 mode,
30837 angle_delta_y,30873 angle_delta_y,
30838 tu_reach,30874 tu_reach,
30839- &vec![0i32; tx_px * tx_px],30875+ &ZERO_RESIDUAL[..tx_px * tx_px],
30840 None,30876 None,
30841 filter_intra,30877 filter_intra,
30842 smooth_neighbor, fctx,30878 smooth_neighbor, fctx,
@@ -30889,7 +30925,7 @@ fn decode_inter_block8(
30889 mode,30925 mode,
30890 angle_delta_y,30926 angle_delta_y,
30891 reach,30927 reach,
30892- &vec![0i32; SIDE * SIDE],30928+ &ZERO_RESIDUAL[..SIDE * SIDE],
30893 None,30929 None,
30894 filter_intra,30930 filter_intra,
30895 smooth_neighbor, fctx,30931 smooth_neighbor, fctx,
@@ -30908,7 +30944,7 @@ fn decode_inter_block8(
30908 uv_predict_mode,30944 uv_predict_mode,
30909 angle_delta_uv,30945 angle_delta_uv,
30910 reach,30946 reach,
30911- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],30947+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE],
30912 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),30948 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
30913 None,30949 None,
30914 smooth_neighbor_uv, fctx,30950 smooth_neighbor_uv, fctx,
@@ -30923,7 +30959,7 @@ fn decode_inter_block8(
30923 uv_predict_mode,30959 uv_predict_mode,
30924 angle_delta_uv,30960 angle_delta_uv,
30925 reach,30961 reach,
30926- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],30962+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE],
30927 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),30963 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
30928 None,30964 None,
30929 smooth_neighbor_uv, fctx,30965 smooth_neighbor_uv, fctx,
@@ -31058,7 +31094,7 @@ fn decode_inter_block8(
31058 palette_record8.2,31094 palette_record8.2,
31059 palette_record8.3,31095 palette_record8.3,
31060 );31096 );
31061- neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);31097+ neighbours.record_mi(leaf_mi, 8, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
31062 // lane-uv8 r1: this leaf never stamped a mode band at all, so the block31098 // lane-uv8 r1: this leaf never stamped a mode band at all, so the block
31063 // below/right of it read whatever block last wrote the coarse [`SUB`]31099 // below/right of it read whatever block last wrote the coarse [`SUB`]
31064 // slot -- now that an intra leaf here can code a smooth/directional31100 // slot -- now that an intra leaf here can code a smooth/directional