forge
Explore
Log in

Don't you dare go Hollow

Skipped blocks stop allocating and copying their zero coefficient grids

Browse files at this commit

bccf2c807797c7fd024c8266ea538b9480629b5dAhmet Kaan GümüşParent: afb2b38
  • perf
    • skipped blocks stop allocating and copying their zero coefficient grids
Show full message
perf(av1): skipped blocks stop allocating and copying their zero coefficient grids

A skipped block handed every consumer a freshly heap-allocated all-zero
level grid -- up to 64 KB per block, three of them for the neighbour
record and one per plane for the recorded write. Those buffers are
read-only at every consumer, so they are now the existing static
`ZERO_RESIDUAL` slice: `Neighbours::record*` takes `&[&[i32]; 3]`
instead of owning Vecs, and the 53 `&vec![0i32; n]` argument
temporaries index the static instead.

`Residual::done` recognises that slice by pointer and records the
all-zero marker `Done(0, 0)` (the one `Residual::coeffs` already
produces), so a skipped block no longer copies its zeros into the
coefficient arena either.

Byte-exact 12/12 at 1/4/16 threads. seg4k instructions:u 414.794 ->
409.809 G at (16,4,2) (-1.2%), 406.145 -> 404.579 G at 1 thread
(-0.39%); page-faults 1.034 -> 1.014 M at (16,4,2).
crates/ec-av1/src/decode.rsmodified+85 -79
@@ -2149,6 +2149,12 @@ impl Residual {
21492149 /// A residual the parse thread already transformed, kept in the arena
21502150 /// instead of its own `Vec`.
21512151 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+ }
21522158 Self::Done(push_coeffs(residual, fctx), residual.len() as u32)
21532159 }
21542160
@@ -7345,7 +7351,7 @@ impl Neighbours {
73457351 side: usize,
73467352 mode: usize,
73477353 uv_mode: usize,
7348- grids: &[Vec<i32>; 3],
7354+ grids: &[&[i32]; 3],
73497355 ) {
73507356 self.record_rect(at, side, side, mode, uv_mode, grids);
73517357 }
@@ -7590,7 +7596,7 @@ impl Neighbours {
75907596 h: usize,
75917597 mode: usize,
75927598 uv_mode: usize,
7593- grids: &[Vec<i32>; 3],
7599+ grids: &[&[i32]; 3],
75947600 ) {
75957601 self.record_rect_mi(sub16_to_mi(at), w, h, mode, uv_mode, grids);
75967602 }
@@ -7607,7 +7613,7 @@ impl Neighbours {
76077613 h: usize,
76087614 mode: usize,
76097615 uv_mode: usize,
7610- grids: &[Vec<i32>; 3],
7616+ grids: &[&[i32]; 3],
76117617 ) {
76127618 let (r, c) = (at_mi.0 / (SUB / MI), at_mi.1 / (SUB / MI));
76137619 // lane-inter4 r2: a strip whose own footprint runs past the frame's
@@ -7638,7 +7644,7 @@ impl Neighbours {
76387644 /// position directly in 4x4 mode-info units rather than [`SUB`]-grid
76397645 /// `(r, c)`: an 8x8 leaf under a straddling 16x16 (lane-av1-rect) sits at
76407646 /// 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]) {
7647+ fn record_mi(&mut self, at_mi: (usize, usize), side: usize, grids: &[&[i32]; 3]) {
76427648 self.record_mi_rect(at_mi, side, side, grids);
76437649 }
76447650
@@ -7649,10 +7655,10 @@ impl Neighbours {
76497655 at_mi: (usize, usize),
76507656 w: usize,
76517657 h: usize,
7652- grids: &[Vec<i32>; 3],
7658+ grids: &[&[i32]; 3],
76537659 ) {
76547660 let (mi_r, mi_c) = at_mi;
7655- let states: [Neighbour; 3] = std::array::from_fn(|plane| neighbour_state(&grids[plane]));
7661+ let states: [Neighbour; 3] = std::array::from_fn(|plane| neighbour_state(grids[plane]));
76567662 let (w_mi, h_mi) = (w / MI, h / MI);
76577663 if crate::envflags::env_flag!("EC_ECPUB") {
76587664 eprintln!("EC_ECPUB blk mi=({mi_r},{mi_c}) wh=({w},{h}) lvl={}", states[0].level);
@@ -10114,7 +10120,7 @@ fn decode_block_rect(
1011410120 mode,
1011510121 angle_delta_y,
1011610122 reach,
10117- &vec![0i32; bw * bh],
10123+ &ZERO_RESIDUAL[..bw * bh],
1011810124 None,
1011910125 filter_intra,
1012010126 smooth_neighbor, fctx,
@@ -10131,7 +10137,7 @@ fn decode_block_rect(
1013110137 uv_predict_mode,
1013210138 angle_delta_uv,
1013310139 reach,
10134- &vec![0i32; chroma_w * chroma_h],
10140+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
1013510141 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1013610142 None,
1013710143 smooth_neighbor_uv, fctx,
@@ -10147,7 +10153,7 @@ fn decode_block_rect(
1014710153 uv_predict_mode,
1014810154 angle_delta_uv,
1014910155 reach,
10150- &vec![0i32; chroma_w * chroma_h],
10156+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
1015110157 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1015210158 None,
1015310159 smooth_neighbor_uv, fctx,
@@ -10159,9 +10165,9 @@ fn decode_block_rect(
1015910165 mode,
1016010166 uv_predict_mode,
1016110167 &[
10162- vec![0i32; bw * bh],
10163- vec![0i32; chroma_w * chroma_h],
10164- vec![0i32; chroma_w * chroma_h],
10168+ &ZERO_RESIDUAL[..bw * bh],
10169+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
10170+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
1016510171 ],
1016610172 );
1016710173 } else {
@@ -10336,7 +10342,7 @@ fn decode_block_rect(
1033610342 None,
1033710343 smooth_neighbor_uv, fctx,
1033810344 );
10339- neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[luma_levels, u_levels, v_levels]);
10345+ neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);
1034010346 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));
1034110347 }
1034210348 }
@@ -10675,7 +10681,7 @@ fn decode_leaf_rect(
1067510681 );
1067610682 RECT_LEAF_COEFF_HITS.with(|c| c.set(c.get() + 1));
1067710683 }
10678- neighbours.record_mi_rect(leaf_mi, bw, bh, &[luma_levels, u_levels, v_levels]);
10684+ neighbours.record_mi_rect(leaf_mi, bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);
1067910685 neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip);
1068010686 neighbours.fill_lf_grid_rect(leaf_mi, mi_w, mi_h, bw as u8, bh as u8, 0, fctx);
1068110687 // The leaf's own palette state (`0` clears, as this site always did
@@ -11067,7 +11073,7 @@ fn decode_block_rect4(
1106711073 (mi_r, mi_c),
1106811074 bw,
1106911075 bh,
11070- &[luma_levels, u_levels, v_levels],
11076+ &[&luma_levels[..], &u_levels[..], &v_levels[..]],
1107111077 );
1107211078 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);
1107311079 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);
@@ -11138,7 +11144,7 @@ fn decode_block_rect4(
1113811144 None,
1113911145 smooth_neighbor_uv, fctx,
1114011146 );
11141- neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[luma_levels.to_vec(), u_levels, v_levels]);
11147+ neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);
1114211148 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);
1114311149 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);
1114411150 record_strip_palette(
@@ -11983,7 +11989,7 @@ fn decode_block_rect64(
1198311989 mode,
1198411990 angle_delta_y,
1198511991 reach,
11986- &vec![0i32; bw * bh],
11992+ &ZERO_RESIDUAL[..bw * bh],
1198711993 None,
1198811994 filter_intra,
1198911995 smooth_neighbor, fctx,
@@ -12000,7 +12006,7 @@ fn decode_block_rect64(
1200012006 uv_predict_mode,
1200112007 angle_delta_uv,
1200212008 reach,
12003- &vec![0i32; chroma_w * chroma_h],
12009+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
1200412010 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1200512011 None,
1200612012 smooth_neighbor_uv, fctx,
@@ -12016,7 +12022,7 @@ fn decode_block_rect64(
1201612022 uv_predict_mode,
1201712023 angle_delta_uv,
1201812024 reach,
12019- &vec![0i32; chroma_w * chroma_h],
12025+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
1202012026 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1202112027 None,
1202212028 smooth_neighbor_uv, fctx,
@@ -12028,9 +12034,9 @@ fn decode_block_rect64(
1202812034 mode,
1202912035 uv_predict_mode,
1203012036 &[
12031- vec![0i32; bw * bh],
12032- vec![0i32; chroma_w * chroma_h],
12033- vec![0i32; chroma_w * chroma_h],
12037+ &ZERO_RESIDUAL[..bw * bh],
12038+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
12039+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
1203412040 ],
1203512041 );
1203612042 } else {
@@ -12277,7 +12283,7 @@ fn decode_block_rect64(
1227712283 None,
1227812284 smooth_neighbor_uv, fctx,
1227912285 );
12280- neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[luma_levels, u_levels, v_levels]);
12286+ neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);
1228112287 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));
1228212288 }
1228312289 let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
@@ -13581,7 +13587,7 @@ fn decode_block(
1358113587 mode,
1358213588 angle_delta_y,
1358313589 tu_reach,
13584- &vec![0i32; logical_tx * logical_tx],
13590+ &ZERO_RESIDUAL[..logical_tx * logical_tx],
1358513591 None,
1358613592 filter_intra,
1358713593 smooth_neighbor, fctx,
@@ -13596,7 +13602,7 @@ fn decode_block(
1359613602 mode,
1359713603 angle_delta_y,
1359813604 reach,
13599- &vec![0i32; side * side],
13605+ &ZERO_RESIDUAL[..side * side],
1360013606 None,
1360113607 filter_intra,
1360213608 smooth_neighbor, fctx,
@@ -13627,7 +13633,7 @@ fn decode_block(
1362713633 uv_predict_mode,
1362813634 angle_delta_uv,
1362913635 cu_r,
13630- &vec![0i32; chroma_tx * chroma_tx],
13636+ &ZERO_RESIDUAL[..chroma_tx * chroma_tx],
1363113637 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1363213638 None,
1363313639 smooth_neighbor_uv, fctx,
@@ -13642,7 +13648,7 @@ fn decode_block(
1364213648 uv_predict_mode,
1364313649 angle_delta_uv,
1364413650 cu_r,
13645- &vec![0i32; chroma_tx * chroma_tx],
13651+ &ZERO_RESIDUAL[..chroma_tx * chroma_tx],
1364613652 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1364713653 None,
1364813654 smooth_neighbor_uv, fctx,
@@ -13652,7 +13658,7 @@ fn decode_block(
1365213658 let luma_grid = vec![0i32; side * side];
1365313659 let u_grid = vec![0i32; chroma_side * chroma_side];
1365413660 let v_grid = vec![0i32; chroma_side * chroma_side];
13655- neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);
13661+ neighbours.record(at, side, mode, uv_predict_mode, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
1365613662 } else if logical_tx == side {
1365713663 // lane-sb128b r1: the test used to be `!tx_select || logical_tx == side`.
1365813664 // Without `tx_select` `logical_tx` IS `side` at every size <= 64, so
@@ -13749,7 +13755,7 @@ fn decode_block(
1374913755 smooth_neighbor_uv, fctx,
1375013756 )?;
1375113757 fctx.intrabc_chroma_tx.with(|c| c.set(None));
13752- neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);
13758+ neighbours.record(at, side, mode, uv_predict_mode, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
1375313759 } else {
1375413760 // Several luma transform units, raster order (spec
1375513761 // `transform_block`'s loop): the block's resolved transform is
@@ -14267,9 +14273,9 @@ fn decode_block_128rect(
1426714273 mode,
1426814274 uv_predict_mode,
1426914275 &[
14270- vec![0i32; bw * bh],
14271- vec![0i32; chroma_w * chroma_h],
14272- vec![0i32; chroma_w * chroma_h],
14276+ &ZERO_RESIDUAL[..bw * bh],
14277+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
14278+ &ZERO_RESIDUAL[..chroma_w * chroma_h],
1427314279 ],
1427414280 );
1427514281 } else {
@@ -14598,7 +14604,7 @@ fn decode_leaf8(
1459814604 mode,
1459914605 angle_delta_y,
1460014606 tu_reach,
14601- &vec![0i32; 16],
14607+ &ZERO_RESIDUAL[..16],
1460214608 None,
1460314609 filter_intra,
1460414610 smooth_neighbor, fctx,
@@ -14616,7 +14622,7 @@ fn decode_leaf8(
1461614622 mode,
1461714623 angle_delta_y,
1461814624 reach,
14619- &vec![0i32; 64],
14625+ &ZERO_RESIDUAL[..64],
1462014626 None,
1462114627 filter_intra,
1462214628 smooth_neighbor, fctx,
@@ -14635,7 +14641,7 @@ fn decode_leaf8(
1463514641 uv_predict_mode,
1463614642 angle_delta_uv,
1463714643 reach,
14638- &vec![0i32; 16],
14644+ &ZERO_RESIDUAL[..16],
1463914645 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1464014646 None,
1464114647 smooth_neighbor_uv, fctx,
@@ -14652,7 +14658,7 @@ fn decode_leaf8(
1465214658 uv_predict_mode,
1465314659 angle_delta_uv,
1465414660 reach,
14655- &vec![0i32; 16],
14661+ &ZERO_RESIDUAL[..16],
1465614662 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1465714663 None,
1465814664 smooth_neighbor_uv, fctx,
@@ -14938,7 +14944,7 @@ fn decode_leaf8(
1493814944 record_intrabc_mi(leaf_mi.0, leaf_mi.1, 2, intrabc_dv, fctx);
1493914945 return Ok(mode);
1494014946 }
14941- neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
14947+ neighbours.record_mi(leaf_mi, 8, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
1494214948 // This leaf's own palette state into the mi-granular above/left bands
1494314949 // (sizes 0 when it used none, which is what clears a previous block's
1494414950 // palette out of the next block's ctx and colour cache).
@@ -15149,8 +15155,8 @@ fn decode_leaf_split4(
1514915155 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
1515015156 let reach = Reach::of(4, px, py, y.width, y.height, fctx);
1515115157 if skip {
15152- push_intra(0, px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra, smooth_neighbor, fctx);
15153- neighbours.record_mi_luma(lmi, 4, &vec![0i32; 16]);
15158+ push_intra(0, px, py, 4, mode, angle_delta_y, reach, &ZERO_RESIDUAL[..16], None, filter_intra, smooth_neighbor, fctx);
15159+ neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]);
1515415160 } else {
1515515161 let tu_around = neighbours.around_mi(lmi, 4)[0];
1515615162 // A `BLOCK_4X4` leaf's luma TU *is* the whole block, so libaom's
@@ -15211,8 +15217,8 @@ fn decode_leaf_split4(
1521115217 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
1521215218 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
1521315219 }
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);
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);
15220+ 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);
15221+ 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);
1521615222 (vec![0i32; 16], vec![0i32; 16])
1521715223 } else {
1521815224 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
@@ -15583,8 +15589,8 @@ fn decode_leaf_rect8(
1558315589 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
1558415590 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
1558515591 }
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);
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);
15592+ 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);
15593+ 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);
1558815594 (vec![0i32; 16], vec![0i32; 16])
1558915595 } else {
1559015596 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
@@ -24974,7 +24980,7 @@ fn decode_inter_block(
2497424980 write_w,
2497524981 write_h,
2497624982 sy,
24977- &vec![0i32; side * side], fctx,
24983+ &ZERO_RESIDUAL[..side * side], fctx,
2497824984 );
2497924985 push_mc_rect(1,
2498024986 cpx,
@@ -24983,7 +24989,7 @@ fn decode_inter_block(
2498324989 write_chroma_w,
2498424990 write_chroma_h,
2498524991 su,
24986- &vec![0i32; chroma_side * chroma_side], fctx,
24992+ &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
2498724993 );
2498824994 push_mc_rect(2,
2498924995 cpx,
@@ -24992,7 +24998,7 @@ fn decode_inter_block(
2499224998 write_chroma_w,
2499324999 write_chroma_h,
2499425000 sv,
24995- &vec![0i32; chroma_side * chroma_side], fctx,
25001+ &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
2499625002 );
2499725003 luma_grid = vec![0i32; side * side];
2499825004 u_grid = vec![0i32; chroma_side * chroma_side];
@@ -26221,7 +26227,7 @@ fn decode_inter_block(
2622126227 write_w,
2622226228 write_h,
2622326229 sy,
26224- &vec![0i32; side * side], fctx,
26230+ &ZERO_RESIDUAL[..side * side], fctx,
2622526231 );
2622626232 if has_chroma {
2622726233 push_mc_rect(1,
@@ -26231,7 +26237,7 @@ fn decode_inter_block(
2623126237 write_chroma_w,
2623226238 write_chroma_h,
2623326239 su,
26234- &vec![0i32; chroma_side * chroma_side], fctx,
26240+ &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
2623526241 );
2623626242 push_mc_rect(2,
2623726243 cpx,
@@ -26240,7 +26246,7 @@ fn decode_inter_block(
2624026246 write_chroma_w,
2624126247 write_chroma_h,
2624226248 sv,
26243- &vec![0i32; chroma_side * chroma_side], fctx,
26249+ &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx,
2624426250 );
2624526251 }
2624626252 luma_grid = vec![0i32; side * side];
@@ -26971,7 +26977,7 @@ fn decode_inter_block(
2697126977 mode,
2697226978 angle_delta_y,
2697326979 tu_reach,
26974- &vec![0i32; tx_px * tx_px],
26980+ &ZERO_RESIDUAL[..tx_px * tx_px],
2697526981 None,
2697626982 filter_intra,
2697726983 smooth_neighbor, fctx,
@@ -27041,7 +27047,7 @@ fn decode_inter_block(
2704127047 uv_predict_mode,
2704227048 angle_delta_uv,
2704327049 cu_reach,
27044- &vec![0i32; cu_tx * cu_tx],
27050+ &ZERO_RESIDUAL[..cu_tx * cu_tx],
2704527051 None,
2704627052 None,
2704727053 smooth_neighbor_uv, fctx,
@@ -27111,7 +27117,7 @@ fn decode_inter_block(
2711127117 mode,
2711227118 angle_delta_y,
2711327119 reach,
27114- &vec![0i32; side * side],
27120+ &ZERO_RESIDUAL[..side * side],
2711527121 None,
2711627122 filter_intra,
2711727123 smooth_neighbor, fctx,
@@ -27128,7 +27134,7 @@ fn decode_inter_block(
2712827134 uv_predict_mode,
2712927135 angle_delta_uv,
2713027136 reach,
27131- &vec![0i32; chroma_side * chroma_side],
27137+ &ZERO_RESIDUAL[..chroma_side * chroma_side],
2713227138 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
2713327139 None,
2713427140 smooth_neighbor_uv, fctx,
@@ -27143,7 +27149,7 @@ fn decode_inter_block(
2714327149 uv_predict_mode,
2714427150 angle_delta_uv,
2714527151 reach,
27146- &vec![0i32; chroma_side * chroma_side],
27152+ &ZERO_RESIDUAL[..chroma_side * chroma_side],
2714727153 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
2714827154 None,
2714927155 smooth_neighbor_uv, fctx,
@@ -27373,7 +27379,7 @@ fn decode_inter_block(
2737327379 write_h,
2737427380 mode_for_tx,
2737527381 uv_predict_mode,
27376- &[luma_grid, u_grid, v_grid],
27382+ &[&luma_grid[..], &u_grid[..], &v_grid[..]],
2737727383 );
2737827384 }
2737927385 if let Some((left, above)) = saved_chroma_ctx {
@@ -27842,8 +27848,8 @@ fn decode_inter_sub8_split4(
2784227848 // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which
2784327849 // `read_inter_plane`'s `plane_idx == 0` arm already assumes).
2784427850 if skip {
27845- push_mc(0, px, py, B4, Pred::dense(&pred_y), &vec![0i32; B4 * B4], fctx);
27846- neighbours.record_mi_luma_rect(lmi, B4, B4, &vec![0i32; B4 * B4]);
27851+ push_mc(0, px, py, B4, Pred::dense(&pred_y), &ZERO_RESIDUAL[..B4 * B4], fctx);
27852+ neighbours.record_mi_luma_rect(lmi, B4, B4, &ZERO_RESIDUAL[..B4 * B4]);
2784727853 } else {
2784827854 let around = neighbours.around_mi(lmi, B4);
2784927855 let (luma_grid, tx_type) = read_inter_plane(
@@ -27957,8 +27963,8 @@ fn decode_inter_sub8_split4(
2795727963 }
2795827964 }
2795927965 let (u_grid, v_grid) = if last_skip {
27960- push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &vec![0i32; B4 * B4], fctx);
27961- push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &vec![0i32; B4 * B4], fctx);
27966+ push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &ZERO_RESIDUAL[..B4 * B4], fctx);
27967+ push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &ZERO_RESIDUAL[..B4 * B4], fctx);
2796227968 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
2796327969 } else {
2796427970 let around = neighbours.around_mi(group_mi, 8);
@@ -28230,10 +28236,10 @@ fn decode_intra_sub8_leaf(
2823028236 // reader [`decode_leaf_split4`] uses.
2823128237 if skip {
2823228238 push_intra(0,
28233- px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra,
28239+ px, py, 4, mode, angle_delta_y, reach, &ZERO_RESIDUAL[..16], None, filter_intra,
2823428240 smooth_neighbor, fctx,
2823528241 );
28236- neighbours.record_mi_luma(lmi, 4, &vec![0i32; 16]);
28242+ neighbours.record_mi_luma(lmi, 4, &ZERO_RESIDUAL[..16]);
2823728243 } else {
2823828244 let tu_around = neighbours.around_mi(lmi, 4)[0];
2823928245 let tu_grid = read_plane(
@@ -28401,8 +28407,8 @@ fn decode_intra_sub8_leaf(
2840128407 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
2840228408 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
2840328409 }
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);
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);
28410+ 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);
28411+ 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);
2840628412 (vec![0i32; 16], vec![0i32; 16])
2840728413 } else {
2840828414 let chroma_around = neighbours.around_mi(group_mi, 8);
@@ -28813,8 +28819,8 @@ fn decode_inter_sub8_rect2(
2881328819 }
2881428820 }
2881528821 if skip {
28816- push_mc_rect(0, px, py, SIDE, bw, bh, Pred::dense(&pred_y), &vec![0i32; SIDE * SIDE], fctx);
28817- neighbours.record_mi_luma_rect(lmi, bw, bh, &vec![0i32; bw * bh]);
28822+ push_mc_rect(0, px, py, SIDE, bw, bh, Pred::dense(&pred_y), &ZERO_RESIDUAL[..SIDE * SIDE], fctx);
28823+ neighbours.record_mi_luma_rect(lmi, bw, bh, &ZERO_RESIDUAL[..bw * bh]);
2881828824 neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx);
2881928825 } else {
2882028826 let (mut last_tw, mut last_th) = (bw, bh);
@@ -28979,8 +28985,8 @@ fn decode_inter_sub8_rect2(
2897928985 }
2898028986 }
2898128987 let (u_grid, v_grid) = if last_skip {
28982- push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &vec![0i32; B4 * B4], fctx);
28983- push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &vec![0i32; B4 * B4], fctx);
28988+ push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &ZERO_RESIDUAL[..B4 * B4], fctx);
28989+ push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &ZERO_RESIDUAL[..B4 * B4], fctx);
2898428990 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
2898528991 } else {
2898628992 let around = neighbours.around_mi(group_mi, 8);
@@ -29812,20 +29818,20 @@ fn decode_inter_block8(
2981229818 .1
2981329819 .is_some();
2981429820 if skip {
29815- push_mc(0, px, py, SIDE, Pred::dense(&pred_y), &vec![0i32; SIDE * SIDE], fctx);
29821+ push_mc(0, px, py, SIDE, Pred::dense(&pred_y), &ZERO_RESIDUAL[..SIDE * SIDE], fctx);
2981629822 push_mc(1,
2981729823 cpx,
2981829824 cpy,
2981929825 CHROMA_SIDE,
2982029826 Pred::dense(&pred_u),
29821- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
29827+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,
2982229828 );
2982329829 push_mc(2,
2982429830 cpx,
2982529831 cpy,
2982629832 CHROMA_SIDE,
2982729833 Pred::dense(&pred_v),
29828- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
29834+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,
2982929835 );
2983029836 luma_grid = vec![0i32; SIDE * SIDE];
2983129837 u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
@@ -29931,7 +29937,7 @@ fn decode_inter_block8(
2993129937 palette_record8.2,
2993229938 palette_record8.3,
2993329939 );
29934- neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
29940+ neighbours.record_mi(leaf_mi, 8, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
2993529941 if let Some((left, above)) = saved_luma_ctx {
2993629942 for (cell, state) in left.into_iter().enumerate() {
2993729943 neighbours.left[leaf_mi.0 + cell][0] = state;
@@ -30460,20 +30466,20 @@ fn decode_inter_block8(
3046030466 .1
3046130467 .is_some();
3046230468 if skip {
30463- push_mc(0, px, py, SIDE, Pred::dense(&pred_y), &vec![0i32; SIDE * SIDE], fctx);
30469+ push_mc(0, px, py, SIDE, Pred::dense(&pred_y), &ZERO_RESIDUAL[..SIDE * SIDE], fctx);
3046430470 push_mc(1,
3046530471 cpx,
3046630472 cpy,
3046730473 CHROMA_SIDE,
3046830474 Pred::dense(&pred_u),
30469- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
30475+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,
3047030476 );
3047130477 push_mc(2,
3047230478 cpx,
3047330479 cpy,
3047430480 CHROMA_SIDE,
3047530481 Pred::dense(&pred_v),
30476- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
30482+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,
3047730483 );
3047830484 luma_grid = vec![0i32; SIDE * SIDE];
3047930485 u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
@@ -30836,7 +30842,7 @@ fn decode_inter_block8(
3083630842 mode,
3083730843 angle_delta_y,
3083830844 tu_reach,
30839- &vec![0i32; tx_px * tx_px],
30845+ &ZERO_RESIDUAL[..tx_px * tx_px],
3084030846 None,
3084130847 filter_intra,
3084230848 smooth_neighbor, fctx,
@@ -30889,7 +30895,7 @@ fn decode_inter_block8(
3088930895 mode,
3089030896 angle_delta_y,
3089130897 reach,
30892- &vec![0i32; SIDE * SIDE],
30898+ &ZERO_RESIDUAL[..SIDE * SIDE],
3089330899 None,
3089430900 filter_intra,
3089530901 smooth_neighbor, fctx,
@@ -30908,7 +30914,7 @@ fn decode_inter_block8(
3090830914 uv_predict_mode,
3090930915 angle_delta_uv,
3091030916 reach,
30911- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],
30917+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE],
3091230918 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
3091330919 None,
3091430920 smooth_neighbor_uv, fctx,
@@ -30923,7 +30929,7 @@ fn decode_inter_block8(
3092330929 uv_predict_mode,
3092430930 angle_delta_uv,
3092530931 reach,
30926- &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],
30932+ &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE],
3092730933 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
3092830934 None,
3092930935 smooth_neighbor_uv, fctx,
@@ -31058,7 +31064,7 @@ fn decode_inter_block8(
3105831064 palette_record8.2,
3105931065 palette_record8.3,
3106031066 );
31061- neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
31067+ neighbours.record_mi(leaf_mi, 8, &[&luma_grid[..], &u_grid[..], &v_grid[..]]);
3106231068 // lane-uv8 r1: this leaf never stamped a mode band at all, so the block
3106331069 // below/right of it read whatever block last wrote the coarse [`SUB`]
3106431070 // slot -- now that an intra leaf here can code a smooth/directional