forge
Explore
Log in

Don't you dare go Hollow

Coefficient readers return the shared zero grid instead of a fresh Vec

Browse files at this commit

f969486e2bb4ec91bb31175dcd49cf64172145b6Ahmet Kaan GümüşParent: c870931
  • perf
    • coefficient readers return the shared zero grid instead of a fresh Vec
Show full message
perf(av1): coefficient readers return the shared zero grid instead of a fresh Vec

read_coeffs/read_coeffs_rect now return the existing Grid enum: an all-zero
transform unit (60% of the 4K segment's) names ZERO_RESIDUAL instead of
allocating and memsetting its own side*side Vec, and the coded corner's
zero-extension (extend_corner) keeps that when nothing was coded. read_plane,
read_inter_plane, read_inter_plane_rect and read_inter_luma8 return Grid, so
nine Grid::Own(read_*(..)) wrappers and every skipped-arm vec![0i32; ..]
collapse to Grid::Zero. Residual::coeffs recognises the shared grid by pointer
instead of scanning it.
crates/ec-av1/src/decode.rsmodified+100 -98
@@ -2140,6 +2140,11 @@ impl Residual {
2140 /// the empty marker, so neither the grid nor the residual is cloned and2140 /// the empty marker, so neither the grid nor the residual is cloned and
2141 /// the worker never runs the transform (60% of the 4K segment's units).2141 /// the worker never runs the transform (60% of the 4K segment's units).
2142 fn coeffs(tx: TxParams, grid: &[i32], fctx: &crate::decode::FrameCtx) -> Self {2142 fn coeffs(tx: TxParams, grid: &[i32], fctx: &crate::decode::FrameCtx) -> Self {
2143+ // lane-coefgrid: a [`Grid::Zero`] unit IS the shared zero grid -- one
2144+ // pointer compare instead of scanning up to 16 K coefficients.
2145+ if std::ptr::eq(grid.as_ptr(), ZERO_RESIDUAL.as_ptr()) {
2146+ return Self::Done(0, 0);
2147+ }
2143 if grid.iter().all(|&c| c == 0) {2148 if grid.iter().all(|&c| c == 0) {
2144 return Self::Done(0, 0);2149 return Self::Done(0, 0);
2145 }2150 }
@@ -2204,6 +2209,7 @@ static ZERO_RESIDUAL: [i32; 128 * 128] = [0; 128 * 128];
2204 /// strip with no chroma, luma under a var-tx split whose units already wrote2209 /// strip with no chroma, luma under a var-tx split whose units already wrote
2205 /// themselves) names the shared [`ZERO_RESIDUAL`] instead of allocating and2210 /// themselves) names the shared [`ZERO_RESIDUAL`] instead of allocating and
2206 /// zeroing up to 64 KB of its own per block.2211 /// zeroing up to 64 KB of its own per block.
2212+#[derive(Clone)]
2207 enum Grid {2213 enum Grid {
2208 Zero(usize),2214 Zero(usize),
2209 Own(Vec<i32>),2215 Own(Vec<i32>),
@@ -5897,10 +5903,9 @@ fn read_coeffs(
5897 // root cause, see [`base_ctx`]). `None` everywhere else -- every other5903 // root cause, see [`base_ctx`]). `None` everywhere else -- every other
5898 // caller's block genuinely is `side` x `side`.5904 // caller's block genuinely is `side` x `side`.
5899 rect_shape: Option<(usize, usize)>,5905 rect_shape: Option<(usize, usize)>,
5900-) -> Result<(Vec<i32>, TxType)> {5906+) -> Result<(Grid, TxType)> {
5901 let trace = crate::envflags::env_flag!("EC_AV1_TRACE");5907 let trace = crate::envflags::env_flag!("EC_AV1_TRACE");
5902 let side = coding.side;5908 let side = coding.side;
5903- let mut grid = vec![0i32; side * side];
5904 if crate::envflags::env_flag!("EC_AV1_EOBPT_CDF") {5909 if crate::envflags::env_flag!("EC_AV1_EOBPT_CDF") {
5905 let (range, value) = dec.debug_state();5910 let (range, value) = dec.debug_state();
5906 eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}");5911 eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}");
@@ -5933,8 +5938,11 @@ fn read_coeffs(
5933 eprintln!("EC_AV1_STATE_AFTER_TXBSKIP range={range} value={value}");5938 eprintln!("EC_AV1_STATE_AFTER_TXBSKIP range={range} value={value}");
5934 }5939 }
5935 if all_zero {5940 if all_zero {
5936- return Ok((grid, TxType::DctDct));5941+ // lane-coefgrid: the all-zero unit (60% of the 4K segment's) names the
5942+ // shared zero grid instead of allocating and zeroing its own.
5943+ return Ok((Grid::Zero(side * side), TxType::DctDct));
5937 }5944 }
5945+ let mut grid = vec![0i32; side * side];
5938 let mut tx_type = default_tx_type;5946 let mut tx_type = default_tx_type;
5939 if let Some(tx_type_cdf) = coding.tx_type.as_deref_mut() {5947 if let Some(tx_type_cdf) = coding.tx_type.as_deref_mut() {
5940 // The CDF row's own width names its set (lane-cdffwd2: extended5948 // The CDF row's own width names its set (lane-cdffwd2: extended
@@ -6116,7 +6124,7 @@ fn read_coeffs(
6116 }6124 }
6117 grid[pos] = if negative { -level } else { level };6125 grid[pos] = if negative { -level } else { level };
6118 }6126 }
6119- Ok((grid, tx_type))6127+ Ok((Grid::Own(grid), tx_type))
6120 }6128 }
6121 6129
6122 /// [`read_coeffs`] widened to `(w, h)` (lane-rectwire; lane-rectx added the6130 /// [`read_coeffs`] widened to `(w, h)` (lane-rectwire; lane-rectx added the
@@ -6136,9 +6144,8 @@ fn read_coeffs_rect(
6136 skip_ctx: usize,6144 skip_ctx: usize,
6137 sign_ctx: usize,6145 sign_ctx: usize,
6138 default_tx_type: TxType,6146 default_tx_type: TxType,
6139-) -> Result<(Vec<i32>, TxType)> {6147+) -> Result<(Grid, TxType)> {
6140 let rect_trace = coeff_trace_on();6148 let rect_trace = coeff_trace_on();
6141- let mut grid = vec![0i32; w * h];
6142 let entry_rng = dec.debug_state().0;6149 let entry_rng = dec.debug_state().0;
6143 let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1;6150 let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1;
6144 if rect_trace {6151 if rect_trace {
@@ -6149,8 +6156,9 @@ fn read_coeffs_rect(
6149 );6156 );
6150 }6157 }
6151 if all_zero {6158 if all_zero {
6152- return Ok((grid, TxType::DctDct));6159+ return Ok((Grid::Zero(w * h), TxType::DctDct));
6153 }6160 }
6161+ let mut grid = vec![0i32; w * h];
6154 RECT_COEFF_TU_HITS.with(|c| c.set(c.get() + 1));6162 RECT_COEFF_TU_HITS.with(|c| c.set(c.get() + 1));
6155 // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is6163 // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is
6156 // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including6164 // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including
@@ -6288,7 +6296,7 @@ fn read_coeffs_rect(
6288 };6296 };
6289 grid[pos] = if negative { -level } else { level };6297 grid[pos] = if negative { -level } else { level };
6290 }6298 }
6291- Ok((grid, tx_type))6299+ Ok((Grid::Own(grid), tx_type))
6292 }6300 }
6293 6301
6294 /// What one coded block leaves behind for the blocks that read it as a6302 /// What one coded block leaves behind for the blocks that read it as a
@@ -9223,7 +9231,7 @@ fn decode_rect_split(
9223 let ac = m.alpha.map(|_| cfl_src_rect(px, py, bw, bh));9231 let ac = m.alpha.map(|_| cfl_src_rect(px, py, bw, bh));
9224 let reach = block_reach;9232 let reach = block_reach;
9225 let (u_grid, v_grid) = if m.skip {9233 let (u_grid, v_grid) = if m.skip {
9226- let zero = vec![0i32; chroma_w * chroma_h];9234+ let zero = Grid::Zero(chroma_w * chroma_h);
9227 if let Some((ub, _)) = &m.palette_uv {9235 if let Some((ub, _)) = &m.palette_uv {
9228 set_palette_pred(ub.clone(), fctx);9236 set_palette_pred(ub.clone(), fctx);
9229 }9237 }
@@ -9250,7 +9258,7 @@ fn decode_rect_split(
9250 default_intra_tx_type(m.uv_predict_mode as u8)9258 default_intra_tx_type(m.uv_predict_mode as u8)
9251 };9259 };
9252 let around = neighbours.around_mi_rect(at_mi, bw, bh);9260 let around = neighbours.around_mi_rect(at_mi, bw, bh);
9253- let mut grids: Vec<Vec<i32>> = Vec::with_capacity(2);9261+ let mut grids: Vec<Grid> = Vec::with_capacity(2);
9254 for plane_idx in 1..=2 {9262 for plane_idx in 1..=2 {
9255 let skip_ctx =9263 let skip_ctx =
9256 usize::from(around[plane_idx].0) + usize::from(around[plane_idx].1);9264 usize::from(around[plane_idx].0) + usize::from(around[plane_idx].1);
@@ -10719,9 +10727,9 @@ fn decode_leaf_rect(
10719 let (chroma_w, chroma_h) = (bw / 2, bh / 2);10727 let (chroma_w, chroma_h) = (bw / 2, bh / 2);
10720 let (luma_levels, u_levels, v_levels);10728 let (luma_levels, u_levels, v_levels);
10721 if skip {10729 if skip {
10722- luma_levels = vec![0i32; bw * bh];10730+ luma_levels = Grid::Zero(bw * bh);
10723- u_levels = vec![0i32; chroma_w * chroma_h];10731+ u_levels = Grid::Zero(chroma_w * chroma_h);
10724- v_levels = vec![0i32; chroma_w * chroma_h];10732+ v_levels = Grid::Zero(chroma_w * chroma_h);
10725 if let Some(b) = &palette_y_buf {10733 if let Some(b) = &palette_y_buf {
10726 set_palette_pred(b.clone(), fctx);10734 set_palette_pred(b.clone(), fctx);
10727 }10735 }
@@ -11647,7 +11655,7 @@ fn decode_rect4_16_strip(
11647 }11655 }
11648 } else {11656 } else {
11649 let levels = if skip {11657 let levels = if skip {
11650- let zeros = vec![0i32; bw * bh];11658+ let zeros = Grid::Zero(bw * bh);
11651 if let Some(b) = &palette_y_buf {11659 if let Some(b) = &palette_y_buf {
11652 set_palette_pred(b.clone(), fctx);11660 set_palette_pred(b.clone(), fctx);
11653 }11661 }
@@ -11748,7 +11756,7 @@ fn decode_rect4_16_strip(
11748 RECT4_16_UV_PAIR_FILT_HITS.with(|h| h.set(h.get() + 1));11756 RECT4_16_UV_PAIR_FILT_HITS.with(|h| h.set(h.get() + 1));
11749 }11757 }
11750 let (u_levels, v_levels) = if skip {11758 let (u_levels, v_levels) = if skip {
11751- let zeros = vec![0i32; cw * ch];11759+ let zeros = Grid::Zero(cw * ch);
11752 // libaom `predict_and_reconstruct_intra_block` (decodeframe.c11760 // libaom `predict_and_reconstruct_intra_block` (decodeframe.c
11753 // ~1000) predicts EVERY plane and only guards the residual on11761 // ~1000) predicts EVERY plane and only guards the residual on
11754 // `mbmi->skip_txfm`, so a skipped `UV_CFL_PRED` block is still11762 // `mbmi->skip_txfm`, so a skipped `UV_CFL_PRED` block is still
@@ -13351,7 +13359,7 @@ fn read_plane(
13351 luma_skip_ctx: Option<usize>,13359 luma_skip_ctx: Option<usize>,
13352 // See [`PlaneBuf::reconstruct`]'s own doc: caller's neighbour-smooth check.13360 // See [`PlaneBuf::reconstruct`]'s own doc: caller's neighbour-smooth check.
13353 smooth_neighbor: bool, fctx: &crate::decode::FrameCtx,13361 smooth_neighbor: bool, fctx: &crate::decode::FrameCtx,
13354-) -> Result<Vec<i32>> {13362+) -> Result<Grid> {
13355 let skip_ctx = if plane_idx == 0 {13363 let skip_ctx = if plane_idx == 0 {
13356 luma_skip_ctx.unwrap_or(0)13364 luma_skip_ctx.unwrap_or(0)
13357 } else {13365 } else {
@@ -13411,19 +13419,11 @@ fn read_plane(
13411 // top-left 32x32 of frequencies are coded (spec 5.11.40); the rest of the13419 // top-left 32x32 of frequencies are coded (spec 5.11.40); the rest of the
13412 // dequantized grid stays zero, which `inverse_transform_2d`'s own `< 32`13420 // dequantized grid stays zero, which `inverse_transform_2d`'s own `< 32`
13413 // guard also assumes.13421 // guard also assumes.
13414- let levels = if tx_side == side {
13415- grid
13416- } else {
13417 // `grid` is `tx_side x tx_side` (the coded corner); `dequant_and_inverse`13422 // `grid` is `tx_side x tx_side` (the coded corner); `dequant_and_inverse`
13418 // wants the true `side x side` transform, with dqDenom (spec 7.12.3)13423 // wants the true `side x side` transform, with dqDenom (spec 7.12.3)
13419 // keyed by that true size, not the coded corner's -- so the corner13424 // keyed by that true size, not the coded corner's -- so the corner
13420 // goes into the top-left of a `side`-sized grid, not the reverse.13425 // goes into the top-left of a `side`-sized grid, not the reverse.
13421- let mut full = vec![0i32; side * side];13426+ let levels = extend_corner(grid, tx_side, tx_side, side, side);
13422- for row in 0..tx_side {
13423- full[row * side..][..tx_side].copy_from_slice(&grid[row * tx_side..][..tx_side]);
13424- }
13425- full
13426- };
13427 let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx);13427 let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx);
13428 let tx = TxParams {13428 let tx = TxParams {
13429 w: side, h: side, bit_depth: bit_depth(fctx), q_idx: block_q_idx(fctx), dc_delta,13429 w: side, h: side, bit_depth: bit_depth(fctx), q_idx: block_q_idx(fctx), dc_delta,
@@ -13432,7 +13432,7 @@ fn read_plane(
13432 if crate::envflags::env_flag!("EC_AV1_TRACE") {13432 if crate::envflags::env_flag!("EC_AV1_TRACE") {
13433 let residual = tx.run(&levels);13433 let residual = tx.run(&levels);
13434 eprintln!(13434 eprintln!(
13435- "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={levels:?} residual={residual:?}",13435+ "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={:?} residual={residual:?}", &*levels,
13436 );13436 );
13437 }13437 }
13438 push_intra_tx(13438 push_intra_tx(
@@ -13946,8 +13946,8 @@ fn decode_block(
13946 let chroma_ctx_offset = if cn > 1 { Some(3) } else { None };13946 let chroma_ctx_offset = if cn > 1 { Some(3) } else { None };
13947 let tpc = (n_axis / nchunk).max(1);13947 let tpc = (n_axis / nchunk).max(1);
13948 let cpc = (cn / nchunk).max(1);13948 let cpc = (cn / nchunk).max(1);
13949- let mut last_grids = [Vec::new(), Vec::new()];13949+ let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];
13950- let mut units: Vec<((usize, usize), usize, Vec<i32>, Vec<i32>)> = Vec::new();13950+ let mut units: Vec<((usize, usize), usize, Grid, Grid)> = Vec::new();
13951 for ch_row in 0..nchunk {13951 for ch_row in 0..nchunk {
13952 for ch_col in 0..nchunk {13952 for ch_col in 0..nchunk {
13953 for tu_row in ch_row * tpc..(ch_row + 1) * tpc {13953 for tu_row in ch_row * tpc..(ch_row + 1) * tpc {
@@ -14309,8 +14309,8 @@ fn decode_block_128rect(
14309 let tpc = 64 / logical_tx;14309 let tpc = 64 / logical_tx;
14310 let zero_tu = vec![0i32; logical_tx * logical_tx];14310 let zero_tu = vec![0i32; logical_tx * logical_tx];
14311 let zero_cu = vec![0i32; chroma_tx * chroma_tx];14311 let zero_cu = vec![0i32; chroma_tx * chroma_tx];
14312- let mut last_grids = [Vec::new(), Vec::new()];14312+ let mut last_grids = [Grid::Zero(0), Grid::Zero(0)];
14313- let mut units: Vec<((usize, usize), Vec<i32>, Vec<i32>)> = Vec::new();14313+ let mut units: Vec<((usize, usize), Grid, Grid)> = Vec::new();
14314 for ch_row in 0..nch_y {14314 for ch_row in 0..nch_y {
14315 for ch_col in 0..nch_x {14315 for ch_col in 0..nch_x {
14316 for tu_row in ch_row * tpc..(ch_row + 1) * tpc {14316 for tu_row in ch_row * tpc..(ch_row + 1) * tpc {
@@ -14830,9 +14830,9 @@ fn decode_leaf8(
14830 None,14830 None,
14831 smooth_neighbor_uv, fctx,14831 smooth_neighbor_uv, fctx,
14832 );14832 );
14833- luma_grid = vec![0i32; 64];14833+ luma_grid = Grid::Zero(64);
14834- u_grid = vec![0i32; 16];14834+ u_grid = Grid::Zero(16);
14835- v_grid = vec![0i32; 16];14835+ v_grid = Grid::Zero(16);
14836 } else if resolved != 4 {14836 } else if resolved != 4 {
14837 let around = neighbours.around_mi(leaf_mi, 8);14837 let around = neighbours.around_mi(leaf_mi, 8);
14838 if let Some(buf) = &palette_y_buf {14838 if let Some(buf) = &palette_y_buf {
@@ -15370,7 +15370,7 @@ fn decode_leaf_split4(
15370 neighbours.above_uv_mode[c] = uv_predict_mode;15370 neighbours.above_uv_mode[c] = uv_predict_mode;
15371 neighbours.left_uv_mode[r] = uv_predict_mode;15371 neighbours.left_uv_mode[r] = uv_predict_mode;
15372 neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode);15372 neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode);
15373- let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[3] {15373+ let (u_grid, v_grid): (Grid, Grid) = if leaf_skips[3] {
15374 // A skipped chroma block still gets its CfL contribution: libaom's15374 // A skipped chroma block still gets its CfL contribution: libaom's
15375 // `predict_and_reconstruct_intra_block` calls `cfl_predict_block`15375 // `predict_and_reconstruct_intra_block` calls `cfl_predict_block`
15376 // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719)15376 // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719)
@@ -15386,7 +15386,7 @@ fn decode_leaf_split4(
15386 }15386 }
15387 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);15387 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);
15388 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);15388 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);
15389- (vec![0i32; 16], vec![0i32; 16])15389+ (Grid::Zero(16), Grid::Zero(16))
15390 } else {15390 } else {
15391 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));15391 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
15392 let chroma_around = neighbours.around_mi(leaf_mi, 8);15392 let chroma_around = neighbours.around_mi(leaf_mi, 8);
@@ -15662,7 +15662,7 @@ fn decode_leaf_rect8(
15662 continue;15662 continue;
15663 }15663 }
15664 let grid = if skip {15664 let grid = if skip {
15665- let zeros = vec![0i32; bw * bh];15665+ let zeros = Grid::Zero(bw * bh);
15666 push_intra_rect(0, 15666 push_intra_rect(0,
15667 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,15667 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
15668 smooth_neighbor, fctx,15668 smooth_neighbor, fctx,
@@ -15742,7 +15742,7 @@ fn decode_leaf_rect8(
15742 neighbours.above_uv_mode[c] = uv_predict_mode;15742 neighbours.above_uv_mode[c] = uv_predict_mode;
15743 neighbours.left_uv_mode[r] = uv_predict_mode;15743 neighbours.left_uv_mode[r] = uv_predict_mode;
15744 neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode);15744 neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode);
15745- let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[1] {15745+ let (u_grid, v_grid): (Grid, Grid) = if leaf_skips[1] {
15746 // A skipped chroma block still gets its CfL contribution: libaom's15746 // A skipped chroma block still gets its CfL contribution: libaom's
15747 // `predict_and_reconstruct_intra_block` calls `cfl_predict_block`15747 // `predict_and_reconstruct_intra_block` calls `cfl_predict_block`
15748 // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719)15748 // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719)
@@ -15758,7 +15758,7 @@ fn decode_leaf_rect8(
15758 }15758 }
15759 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);15759 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);
15760 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);15760 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);
15761- (vec![0i32; 16], vec![0i32; 16])15761+ (Grid::Zero(16), Grid::Zero(16))
15762 } else {15762 } else {
15763 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));15763 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
15764 let chroma_around = neighbours.around_mi(leaf_mi, 8);15764 let chroma_around = neighbours.around_mi(leaf_mi, 8);
@@ -17676,7 +17676,7 @@ fn read_inter_plane_rect(
17676 prediction: Pred<'_>,17676 prediction: Pred<'_>,
17677 inherited_luma_tx_type: Option<TxType>,17677 inherited_luma_tx_type: Option<TxType>,
17678 luma_skip_ctx: Option<usize>, fctx: &crate::decode::FrameCtx,17678 luma_skip_ctx: Option<usize>, fctx: &crate::decode::FrameCtx,
17679-) -> Result<(Vec<i32>, TxType)> {17679+) -> Result<(Grid, TxType)> {
17680 let skip_ctx = if plane_idx == 0 {17680 let skip_ctx = if plane_idx == 0 {
17681 // `get_txb_ctx_general`: 0 only when this unit IS the whole plane17681 // `get_txb_ctx_general`: 0 only when this unit IS the whole plane
17682 // block; a var-tx leaf passes its own neighbour-table context.17682 // block; a var-tx leaf passes its own neighbour-table context.
@@ -17733,15 +17733,7 @@ fn read_inter_plane_rect(
17733 default_tx_type,17733 default_tx_type,
17734 )?17734 )?
17735 };17735 };
17736- let grid = if (cw, ch) == (w, h) {17736+ let grid = extend_corner(corner, cw, ch, w, h);
17737- corner
17738- } else {
17739- let mut full = vec![0i32; w * h];
17740- for row in 0..ch {
17741- full[row * w..][..cw].copy_from_slice(&corner[row * cw..][..cw]);
17742- }
17743- full
17744- };
17745 let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx);17737 let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx);
17746 if crate::envflags::env_flag!("EC_TRACE_TXTYPE") {17738 if crate::envflags::env_flag!("EC_TRACE_TXTYPE") {
17747 eprintln!("OUR_TXTYPE plane={plane_idx} x={x} y={y} w={w} h={h} tx_type={tx_type:?} inh={inherited_luma_tx_type:?}");17739 eprintln!("OUR_TXTYPE plane={plane_idx} x={x} y={y} w={w} h={h} tx_type={tx_type:?} inh={inherited_luma_tx_type:?}");
@@ -17757,6 +17749,24 @@ fn read_inter_plane_rect(
17757 Ok((grid, tx_type))17749 Ok((grid, tx_type))
17758 }17750 }
17759 17751
17752+/// The coded `cw x ch` corner of a transform zero-extended into its true
17753+/// `w x h` grid (a 64-length axis codes only its low 32 coefficients). A
17754+/// corner that coded nothing stays the shared zero grid -- no allocation
17755+/// (lane-coefgrid).
17756+fn extend_corner(corner: Grid, cw: usize, ch: usize, w: usize, h: usize) -> Grid {
17757+ if (cw, ch) == (w, h) {
17758+ return corner;
17759+ }
17760+ if let Grid::Zero(_) = corner {
17761+ return Grid::Zero(w * h);
17762+ }
17763+ let mut full = vec![0i32; w * h];
17764+ for row in 0..ch {
17765+ full[row * w..][..cw].copy_from_slice(&corner[row * cw..][..cw]);
17766+ }
17767+ Grid::Own(full)
17768+}
17769+
17760 /// A rect coefficient grid re-laid into the square `stride x stride` grid the17770 /// A rect coefficient grid re-laid into the square `stride x stride` grid the
17761 /// neighbour/deblock stamps downstream of the residual expect.17771 /// neighbour/deblock stamps downstream of the residual expect.
17762 fn embed_rect_grid(grid: &[i32], w: usize, h: usize, stride: usize) -> Vec<i32> {17772 fn embed_rect_grid(grid: &[i32], w: usize, h: usize, stride: usize) -> Vec<i32> {
@@ -17791,7 +17801,7 @@ fn read_inter_luma8(
17791 scan4: &[u16],17801 scan4: &[u16],
17792 reduced_tx_set: bool,17802 reduced_tx_set: bool,
17793 split: bool, fctx: &crate::decode::FrameCtx,17803 split: bool, fctx: &crate::decode::FrameCtx,
17794-) -> Result<(Vec<i32>, TxType)> {17804+) -> Result<(Grid, TxType)> {
17795 if !split {17805 if !split {
17796 return read_inter_plane(17806 return read_inter_plane(
17797 dec,17807 dec,
@@ -17848,7 +17858,7 @@ fn read_inter_luma8(
17848 neighbours.record_mi_luma(tu_mi, 4, &tu_grid);17858 neighbours.record_mi_luma(tu_mi, 4, &tu_grid);
17849 }17859 }
17850 }17860 }
17851- Ok((vec![0i32; 64], first))17861+ Ok((Grid::Zero(64), first))
17852 }17862 }
17853 17863
17854 /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its17864 /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its
@@ -23085,7 +23095,7 @@ fn read_inter_plane(
23085 // transform every non-var-tx caller reads, whose plane-0 context is the23095 // transform every non-var-tx caller reads, whose plane-0 context is the
23086 // lone-transform-unit 0.23096 // lone-transform-unit 0.
23087 luma_skip_ctx: Option<usize>, fctx: &crate::decode::FrameCtx,23097 luma_skip_ctx: Option<usize>, fctx: &crate::decode::FrameCtx,
23088-) -> Result<(Vec<i32>, TxType)> {23098+) -> Result<(Grid, TxType)> {
23089 let skip_ctx = if plane_idx == 0 {23099 let skip_ctx = if plane_idx == 0 {
23090 luma_skip_ctx.unwrap_or(0)23100 luma_skip_ctx.unwrap_or(0)
23091 } else {23101 } else {
@@ -23123,15 +23133,7 @@ fn read_inter_plane(
23123 // [`read_plane`]'s own `tx_side != side` branch. Every other transform23133 // [`read_plane`]'s own `tx_side != side` branch. Every other transform
23124 // this decoder codes has `tx_side == side`, so this is inert below 64.23134 // this decoder codes has `tx_side == side`, so this is inert below 64.
23125 let tx_side = side.min(32);23135 let tx_side = side.min(32);
23126- let grid = if tx_side == side {23136+ let grid = extend_corner(grid, tx_side, tx_side, side, side);
23127- grid
23128- } else {
23129- let mut full = vec![0i32; side * side];
23130- for row in 0..tx_side {
23131- full[row * side..][..tx_side].copy_from_slice(&grid[row * tx_side..][..tx_side]);
23132- }
23133- full
23134- };
23135 let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx);23137 let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx);
23136 let tx = TxParams {23138 let tx = TxParams {
23137 w: side, h: side, bit_depth: bit_depth(fctx), q_idx: block_q_idx(fctx), dc_delta,23139 w: side, h: side, bit_depth: bit_depth(fctx), q_idx: block_q_idx(fctx), dc_delta,
@@ -25928,7 +25930,7 @@ fn decode_inter_block(
25928 None,25930 None,
25929 None, fctx,25931 None, fctx,
25930 )?;25932 )?;
25931- luma_grid = Grid::Own(coded.0);25933+ luma_grid = coded.0;
25932 luma_tx_type = coded.1;25934 luma_tx_type = coded.1;
25933 }25935 }
25934 }25936 }
@@ -25997,7 +25999,7 @@ fn decode_inter_block(
25997 chroma_side,25999 chroma_side,
25998 ));26000 ));
25999 } else {26001 } else {
26000- u_grid = Grid::Own(read_inter_plane(26002+ u_grid = read_inter_plane(
26001 dec,26003 dec,
26002 cdfs,26004 cdfs,
26003 chroma_set,26005 chroma_set,
@@ -26014,8 +26016,8 @@ fn decode_inter_block(
26014 Some(luma_tx_type),26016 Some(luma_tx_type),
26015 None, fctx,26017 None, fctx,
26016 )?26018 )?
26017- .0);26019+ .0;
26018- v_grid = Grid::Own(read_inter_plane(26020+ v_grid = read_inter_plane(
26019 dec,26021 dec,
26020 cdfs,26022 cdfs,
26021 chroma_set,26023 chroma_set,
@@ -26032,7 +26034,7 @@ fn decode_inter_block(
26032 Some(luma_tx_type),26034 Some(luma_tx_type),
26033 None, fctx,26035 None, fctx,
26034 )?26036 )?
26035- .0);26037+ .0;
26036 }26038 }
26037 }26039 }
26038 } else {26040 } else {
@@ -27202,7 +27204,7 @@ fn decode_inter_block(
27202 None,27204 None,
27203 None, fctx,27205 None, fctx,
27204 )?;27206 )?;
27205- luma_grid = Grid::Own(coded.0);27207+ luma_grid = coded.0;
27206 luma_tx_type = coded.1;27208 luma_tx_type = coded.1;
27207 }27209 }
27208 }27210 }
@@ -27280,7 +27282,7 @@ fn decode_inter_block(
27280 chroma_side,27282 chroma_side,
27281 ));27283 ));
27282 } else {27284 } else {
27283- u_grid = Grid::Own(read_inter_plane(27285+ u_grid = read_inter_plane(
27284 dec,27286 dec,
27285 cdfs,27287 cdfs,
27286 chroma_set,27288 chroma_set,
@@ -27297,8 +27299,8 @@ fn decode_inter_block(
27297 Some(luma_tx_type),27299 Some(luma_tx_type),
27298 None, fctx,27300 None, fctx,
27299 )?27301 )?
27300- .0);27302+ .0;
27301- v_grid = Grid::Own(read_inter_plane(27303+ v_grid = read_inter_plane(
27302 dec,27304 dec,
27303 cdfs,27305 cdfs,
27304 chroma_set,27306 chroma_set,
@@ -27315,7 +27317,7 @@ fn decode_inter_block(
27315 Some(luma_tx_type),27317 Some(luma_tx_type),
27316 None, fctx,27318 None, fctx,
27317 )?27319 )?
27318- .0);27320+ .0;
27319 }27321 }
27320 }27322 }
27321 }27323 }
@@ -27741,7 +27743,7 @@ fn decode_inter_block(
27741 // so `txb_skip_ctx` is the neighbour-magnitude table, not27743 // so `txb_skip_ctx` is the neighbour-magnitude table, not
27742 // the lone-TU 0 (`get_txb_ctx_general`).27744 // the lone-TU 0 (`get_txb_ctx_general`).
27743 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);27745 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
27744- Grid::Own(read_plane(27746+ read_plane(
27745 dec,27747 dec,
27746 cdfs,27748 cdfs,
27747 txbset_for(tx_px, reduced),27749 txbset_for(tx_px, reduced),
@@ -27766,7 +27768,7 @@ fn decode_inter_block(
27766 filter_intra,27768 filter_intra,
27767 Some(tu_skip_ctx),27769 Some(tu_skip_ctx),
27768 smooth_neighbor, fctx,27770 smooth_neighbor, fctx,
27769- )?)27771+ )?
27770 };27772 };
27771 neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);27773 neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);
27772 if side > 64 {27774 if side > 64 {
@@ -27807,7 +27809,7 @@ fn decode_inter_block(
27807 );27809 );
27808 Grid::Zero(cu_tx * cu_tx)27810 Grid::Zero(cu_tx * cu_tx)
27809 } else {27811 } else {
27810- Grid::Own(read_plane(27812+ read_plane(
27811 dec,27813 dec,
27812 cdfs,27814 cdfs,
27813 chroma_set,27815 chroma_set,
@@ -27834,7 +27836,7 @@ fn decode_inter_block(
27834 // (lane-sb128b r3).27836 // (lane-sb128b r3).
27835 Some(3),27837 Some(3),
27836 smooth_neighbor_uv, fctx,27838 smooth_neighbor_uv, fctx,
27837- )?)27839+ )?
27838 };27840 };
27839 // Immediately, so the NEXT chunk's unit reads this27841 // Immediately, so the NEXT chunk's unit reads this
27840 // one's coefficient context.27842 // one's coefficient context.
@@ -27932,7 +27934,7 @@ fn decode_inter_block(
27932 if let Some(buf) = &palette_y_buf {27934 if let Some(buf) = &palette_y_buf {
27933 set_palette_pred(buf.clone(), fctx);27935 set_palette_pred(buf.clone(), fctx);
27934 }27936 }
27935- luma_grid = Grid::Own(read_plane(27937+ luma_grid = read_plane(
27936 dec,27938 dec,
27937 cdfs,27939 cdfs,
27938 luma_set_intra,27940 luma_set_intra,
@@ -27953,13 +27955,13 @@ fn decode_inter_block(
27953 filter_intra,27955 filter_intra,
27954 None,27956 None,
27955 smooth_neighbor, fctx,27957 smooth_neighbor, fctx,
27956- )?);27958+ )?;
27957 }27959 }
27958 let ac = alpha.map(|_| cfl_src(px, py, side));27960 let ac = alpha.map(|_| cfl_src(px, py, side));
27959 if let Some((ub, _)) = &palette_uv_bufs {27961 if let Some((ub, _)) = &palette_uv_bufs {
27960 set_palette_pred(ub.clone(), fctx);27962 set_palette_pred(ub.clone(), fctx);
27961 }27963 }
27962- u_grid = Grid::Own(read_plane(27964+ u_grid = read_plane(
27963 dec,27965 dec,
27964 cdfs,27966 cdfs,
27965 chroma_set,27967 chroma_set,
@@ -27980,11 +27982,11 @@ fn decode_inter_block(
27980 None,27982 None,
27981 None,27983 None,
27982 smooth_neighbor_uv, fctx,27984 smooth_neighbor_uv, fctx,
27983- )?);27985+ )?;
27984 if let Some((_, vb)) = &palette_uv_bufs {27986 if let Some((_, vb)) = &palette_uv_bufs {
27985 set_palette_pred(vb.clone(), fctx);27987 set_palette_pred(vb.clone(), fctx);
27986 }27988 }
27987- v_grid = Grid::Own(read_plane(27989+ v_grid = read_plane(
27988 dec,27990 dec,
27989 cdfs,27991 cdfs,
27990 chroma_set,27992 chroma_set,
@@ -28005,7 +28007,7 @@ fn decode_inter_block(
28005 None,28007 None,
28006 None,28008 None,
28007 smooth_neighbor_uv, fctx,28009 smooth_neighbor_uv, fctx,
28008- )?);28010+ )?;
28009 }28011 }
28010 }28012 }
28011 // lane-comppin r9: end-of-block checkpoint -- everything between28013 // lane-comppin r9: end-of-block checkpoint -- everything between
@@ -28037,7 +28039,7 @@ fn decode_inter_block(
28037 // the partial right superblock read row 1 where libaom reads row 2). The28039 // the partial right superblock read row 1 where libaom reads row 2). The
28038 // units are collected here and re-stamped after that record, in mu-chunk28040 // units are collected here and re-stamped after that record, in mu-chunk
28039 // order so a later unit still wins over an earlier one.28041 // order so a later unit still wins over an earlier one.
28040- let mu_chroma_units: Vec<((usize, usize), usize, Vec<i32>)> = if mu_chroma {28042+ let mu_chroma_units: Vec<((usize, usize), usize, Grid)> = if mu_chroma {
28041 let cu = 32usize;28043 let cu = 32usize;
28042 let mut units = Vec::new();28044 let mut units = Vec::new();
28043 for cr in 0..(write_h / 64).max(1) {28045 for cr in 0..(write_h / 64).max(1) {
@@ -28049,7 +28051,7 @@ fn decode_inter_block(
28049 let start = (cr * cu + rr) * chroma_side + cc * cu;28051 let start = (cr * cu + rr) * chroma_side + cc * cu;
28050 unit.extend_from_slice(&grid[start..start + cu]);28052 unit.extend_from_slice(&grid[start..start + cu]);
28051 }28053 }
28052- units.push((cu_mi, plane, unit));28054+ units.push((cu_mi, plane, Grid::Own(unit)));
28053 }28055 }
28054 }28056 }
28055 }28057 }
@@ -28729,7 +28731,7 @@ fn decode_inter_sub8_split4(
28729 let (u_grid, v_grid) = if last_skip {28731 let (u_grid, v_grid) = if last_skip {
28730 push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &ZERO_RESIDUAL[..B4 * B4], fctx);28732 push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &ZERO_RESIDUAL[..B4 * B4], fctx);
28731 push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &ZERO_RESIDUAL[..B4 * B4], fctx);28733 push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &ZERO_RESIDUAL[..B4 * B4], fctx);
28732- (vec![0i32; B4 * B4], vec![0i32; B4 * B4])28734+ (Grid::Zero(B4 * B4), Grid::Zero(B4 * B4))
28733 } else {28735 } else {
28734 let around = neighbours.around_mi(group_mi, 8);28736 let around = neighbours.around_mi(group_mi, 8);
28735 let ug = read_inter_plane(28737 let ug = read_inter_plane(
@@ -29036,7 +29038,7 @@ fn decode_intra_sub8_leaf(
29036 }29038 }
29037 } else {29039 } else {
29038 let grid_levels = if skip {29040 let grid_levels = if skip {
29039- let zeros = vec![0i32; bw * bh];29041+ let zeros = Grid::Zero(bw * bh);
29040 push_intra_rect(0, 29042 push_intra_rect(0,
29041 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,29043 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
29042 smooth_neighbor, fctx,29044 smooth_neighbor, fctx,
@@ -29166,14 +29168,14 @@ fn decode_intra_sub8_leaf(
29166 record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);29168 record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);
29167 29169
29168 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));29170 let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
29169- let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if skip {29171+ let (u_grid, v_grid): (Grid, Grid) = if skip {
29170 if alpha.is_some() {29172 if alpha.is_some() {
29171 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));29173 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
29172 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));29174 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
29173 }29175 }
29174 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);29176 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);
29175 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);29177 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);
29176- (vec![0i32; 16], vec![0i32; 16])29178+ (Grid::Zero(16), Grid::Zero(16))
29177 } else {29179 } else {
29178 let chroma_around = neighbours.around_mi(group_mi, 8);29180 let chroma_around = neighbours.around_mi(group_mi, 8);
29179 let ug = read_plane(29181 let ug = read_plane(
@@ -29751,7 +29753,7 @@ fn decode_inter_sub8_rect2(
29751 let (u_grid, v_grid) = if last_skip {29753 let (u_grid, v_grid) = if last_skip {
29752 push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &ZERO_RESIDUAL[..B4 * B4], fctx);29754 push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &ZERO_RESIDUAL[..B4 * B4], fctx);
29753 push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &ZERO_RESIDUAL[..B4 * B4], fctx);29755 push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &ZERO_RESIDUAL[..B4 * B4], fctx);
29754- (vec![0i32; B4 * B4], vec![0i32; B4 * B4])29756+ (Grid::Zero(B4 * B4), Grid::Zero(B4 * B4))
29755 } else {29757 } else {
29756 let around = neighbours.around_mi(group_mi, 8);29758 let around = neighbours.around_mi(group_mi, 8);
29757 let ug = read_inter_plane(29759 let ug = read_inter_plane(
@@ -30597,9 +30599,9 @@ fn decode_inter_block8(
30597 Pred::dense(&pred_v),30599 Pred::dense(&pred_v),
30598 &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,30600 &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,
30599 );30601 );
30600- luma_grid = vec![0i32; SIDE * SIDE];30602+ luma_grid = Grid::Zero(SIDE * SIDE);
30601- u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];30603+ u_grid = Grid::Zero(CHROMA_SIDE * CHROMA_SIDE);
30602- v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];30604+ v_grid = Grid::Zero(CHROMA_SIDE * CHROMA_SIDE);
30603 } else {30605 } else {
30604 let around = neighbours.around_mi(leaf_mi, 8);30606 let around = neighbours.around_mi(leaf_mi, 8);
30605 let (grid8, luma_tx_type) = read_inter_luma8(30607 let (grid8, luma_tx_type) = read_inter_luma8(
@@ -31245,9 +31247,9 @@ fn decode_inter_block8(
31245 Pred::dense(&pred_v),31247 Pred::dense(&pred_v),
31246 &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,31248 &ZERO_RESIDUAL[..CHROMA_SIDE * CHROMA_SIDE], fctx,
31247 );31249 );
31248- luma_grid = vec![0i32; SIDE * SIDE];31250+ luma_grid = Grid::Zero(SIDE * SIDE);
31249- u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];31251+ u_grid = Grid::Zero(CHROMA_SIDE * CHROMA_SIDE);
31250- v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];31252+ v_grid = Grid::Zero(CHROMA_SIDE * CHROMA_SIDE);
31251 } else {31253 } else {
31252 let around = neighbours.around_mi(leaf_mi, 8);31254 let around = neighbours.around_mi(leaf_mi, 8);
31253 let (grid8, luma_tx_type) = read_inter_luma8(31255 let (grid8, luma_tx_type) = read_inter_luma8(
@@ -31611,7 +31613,7 @@ fn decode_inter_block8(
31611 filter_intra,31613 filter_intra,
31612 smooth_neighbor, fctx,31614 smooth_neighbor, fctx,
31613 );31615 );
31614- vec![0i32; tx_px * tx_px]31616+ Grid::Zero(tx_px * tx_px)
31615 } else {31617 } else {
31616 // The unit is smaller than the block it sits in, so31618 // The unit is smaller than the block it sits in, so
31617 // `txb_skip_ctx` is the neighbour-magnitude table, not31619 // `txb_skip_ctx` is the neighbour-magnitude table, not
@@ -31698,16 +31700,16 @@ fn decode_inter_block8(
31698 None,31700 None,
31699 smooth_neighbor_uv, fctx,31701 smooth_neighbor_uv, fctx,
31700 );31702 );
31701- luma_grid = vec![0i32; SIDE * SIDE];31703+ luma_grid = Grid::Zero(SIDE * SIDE);
31702- u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];31704+ u_grid = Grid::Zero(CHROMA_SIDE * CHROMA_SIDE);
31703- v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];31705+ v_grid = Grid::Zero(CHROMA_SIDE * CHROMA_SIDE);
31704 } else {31706 } else {
31705 let around = neighbours.around_mi(leaf_mi, 8);31707 let around = neighbours.around_mi(leaf_mi, 8);
31706 luma_grid = if split8 {31708 luma_grid = if split8 {
31707 // Already coded and reconstructed unit by unit above; the31709 // Already coded and reconstructed unit by unit above; the
31708 // block-level grid only feeds the neighbour write-back,31710 // block-level grid only feeds the neighbour write-back,
31709 // which the `saved_luma_ctx` restore below keeps per-TU.31711 // which the `saved_luma_ctx` restore below keeps per-TU.
31710- vec![0i32; SIDE * SIDE]31712+ Grid::Zero(SIDE * SIDE)
31711 } else {31713 } else {
31712 if let Some(buf) = &palette_y_buf {31714 if let Some(buf) = &palette_y_buf {
31713 set_palette_pred(buf.clone(), fctx);31715 set_palette_pred(buf.clone(), fctx);