forge
Explore
Log in

Don't you dare go Hollow

Entropy parse split from reconstruction inside the tile decoder

Browse files at this commit

1499973b1f11767896691f7a1489d62a9da5d4beAhmet Kaan GümüşParent: 1a45793
  • refactor
    • entropy parse split from reconstruction inside the tile decoder
Show full message
refactor(av1): entropy parse split from reconstruction inside the tile decoder

Step (i) of the decode-speed wavefront: a superblock's parsing no longer
writes (or reads) the frame's own planes. Every `PlaneBuf::reconstruct*`
call is recorded as a `ReconOp` on `FrameCtx::recon_ops` -- the resolved
argument tuple of the call it replaces -- and `flush_recon` replays the
queue, in push order, at the top of each superblock visit and at the end of
each tile. Same thread, same order, so the output is byte-identical, and
step (ii) can hand the replay to a superblock-row worker.

Three pixel dependencies that used to sit in the middle of parsing moved
with it:

- the CfL AC signal is no longer read at parse time (it wanted this block's
  own luma, which is now still queued); parse records the luma window as a
  `CflSrc` and the replay reads it back off the luma it has just written;
- the palette/intrabc prediction override no longer crosses into
  reconstruction through `FrameCtx::palette_pred` -- the push site takes it,
  in parse order, and carries it in the record, so `reconstruct`/
  `reconstruct_rect` take it as a parameter;
- `reconstruct_mc` folded into `reconstruct_mc_rect`, its only body.

Two parse-time pixel READS survive and flush ahead of themselves instead:
the intrabc source fetch and the interintra intra predictor. They are what
step (ii) still has to move, and naming them is the point of doing it this
way.

Byte-exact at 1 thread on seg1080/seg4k/seg4k_lr/palette_screen_witness.
crates/ec-av1/src/decode.rsmodified+407 -186
@@ -79,6 +79,9 @@ pub(crate) struct FrameCtx {
7979 pub(crate) last_frame_wide_margin: std::cell::RefCell<Option<Picture>>,
8080 pub(crate) reach_sb_px: std::cell::Cell<usize>,
8181 pub(crate) grain_bit_depth: std::cell::Cell<u32>,
82+ /// lane-wave1 step (i): this superblock's recorded pixel writes, see
83+ /// [`ReconOp`]. Pushed by parse, replayed by [`flush_recon`].
84+ pub(crate) recon_ops: std::cell::RefCell<Vec<ReconOp>>,
8285 }
8386
8487 impl std::fmt::Debug for FrameCtx {
@@ -136,6 +139,7 @@ impl FrameCtx {
136139 last_frame_wide_margin: std::cell::RefCell::new(None),
137140 reach_sb_px: std::cell::Cell::new(crate::encode::SUPERBLOCK),
138141 grain_bit_depth: std::cell::Cell::new(8),
142+ recon_ops: std::cell::RefCell::new(Vec::new()),
139143 }
140144 }
141145 }
@@ -2010,6 +2014,204 @@ fn take_palette_pred(fctx: &crate::decode::FrameCtx) -> Option<Vec<u16>> {
20102014 got
20112015 }
20122016
2017+/// The luma window a `UV_CFL_PRED` chroma block averages its AC signal over
2018+/// (lane-wave1 step (i)). Parse records the window; [`flush_recon`] reads the
2019+/// pixels, because at parse time this block's own luma is still queued.
2020+#[derive(Clone, Copy, Debug)]
2021+pub(crate) struct CflSrc {
2022+ px: usize,
2023+ py: usize,
2024+ bw: usize,
2025+ bh: usize,
2026+ /// Which averager the parse site asked for -- [`cfl_ac_q3_rect`] and
2027+ /// [`cfl_ac_q3`] are not the same function at `bw == bh`.
2028+ rect: bool,
2029+}
2030+
2031+fn cfl_src(px: usize, py: usize, side: usize) -> CflSrc {
2032+ CflSrc { px, py, bw: side, bh: side, rect: false }
2033+}
2034+
2035+fn cfl_src_rect(px: usize, py: usize, bw: usize, bh: usize) -> CflSrc {
2036+ CflSrc { px, py, bw, bh, rect: true }
2037+}
2038+
2039+/// lane-wave1 step (i): the pixel-writing half of block decoding, recorded
2040+/// instead of executed. Each variant is the resolved argument tuple of the
2041+/// `PlaneBuf::reconstruct*` call it replaces, so replaying the queue in push
2042+/// order performs exactly the same writes in exactly the same order --
2043+/// entropy parsing no longer touches the frame's own planes (except the two
2044+/// sites named in [`flush_recon`]'s doc), which is what lets step (ii) run
2045+/// the replay on a superblock-row wavefront worker.
2046+pub(crate) enum ReconOp {
2047+ Intra {
2048+ plane: usize,
2049+ x: usize,
2050+ y: usize,
2051+ bw: usize,
2052+ bh: usize,
2053+ /// `true` when the parse site called `reconstruct_rect` (whose
2054+ /// `edges_rect` differs from `edges` even at `bw == bh`).
2055+ rect: bool,
2056+ mode: usize,
2057+ angle_delta: i32,
2058+ reach: Reach,
2059+ residual: Vec<i32>,
2060+ cfl: Option<(i32, CflSrc)>,
2061+ filter_intra: Option<usize>,
2062+ smooth_neighbor: bool,
2063+ /// The palette/intrabc prediction override, taken off
2064+ /// [`FrameCtx::palette_pred`] at PUSH time (parse order), never read
2065+ /// from that slot by the replay.
2066+ pred: Option<Vec<u16>>,
2067+ },
2068+ Mc {
2069+ plane: usize,
2070+ x: usize,
2071+ y: usize,
2072+ stride: usize,
2073+ w: usize,
2074+ h: usize,
2075+ prediction: Vec<u16>,
2076+ residual: Vec<i32>,
2077+ },
2078+}
2079+
2080+fn push_op(fctx: &crate::decode::FrameCtx, op: ReconOp) {
2081+ fctx.recon_ops.with(|c| c.borrow_mut().push(op));
2082+}
2083+
2084+/// [`PlaneBuf::reconstruct`], recorded (lane-wave1 step (i)).
2085+#[allow(clippy::too_many_arguments)]
2086+fn push_intra(
2087+ plane: usize,
2088+ x: usize,
2089+ y: usize,
2090+ side: usize,
2091+ mode: usize,
2092+ angle_delta: i32,
2093+ reach: Reach,
2094+ residual: &[i32],
2095+ cfl: Option<(i32, CflSrc)>,
2096+ filter_intra: Option<usize>,
2097+ smooth_neighbor: bool, fctx: &crate::decode::FrameCtx,
2098+) {
2099+ let pred = take_palette_pred(fctx);
2100+ push_op(fctx, ReconOp::Intra {
2101+ plane, x, y, bw: side, bh: side, rect: false, mode, angle_delta, reach,
2102+ residual: residual.to_vec(), cfl, filter_intra, smooth_neighbor, pred,
2103+ });
2104+}
2105+
2106+/// [`PlaneBuf::reconstruct_rect`], recorded (lane-wave1 step (i)).
2107+#[allow(clippy::too_many_arguments)]
2108+fn push_intra_rect(
2109+ plane: usize,
2110+ x: usize,
2111+ y: usize,
2112+ bw: usize,
2113+ bh: usize,
2114+ mode: usize,
2115+ angle_delta: i32,
2116+ reach: Reach,
2117+ residual: &[i32],
2118+ cfl: Option<(i32, CflSrc)>,
2119+ filter_intra: Option<usize>,
2120+ smooth_neighbor: bool, fctx: &crate::decode::FrameCtx,
2121+) {
2122+ let pred = take_palette_pred(fctx);
2123+ push_op(fctx, ReconOp::Intra {
2124+ plane, x, y, bw, bh, rect: true, mode, angle_delta, reach,
2125+ residual: residual.to_vec(), cfl, filter_intra, smooth_neighbor, pred,
2126+ });
2127+}
2128+
2129+/// [`PlaneBuf::reconstruct_mc_rect`] at `stride == w == h == side`, recorded.
2130+fn push_mc(
2131+ plane: usize,
2132+ x: usize,
2133+ y: usize,
2134+ side: usize,
2135+ prediction: &[u16],
2136+ residual: &[i32], fctx: &crate::decode::FrameCtx,
2137+) {
2138+ push_mc_rect(plane, x, y, side, side, side, prediction, residual, fctx);
2139+}
2140+
2141+/// [`PlaneBuf::reconstruct_mc_rect`], recorded (lane-wave1 step (i)).
2142+#[allow(clippy::too_many_arguments)]
2143+fn push_mc_rect(
2144+ plane: usize,
2145+ x: usize,
2146+ y: usize,
2147+ stride: usize,
2148+ w: usize,
2149+ h: usize,
2150+ prediction: &[u16],
2151+ residual: &[i32], fctx: &crate::decode::FrameCtx,
2152+) {
2153+ push_op(fctx, ReconOp::Mc {
2154+ plane, x, y, stride, w, h,
2155+ prediction: prediction.to_vec(), residual: residual.to_vec(),
2156+ });
2157+}
2158+
2159+/// Replays every recorded [`ReconOp`] into the frame's planes, in push order,
2160+/// and empties the queue (lane-wave1 step (i)).
2161+///
2162+/// Called at the top of each superblock visit and at the end of each tile, so
2163+/// a whole superblock's parsing runs with no plane access at all; the two
2164+/// parse-time pixel READS that survive -- the intrabc source fetch and the
2165+/// interintra intra predictor -- flush ahead of themselves instead, which
2166+/// keeps them byte-exact and names exactly what step (ii) still has to move.
2167+fn flush_recon(
2168+ fctx: &crate::decode::FrameCtx,
2169+ y: &mut PlaneBuf<'static>,
2170+ u: &mut PlaneBuf<'static>,
2171+ v: &mut PlaneBuf<'static>,
2172+) {
2173+ let ops = fctx.recon_ops.with(|c| std::mem::take(&mut *c.borrow_mut()));
2174+ for op in ops {
2175+ match op {
2176+ ReconOp::Intra {
2177+ plane, x, y: oy, bw, bh, rect, mode, angle_delta, reach, residual, cfl,
2178+ filter_intra, smooth_neighbor, pred,
2179+ } => {
2180+ // The CfL AC signal is read HERE, off the luma this very
2181+ // replay has already written for this block -- at parse time
2182+ // it would have been the previous frame's samples.
2183+ let ac = cfl.map(|(alpha, src)| {
2184+ let sig = if src.rect {
2185+ cfl_ac_q3_rect(&*y, src.px, src.py, src.bw, src.bh)
2186+ } else {
2187+ cfl_ac_q3(&*y, src.px, src.py, src.bw)
2188+ };
2189+ (alpha, sig)
2190+ });
2191+ let cfl = ac.as_ref().map(|(a, sig)| (*a, sig.as_slice()));
2192+ let target: &mut PlaneBuf<'static> =
2193+ match plane { 0 => &mut *y, 1 => &mut *u, _ => &mut *v };
2194+ if rect {
2195+ target.reconstruct_rect(
2196+ x, oy, bw, bh, mode, angle_delta, reach, &residual, cfl, filter_intra,
2197+ smooth_neighbor, pred, fctx,
2198+ );
2199+ } else {
2200+ target.reconstruct(
2201+ x, oy, bw, mode, angle_delta, reach, &residual, cfl, filter_intra,
2202+ smooth_neighbor, pred, fctx,
2203+ );
2204+ }
2205+ }
2206+ ReconOp::Mc { plane, x, y: oy, stride, w, h, prediction, residual } => {
2207+ let target: &mut PlaneBuf<'static> =
2208+ match plane { 0 => &mut *y, 1 => &mut *u, _ => &mut *v };
2209+ target.reconstruct_mc_rect(x, oy, stride, w, h, &prediction, &residual, fctx);
2210+ }
2211+ }
2212+ }
2213+}
2214+
20132215 thread_local! {
20142216 /// The current frame's `mi` grid, kept only while a frame header set
20152217 /// `allow_intrabc` -- an intrabc block's DV predictor is the ordinary
@@ -7693,7 +7895,7 @@ fn decode_rect_split(
76937895 set_palette_pred(tu_buf, fctx);
76947896 }
76957897 if m.skip {
7696- y.reconstruct_rect(
7898+ push_intra_rect(0,
76977899 tu_px,
76987900 tu_py,
76997901 tx_w,
@@ -7751,7 +7953,7 @@ fn decode_rect_split(
77517953 plane_q_delta(0, fctx).1,
77527954 tu_tx_type,
77537955 );
7754- y.reconstruct_rect(
7956+ push_intra_rect(0,
77557957 tu_px,
77567958 tu_py,
77577959 tx_w,
@@ -7807,7 +8009,7 @@ fn decode_rect_split(
78078009 plane_q_delta(0, fctx).1,
78088010 tu_tx_type,
78098011 );
7810- y.reconstruct_rect(
8012+ push_intra_rect(0,
78118013 tu_px,
78128014 tu_py,
78138015 tx_w,
@@ -7854,23 +8056,23 @@ fn decode_rect_split(
78548056 }
78558057 }
78568058 // CHROMA: one un-split rect transform for the whole strip.
7857- let ac = m.alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
8059+ let ac = m.alpha.map(|_| cfl_src_rect(px, py, bw, bh));
78588060 let reach = block_reach;
78598061 let (u_grid, v_grid) = if m.skip {
78608062 let zero = vec![0i32; chroma_w * chroma_h];
78618063 if let Some((ub, _)) = &m.palette_uv {
78628064 set_palette_pred(ub.clone(), fctx);
78638065 }
7864- u.reconstruct_rect(
8066+ push_intra_rect(1,
78658067 cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero,
7866- m.alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, m.smooth_neighbor_uv, fctx,
8068+ m.alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, m.smooth_neighbor_uv, fctx,
78678069 );
78688070 if let Some((_, vb)) = &m.palette_uv {
78698071 set_palette_pred(vb.clone(), fctx);
78708072 }
7871- v.reconstruct_rect(
8073+ push_intra_rect(2,
78728074 cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero,
7873- m.alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, m.smooth_neighbor_uv, fctx,
8075+ m.alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, m.smooth_neighbor_uv, fctx,
78748076 );
78758077 (zero.clone(), zero)
78768078 } else {
@@ -7918,14 +8120,14 @@ fn decode_rect_split(
79188120 );
79198121 let cfl = m
79208122 .alpha
7921- .zip(ac.as_deref())
8123+ .zip(ac)
79228124 .map(|((au, av), ac)| (if plane_idx == 1 { au } else { av }, ac));
7923- let plane = if plane_idx == 1 { &mut *u } else { &mut *v };
8125+ let _plane = if plane_idx == 1 { &mut *u } else { &mut *v };
79248126 if let Some((ub, vb)) = &m.palette_uv {
79258127 let buf = if plane_idx == 1 { ub } else { vb };
79268128 set_palette_pred(buf.clone(), fctx);
79278129 }
7928- plane.reconstruct_rect(
8130+ push_intra_rect(plane_idx,
79298131 cpx,
79308132 cpy,
79318133 chroma_w,
@@ -8888,7 +9090,7 @@ fn decode_block_rect(
88889090 )
88899091 });
88909092 if skip {
8891- y.reconstruct_rect(
9093+ push_intra_rect(0,
88929094 px,
88939095 py,
88949096 bw,
@@ -8901,11 +9103,11 @@ fn decode_block_rect(
89019103 filter_intra,
89029104 smooth_neighbor, fctx,
89039105 );
8904- let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
9106+ let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
89059107 if let Some((ub, _)) = &palette_uv_bufs {
89069108 set_palette_pred(ub.clone(), fctx);
89079109 }
8908- u.reconstruct_rect(
9110+ push_intra_rect(1,
89099111 cpx,
89109112 cpy,
89119113 chroma_w,
@@ -8914,14 +9116,14 @@ fn decode_block_rect(
89149116 angle_delta_uv,
89159117 reach,
89169118 &vec![0i32; chroma_w * chroma_h],
8917- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
9119+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
89189120 None,
89199121 smooth_neighbor_uv, fctx,
89209122 );
89219123 if let Some((_, vb)) = &palette_uv_bufs {
89229124 set_palette_pred(vb.clone(), fctx);
89239125 }
8924- v.reconstruct_rect(
9126+ push_intra_rect(2,
89259127 cpx,
89269128 cpy,
89279129 chroma_w,
@@ -8930,7 +9132,7 @@ fn decode_block_rect(
89309132 angle_delta_uv,
89319133 reach,
89329134 &vec![0i32; chroma_w * chroma_h],
8933- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
9135+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
89349136 None,
89359137 smooth_neighbor_uv, fctx,
89369138 );
@@ -9018,7 +9220,7 @@ fn decode_block_rect(
90189220 plane_q_delta(0, fctx).1,
90199221 luma_tx_type,
90209222 );
9021- y.reconstruct_rect(
9223+ push_intra_rect(0,
90229224 px,
90239225 py,
90249226 bw,
@@ -9031,7 +9233,7 @@ fn decode_block_rect(
90319233 filter_intra,
90329234 smooth_neighbor, fctx,
90339235 );
9034- let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
9236+ let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
90359237 if let Some((ub, _)) = &palette_uv_bufs {
90369238 set_palette_pred(ub.clone(), fctx);
90379239 }
@@ -9062,7 +9264,7 @@ fn decode_block_rect(
90629264 plane_q_delta(1, fctx).1,
90639265 u_tx_type,
90649266 );
9065- u.reconstruct_rect(
9267+ push_intra_rect(1,
90669268 cpx,
90679269 cpy,
90689270 chroma_w,
@@ -9071,7 +9273,7 @@ fn decode_block_rect(
90719273 angle_delta_uv,
90729274 reach,
90739275 &u_residual,
9074- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
9276+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
90759277 None,
90769278 smooth_neighbor_uv, fctx,
90779279 );
@@ -9105,7 +9307,7 @@ fn decode_block_rect(
91059307 plane_q_delta(2, fctx).1,
91069308 v_tx_type,
91079309 );
9108- v.reconstruct_rect(
9310+ push_intra_rect(2,
91099311 cpx,
91109312 cpy,
91119313 chroma_w,
@@ -9114,7 +9316,7 @@ fn decode_block_rect(
91149316 angle_delta_uv,
91159317 reach,
91169318 &v_residual,
9117- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
9319+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
91189320 None,
91199321 smooth_neighbor_uv, fctx,
91209322 );
@@ -9359,24 +9561,24 @@ fn decode_leaf_rect(
93599561 if let Some(b) = &palette_y_buf {
93609562 set_palette_pred(b.clone(), fctx);
93619563 }
9362- y.reconstruct_rect(
9564+ push_intra_rect(0,
93639565 px, py, bw, bh, mode, angle_delta_y, reach, &luma_levels, None, filter_intra,
93649566 smooth_neighbor, fctx,
93659567 );
9366- let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
9568+ let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
93679569 if let Some((ub, _)) = &palette_uv_bufs {
93689570 set_palette_pred(ub.clone(), fctx);
93699571 }
9370- u.reconstruct_rect(
9572+ push_intra_rect(1,
93719573 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_levels,
9372- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx,
9574+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx,
93739575 );
93749576 if let Some((_, vb)) = &palette_uv_bufs {
93759577 set_palette_pred(vb.clone(), fctx);
93769578 }
9377- v.reconstruct_rect(
9579+ push_intra_rect(2,
93789580 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_levels,
9379- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx,
9581+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx,
93809582 );
93819583 } else {
93829584 // lane-rectx: a genuine 16x8/8x16 luma transform (`TxbSet::LumaRect16x8`,
@@ -9412,11 +9614,11 @@ fn decode_leaf_rect(
94129614 if let Some(b) = &palette_y_buf {
94139615 set_palette_pred(b.clone(), fctx);
94149616 }
9415- y.reconstruct_rect(
9617+ push_intra_rect(0,
94169618 px, py, bw, bh, mode, angle_delta_y, reach, &luma_residual, None, filter_intra,
94179619 smooth_neighbor, fctx,
94189620 );
9419- let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
9621+ let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
94209622 let u_default_tx = default_intra_tx_type(uv_predict_mode as u8);
94219623 let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1);
94229624 let mut u_coding = cdfs.txb(TxbSet::ChromaRect8x4, uv_predict_mode);
@@ -9432,9 +9634,9 @@ fn decode_leaf_rect(
94329634 if let Some((ub, _)) = &palette_uv_bufs {
94339635 set_palette_pred(ub.clone(), fctx);
94349636 }
9435- u.reconstruct_rect(
9637+ push_intra_rect(1,
94369638 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_residual,
9437- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx,
9639+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx,
94389640 );
94399641 let v_default_tx = default_intra_tx_type(uv_predict_mode as u8);
94409642 let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1);
@@ -9451,9 +9653,9 @@ fn decode_leaf_rect(
94519653 if let Some((_, vb)) = &palette_uv_bufs {
94529654 set_palette_pred(vb.clone(), fctx);
94539655 }
9454- v.reconstruct_rect(
9656+ push_intra_rect(2,
94559657 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual,
9456- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx,
9658+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx,
94579659 );
94589660 RECT_LEAF_COEFF_HITS.with(|c| c.set(c.get() + 1));
94599661 }
@@ -9798,7 +10000,7 @@ fn decode_block_rect4(
979810000 if let Some(b) = &palette_y_buf {
979910001 set_palette_pred(b.clone(), fctx);
980010002 }
9801- y.reconstruct_rect(
10003+ push_intra_rect(0,
980210004 px,
980310005 py,
980410006 bw,
@@ -9811,8 +10013,8 @@ fn decode_block_rect4(
981110013 filter_intra,
981210014 smooth_neighbor, fctx,
981310015 );
9814- let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
9815- for (plane, buf, levels, tx_type) in [
10016+ let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
10017+ for (plane, _buf, levels, tx_type) in [
981610018 (1usize, &mut *u, &u_levels, u_tx_type),
981710019 (2, &mut *v, &v_levels, v_tx_type),
981810020 ] {
@@ -9829,7 +10031,7 @@ fn decode_block_rect4(
982910031 if let Some((ub, vb)) = &palette_uv_bufs {
983010032 set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx);
983110033 }
9832- buf.reconstruct_rect(
10034+ push_intra_rect(plane,
983310035 cpx,
983410036 cpy,
983510037 chroma_w,
@@ -9839,7 +10041,7 @@ fn decode_block_rect4(
983910041 reach,
984010042 &residual,
984110043 alpha
9842- .zip(ac.as_deref())
10044+ .zip(ac)
984310045 .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
984410046 None,
984510047 smooth_neighbor_uv, fctx,
@@ -9874,7 +10076,7 @@ fn decode_block_rect4(
987410076 if let Some(b) = &palette_y_buf {
987510077 set_palette_pred(b.clone(), fctx);
987610078 }
9877- y.reconstruct_rect(
10079+ push_intra_rect(0,
987810080 px,
987910081 py,
988010082 bw,
@@ -9887,11 +10089,11 @@ fn decode_block_rect4(
988710089 filter_intra,
988810090 smooth_neighbor, fctx,
988910091 );
9890- let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
10092+ let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
989110093 if let Some((ub, _)) = &palette_uv_bufs {
989210094 set_palette_pred(ub.clone(), fctx);
989310095 }
9894- u.reconstruct_rect(
10096+ push_intra_rect(1,
989510097 cpx,
989610098 cpy,
989710099 chroma_w,
@@ -9900,14 +10102,14 @@ fn decode_block_rect4(
990010102 angle_delta_uv,
990110103 reach,
990210104 &u_levels,
9903- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
10105+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
990410106 None,
990510107 smooth_neighbor_uv, fctx,
990610108 );
990710109 if let Some((_, vb)) = &palette_uv_bufs {
990810110 set_palette_pred(vb.clone(), fctx);
990910111 }
9910- v.reconstruct_rect(
10112+ push_intra_rect(2,
991110113 cpx,
991210114 cpy,
991310115 chroma_w,
@@ -9916,7 +10118,7 @@ fn decode_block_rect4(
991610118 angle_delta_uv,
991710119 reach,
991810120 &v_levels,
9919- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
10121+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
992010122 None,
992110123 smooth_neighbor_uv, fctx,
992210124 );
@@ -10200,7 +10402,7 @@ fn decode_rect4_16_strip(
1020010402 set_palette_pred(tu_buf, fctx);
1020110403 }
1020210404 if skip {
10203- y.reconstruct_rect(
10405+ push_intra_rect(0,
1020410406 tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &zero_tu,
1020510407 None, filter_intra, smooth_neighbor, fctx,
1020610408 );
@@ -10239,7 +10441,7 @@ fn decode_rect4_16_strip(
1023910441 plane_q_delta(0, fctx).1,
1024010442 tu_tx_type,
1024110443 );
10242- y.reconstruct_rect(
10444+ push_intra_rect(0,
1024310445 tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &residual,
1024410446 None, filter_intra, smooth_neighbor, fctx,
1024510447 );
@@ -10285,7 +10487,7 @@ fn decode_rect4_16_strip(
1028510487 if let Some(b) = &palette_y_buf {
1028610488 set_palette_pred(b.clone(), fctx);
1028710489 }
10288- y.reconstruct_rect(
10490+ push_intra_rect(0,
1028910491 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
1029010492 smooth_neighbor, fctx,
1029110493 );
@@ -10324,7 +10526,7 @@ fn decode_rect4_16_strip(
1032410526 if let Some(b) = &palette_y_buf {
1032510527 set_palette_pred(b.clone(), fctx);
1032610528 }
10327- y.reconstruct_rect(
10529+ push_intra_rect(0,
1032810530 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
1032910531 smooth_neighbor, fctx,
1033010532 );
@@ -10388,15 +10590,15 @@ fn decode_rect4_16_strip(
1038810590 // `mbmi->skip_txfm`, so a skipped `UV_CFL_PRED` block is still
1038910591 // DC + alpha * luma-AC. Dropping the CfL term here left a
1039010592 // chroma-only bounded box on ReelC's key frames.
10391- let ac = alpha.map(|_| cfl_ac_q3_rect(y, ppx, ppy, pw, ph));
10593+ let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph));
1039210594 if alpha.is_some() {
1039310595 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
1039410596 }
10395- for (buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] {
10597+ for (_buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] {
1039610598 if let Some((ub, vb)) = &palette_uv_bufs {
1039710599 set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx);
1039810600 }
10399- buf.reconstruct_rect(
10601+ push_intra_rect(plane,
1040010602 cpx,
1040110603 cpy,
1040210604 cw,
@@ -10406,7 +10608,7 @@ fn decode_rect4_16_strip(
1040610608 pair_reach,
1040710609 &zeros,
1040810610 alpha
10409- .zip(ac.as_deref())
10611+ .zip(ac)
1041010612 .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
1041110613 None,
1041210614 smooth_neighbor_uv, fctx,
@@ -10436,8 +10638,8 @@ fn decode_rect4_16_strip(
1043610638 let (u_levels, u_tx_type) = planes.pop().expect("plane 1");
1043710639 // CfL averages the luma of the WHOLE pair, the region this one
1043810640 // chroma transform covers.
10439- let ac = alpha.map(|_| cfl_ac_q3_rect(y, ppx, ppy, pw, ph));
10440- for (plane, buf, levels, tx_type) in [
10641+ let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph));
10642+ for (plane, _buf, levels, tx_type) in [
1044110643 (1usize, &mut *u, &u_levels, u_tx_type),
1044210644 (2, &mut *v, &v_levels, v_tx_type),
1044310645 ] {
@@ -10454,7 +10656,7 @@ fn decode_rect4_16_strip(
1045410656 if let Some((ub, vb)) = &palette_uv_bufs {
1045510657 set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx);
1045610658 }
10457- buf.reconstruct_rect(
10659+ push_intra_rect(plane,
1045810660 cpx,
1045910661 cpy,
1046010662 cw,
@@ -10464,7 +10666,7 @@ fn decode_rect4_16_strip(
1046410666 pair_reach,
1046510667 &residual,
1046610668 alpha
10467- .zip(ac.as_deref())
10669+ .zip(ac)
1046810670 .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
1046910671 None,
1047010672 smooth_neighbor_uv, fctx,
@@ -10757,7 +10959,7 @@ fn decode_block_rect64(
1075710959 )
1075810960 });
1075910961 if skip {
10760- y.reconstruct_rect(
10962+ push_intra_rect(0,
1076110963 px,
1076210964 py,
1076310965 bw,
@@ -10770,11 +10972,11 @@ fn decode_block_rect64(
1077010972 filter_intra,
1077110973 smooth_neighbor, fctx,
1077210974 );
10773- let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
10975+ let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
1077410976 if let Some((ub, _)) = &palette_uv_bufs {
1077510977 set_palette_pred(ub.clone(), fctx);
1077610978 }
10777- u.reconstruct_rect(
10979+ push_intra_rect(1,
1077810980 cpx,
1077910981 cpy,
1078010982 chroma_w,
@@ -10783,14 +10985,14 @@ fn decode_block_rect64(
1078310985 angle_delta_uv,
1078410986 reach,
1078510987 &vec![0i32; chroma_w * chroma_h],
10786- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
10988+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1078710989 None,
1078810990 smooth_neighbor_uv, fctx,
1078910991 );
1079010992 if let Some((_, vb)) = &palette_uv_bufs {
1079110993 set_palette_pred(vb.clone(), fctx);
1079210994 }
10793- v.reconstruct_rect(
10995+ push_intra_rect(2,
1079410996 cpx,
1079510997 cpy,
1079610998 chroma_w,
@@ -10799,7 +11001,7 @@ fn decode_block_rect64(
1079911001 angle_delta_uv,
1080011002 reach,
1080111003 &vec![0i32; chroma_w * chroma_h],
10802- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
11004+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1080311005 None,
1080411006 smooth_neighbor_uv, fctx,
1080511007 );
@@ -10896,7 +11098,7 @@ fn decode_block_rect64(
1089611098 plane_q_delta(0, fctx).1,
1089711099 luma_tx_type,
1089811100 );
10899- y.reconstruct_rect(
11101+ push_intra_rect(0,
1090011102 px,
1090111103 py,
1090211104 bw,
@@ -10925,7 +11127,7 @@ fn decode_block_rect64(
1092511127 }
1092611128 // CHROMA: a real, untruncated chroma_w x chroma_h transform -- no
1092711129 // corner crop needed (see doc comment).
10928- let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
11130+ let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
1092911131 // The chroma plane is never truncated (both axes <= 32 after
1093011132 // subsampling). Under a 1:4 strip it is a true 32x8/8x32:
1093111133 // `get_txsize_entropy_ctx(TX_32X8)` = (TX_8X8 + TX_32X32 + 1) >> 1 =
@@ -10989,7 +11191,7 @@ fn decode_block_rect64(
1098911191 if let Some((ub, _)) = &palette_uv_bufs {
1099011192 set_palette_pred(ub.clone(), fctx);
1099111193 }
10992- u.reconstruct_rect(
11194+ push_intra_rect(1,
1099311195 cpx,
1099411196 cpy,
1099511197 chroma_w,
@@ -10998,7 +11200,7 @@ fn decode_block_rect64(
1099811200 angle_delta_uv,
1099911201 reach,
1100011202 &u_residual,
11001- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
11203+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1100211204 None,
1100311205 smooth_neighbor_uv, fctx,
1100411206 );
@@ -11046,7 +11248,7 @@ fn decode_block_rect64(
1104611248 if let Some((_, vb)) = &palette_uv_bufs {
1104711249 set_palette_pred(vb.clone(), fctx);
1104811250 }
11049- v.reconstruct_rect(
11251+ push_intra_rect(2,
1105011252 cpx,
1105111253 cpy,
1105211254 chroma_w,
@@ -11055,7 +11257,7 @@ fn decode_block_rect64(
1105511257 angle_delta_uv,
1105611258 reach,
1105711259 &v_residual,
11058- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
11260+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1105911261 None,
1106011262 smooth_neighbor_uv, fctx,
1106111263 );
@@ -11719,12 +11921,16 @@ impl PlaneBuf<'_> {
1171911921 residual: &[i32],
1172011922 cfl: Option<(i32, &[i32])>,
1172111923 filter_intra: Option<usize>,
11722- smooth_neighbor: bool, fctx: &crate::decode::FrameCtx,
11924+ smooth_neighbor: bool,
11925+ // lane-wave1 step (i): the palette/intrabc prediction override, taken
11926+ // off `FrameCtx::palette_pred` by the PUSH site (parse order) rather
11927+ // than by this replay.
11928+ pred: Option<Vec<u16>>, fctx: &crate::decode::FrameCtx,
1172311929 ) {
1172411930 // As [`Self::reconstruct`]'s own [`PALETTE_PRED`] override
1172511931 // (lane-palette2 r4): a palette block's prediction is the
1172611932 // reconstructed colour-index map, needing no edge pixels at all.
11727- let prediction = if let Some(buf) = take_palette_pred(fctx) {
11933+ let prediction = if let Some(buf) = pred {
1172811934 buf
1172911935 } else {
1173011936 let (above, left, corner) = self.edges_rect(x, y, bw, bh, reach);
@@ -11823,12 +12029,16 @@ impl PlaneBuf<'_> {
1182312029 // callers until a smooth/paeth `uv_mode` can reach this call at all
1182412030 // (still refused in `read_intra_mode`/`read_intra_mode_rect`), which
1182512031 // keeps `false` exact for chroma without this fn needing to know why.
11826- smooth_neighbor: bool, fctx: &crate::decode::FrameCtx,
12032+ smooth_neighbor: bool,
12033+ // lane-wave1 step (i): the palette/intrabc prediction override, taken
12034+ // off `FrameCtx::palette_pred` by the PUSH site (parse order) rather
12035+ // than by this replay.
12036+ pred: Option<Vec<u16>>, fctx: &crate::decode::FrameCtx,
1182712037 ) {
1182812038 // A palette block's own [`PALETTE_PRED`] override (lane-palette r2)
1182912039 // takes priority over `predict()`/`predict_filter_intra` entirely --
1183012040 // palette prediction needs no edge pixels at all.
11831- let prediction = if let Some(buf) = take_palette_pred(fctx) {
12041+ let prediction = if let Some(buf) = pred {
1183212042 buf
1183312043 } else {
1183412044 let (above, left, corner) = self.edges(x, y, side, reach);
@@ -11922,13 +12132,17 @@ fn read_plane(
1192212132 predict_mode: usize,
1192312133 angle_delta: i32,
1192412134 reach: Reach,
11925- plane: &mut PlaneBuf<'static>,
12135+ // lane-wave1 step (i): unread -- this reader records its write
12136+ // ([`push_intra`]/[`push_mc`]) instead of performing it; the borrow
12137+ // stays in the signature so every call site still proves the plane is
12138+ // exclusively held while its coefficients are parsed.
12139+ _plane: &mut PlaneBuf<'static>,
1192612140 x: usize,
1192712141 y: usize,
1192812142 side: usize,
1192912143 tx_side: usize,
1193012144 base_q_idx: u8,
11931- cfl: Option<(i32, &[i32])>,
12145+ cfl: Option<(i32, CflSrc)>,
1193212146 filter_intra: Option<usize>,
1193312147 // Only meaningful for `plane_idx == 0`: `Some` when this transform unit is
1193412148 // smaller than its own block (spec `get_txb_ctx_general`'s
@@ -12019,7 +12233,7 @@ fn read_plane(
1201912233 "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={levels:?} residual={residual:?}",
1202012234 );
1202112235 }
12022- plane.reconstruct(
12236+ push_intra(plane_idx,
1202312237 x,
1202412238 y,
1202512239 side,
@@ -12215,6 +12429,7 @@ fn decode_block(
1221512429 // block vector, with the BILINEAR kernel libaom forces for intrabc --
1221612430 // luma is a straight copy, chroma lands half-pel whenever the luma DV is
1221712431 // odd, which is exactly what the bilinear taps then interpolate.
12432+ flush_recon(fctx, y, u, v);
1221812433 let intrabc_bufs = intrabc_dv.map(|(dv_row, dv_col)| {
1221912434 let mut yb = vec![0u16; side * side];
1222012435 mc::predict_with_filter(
@@ -12333,7 +12548,7 @@ fn decode_block(
1233312548 y.width,
1233412549 y.height, fctx,
1233512550 );
12336- y.reconstruct(
12551+ push_intra(0,
1233712552 tu_px,
1233812553 tu_py,
1233912554 logical_tx,
@@ -12348,7 +12563,7 @@ fn decode_block(
1234812563 }
1234912564 }
1235012565 } else {
12351- y.reconstruct(
12566+ push_intra(0,
1235212567 px,
1235312568 py,
1235412569 side,
@@ -12361,7 +12576,7 @@ fn decode_block(
1236112576 smooth_neighbor, fctx,
1236212577 );
1236312578 }
12364- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
12579+ let ac = alpha.map(|_| cfl_src(px, py, side));
1236512580 let cn = (chroma_side / chroma_tx).max(1);
1236612581 for cu_row in 0..cn {
1236712582 for cu_col in 0..cn {
@@ -12379,7 +12594,7 @@ fn decode_block(
1237912594 if let Some((ub, _)) = &palette_uv_bufs {
1238012595 set_palette_pred(ub.clone(), fctx);
1238112596 }
12382- u.reconstruct(
12597+ push_intra(1,
1238312598 cu_x,
1238412599 cu_y,
1238512600 chroma_tx,
@@ -12387,14 +12602,14 @@ fn decode_block(
1238712602 angle_delta_uv,
1238812603 cu_r,
1238912604 &vec![0i32; chroma_tx * chroma_tx],
12390- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
12605+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1239112606 None,
1239212607 smooth_neighbor_uv, fctx,
1239312608 );
1239412609 if let Some((_, vb)) = &palette_uv_bufs {
1239512610 set_palette_pred(vb.clone(), fctx);
1239612611 }
12397- v.reconstruct(
12612+ push_intra(2,
1239812613 cu_x,
1239912614 cu_y,
1240012615 chroma_tx,
@@ -12402,7 +12617,7 @@ fn decode_block(
1240212617 angle_delta_uv,
1240312618 cu_r,
1240412619 &vec![0i32; chroma_tx * chroma_tx],
12405- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
12620+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1240612621 None,
1240712622 smooth_neighbor_uv, fctx,
1240812623 );
@@ -12444,7 +12659,7 @@ fn decode_block(
1244412659 None,
1244512660 smooth_neighbor, fctx,
1244612661 )?;
12447- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
12662+ let ac = alpha.map(|_| cfl_src(px, py, side));
1244812663 // Armed for exactly this block's two chroma reads (see
1244912664 // [`INTRABC_CHROMA_TX`]); the luma call above just set
1245012665 // [`LUMA_TX_TYPE`] to the type it coded.
@@ -12471,7 +12686,7 @@ fn decode_block(
1247112686 chroma_side,
1247212687 chroma_tx,
1247312688 base_q_idx,
12474- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
12689+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1247512690 None,
1247612691 None,
1247712692 smooth_neighbor_uv, fctx,
@@ -12502,7 +12717,7 @@ fn decode_block(
1250212717 chroma_side,
1250312718 chroma_tx,
1250412719 base_q_idx,
12505- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
12720+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1250612721 None,
1250712722 None,
1250812723 smooth_neighbor_uv, fctx,
@@ -12622,7 +12837,7 @@ fn decode_block(
1262212837 }
1262312838 // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where
1262412839 // this still runs after every luma unit of the block.
12625- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
12840+ let ac = alpha.map(|_| cfl_src(px, py, side));
1262612841 // The block's uv plane block is `chroma_side` across but its uv
1262712842 // transform is `chroma_tx` (`av1_get_max_uv_txsize` =
1262812843 // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`):
@@ -12657,7 +12872,7 @@ fn decode_block(
1265712872 dec, cdfs, chroma_set, scans.1, 1, cu_around[1], mode,
1265812873 uv_predict_mode, angle_delta_uv, cu_reach, u, cu_x, cu_y,
1265912874 chroma_tx, chroma_tx, base_q_idx,
12660- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
12875+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1266112876 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,
1266212877 )?;
1266312878 if let Some((_, vb)) = &palette_uv_bufs {
@@ -12667,7 +12882,7 @@ fn decode_block(
1266712882 dec, cdfs, chroma_set, scans.1, 2, cu_around[2], mode,
1266812883 uv_predict_mode, angle_delta_uv, cu_reach, v, cu_x, cu_y,
1266912884 chroma_tx, chroma_tx, base_q_idx,
12670- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
12885+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1267112886 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,
1267212887 )?;
1267312888 if cn > 1 {
@@ -12930,7 +13145,7 @@ fn decode_block_128rect(
1293013145 y.height, fctx,
1293113146 );
1293213147 if skip {
12933- y.reconstruct(
13148+ push_intra(0,
1293413149 tu_px, tu_py, logical_tx, mode, angle_delta_y, tu_r, &zero_tu, None,
1293513150 None, smooth_neighbor, fctx,
1293613151 );
@@ -12987,11 +13202,11 @@ fn decode_block_128rect(
1298713202 );
1298813203 let (cu_x, cu_y) = (cpx + ch_col * chroma_tx, cpy + ch_row * chroma_tx);
1298913204 if skip {
12990- u.reconstruct(
13205+ push_intra(1,
1299113206 cu_x, cu_y, chroma_tx, uv_predict_mode, angle_delta_uv, cu_r, &zero_cu, None,
1299213207 None, smooth_neighbor_uv, fctx,
1299313208 );
12994- v.reconstruct(
13209+ push_intra(2,
1299513210 cu_x, cu_y, chroma_tx, uv_predict_mode, angle_delta_uv, cu_r, &zero_cu, None,
1299613211 None, smooth_neighbor_uv, fctx,
1299713212 );
@@ -13287,6 +13502,7 @@ fn decode_leaf8(
1328713502 // the CURRENT frame's own pre-loop-filter reconstruction (every loop
1328813503 // filter is off whenever `allow_intrabc`, frame.rs:194/210/252/272) at
1328913504 // the full-pel block vector, with the BILINEAR kernel libaom forces.
13505+ flush_recon(fctx, y, u, v);
1329013506 let intrabc_bufs = intrabc_dv.map(|(dv_row, dv_col)| {
1329113507 let mut yb = vec![0u16; 8 * 8];
1329213508 mc::predict_with_filter(
@@ -13349,7 +13565,7 @@ fn decode_leaf8(
1334913565 y.width,
1335013566 y.height, fctx,
1335113567 );
13352- y.reconstruct(
13568+ push_intra(0,
1335313569 tu_px,
1335413570 tu_py,
1335513571 4,
@@ -13367,7 +13583,7 @@ fn decode_leaf8(
1336713583 if let Some(buf) = &palette_y_buf {
1336813584 set_palette_pred(buf.clone(), fctx);
1336913585 }
13370- y.reconstruct(
13586+ push_intra(0,
1337113587 px,
1337213588 py,
1337313589 8,
@@ -13380,13 +13596,13 @@ fn decode_leaf8(
1338013596 smooth_neighbor, fctx,
1338113597 );
1338213598 }
13383- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
13599+ let ac = alpha.map(|_| cfl_src(px, py, 8));
1338413600 if let Some((_, ub, _)) = &intrabc_bufs {
1338513601 set_palette_pred(ub.clone(), fctx);
1338613602 } else if let Some((ub, _)) = &palette_uv_bufs {
1338713603 set_palette_pred(ub.clone(), fctx);
1338813604 }
13389- u.reconstruct(
13605+ push_intra(1,
1339013606 cpx,
1339113607 cpy,
1339213608 4,
@@ -13394,7 +13610,7 @@ fn decode_leaf8(
1339413610 angle_delta_uv,
1339513611 reach,
1339613612 &vec![0i32; 16],
13397- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
13613+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1339813614 None,
1339913615 smooth_neighbor_uv, fctx,
1340013616 );
@@ -13403,7 +13619,7 @@ fn decode_leaf8(
1340313619 } else if let Some((_, vb)) = &palette_uv_bufs {
1340413620 set_palette_pred(vb.clone(), fctx);
1340513621 }
13406- v.reconstruct(
13622+ push_intra(2,
1340713623 cpx,
1340813624 cpy,
1340913625 4,
@@ -13411,7 +13627,7 @@ fn decode_leaf8(
1341113627 angle_delta_uv,
1341213628 reach,
1341313629 &vec![0i32; 16],
13414- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
13630+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1341513631 None,
1341613632 smooth_neighbor_uv, fctx,
1341713633 );
@@ -13457,7 +13673,7 @@ fn decode_leaf8(
1345713673 if intrabc_dv.is_some() {
1345813674 fctx.intrabc_chroma_tx.with(|c| c.set(Some(fctx.luma_tx_type.with(std::cell::Cell::get))));
1345913675 }
13460- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
13676+ let ac = alpha.map(|_| cfl_src(px, py, 8));
1346113677 if let Some((_, ub, _)) = &intrabc_bufs {
1346213678 set_palette_pred(ub.clone(), fctx);
1346313679 } else if let Some((ub, _)) = &palette_uv_bufs {
@@ -13480,7 +13696,7 @@ fn decode_leaf8(
1348013696 4,
1348113697 TX4,
1348213698 base_q_idx,
13483- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
13699+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1348413700 None,
1348513701 None,
1348613702 smooth_neighbor_uv, fctx,
@@ -13507,7 +13723,7 @@ fn decode_leaf8(
1350713723 4,
1350813724 TX4,
1350913725 base_q_idx,
13510- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
13726+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1351113727 None,
1351213728 None,
1351313729 smooth_neighbor_uv, fctx,
@@ -13597,7 +13813,7 @@ fn decode_leaf8(
1359713813 neighbours.record_mi_luma(tu_mi, 4, &tu_grid);
1359813814 }
1359913815 }
13600- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
13816+ let ac = alpha.map(|_| cfl_src(px, py, 8));
1360113817 let chroma_around = neighbours.around_mi(leaf_mi, 8);
1360213818 if let Some((ub, _)) = &palette_uv_bufs {
1360313819 set_palette_pred(ub.clone(), fctx);
@@ -13619,7 +13835,7 @@ fn decode_leaf8(
1361913835 4,
1362013836 TX4,
1362113837 base_q_idx,
13622- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
13838+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
1362313839 None,
1362413840 None,
1362513841 smooth_neighbor_uv, fctx,
@@ -13644,7 +13860,7 @@ fn decode_leaf8(
1364413860 4,
1364513861 TX4,
1364613862 base_q_idx,
13647- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
13863+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
1364813864 None,
1364913865 None,
1365013866 smooth_neighbor_uv, fctx,
@@ -13907,7 +14123,7 @@ fn decode_leaf_split4(
1390714123 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
1390814124 let reach = Reach::of(4, px, py, y.width, y.height, fctx);
1390914125 if skip {
13910- y.reconstruct(px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra, smooth_neighbor, fctx);
14126+ push_intra(0, px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra, smooth_neighbor, fctx);
1391114127 neighbours.record_mi_luma(lmi, 4, &vec![0i32; 16]);
1391214128 } else {
1391314129 let tu_around = neighbours.around_mi(lmi, 4)[0];
@@ -13964,26 +14180,26 @@ fn decode_leaf_split4(
1396414180 // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the
1396514181 // merge keeps one fix and feeds both lanes' counters so neither of
1396614182 // their gates goes vacuous.
13967- let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));
14183+ let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
1396814184 if alpha.is_some() {
1396914185 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
1397014186 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
1397114187 }
13972- u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);
13973- v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);
14188+ 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);
14189+ 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);
1397414190 (vec![0i32; 16], vec![0i32; 16])
1397514191 } else {
13976- let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));
14192+ let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
1397714193 let chroma_around = neighbours.around_mi(leaf_mi, 8);
1397814194 let ug = read_plane(
1397914195 dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,
1398014196 angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx,
13981- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx,
14197+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx,
1398214198 )?;
1398314199 let vg = read_plane(
1398414200 dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,
1398514201 angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx,
13986- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx,
14202+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx,
1398714203 )?;
1398814204 (ug, vg)
1398914205 };
@@ -14194,7 +14410,7 @@ fn decode_leaf_rect8(
1419414410 // one's reconstruction, which is NOT what a single 4x8
1419514411 // prediction of the same mode produces.
1419614412 let zeros = vec![0i32; 16];
14197- y.reconstruct(
14413+ push_intra(0,
1419814414 tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None,
1419914415 filter_intra, smooth_neighbor, fctx,
1420014416 );
@@ -14248,7 +14464,7 @@ fn decode_leaf_rect8(
1424814464 }
1424914465 let grid = if skip {
1425014466 let zeros = vec![0i32; bw * bh];
14251- y.reconstruct_rect(
14467+ push_intra_rect(0,
1425214468 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
1425314469 smooth_neighbor, fctx,
1425414470 );
@@ -14291,7 +14507,7 @@ fn decode_leaf_rect8(
1429114507 plane_q_delta(0, fctx).1,
1429214508 tx_type,
1429314509 );
14294- y.reconstruct_rect(
14510+ push_intra_rect(0,
1429514511 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
1429614512 smooth_neighbor, fctx,
1429714513 );
@@ -14336,26 +14552,26 @@ fn decode_leaf_rect8(
1433614552 // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the
1433714553 // merge keeps one fix and feeds both lanes' counters so neither of
1433814554 // their gates goes vacuous.
14339- let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));
14555+ let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
1434014556 if alpha.is_some() {
1434114557 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
1434214558 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
1434314559 }
14344- u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);
14345- v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);
14560+ 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);
14561+ 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);
1434614562 (vec![0i32; 16], vec![0i32; 16])
1434714563 } else {
14348- let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));
14564+ let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
1434914565 let chroma_around = neighbours.around_mi(leaf_mi, 8);
1435014566 let ug = read_plane(
1435114567 dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,
1435214568 angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx,
14353- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx,
14569+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx,
1435414570 )?;
1435514571 let vg = read_plane(
1435614572 dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,
1435714573 angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx,
14358- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx,
14574+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx,
1435914575 )?;
1436014576 (ug, vg)
1436114577 };
@@ -16138,7 +16354,11 @@ fn read_inter_plane_rect(
1613816354 plane_idx: usize,
1613916355 around: (bool, bool, i32),
1614016356 tx_mode: usize,
16141- plane: &mut PlaneBuf<'static>,
16357+ // lane-wave1 step (i): unread -- this reader records its write
16358+ // ([`push_intra`]/[`push_mc`]) instead of performing it; the borrow
16359+ // stays in the signature so every call site still proves the plane is
16360+ // exclusively held while its coefficients are parsed.
16361+ _plane: &mut PlaneBuf<'static>,
1614216362 x: usize,
1614316363 y: usize,
1614416364 prediction: &[u16],
@@ -16230,7 +16450,7 @@ fn read_inter_plane_rect(
1623016450 for row in 0..h {
1623116451 strided[row * stride..][..w].copy_from_slice(&residual[row * w..][..w]);
1623216452 }
16233- plane.reconstruct_mc_rect(x, y, stride, w, h, prediction, &strided, fctx);
16453+ push_mc_rect(plane_idx, x, y, stride, w, h, prediction, &strided, fctx);
1623416454 Ok((grid, tx_type))
1623516455 }
1623616456
@@ -18365,6 +18585,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1836518585 // visits of this superblock code nothing at all.
1836618586 let mut sb128_none = false;
1836718587 for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) {
18588+ // lane-wave1 step (i): the previous superblock's recorded writes.
18589+ flush_recon(fctx, &mut y, &mut u, &mut v);
1836818590 if row_start {
1836918591 neighbours.start_row();
1837018592 }
@@ -20105,6 +20327,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2010520327 }
2010620328 }
2010720329 }
20330+ flush_recon(fctx, &mut y, &mut u, &mut v);
2010820331
2010920332 if tile_num == tile_info.context_update_tile_id {
2011020333 result_cdfs = cdfs;
@@ -20589,18 +20812,7 @@ impl PlaneBuf<'_> {
2058920812 /// compensation's output, rather than [`predict`]'s intra one), writing
2059020813 /// the clamped reconstruction into the plane at `(x, y)` -- the inter
2059120814 /// counterpart of [`PlaneBuf::reconstruct`].
20592- fn reconstruct_mc(
20593- &mut self,
20594- x: usize,
20595- y: usize,
20596- side: usize,
20597- prediction: &[u16],
20598- residual: &[i32], fctx: &crate::decode::FrameCtx,
20599- ) {
20600- self.reconstruct_mc_rect(x, y, side, side, side, prediction, residual, fctx);
20601- }
20602-
20603- /// [`Self::reconstruct_mc`], writing only a `w`x`h` sub-rectangle of the
20815+ /// [`Self::reconstruct_mc_rect`], writing only a `w`x`h` sub-rectangle of the
2060420816 /// `side`x`side` `prediction`/`residual` buffers (which stay `side`-square
2060520817 /// for stride/indexing) -- lane-partitions r1: a true rectangular HORZ/
2060620818 /// VERT strip is predicted at its enclosing square `side` (matching
@@ -20656,7 +20868,11 @@ fn read_inter_plane(
2065620868 plane_idx: usize,
2065720869 around: (bool, bool, i32),
2065820870 tx_mode: usize,
20659- plane: &mut PlaneBuf<'static>,
20871+ // lane-wave1 step (i): unread -- this reader records its write
20872+ // ([`push_intra`]/[`push_mc`]) instead of performing it; the borrow
20873+ // stays in the signature so every call site still proves the plane is
20874+ // exclusively held while its coefficients are parsed.
20875+ _plane: &mut PlaneBuf<'static>,
2066020876 x: usize,
2066120877 y: usize,
2066220878 side: usize,
@@ -20727,7 +20943,7 @@ fn read_inter_plane(
2072720943 };
2072820944 let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx);
2072920945 let residual = dequant_and_inverse_typed(&grid, side, bit_depth(fctx), block_q_idx(fctx), dc_delta, ac_delta, tx_type);
20730- plane.reconstruct_mc(x, y, side, prediction, &residual, fctx);
20946+ push_mc(plane_idx, x, y, side, prediction, &residual, fctx);
2073120947 Ok((grid, tx_type))
2073220948 }
2073320949
@@ -23244,7 +23460,7 @@ fn decode_inter_block(
2324423460 .1
2324523461 };
2324623462 if skip {
23247- y.reconstruct_mc_rect(
23463+ push_mc_rect(0,
2324823464 px,
2324923465 py,
2325023466 side,
@@ -23253,7 +23469,7 @@ fn decode_inter_block(
2325323469 &pred_y,
2325423470 &vec![0i32; side * side], fctx,
2325523471 );
23256- u.reconstruct_mc_rect(
23472+ push_mc_rect(1,
2325723473 cpx,
2325823474 cpy,
2325923475 chroma_side,
@@ -23262,7 +23478,7 @@ fn decode_inter_block(
2326223478 &pred_u,
2326323479 &vec![0i32; chroma_side * chroma_side], fctx,
2326423480 );
23265- v.reconstruct_mc_rect(
23481+ push_mc_rect(2,
2326623482 cpx,
2326723483 cpy,
2326823484 chroma_side,
@@ -24367,6 +24583,7 @@ fn decode_inter_block(
2436724583 // result, all planes (reconinter.c av1_build_interintra_predictor
2436824584 // plane loop).
2436924585 if let Some(ii) = interintra_mode {
24586+ flush_recon(fctx, y, u, v);
2437024587 if write_w != write_h {
2437124588 INTERINTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
2437224589 }
@@ -24454,7 +24671,7 @@ fn decode_inter_block(
2445424671 .1
2445524672 };
2445624673 if skip {
24457- y.reconstruct_mc_rect(
24674+ push_mc_rect(0,
2445824675 px,
2445924676 py,
2446024677 side,
@@ -24464,7 +24681,7 @@ fn decode_inter_block(
2446424681 &vec![0i32; side * side], fctx,
2446524682 );
2446624683 if has_chroma {
24467- u.reconstruct_mc_rect(
24684+ push_mc_rect(1,
2446824685 cpx,
2446924686 cpy,
2447024687 chroma_side,
@@ -24473,7 +24690,7 @@ fn decode_inter_block(
2447324690 &pred_u,
2447424691 &vec![0i32; chroma_side * chroma_side], fctx,
2447524692 );
24476- v.reconstruct_mc_rect(
24693+ push_mc_rect(2,
2447724694 cpx,
2447824695 cpy,
2447924696 chroma_side,
@@ -25216,7 +25433,7 @@ fn decode_inter_block(
2521625433 set_palette_pred(window, fctx);
2521725434 }
2521825435 let tu_grid = if skip {
25219- y.reconstruct(
25436+ push_intra(0,
2522025437 tu_px,
2522125438 tu_py,
2522225439 tx_px,
@@ -25286,7 +25503,7 @@ fn decode_inter_block(
2528625503 for plane_idx in 1..3 {
2528725504 let buf: &mut PlaneBuf<'static> = if plane_idx == 1 { &mut *u } else { &mut *v };
2528825505 let cu_grid = if skip {
25289- buf.reconstruct(
25506+ push_intra(plane_idx,
2529025507 cu_x,
2529125508 cu_y,
2529225509 cu_tx,
@@ -25356,7 +25573,7 @@ fn decode_inter_block(
2535625573 if let Some(buf) = &palette_y_buf {
2535725574 set_palette_pred(buf.clone(), fctx);
2535825575 }
25359- y.reconstruct(
25576+ push_intra(0,
2536025577 px,
2536125578 py,
2536225579 side,
@@ -25369,11 +25586,11 @@ fn decode_inter_block(
2536925586 smooth_neighbor, fctx,
2537025587 );
2537125588 }
25372- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
25589+ let ac = alpha.map(|_| cfl_src(px, py, side));
2537325590 if let Some((ub, _)) = &palette_uv_bufs {
2537425591 set_palette_pred(ub.clone(), fctx);
2537525592 }
25376- u.reconstruct(
25593+ push_intra(1,
2537725594 cpx,
2537825595 cpy,
2537925596 chroma_side,
@@ -25381,14 +25598,14 @@ fn decode_inter_block(
2538125598 angle_delta_uv,
2538225599 reach,
2538325600 &vec![0i32; chroma_side * chroma_side],
25384- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
25601+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
2538525602 None,
2538625603 smooth_neighbor_uv, fctx,
2538725604 );
2538825605 if let Some((_, vb)) = &palette_uv_bufs {
2538925606 set_palette_pred(vb.clone(), fctx);
2539025607 }
25391- v.reconstruct(
25608+ push_intra(2,
2539225609 cpx,
2539325610 cpy,
2539425611 chroma_side,
@@ -25396,7 +25613,7 @@ fn decode_inter_block(
2539625613 angle_delta_uv,
2539725614 reach,
2539825615 &vec![0i32; chroma_side * chroma_side],
25399- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
25616+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
2540025617 None,
2540125618 smooth_neighbor_uv, fctx,
2540225619 );
@@ -25437,7 +25654,7 @@ fn decode_inter_block(
2543725654 smooth_neighbor, fctx,
2543825655 )?
2543925656 };
25440- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
25657+ let ac = alpha.map(|_| cfl_src(px, py, side));
2544125658 if let Some((ub, _)) = &palette_uv_bufs {
2544225659 set_palette_pred(ub.clone(), fctx);
2544325660 }
@@ -25458,7 +25675,7 @@ fn decode_inter_block(
2545825675 chroma_side,
2545925676 chroma_tx,
2546025677 base_q_idx,
25461- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
25678+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
2546225679 None,
2546325680 None,
2546425681 smooth_neighbor_uv, fctx,
@@ -25483,7 +25700,7 @@ fn decode_inter_block(
2548325700 chroma_side,
2548425701 chroma_tx,
2548525702 base_q_idx,
25486- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
25703+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
2548725704 None,
2548825705 None,
2548925706 smooth_neighbor_uv, fctx,
@@ -26094,7 +26311,7 @@ fn decode_inter_sub8_split4(
2609426311 // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which
2609526312 // `read_inter_plane`'s `plane_idx == 0` arm already assumes).
2609626313 if skip {
26097- y.reconstruct_mc(px, py, B4, &pred_y, &vec![0i32; B4 * B4], fctx);
26314+ push_mc(0, px, py, B4, &pred_y, &vec![0i32; B4 * B4], fctx);
2609826315 neighbours.record_mi_luma_rect(lmi, B4, B4, &vec![0i32; B4 * B4]);
2609926316 } else {
2610026317 let around = neighbours.around_mi(lmi, B4);
@@ -26209,8 +26426,8 @@ fn decode_inter_sub8_split4(
2620926426 }
2621026427 }
2621126428 let (u_grid, v_grid) = if last_skip {
26212- u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx);
26213- v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx);
26429+ push_mc(1, cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx);
26430+ push_mc(2, cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx);
2621426431 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
2621526432 } else {
2621626433 let around = neighbours.around_mi(group_mi, 8);
@@ -26439,7 +26656,7 @@ fn decode_intra_sub8_leaf(
2643926656 );
2644026657 if skip {
2644126658 let zeros = vec![0i32; 16];
26442- y.reconstruct(
26659+ push_intra(0,
2644326660 tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None, filter_intra,
2644426661 smooth_neighbor, fctx,
2644526662 );
@@ -26481,7 +26698,7 @@ fn decode_intra_sub8_leaf(
2648126698 // fixes `txb_skip_ctx` at 0 (`luma_skip_ctx: None`) -- the same square
2648226699 // reader [`decode_leaf_split4`] uses.
2648326700 if skip {
26484- y.reconstruct(
26701+ push_intra(0,
2648526702 px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra,
2648626703 smooth_neighbor, fctx,
2648726704 );
@@ -26519,7 +26736,7 @@ fn decode_intra_sub8_leaf(
2651926736 } else {
2652026737 let grid_levels = if skip {
2652126738 let zeros = vec![0i32; bw * bh];
26522- y.reconstruct_rect(
26739+ push_intra_rect(0,
2652326740 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
2652426741 smooth_neighbor, fctx,
2652526742 );
@@ -26554,7 +26771,7 @@ fn decode_intra_sub8_leaf(
2655426771 plane_q_delta(0, fctx).1,
2655526772 tx_type,
2655626773 );
26557- y.reconstruct_rect(
26774+ push_intra_rect(0,
2655826775 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
2655926776 smooth_neighbor, fctx,
2656026777 );
@@ -26649,26 +26866,26 @@ fn decode_intra_sub8_leaf(
2664926866 // needs `bsize >= BLOCK_8X8`), so the group always clears.
2665026867 record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);
2665126868
26652- let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));
26869+ let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
2665326870 let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if skip {
2665426871 if alpha.is_some() {
2665526872 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
2665626873 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
2665726874 }
26658- u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx);
26659- v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx);
26875+ 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);
26876+ 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);
2666026877 (vec![0i32; 16], vec![0i32; 16])
2666126878 } else {
2666226879 let chroma_around = neighbours.around_mi(group_mi, 8);
2666326880 let ug = read_plane(
2666426881 dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,
2666526882 angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx,
26666- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx,
26883+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx,
2666726884 )?;
2666826885 let vg = read_plane(
2666926886 dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,
2667026887 angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx,
26671- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx,
26888+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx,
2667226889 )?;
2667326890 (ug, vg)
2667426891 };
@@ -27067,7 +27284,7 @@ fn decode_inter_sub8_rect2(
2706727284 }
2706827285 }
2706927286 if skip {
27070- y.reconstruct_mc_rect(px, py, SIDE, bw, bh, &pred_y, &vec![0i32; SIDE * SIDE], fctx);
27287+ push_mc_rect(0, px, py, SIDE, bw, bh, &pred_y, &vec![0i32; SIDE * SIDE], fctx);
2707127288 neighbours.record_mi_luma_rect(lmi, bw, bh, &vec![0i32; bw * bh]);
2707227289 neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx);
2707327290 } else {
@@ -27233,8 +27450,8 @@ fn decode_inter_sub8_rect2(
2723327450 }
2723427451 }
2723527452 let (u_grid, v_grid) = if last_skip {
27236- u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx);
27237- v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx);
27453+ push_mc(1, cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx);
27454+ push_mc(2, cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx);
2723827455 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
2723927456 } else {
2724027457 let around = neighbours.around_mi(group_mi, 8);
@@ -28070,15 +28287,15 @@ fn decode_inter_block8(
2807028287 .1
2807128288 .is_some();
2807228289 if skip {
28073- y.reconstruct_mc(px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx);
28074- u.reconstruct_mc(
28290+ push_mc(0, px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx);
28291+ push_mc(1,
2807528292 cpx,
2807628293 cpy,
2807728294 CHROMA_SIDE,
2807828295 &pred_u,
2807928296 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
2808028297 );
28081- v.reconstruct_mc(
28298+ push_mc(2,
2808228299 cpx,
2808328300 cpy,
2808428301 CHROMA_SIDE,
@@ -28697,6 +28914,7 @@ fn decode_inter_block8(
2869728914 // Non-wedge interintra blend, mutually exclusive with OBMC (the
2869828915 // motion_mode symbol is not read for an interintra block).
2869928916 if let Some(ii) = interintra_mode {
28917+ flush_recon(fctx, y, u, v);
2870028918 interintra_blend(y, px, py, SIDE, SIDE, SIDE, ii, wedge_mask, &mut pred_y, fctx);
2870128919 interintra_blend(
2870228920 u, cpx, cpy, CHROMA_SIDE, CHROMA_SIDE, CHROMA_SIDE, ii, wedge_mask, &mut pred_u, fctx,
@@ -28719,15 +28937,15 @@ fn decode_inter_block8(
2871928937 .1
2872028938 .is_some();
2872128939 if skip {
28722- y.reconstruct_mc(px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx);
28723- u.reconstruct_mc(
28940+ push_mc(0, px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx);
28941+ push_mc(1,
2872428942 cpx,
2872528943 cpy,
2872628944 CHROMA_SIDE,
2872728945 &pred_u,
2872828946 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
2872928947 );
28730- v.reconstruct_mc(
28948+ push_mc(2,
2873128949 cpx,
2873228950 cpy,
2873328951 CHROMA_SIDE,
@@ -29090,7 +29308,7 @@ fn decode_inter_block8(
2909029308 set_palette_pred(window, fctx);
2909129309 }
2909229310 let tu_grid = if skip {
29093- y.reconstruct(
29311+ push_intra(0,
2909429312 tu_px,
2909529313 tu_py,
2909629314 tx_px,
@@ -29143,7 +29361,7 @@ fn decode_inter_block8(
2914329361 if let Some(buf) = &palette_y_buf {
2914429362 set_palette_pred(buf.clone(), fctx);
2914529363 }
29146- y.reconstruct(
29364+ push_intra(0,
2914729365 px,
2914829366 py,
2914929367 SIDE,
@@ -29158,11 +29376,11 @@ fn decode_inter_block8(
2915829376 }
2915929377 // CfL's AC contribution is the luma this leaf just reconstructed,
2916029378 // averaged over the 4x4 chroma block (`cfl_ac_q3`, spec 7.11.5).
29161- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, SIDE));
29379+ let ac = alpha.map(|_| cfl_src(px, py, SIDE));
2916229380 if let Some((ub, _)) = &palette_uv_bufs {
2916329381 set_palette_pred(ub.clone(), fctx);
2916429382 }
29165- u.reconstruct(
29383+ push_intra(1,
2916629384 cpx,
2916729385 cpy,
2916829386 CHROMA_SIDE,
@@ -29170,14 +29388,14 @@ fn decode_inter_block8(
2917029388 angle_delta_uv,
2917129389 reach,
2917229390 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],
29173- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
29391+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
2917429392 None,
2917529393 smooth_neighbor_uv, fctx,
2917629394 );
2917729395 if let Some((_, vb)) = &palette_uv_bufs {
2917829396 set_palette_pred(vb.clone(), fctx);
2917929397 }
29180- v.reconstruct(
29398+ push_intra(2,
2918129399 cpx,
2918229400 cpy,
2918329401 CHROMA_SIDE,
@@ -29185,7 +29403,7 @@ fn decode_inter_block8(
2918529403 angle_delta_uv,
2918629404 reach,
2918729405 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],
29188- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
29406+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
2918929407 None,
2919029408 smooth_neighbor_uv, fctx,
2919129409 );
@@ -29234,7 +29452,7 @@ fn decode_inter_block8(
2923429452 smooth_neighbor, fctx,
2923529453 )?
2923629454 };
29237- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, SIDE));
29455+ let ac = alpha.map(|_| cfl_src(px, py, SIDE));
2923829456 if let Some((ub, _)) = &palette_uv_bufs {
2923929457 set_palette_pred(ub.clone(), fctx);
2924029458 }
@@ -29255,7 +29473,7 @@ fn decode_inter_block8(
2925529473 CHROMA_SIDE,
2925629474 TX4,
2925729475 base_q_idx,
29258- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
29476+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
2925929477 None,
2926029478 None,
2926129479 smooth_neighbor_uv, fctx,
@@ -29280,7 +29498,7 @@ fn decode_inter_block8(
2928029498 CHROMA_SIDE,
2928129499 TX4,
2928229500 base_q_idx,
29283- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
29501+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
2928429502 None,
2928529503 None,
2928629504 smooth_neighbor_uv, fctx,
@@ -29819,6 +30037,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2981930037 // key-frame tile loop runs).
2982030038 let mut sb128_none = false;
2982130039 for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) {
30040+ // lane-wave1 step (i): the previous superblock's recorded writes.
30041+ flush_recon(fctx, &mut y, &mut u, &mut v);
2982230042 if row_start {
2982330043 neighbours.start_row();
2982430044 }
@@ -32162,6 +32382,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
3216232382 }
3216332383 }
3216432384 }
32385+ flush_recon(fctx, &mut y, &mut u, &mut v);
3216532386
3216632387 if tile_num == tile_info.context_update_tile_id {
3216732388 result_cdfs = cdfs;