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 {
79 pub(crate) last_frame_wide_margin: std::cell::RefCell<Option<Picture>>,79 pub(crate) last_frame_wide_margin: std::cell::RefCell<Option<Picture>>,
80 pub(crate) reach_sb_px: std::cell::Cell<usize>,80 pub(crate) reach_sb_px: std::cell::Cell<usize>,
81 pub(crate) grain_bit_depth: std::cell::Cell<u32>,81 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>>,
82 }85 }
83 86
84 impl std::fmt::Debug for FrameCtx {87 impl std::fmt::Debug for FrameCtx {
@@ -136,6 +139,7 @@ impl FrameCtx {
136 last_frame_wide_margin: std::cell::RefCell::new(None),139 last_frame_wide_margin: std::cell::RefCell::new(None),
137 reach_sb_px: std::cell::Cell::new(crate::encode::SUPERBLOCK),140 reach_sb_px: std::cell::Cell::new(crate::encode::SUPERBLOCK),
138 grain_bit_depth: std::cell::Cell::new(8),141 grain_bit_depth: std::cell::Cell::new(8),
142+ recon_ops: std::cell::RefCell::new(Vec::new()),
139 }143 }
140 }144 }
141 }145 }
@@ -2010,6 +2014,204 @@ fn take_palette_pred(fctx: &crate::decode::FrameCtx) -> Option<Vec<u16>> {
2010 got2014 got
2011 }2015 }
2012 2016
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+
2013 thread_local! {2215 thread_local! {
2014 /// The current frame's `mi` grid, kept only while a frame header set2216 /// The current frame's `mi` grid, kept only while a frame header set
2015 /// `allow_intrabc` -- an intrabc block's DV predictor is the ordinary2217 /// `allow_intrabc` -- an intrabc block's DV predictor is the ordinary
@@ -7693,7 +7895,7 @@ fn decode_rect_split(
7693 set_palette_pred(tu_buf, fctx);7895 set_palette_pred(tu_buf, fctx);
7694 }7896 }
7695 if m.skip {7897 if m.skip {
7696- y.reconstruct_rect(7898+ push_intra_rect(0,
7697 tu_px,7899 tu_px,
7698 tu_py,7900 tu_py,
7699 tx_w,7901 tx_w,
@@ -7751,7 +7953,7 @@ fn decode_rect_split(
7751 plane_q_delta(0, fctx).1,7953 plane_q_delta(0, fctx).1,
7752 tu_tx_type,7954 tu_tx_type,
7753 );7955 );
7754- y.reconstruct_rect(7956+ push_intra_rect(0,
7755 tu_px,7957 tu_px,
7756 tu_py,7958 tu_py,
7757 tx_w,7959 tx_w,
@@ -7807,7 +8009,7 @@ fn decode_rect_split(
7807 plane_q_delta(0, fctx).1,8009 plane_q_delta(0, fctx).1,
7808 tu_tx_type,8010 tu_tx_type,
7809 );8011 );
7810- y.reconstruct_rect(8012+ push_intra_rect(0,
7811 tu_px,8013 tu_px,
7812 tu_py,8014 tu_py,
7813 tx_w,8015 tx_w,
@@ -7854,23 +8056,23 @@ fn decode_rect_split(
7854 }8056 }
7855 }8057 }
7856 // CHROMA: one un-split rect transform for the whole strip.8058 // 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));
7858 let reach = block_reach;8060 let reach = block_reach;
7859 let (u_grid, v_grid) = if m.skip {8061 let (u_grid, v_grid) = if m.skip {
7860 let zero = vec![0i32; chroma_w * chroma_h];8062 let zero = vec![0i32; chroma_w * chroma_h];
7861 if let Some((ub, _)) = &m.palette_uv {8063 if let Some((ub, _)) = &m.palette_uv {
7862 set_palette_pred(ub.clone(), fctx);8064 set_palette_pred(ub.clone(), fctx);
7863 }8065 }
7864- u.reconstruct_rect(8066+ push_intra_rect(1,
7865 cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero,8067 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,
7867 );8069 );
7868 if let Some((_, vb)) = &m.palette_uv {8070 if let Some((_, vb)) = &m.palette_uv {
7869 set_palette_pred(vb.clone(), fctx);8071 set_palette_pred(vb.clone(), fctx);
7870 }8072 }
7871- v.reconstruct_rect(8073+ push_intra_rect(2,
7872 cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero,8074 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,
7874 );8076 );
7875 (zero.clone(), zero)8077 (zero.clone(), zero)
7876 } else {8078 } else {
@@ -7918,14 +8120,14 @@ fn decode_rect_split(
7918 );8120 );
7919 let cfl = m8121 let cfl = m
7920 .alpha8122 .alpha
7921- .zip(ac.as_deref())8123+ .zip(ac)
7922 .map(|((au, av), ac)| (if plane_idx == 1 { au } else { av }, ac));8124 .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 };
7924 if let Some((ub, vb)) = &m.palette_uv {8126 if let Some((ub, vb)) = &m.palette_uv {
7925 let buf = if plane_idx == 1 { ub } else { vb };8127 let buf = if plane_idx == 1 { ub } else { vb };
7926 set_palette_pred(buf.clone(), fctx);8128 set_palette_pred(buf.clone(), fctx);
7927 }8129 }
7928- plane.reconstruct_rect(8130+ push_intra_rect(plane_idx,
7929 cpx,8131 cpx,
7930 cpy,8132 cpy,
7931 chroma_w,8133 chroma_w,
@@ -8888,7 +9090,7 @@ fn decode_block_rect(
8888 )9090 )
8889 });9091 });
8890 if skip {9092 if skip {
8891- y.reconstruct_rect(9093+ push_intra_rect(0,
8892 px,9094 px,
8893 py,9095 py,
8894 bw,9096 bw,
@@ -8901,11 +9103,11 @@ fn decode_block_rect(
8901 filter_intra,9103 filter_intra,
8902 smooth_neighbor, fctx,9104 smooth_neighbor, fctx,
8903 );9105 );
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));
8905 if let Some((ub, _)) = &palette_uv_bufs {9107 if let Some((ub, _)) = &palette_uv_bufs {
8906 set_palette_pred(ub.clone(), fctx);9108 set_palette_pred(ub.clone(), fctx);
8907 }9109 }
8908- u.reconstruct_rect(9110+ push_intra_rect(1,
8909 cpx,9111 cpx,
8910 cpy,9112 cpy,
8911 chroma_w,9113 chroma_w,
@@ -8914,14 +9116,14 @@ fn decode_block_rect(
8914 angle_delta_uv,9116 angle_delta_uv,
8915 reach,9117 reach,
8916 &vec![0i32; chroma_w * chroma_h],9118 &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)),
8918 None,9120 None,
8919 smooth_neighbor_uv, fctx,9121 smooth_neighbor_uv, fctx,
8920 );9122 );
8921 if let Some((_, vb)) = &palette_uv_bufs {9123 if let Some((_, vb)) = &palette_uv_bufs {
8922 set_palette_pred(vb.clone(), fctx);9124 set_palette_pred(vb.clone(), fctx);
8923 }9125 }
8924- v.reconstruct_rect(9126+ push_intra_rect(2,
8925 cpx,9127 cpx,
8926 cpy,9128 cpy,
8927 chroma_w,9129 chroma_w,
@@ -8930,7 +9132,7 @@ fn decode_block_rect(
8930 angle_delta_uv,9132 angle_delta_uv,
8931 reach,9133 reach,
8932 &vec![0i32; chroma_w * chroma_h],9134 &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)),
8934 None,9136 None,
8935 smooth_neighbor_uv, fctx,9137 smooth_neighbor_uv, fctx,
8936 );9138 );
@@ -9018,7 +9220,7 @@ fn decode_block_rect(
9018 plane_q_delta(0, fctx).1,9220 plane_q_delta(0, fctx).1,
9019 luma_tx_type,9221 luma_tx_type,
9020 );9222 );
9021- y.reconstruct_rect(9223+ push_intra_rect(0,
9022 px,9224 px,
9023 py,9225 py,
9024 bw,9226 bw,
@@ -9031,7 +9233,7 @@ fn decode_block_rect(
9031 filter_intra,9233 filter_intra,
9032 smooth_neighbor, fctx,9234 smooth_neighbor, fctx,
9033 );9235 );
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));
9035 if let Some((ub, _)) = &palette_uv_bufs {9237 if let Some((ub, _)) = &palette_uv_bufs {
9036 set_palette_pred(ub.clone(), fctx);9238 set_palette_pred(ub.clone(), fctx);
9037 }9239 }
@@ -9062,7 +9264,7 @@ fn decode_block_rect(
9062 plane_q_delta(1, fctx).1,9264 plane_q_delta(1, fctx).1,
9063 u_tx_type,9265 u_tx_type,
9064 );9266 );
9065- u.reconstruct_rect(9267+ push_intra_rect(1,
9066 cpx,9268 cpx,
9067 cpy,9269 cpy,
9068 chroma_w,9270 chroma_w,
@@ -9071,7 +9273,7 @@ fn decode_block_rect(
9071 angle_delta_uv,9273 angle_delta_uv,
9072 reach,9274 reach,
9073 &u_residual,9275 &u_residual,
9074- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),9276+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
9075 None,9277 None,
9076 smooth_neighbor_uv, fctx,9278 smooth_neighbor_uv, fctx,
9077 );9279 );
@@ -9105,7 +9307,7 @@ fn decode_block_rect(
9105 plane_q_delta(2, fctx).1,9307 plane_q_delta(2, fctx).1,
9106 v_tx_type,9308 v_tx_type,
9107 );9309 );
9108- v.reconstruct_rect(9310+ push_intra_rect(2,
9109 cpx,9311 cpx,
9110 cpy,9312 cpy,
9111 chroma_w,9313 chroma_w,
@@ -9114,7 +9316,7 @@ fn decode_block_rect(
9114 angle_delta_uv,9316 angle_delta_uv,
9115 reach,9317 reach,
9116 &v_residual,9318 &v_residual,
9117- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),9319+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
9118 None,9320 None,
9119 smooth_neighbor_uv, fctx,9321 smooth_neighbor_uv, fctx,
9120 );9322 );
@@ -9359,24 +9561,24 @@ fn decode_leaf_rect(
9359 if let Some(b) = &palette_y_buf {9561 if let Some(b) = &palette_y_buf {
9360 set_palette_pred(b.clone(), fctx);9562 set_palette_pred(b.clone(), fctx);
9361 }9563 }
9362- y.reconstruct_rect(9564+ push_intra_rect(0,
9363 px, py, bw, bh, mode, angle_delta_y, reach, &luma_levels, None, filter_intra,9565 px, py, bw, bh, mode, angle_delta_y, reach, &luma_levels, None, filter_intra,
9364 smooth_neighbor, fctx,9566 smooth_neighbor, fctx,
9365 );9567 );
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));
9367 if let Some((ub, _)) = &palette_uv_bufs {9569 if let Some((ub, _)) = &palette_uv_bufs {
9368 set_palette_pred(ub.clone(), fctx);9570 set_palette_pred(ub.clone(), fctx);
9369 }9571 }
9370- u.reconstruct_rect(9572+ push_intra_rect(1,
9371 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_levels,9573 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,
9373 );9575 );
9374 if let Some((_, vb)) = &palette_uv_bufs {9576 if let Some((_, vb)) = &palette_uv_bufs {
9375 set_palette_pred(vb.clone(), fctx);9577 set_palette_pred(vb.clone(), fctx);
9376 }9578 }
9377- v.reconstruct_rect(9579+ push_intra_rect(2,
9378 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_levels,9580 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,
9380 );9582 );
9381 } else {9583 } else {
9382 // lane-rectx: a genuine 16x8/8x16 luma transform (`TxbSet::LumaRect16x8`,9584 // lane-rectx: a genuine 16x8/8x16 luma transform (`TxbSet::LumaRect16x8`,
@@ -9412,11 +9614,11 @@ fn decode_leaf_rect(
9412 if let Some(b) = &palette_y_buf {9614 if let Some(b) = &palette_y_buf {
9413 set_palette_pred(b.clone(), fctx);9615 set_palette_pred(b.clone(), fctx);
9414 }9616 }
9415- y.reconstruct_rect(9617+ push_intra_rect(0,
9416 px, py, bw, bh, mode, angle_delta_y, reach, &luma_residual, None, filter_intra,9618 px, py, bw, bh, mode, angle_delta_y, reach, &luma_residual, None, filter_intra,
9417 smooth_neighbor, fctx,9619 smooth_neighbor, fctx,
9418 );9620 );
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));
9420 let u_default_tx = default_intra_tx_type(uv_predict_mode as u8);9622 let u_default_tx = default_intra_tx_type(uv_predict_mode as u8);
9421 let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1);9623 let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1);
9422 let mut u_coding = cdfs.txb(TxbSet::ChromaRect8x4, uv_predict_mode);9624 let mut u_coding = cdfs.txb(TxbSet::ChromaRect8x4, uv_predict_mode);
@@ -9432,9 +9634,9 @@ fn decode_leaf_rect(
9432 if let Some((ub, _)) = &palette_uv_bufs {9634 if let Some((ub, _)) = &palette_uv_bufs {
9433 set_palette_pred(ub.clone(), fctx);9635 set_palette_pred(ub.clone(), fctx);
9434 }9636 }
9435- u.reconstruct_rect(9637+ push_intra_rect(1,
9436 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_residual,9638 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,
9438 );9640 );
9439 let v_default_tx = default_intra_tx_type(uv_predict_mode as u8);9641 let v_default_tx = default_intra_tx_type(uv_predict_mode as u8);
9440 let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1);9642 let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1);
@@ -9451,9 +9653,9 @@ fn decode_leaf_rect(
9451 if let Some((_, vb)) = &palette_uv_bufs {9653 if let Some((_, vb)) = &palette_uv_bufs {
9452 set_palette_pred(vb.clone(), fctx);9654 set_palette_pred(vb.clone(), fctx);
9453 }9655 }
9454- v.reconstruct_rect(9656+ push_intra_rect(2,
9455 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual,9657 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,
9457 );9659 );
9458 RECT_LEAF_COEFF_HITS.with(|c| c.set(c.get() + 1));9660 RECT_LEAF_COEFF_HITS.with(|c| c.set(c.get() + 1));
9459 }9661 }
@@ -9798,7 +10000,7 @@ fn decode_block_rect4(
9798 if let Some(b) = &palette_y_buf {10000 if let Some(b) = &palette_y_buf {
9799 set_palette_pred(b.clone(), fctx);10001 set_palette_pred(b.clone(), fctx);
9800 }10002 }
9801- y.reconstruct_rect(10003+ push_intra_rect(0,
9802 px,10004 px,
9803 py,10005 py,
9804 bw,10006 bw,
@@ -9811,8 +10013,8 @@ fn decode_block_rect4(
9811 filter_intra,10013 filter_intra,
9812 smooth_neighbor, fctx,10014 smooth_neighbor, fctx,
9813 );10015 );
9814- let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));10016+ let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
9815- for (plane, buf, levels, tx_type) in [10017+ for (plane, _buf, levels, tx_type) in [
9816 (1usize, &mut *u, &u_levels, u_tx_type),10018 (1usize, &mut *u, &u_levels, u_tx_type),
9817 (2, &mut *v, &v_levels, v_tx_type),10019 (2, &mut *v, &v_levels, v_tx_type),
9818 ] {10020 ] {
@@ -9829,7 +10031,7 @@ fn decode_block_rect4(
9829 if let Some((ub, vb)) = &palette_uv_bufs {10031 if let Some((ub, vb)) = &palette_uv_bufs {
9830 set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx);10032 set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx);
9831 }10033 }
9832- buf.reconstruct_rect(10034+ push_intra_rect(plane,
9833 cpx,10035 cpx,
9834 cpy,10036 cpy,
9835 chroma_w,10037 chroma_w,
@@ -9839,7 +10041,7 @@ fn decode_block_rect4(
9839 reach,10041 reach,
9840 &residual,10042 &residual,
9841 alpha10043 alpha
9842- .zip(ac.as_deref())10044+ .zip(ac)
9843 .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),10045 .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
9844 None,10046 None,
9845 smooth_neighbor_uv, fctx,10047 smooth_neighbor_uv, fctx,
@@ -9874,7 +10076,7 @@ fn decode_block_rect4(
9874 if let Some(b) = &palette_y_buf {10076 if let Some(b) = &palette_y_buf {
9875 set_palette_pred(b.clone(), fctx);10077 set_palette_pred(b.clone(), fctx);
9876 }10078 }
9877- y.reconstruct_rect(10079+ push_intra_rect(0,
9878 px,10080 px,
9879 py,10081 py,
9880 bw,10082 bw,
@@ -9887,11 +10089,11 @@ fn decode_block_rect4(
9887 filter_intra,10089 filter_intra,
9888 smooth_neighbor, fctx,10090 smooth_neighbor, fctx,
9889 );10091 );
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));
9891 if let Some((ub, _)) = &palette_uv_bufs {10093 if let Some((ub, _)) = &palette_uv_bufs {
9892 set_palette_pred(ub.clone(), fctx);10094 set_palette_pred(ub.clone(), fctx);
9893 }10095 }
9894- u.reconstruct_rect(10096+ push_intra_rect(1,
9895 cpx,10097 cpx,
9896 cpy,10098 cpy,
9897 chroma_w,10099 chroma_w,
@@ -9900,14 +10102,14 @@ fn decode_block_rect4(
9900 angle_delta_uv,10102 angle_delta_uv,
9901 reach,10103 reach,
9902 &u_levels,10104 &u_levels,
9903- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),10105+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
9904 None,10106 None,
9905 smooth_neighbor_uv, fctx,10107 smooth_neighbor_uv, fctx,
9906 );10108 );
9907 if let Some((_, vb)) = &palette_uv_bufs {10109 if let Some((_, vb)) = &palette_uv_bufs {
9908 set_palette_pred(vb.clone(), fctx);10110 set_palette_pred(vb.clone(), fctx);
9909 }10111 }
9910- v.reconstruct_rect(10112+ push_intra_rect(2,
9911 cpx,10113 cpx,
9912 cpy,10114 cpy,
9913 chroma_w,10115 chroma_w,
@@ -9916,7 +10118,7 @@ fn decode_block_rect4(
9916 angle_delta_uv,10118 angle_delta_uv,
9917 reach,10119 reach,
9918 &v_levels,10120 &v_levels,
9919- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),10121+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
9920 None,10122 None,
9921 smooth_neighbor_uv, fctx,10123 smooth_neighbor_uv, fctx,
9922 );10124 );
@@ -10200,7 +10402,7 @@ fn decode_rect4_16_strip(
10200 set_palette_pred(tu_buf, fctx);10402 set_palette_pred(tu_buf, fctx);
10201 }10403 }
10202 if skip {10404 if skip {
10203- y.reconstruct_rect(10405+ push_intra_rect(0,
10204 tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &zero_tu,10406 tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &zero_tu,
10205 None, filter_intra, smooth_neighbor, fctx,10407 None, filter_intra, smooth_neighbor, fctx,
10206 );10408 );
@@ -10239,7 +10441,7 @@ fn decode_rect4_16_strip(
10239 plane_q_delta(0, fctx).1,10441 plane_q_delta(0, fctx).1,
10240 tu_tx_type,10442 tu_tx_type,
10241 );10443 );
10242- y.reconstruct_rect(10444+ push_intra_rect(0,
10243 tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &residual,10445 tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &residual,
10244 None, filter_intra, smooth_neighbor, fctx,10446 None, filter_intra, smooth_neighbor, fctx,
10245 );10447 );
@@ -10285,7 +10487,7 @@ fn decode_rect4_16_strip(
10285 if let Some(b) = &palette_y_buf {10487 if let Some(b) = &palette_y_buf {
10286 set_palette_pred(b.clone(), fctx);10488 set_palette_pred(b.clone(), fctx);
10287 }10489 }
10288- y.reconstruct_rect(10490+ push_intra_rect(0,
10289 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,10491 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
10290 smooth_neighbor, fctx,10492 smooth_neighbor, fctx,
10291 );10493 );
@@ -10324,7 +10526,7 @@ fn decode_rect4_16_strip(
10324 if let Some(b) = &palette_y_buf {10526 if let Some(b) = &palette_y_buf {
10325 set_palette_pred(b.clone(), fctx);10527 set_palette_pred(b.clone(), fctx);
10326 }10528 }
10327- y.reconstruct_rect(10529+ push_intra_rect(0,
10328 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,10530 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
10329 smooth_neighbor, fctx,10531 smooth_neighbor, fctx,
10330 );10532 );
@@ -10388,15 +10590,15 @@ fn decode_rect4_16_strip(
10388 // `mbmi->skip_txfm`, so a skipped `UV_CFL_PRED` block is still10590 // `mbmi->skip_txfm`, so a skipped `UV_CFL_PRED` block is still
10389 // DC + alpha * luma-AC. Dropping the CfL term here left a10591 // DC + alpha * luma-AC. Dropping the CfL term here left a
10390 // chroma-only bounded box on ReelC's key frames.10592 // 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));
10392 if alpha.is_some() {10594 if alpha.is_some() {
10393 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));10595 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
10394 }10596 }
10395- for (buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] {10597+ for (_buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] {
10396 if let Some((ub, vb)) = &palette_uv_bufs {10598 if let Some((ub, vb)) = &palette_uv_bufs {
10397 set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx);10599 set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx);
10398 }10600 }
10399- buf.reconstruct_rect(10601+ push_intra_rect(plane,
10400 cpx,10602 cpx,
10401 cpy,10603 cpy,
10402 cw,10604 cw,
@@ -10406,7 +10608,7 @@ fn decode_rect4_16_strip(
10406 pair_reach,10608 pair_reach,
10407 &zeros,10609 &zeros,
10408 alpha10610 alpha
10409- .zip(ac.as_deref())10611+ .zip(ac)
10410 .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),10612 .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
10411 None,10613 None,
10412 smooth_neighbor_uv, fctx,10614 smooth_neighbor_uv, fctx,
@@ -10436,8 +10638,8 @@ fn decode_rect4_16_strip(
10436 let (u_levels, u_tx_type) = planes.pop().expect("plane 1");10638 let (u_levels, u_tx_type) = planes.pop().expect("plane 1");
10437 // CfL averages the luma of the WHOLE pair, the region this one10639 // CfL averages the luma of the WHOLE pair, the region this one
10438 // chroma transform covers.10640 // chroma transform covers.
10439- let ac = alpha.map(|_| cfl_ac_q3_rect(y, ppx, ppy, pw, ph));10641+ let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph));
10440- for (plane, buf, levels, tx_type) in [10642+ for (plane, _buf, levels, tx_type) in [
10441 (1usize, &mut *u, &u_levels, u_tx_type),10643 (1usize, &mut *u, &u_levels, u_tx_type),
10442 (2, &mut *v, &v_levels, v_tx_type),10644 (2, &mut *v, &v_levels, v_tx_type),
10443 ] {10645 ] {
@@ -10454,7 +10656,7 @@ fn decode_rect4_16_strip(
10454 if let Some((ub, vb)) = &palette_uv_bufs {10656 if let Some((ub, vb)) = &palette_uv_bufs {
10455 set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx);10657 set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx);
10456 }10658 }
10457- buf.reconstruct_rect(10659+ push_intra_rect(plane,
10458 cpx,10660 cpx,
10459 cpy,10661 cpy,
10460 cw,10662 cw,
@@ -10464,7 +10666,7 @@ fn decode_rect4_16_strip(
10464 pair_reach,10666 pair_reach,
10465 &residual,10667 &residual,
10466 alpha10668 alpha
10467- .zip(ac.as_deref())10669+ .zip(ac)
10468 .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),10670 .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
10469 None,10671 None,
10470 smooth_neighbor_uv, fctx,10672 smooth_neighbor_uv, fctx,
@@ -10757,7 +10959,7 @@ fn decode_block_rect64(
10757 )10959 )
10758 });10960 });
10759 if skip {10961 if skip {
10760- y.reconstruct_rect(10962+ push_intra_rect(0,
10761 px,10963 px,
10762 py,10964 py,
10763 bw,10965 bw,
@@ -10770,11 +10972,11 @@ fn decode_block_rect64(
10770 filter_intra,10972 filter_intra,
10771 smooth_neighbor, fctx,10973 smooth_neighbor, fctx,
10772 );10974 );
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));
10774 if let Some((ub, _)) = &palette_uv_bufs {10976 if let Some((ub, _)) = &palette_uv_bufs {
10775 set_palette_pred(ub.clone(), fctx);10977 set_palette_pred(ub.clone(), fctx);
10776 }10978 }
10777- u.reconstruct_rect(10979+ push_intra_rect(1,
10778 cpx,10980 cpx,
10779 cpy,10981 cpy,
10780 chroma_w,10982 chroma_w,
@@ -10783,14 +10985,14 @@ fn decode_block_rect64(
10783 angle_delta_uv,10985 angle_delta_uv,
10784 reach,10986 reach,
10785 &vec![0i32; chroma_w * chroma_h],10987 &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)),
10787 None,10989 None,
10788 smooth_neighbor_uv, fctx,10990 smooth_neighbor_uv, fctx,
10789 );10991 );
10790 if let Some((_, vb)) = &palette_uv_bufs {10992 if let Some((_, vb)) = &palette_uv_bufs {
10791 set_palette_pred(vb.clone(), fctx);10993 set_palette_pred(vb.clone(), fctx);
10792 }10994 }
10793- v.reconstruct_rect(10995+ push_intra_rect(2,
10794 cpx,10996 cpx,
10795 cpy,10997 cpy,
10796 chroma_w,10998 chroma_w,
@@ -10799,7 +11001,7 @@ fn decode_block_rect64(
10799 angle_delta_uv,11001 angle_delta_uv,
10800 reach,11002 reach,
10801 &vec![0i32; chroma_w * chroma_h],11003 &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)),
10803 None,11005 None,
10804 smooth_neighbor_uv, fctx,11006 smooth_neighbor_uv, fctx,
10805 );11007 );
@@ -10896,7 +11098,7 @@ fn decode_block_rect64(
10896 plane_q_delta(0, fctx).1,11098 plane_q_delta(0, fctx).1,
10897 luma_tx_type,11099 luma_tx_type,
10898 );11100 );
10899- y.reconstruct_rect(11101+ push_intra_rect(0,
10900 px,11102 px,
10901 py,11103 py,
10902 bw,11104 bw,
@@ -10925,7 +11127,7 @@ fn decode_block_rect64(
10925 }11127 }
10926 // CHROMA: a real, untruncated chroma_w x chroma_h transform -- no11128 // CHROMA: a real, untruncated chroma_w x chroma_h transform -- no
10927 // corner crop needed (see doc comment).11129 // 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));
10929 // The chroma plane is never truncated (both axes <= 32 after11131 // The chroma plane is never truncated (both axes <= 32 after
10930 // subsampling). Under a 1:4 strip it is a true 32x8/8x32:11132 // subsampling). Under a 1:4 strip it is a true 32x8/8x32:
10931 // `get_txsize_entropy_ctx(TX_32X8)` = (TX_8X8 + TX_32X32 + 1) >> 1 =11133 // `get_txsize_entropy_ctx(TX_32X8)` = (TX_8X8 + TX_32X32 + 1) >> 1 =
@@ -10989,7 +11191,7 @@ fn decode_block_rect64(
10989 if let Some((ub, _)) = &palette_uv_bufs {11191 if let Some((ub, _)) = &palette_uv_bufs {
10990 set_palette_pred(ub.clone(), fctx);11192 set_palette_pred(ub.clone(), fctx);
10991 }11193 }
10992- u.reconstruct_rect(11194+ push_intra_rect(1,
10993 cpx,11195 cpx,
10994 cpy,11196 cpy,
10995 chroma_w,11197 chroma_w,
@@ -10998,7 +11200,7 @@ fn decode_block_rect64(
10998 angle_delta_uv,11200 angle_delta_uv,
10999 reach,11201 reach,
11000 &u_residual,11202 &u_residual,
11001- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),11203+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
11002 None,11204 None,
11003 smooth_neighbor_uv, fctx,11205 smooth_neighbor_uv, fctx,
11004 );11206 );
@@ -11046,7 +11248,7 @@ fn decode_block_rect64(
11046 if let Some((_, vb)) = &palette_uv_bufs {11248 if let Some((_, vb)) = &palette_uv_bufs {
11047 set_palette_pred(vb.clone(), fctx);11249 set_palette_pred(vb.clone(), fctx);
11048 }11250 }
11049- v.reconstruct_rect(11251+ push_intra_rect(2,
11050 cpx,11252 cpx,
11051 cpy,11253 cpy,
11052 chroma_w,11254 chroma_w,
@@ -11055,7 +11257,7 @@ fn decode_block_rect64(
11055 angle_delta_uv,11257 angle_delta_uv,
11056 reach,11258 reach,
11057 &v_residual,11259 &v_residual,
11058- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),11260+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
11059 None,11261 None,
11060 smooth_neighbor_uv, fctx,11262 smooth_neighbor_uv, fctx,
11061 );11263 );
@@ -11719,12 +11921,16 @@ impl PlaneBuf<'_> {
11719 residual: &[i32],11921 residual: &[i32],
11720 cfl: Option<(i32, &[i32])>,11922 cfl: Option<(i32, &[i32])>,
11721 filter_intra: Option<usize>,11923 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,
11723 ) {11929 ) {
11724 // As [`Self::reconstruct`]'s own [`PALETTE_PRED`] override11930 // As [`Self::reconstruct`]'s own [`PALETTE_PRED`] override
11725 // (lane-palette2 r4): a palette block's prediction is the11931 // (lane-palette2 r4): a palette block's prediction is the
11726 // reconstructed colour-index map, needing no edge pixels at all.11932 // 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 {
11728 buf11934 buf
11729 } else {11935 } else {
11730 let (above, left, corner) = self.edges_rect(x, y, bw, bh, reach);11936 let (above, left, corner) = self.edges_rect(x, y, bw, bh, reach);
@@ -11823,12 +12029,16 @@ impl PlaneBuf<'_> {
11823 // callers until a smooth/paeth `uv_mode` can reach this call at all12029 // callers until a smooth/paeth `uv_mode` can reach this call at all
11824 // (still refused in `read_intra_mode`/`read_intra_mode_rect`), which12030 // (still refused in `read_intra_mode`/`read_intra_mode_rect`), which
11825 // keeps `false` exact for chroma without this fn needing to know why.12031 // 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,
11827 ) {12037 ) {
11828 // A palette block's own [`PALETTE_PRED`] override (lane-palette r2)12038 // A palette block's own [`PALETTE_PRED`] override (lane-palette r2)
11829 // takes priority over `predict()`/`predict_filter_intra` entirely --12039 // takes priority over `predict()`/`predict_filter_intra` entirely --
11830 // palette prediction needs no edge pixels at all.12040 // 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 {
11832 buf12042 buf
11833 } else {12043 } else {
11834 let (above, left, corner) = self.edges(x, y, side, reach);12044 let (above, left, corner) = self.edges(x, y, side, reach);
@@ -11922,13 +12132,17 @@ fn read_plane(
11922 predict_mode: usize,12132 predict_mode: usize,
11923 angle_delta: i32,12133 angle_delta: i32,
11924 reach: Reach,12134 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>,
11926 x: usize,12140 x: usize,
11927 y: usize,12141 y: usize,
11928 side: usize,12142 side: usize,
11929 tx_side: usize,12143 tx_side: usize,
11930 base_q_idx: u8,12144 base_q_idx: u8,
11931- cfl: Option<(i32, &[i32])>,12145+ cfl: Option<(i32, CflSrc)>,
11932 filter_intra: Option<usize>,12146 filter_intra: Option<usize>,
11933 // Only meaningful for `plane_idx == 0`: `Some` when this transform unit is12147 // Only meaningful for `plane_idx == 0`: `Some` when this transform unit is
11934 // smaller than its own block (spec `get_txb_ctx_general`'s12148 // smaller than its own block (spec `get_txb_ctx_general`'s
@@ -12019,7 +12233,7 @@ fn read_plane(
12019 "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={levels:?} residual={residual:?}",12233 "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={levels:?} residual={residual:?}",
12020 );12234 );
12021 }12235 }
12022- plane.reconstruct(12236+ push_intra(plane_idx,
12023 x,12237 x,
12024 y,12238 y,
12025 side,12239 side,
@@ -12215,6 +12429,7 @@ fn decode_block(
12215 // block vector, with the BILINEAR kernel libaom forces for intrabc --12429 // block vector, with the BILINEAR kernel libaom forces for intrabc --
12216 // luma is a straight copy, chroma lands half-pel whenever the luma DV is12430 // luma is a straight copy, chroma lands half-pel whenever the luma DV is
12217 // odd, which is exactly what the bilinear taps then interpolate.12431 // odd, which is exactly what the bilinear taps then interpolate.
12432+ flush_recon(fctx, y, u, v);
12218 let intrabc_bufs = intrabc_dv.map(|(dv_row, dv_col)| {12433 let intrabc_bufs = intrabc_dv.map(|(dv_row, dv_col)| {
12219 let mut yb = vec![0u16; side * side];12434 let mut yb = vec![0u16; side * side];
12220 mc::predict_with_filter(12435 mc::predict_with_filter(
@@ -12333,7 +12548,7 @@ fn decode_block(
12333 y.width,12548 y.width,
12334 y.height, fctx,12549 y.height, fctx,
12335 );12550 );
12336- y.reconstruct(12551+ push_intra(0,
12337 tu_px,12552 tu_px,
12338 tu_py,12553 tu_py,
12339 logical_tx,12554 logical_tx,
@@ -12348,7 +12563,7 @@ fn decode_block(
12348 }12563 }
12349 }12564 }
12350 } else {12565 } else {
12351- y.reconstruct(12566+ push_intra(0,
12352 px,12567 px,
12353 py,12568 py,
12354 side,12569 side,
@@ -12361,7 +12576,7 @@ fn decode_block(
12361 smooth_neighbor, fctx,12576 smooth_neighbor, fctx,
12362 );12577 );
12363 }12578 }
12364- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));12579+ let ac = alpha.map(|_| cfl_src(px, py, side));
12365 let cn = (chroma_side / chroma_tx).max(1);12580 let cn = (chroma_side / chroma_tx).max(1);
12366 for cu_row in 0..cn {12581 for cu_row in 0..cn {
12367 for cu_col in 0..cn {12582 for cu_col in 0..cn {
@@ -12379,7 +12594,7 @@ fn decode_block(
12379 if let Some((ub, _)) = &palette_uv_bufs {12594 if let Some((ub, _)) = &palette_uv_bufs {
12380 set_palette_pred(ub.clone(), fctx);12595 set_palette_pred(ub.clone(), fctx);
12381 }12596 }
12382- u.reconstruct(12597+ push_intra(1,
12383 cu_x,12598 cu_x,
12384 cu_y,12599 cu_y,
12385 chroma_tx,12600 chroma_tx,
@@ -12387,14 +12602,14 @@ fn decode_block(
12387 angle_delta_uv,12602 angle_delta_uv,
12388 cu_r,12603 cu_r,
12389 &vec![0i32; chroma_tx * chroma_tx],12604 &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)),
12391 None,12606 None,
12392 smooth_neighbor_uv, fctx,12607 smooth_neighbor_uv, fctx,
12393 );12608 );
12394 if let Some((_, vb)) = &palette_uv_bufs {12609 if let Some((_, vb)) = &palette_uv_bufs {
12395 set_palette_pred(vb.clone(), fctx);12610 set_palette_pred(vb.clone(), fctx);
12396 }12611 }
12397- v.reconstruct(12612+ push_intra(2,
12398 cu_x,12613 cu_x,
12399 cu_y,12614 cu_y,
12400 chroma_tx,12615 chroma_tx,
@@ -12402,7 +12617,7 @@ fn decode_block(
12402 angle_delta_uv,12617 angle_delta_uv,
12403 cu_r,12618 cu_r,
12404 &vec![0i32; chroma_tx * chroma_tx],12619 &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)),
12406 None,12621 None,
12407 smooth_neighbor_uv, fctx,12622 smooth_neighbor_uv, fctx,
12408 );12623 );
@@ -12444,7 +12659,7 @@ fn decode_block(
12444 None,12659 None,
12445 smooth_neighbor, fctx,12660 smooth_neighbor, fctx,
12446 )?;12661 )?;
12447- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));12662+ let ac = alpha.map(|_| cfl_src(px, py, side));
12448 // Armed for exactly this block's two chroma reads (see12663 // Armed for exactly this block's two chroma reads (see
12449 // [`INTRABC_CHROMA_TX`]); the luma call above just set12664 // [`INTRABC_CHROMA_TX`]); the luma call above just set
12450 // [`LUMA_TX_TYPE`] to the type it coded.12665 // [`LUMA_TX_TYPE`] to the type it coded.
@@ -12471,7 +12686,7 @@ fn decode_block(
12471 chroma_side,12686 chroma_side,
12472 chroma_tx,12687 chroma_tx,
12473 base_q_idx,12688 base_q_idx,
12474- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),12689+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
12475 None,12690 None,
12476 None,12691 None,
12477 smooth_neighbor_uv, fctx,12692 smooth_neighbor_uv, fctx,
@@ -12502,7 +12717,7 @@ fn decode_block(
12502 chroma_side,12717 chroma_side,
12503 chroma_tx,12718 chroma_tx,
12504 base_q_idx,12719 base_q_idx,
12505- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),12720+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
12506 None,12721 None,
12507 None,12722 None,
12508 smooth_neighbor_uv, fctx,12723 smooth_neighbor_uv, fctx,
@@ -12622,7 +12837,7 @@ fn decode_block(
12622 }12837 }
12623 // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where12838 // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where
12624 // this still runs after every luma unit of the block.12839 // 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));
12626 // The block's uv plane block is `chroma_side` across but its uv12841 // The block's uv plane block is `chroma_side` across but its uv
12627 // transform is `chroma_tx` (`av1_get_max_uv_txsize` =12842 // transform is `chroma_tx` (`av1_get_max_uv_txsize` =
12628 // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`):12843 // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`):
@@ -12657,7 +12872,7 @@ fn decode_block(
12657 dec, cdfs, chroma_set, scans.1, 1, cu_around[1], mode,12872 dec, cdfs, chroma_set, scans.1, 1, cu_around[1], mode,
12658 uv_predict_mode, angle_delta_uv, cu_reach, u, cu_x, cu_y,12873 uv_predict_mode, angle_delta_uv, cu_reach, u, cu_x, cu_y,
12659 chroma_tx, chroma_tx, base_q_idx,12874 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)),
12661 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,12876 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,
12662 )?;12877 )?;
12663 if let Some((_, vb)) = &palette_uv_bufs {12878 if let Some((_, vb)) = &palette_uv_bufs {
@@ -12667,7 +12882,7 @@ fn decode_block(
12667 dec, cdfs, chroma_set, scans.1, 2, cu_around[2], mode,12882 dec, cdfs, chroma_set, scans.1, 2, cu_around[2], mode,
12668 uv_predict_mode, angle_delta_uv, cu_reach, v, cu_x, cu_y,12883 uv_predict_mode, angle_delta_uv, cu_reach, v, cu_x, cu_y,
12669 chroma_tx, chroma_tx, base_q_idx,12884 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)),
12671 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,12886 None, chroma_ctx_offset, smooth_neighbor_uv, fctx,
12672 )?;12887 )?;
12673 if cn > 1 {12888 if cn > 1 {
@@ -12930,7 +13145,7 @@ fn decode_block_128rect(
12930 y.height, fctx,13145 y.height, fctx,
12931 );13146 );
12932 if skip {13147 if skip {
12933- y.reconstruct(13148+ push_intra(0,
12934 tu_px, tu_py, logical_tx, mode, angle_delta_y, tu_r, &zero_tu, None,13149 tu_px, tu_py, logical_tx, mode, angle_delta_y, tu_r, &zero_tu, None,
12935 None, smooth_neighbor, fctx,13150 None, smooth_neighbor, fctx,
12936 );13151 );
@@ -12987,11 +13202,11 @@ fn decode_block_128rect(
12987 );13202 );
12988 let (cu_x, cu_y) = (cpx + ch_col * chroma_tx, cpy + ch_row * chroma_tx);13203 let (cu_x, cu_y) = (cpx + ch_col * chroma_tx, cpy + ch_row * chroma_tx);
12989 if skip {13204 if skip {
12990- u.reconstruct(13205+ push_intra(1,
12991 cu_x, cu_y, chroma_tx, uv_predict_mode, angle_delta_uv, cu_r, &zero_cu, None,13206 cu_x, cu_y, chroma_tx, uv_predict_mode, angle_delta_uv, cu_r, &zero_cu, None,
12992 None, smooth_neighbor_uv, fctx,13207 None, smooth_neighbor_uv, fctx,
12993 );13208 );
12994- v.reconstruct(13209+ push_intra(2,
12995 cu_x, cu_y, chroma_tx, uv_predict_mode, angle_delta_uv, cu_r, &zero_cu, None,13210 cu_x, cu_y, chroma_tx, uv_predict_mode, angle_delta_uv, cu_r, &zero_cu, None,
12996 None, smooth_neighbor_uv, fctx,13211 None, smooth_neighbor_uv, fctx,
12997 );13212 );
@@ -13287,6 +13502,7 @@ fn decode_leaf8(
13287 // the CURRENT frame's own pre-loop-filter reconstruction (every loop13502 // the CURRENT frame's own pre-loop-filter reconstruction (every loop
13288 // filter is off whenever `allow_intrabc`, frame.rs:194/210/252/272) at13503 // filter is off whenever `allow_intrabc`, frame.rs:194/210/252/272) at
13289 // the full-pel block vector, with the BILINEAR kernel libaom forces.13504 // the full-pel block vector, with the BILINEAR kernel libaom forces.
13505+ flush_recon(fctx, y, u, v);
13290 let intrabc_bufs = intrabc_dv.map(|(dv_row, dv_col)| {13506 let intrabc_bufs = intrabc_dv.map(|(dv_row, dv_col)| {
13291 let mut yb = vec![0u16; 8 * 8];13507 let mut yb = vec![0u16; 8 * 8];
13292 mc::predict_with_filter(13508 mc::predict_with_filter(
@@ -13349,7 +13565,7 @@ fn decode_leaf8(
13349 y.width,13565 y.width,
13350 y.height, fctx,13566 y.height, fctx,
13351 );13567 );
13352- y.reconstruct(13568+ push_intra(0,
13353 tu_px,13569 tu_px,
13354 tu_py,13570 tu_py,
13355 4,13571 4,
@@ -13367,7 +13583,7 @@ fn decode_leaf8(
13367 if let Some(buf) = &palette_y_buf {13583 if let Some(buf) = &palette_y_buf {
13368 set_palette_pred(buf.clone(), fctx);13584 set_palette_pred(buf.clone(), fctx);
13369 }13585 }
13370- y.reconstruct(13586+ push_intra(0,
13371 px,13587 px,
13372 py,13588 py,
13373 8,13589 8,
@@ -13380,13 +13596,13 @@ fn decode_leaf8(
13380 smooth_neighbor, fctx,13596 smooth_neighbor, fctx,
13381 );13597 );
13382 }13598 }
13383- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));13599+ let ac = alpha.map(|_| cfl_src(px, py, 8));
13384 if let Some((_, ub, _)) = &intrabc_bufs {13600 if let Some((_, ub, _)) = &intrabc_bufs {
13385 set_palette_pred(ub.clone(), fctx);13601 set_palette_pred(ub.clone(), fctx);
13386 } else if let Some((ub, _)) = &palette_uv_bufs {13602 } else if let Some((ub, _)) = &palette_uv_bufs {
13387 set_palette_pred(ub.clone(), fctx);13603 set_palette_pred(ub.clone(), fctx);
13388 }13604 }
13389- u.reconstruct(13605+ push_intra(1,
13390 cpx,13606 cpx,
13391 cpy,13607 cpy,
13392 4,13608 4,
@@ -13394,7 +13610,7 @@ fn decode_leaf8(
13394 angle_delta_uv,13610 angle_delta_uv,
13395 reach,13611 reach,
13396 &vec![0i32; 16],13612 &vec![0i32; 16],
13397- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),13613+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
13398 None,13614 None,
13399 smooth_neighbor_uv, fctx,13615 smooth_neighbor_uv, fctx,
13400 );13616 );
@@ -13403,7 +13619,7 @@ fn decode_leaf8(
13403 } else if let Some((_, vb)) = &palette_uv_bufs {13619 } else if let Some((_, vb)) = &palette_uv_bufs {
13404 set_palette_pred(vb.clone(), fctx);13620 set_palette_pred(vb.clone(), fctx);
13405 }13621 }
13406- v.reconstruct(13622+ push_intra(2,
13407 cpx,13623 cpx,
13408 cpy,13624 cpy,
13409 4,13625 4,
@@ -13411,7 +13627,7 @@ fn decode_leaf8(
13411 angle_delta_uv,13627 angle_delta_uv,
13412 reach,13628 reach,
13413 &vec![0i32; 16],13629 &vec![0i32; 16],
13414- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),13630+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
13415 None,13631 None,
13416 smooth_neighbor_uv, fctx,13632 smooth_neighbor_uv, fctx,
13417 );13633 );
@@ -13457,7 +13673,7 @@ fn decode_leaf8(
13457 if intrabc_dv.is_some() {13673 if intrabc_dv.is_some() {
13458 fctx.intrabc_chroma_tx.with(|c| c.set(Some(fctx.luma_tx_type.with(std::cell::Cell::get))));13674 fctx.intrabc_chroma_tx.with(|c| c.set(Some(fctx.luma_tx_type.with(std::cell::Cell::get))));
13459 }13675 }
13460- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));13676+ let ac = alpha.map(|_| cfl_src(px, py, 8));
13461 if let Some((_, ub, _)) = &intrabc_bufs {13677 if let Some((_, ub, _)) = &intrabc_bufs {
13462 set_palette_pred(ub.clone(), fctx);13678 set_palette_pred(ub.clone(), fctx);
13463 } else if let Some((ub, _)) = &palette_uv_bufs {13679 } else if let Some((ub, _)) = &palette_uv_bufs {
@@ -13480,7 +13696,7 @@ fn decode_leaf8(
13480 4,13696 4,
13481 TX4,13697 TX4,
13482 base_q_idx,13698 base_q_idx,
13483- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),13699+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
13484 None,13700 None,
13485 None,13701 None,
13486 smooth_neighbor_uv, fctx,13702 smooth_neighbor_uv, fctx,
@@ -13507,7 +13723,7 @@ fn decode_leaf8(
13507 4,13723 4,
13508 TX4,13724 TX4,
13509 base_q_idx,13725 base_q_idx,
13510- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),13726+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
13511 None,13727 None,
13512 None,13728 None,
13513 smooth_neighbor_uv, fctx,13729 smooth_neighbor_uv, fctx,
@@ -13597,7 +13813,7 @@ fn decode_leaf8(
13597 neighbours.record_mi_luma(tu_mi, 4, &tu_grid);13813 neighbours.record_mi_luma(tu_mi, 4, &tu_grid);
13598 }13814 }
13599 }13815 }
13600- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));13816+ let ac = alpha.map(|_| cfl_src(px, py, 8));
13601 let chroma_around = neighbours.around_mi(leaf_mi, 8);13817 let chroma_around = neighbours.around_mi(leaf_mi, 8);
13602 if let Some((ub, _)) = &palette_uv_bufs {13818 if let Some((ub, _)) = &palette_uv_bufs {
13603 set_palette_pred(ub.clone(), fctx);13819 set_palette_pred(ub.clone(), fctx);
@@ -13619,7 +13835,7 @@ fn decode_leaf8(
13619 4,13835 4,
13620 TX4,13836 TX4,
13621 base_q_idx,13837 base_q_idx,
13622- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),13838+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
13623 None,13839 None,
13624 None,13840 None,
13625 smooth_neighbor_uv, fctx,13841 smooth_neighbor_uv, fctx,
@@ -13644,7 +13860,7 @@ fn decode_leaf8(
13644 4,13860 4,
13645 TX4,13861 TX4,
13646 base_q_idx,13862 base_q_idx,
13647- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),13863+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
13648 None,13864 None,
13649 None,13865 None,
13650 smooth_neighbor_uv, fctx,13866 smooth_neighbor_uv, fctx,
@@ -13907,7 +14123,7 @@ fn decode_leaf_split4(
13907 let (px, py) = (lmi.1 * MI, lmi.0 * MI);14123 let (px, py) = (lmi.1 * MI, lmi.0 * MI);
13908 let reach = Reach::of(4, px, py, y.width, y.height, fctx);14124 let reach = Reach::of(4, px, py, y.width, y.height, fctx);
13909 if skip {14125 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);
13911 neighbours.record_mi_luma(lmi, 4, &vec![0i32; 16]);14127 neighbours.record_mi_luma(lmi, 4, &vec![0i32; 16]);
13912 } else {14128 } else {
13913 let tu_around = neighbours.around_mi(lmi, 4)[0];14129 let tu_around = neighbours.around_mi(lmi, 4)[0];
@@ -13964,26 +14180,26 @@ fn decode_leaf_split4(
13964 // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the14180 // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the
13965 // merge keeps one fix and feeds both lanes' counters so neither of14181 // merge keeps one fix and feeds both lanes' counters so neither of
13966 // their gates goes vacuous.14182 // 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));
13968 if alpha.is_some() {14184 if alpha.is_some() {
13969 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));14185 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
13970 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));14186 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
13971 }14187 }
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);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);
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);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);
13974 (vec![0i32; 16], vec![0i32; 16])14190 (vec![0i32; 16], vec![0i32; 16])
13975 } else {14191 } else {
13976- let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));14192+ let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
13977 let chroma_around = neighbours.around_mi(leaf_mi, 8);14193 let chroma_around = neighbours.around_mi(leaf_mi, 8);
13978 let ug = read_plane(14194 let ug = read_plane(
13979 dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,14195 dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,
13980 angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx,14196 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,
13982 )?;14198 )?;
13983 let vg = read_plane(14199 let vg = read_plane(
13984 dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,14200 dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,
13985 angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx,14201 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,
13987 )?;14203 )?;
13988 (ug, vg)14204 (ug, vg)
13989 };14205 };
@@ -14194,7 +14410,7 @@ fn decode_leaf_rect8(
14194 // one's reconstruction, which is NOT what a single 4x814410 // one's reconstruction, which is NOT what a single 4x8
14195 // prediction of the same mode produces.14411 // prediction of the same mode produces.
14196 let zeros = vec![0i32; 16];14412 let zeros = vec![0i32; 16];
14197- y.reconstruct(14413+ push_intra(0,
14198 tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None,14414 tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None,
14199 filter_intra, smooth_neighbor, fctx,14415 filter_intra, smooth_neighbor, fctx,
14200 );14416 );
@@ -14248,7 +14464,7 @@ fn decode_leaf_rect8(
14248 }14464 }
14249 let grid = if skip {14465 let grid = if skip {
14250 let zeros = vec![0i32; bw * bh];14466 let zeros = vec![0i32; bw * bh];
14251- y.reconstruct_rect(14467+ push_intra_rect(0,
14252 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,14468 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
14253 smooth_neighbor, fctx,14469 smooth_neighbor, fctx,
14254 );14470 );
@@ -14291,7 +14507,7 @@ fn decode_leaf_rect8(
14291 plane_q_delta(0, fctx).1,14507 plane_q_delta(0, fctx).1,
14292 tx_type,14508 tx_type,
14293 );14509 );
14294- y.reconstruct_rect(14510+ push_intra_rect(0,
14295 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,14511 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
14296 smooth_neighbor, fctx,14512 smooth_neighbor, fctx,
14297 );14513 );
@@ -14336,26 +14552,26 @@ fn decode_leaf_rect8(
14336 // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the14552 // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the
14337 // merge keeps one fix and feeds both lanes' counters so neither of14553 // merge keeps one fix and feeds both lanes' counters so neither of
14338 // their gates goes vacuous.14554 // 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));
14340 if alpha.is_some() {14556 if alpha.is_some() {
14341 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));14557 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
14342 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));14558 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
14343 }14559 }
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);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);
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);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);
14346 (vec![0i32; 16], vec![0i32; 16])14562 (vec![0i32; 16], vec![0i32; 16])
14347 } else {14563 } else {
14348- let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));14564+ let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
14349 let chroma_around = neighbours.around_mi(leaf_mi, 8);14565 let chroma_around = neighbours.around_mi(leaf_mi, 8);
14350 let ug = read_plane(14566 let ug = read_plane(
14351 dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,14567 dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,
14352 angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx,14568 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,
14354 )?;14570 )?;
14355 let vg = read_plane(14571 let vg = read_plane(
14356 dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,14572 dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,
14357 angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx,14573 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,
14359 )?;14575 )?;
14360 (ug, vg)14576 (ug, vg)
14361 };14577 };
@@ -16138,7 +16354,11 @@ fn read_inter_plane_rect(
16138 plane_idx: usize,16354 plane_idx: usize,
16139 around: (bool, bool, i32),16355 around: (bool, bool, i32),
16140 tx_mode: usize,16356 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>,
16142 x: usize,16362 x: usize,
16143 y: usize,16363 y: usize,
16144 prediction: &[u16],16364 prediction: &[u16],
@@ -16230,7 +16450,7 @@ fn read_inter_plane_rect(
16230 for row in 0..h {16450 for row in 0..h {
16231 strided[row * stride..][..w].copy_from_slice(&residual[row * w..][..w]);16451 strided[row * stride..][..w].copy_from_slice(&residual[row * w..][..w]);
16232 }16452 }
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);
16234 Ok((grid, tx_type))16454 Ok((grid, tx_type))
16235 }16455 }
16236 16456
@@ -18365,6 +18585,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
18365 // visits of this superblock code nothing at all.18585 // visits of this superblock code nothing at all.
18366 let mut sb128_none = false;18586 let mut sb128_none = false;
18367 for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) {18587 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);
18368 if row_start {18590 if row_start {
18369 neighbours.start_row();18591 neighbours.start_row();
18370 }18592 }
@@ -20105,6 +20327,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
20105 }20327 }
20106 }20328 }
20107 }20329 }
20330+ flush_recon(fctx, &mut y, &mut u, &mut v);
20108 20331
20109 if tile_num == tile_info.context_update_tile_id {20332 if tile_num == tile_info.context_update_tile_id {
20110 result_cdfs = cdfs;20333 result_cdfs = cdfs;
@@ -20589,18 +20812,7 @@ impl PlaneBuf<'_> {
20589 /// compensation's output, rather than [`predict`]'s intra one), writing20812 /// compensation's output, rather than [`predict`]'s intra one), writing
20590 /// the clamped reconstruction into the plane at `(x, y)` -- the inter20813 /// the clamped reconstruction into the plane at `(x, y)` -- the inter
20591 /// counterpart of [`PlaneBuf::reconstruct`].20814 /// counterpart of [`PlaneBuf::reconstruct`].
20592- fn reconstruct_mc(20815+ /// [`Self::reconstruct_mc_rect`], writing only a `w`x`h` sub-rectangle of the
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
20604 /// `side`x`side` `prediction`/`residual` buffers (which stay `side`-square20816 /// `side`x`side` `prediction`/`residual` buffers (which stay `side`-square
20605 /// for stride/indexing) -- lane-partitions r1: a true rectangular HORZ/20817 /// for stride/indexing) -- lane-partitions r1: a true rectangular HORZ/
20606 /// VERT strip is predicted at its enclosing square `side` (matching20818 /// VERT strip is predicted at its enclosing square `side` (matching
@@ -20656,7 +20868,11 @@ fn read_inter_plane(
20656 plane_idx: usize,20868 plane_idx: usize,
20657 around: (bool, bool, i32),20869 around: (bool, bool, i32),
20658 tx_mode: usize,20870 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>,
20660 x: usize,20876 x: usize,
20661 y: usize,20877 y: usize,
20662 side: usize,20878 side: usize,
@@ -20727,7 +20943,7 @@ fn read_inter_plane(
20727 };20943 };
20728 let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx);20944 let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx);
20729 let residual = dequant_and_inverse_typed(&grid, side, bit_depth(fctx), block_q_idx(fctx), dc_delta, ac_delta, tx_type);20945 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);
20731 Ok((grid, tx_type))20947 Ok((grid, tx_type))
20732 }20948 }
20733 20949
@@ -23244,7 +23460,7 @@ fn decode_inter_block(
23244 .123460 .1
23245 };23461 };
23246 if skip {23462 if skip {
23247- y.reconstruct_mc_rect(23463+ push_mc_rect(0,
23248 px,23464 px,
23249 py,23465 py,
23250 side,23466 side,
@@ -23253,7 +23469,7 @@ fn decode_inter_block(
23253 &pred_y,23469 &pred_y,
23254 &vec![0i32; side * side], fctx,23470 &vec![0i32; side * side], fctx,
23255 );23471 );
23256- u.reconstruct_mc_rect(23472+ push_mc_rect(1,
23257 cpx,23473 cpx,
23258 cpy,23474 cpy,
23259 chroma_side,23475 chroma_side,
@@ -23262,7 +23478,7 @@ fn decode_inter_block(
23262 &pred_u,23478 &pred_u,
23263 &vec![0i32; chroma_side * chroma_side], fctx,23479 &vec![0i32; chroma_side * chroma_side], fctx,
23264 );23480 );
23265- v.reconstruct_mc_rect(23481+ push_mc_rect(2,
23266 cpx,23482 cpx,
23267 cpy,23483 cpy,
23268 chroma_side,23484 chroma_side,
@@ -24367,6 +24583,7 @@ fn decode_inter_block(
24367 // result, all planes (reconinter.c av1_build_interintra_predictor24583 // result, all planes (reconinter.c av1_build_interintra_predictor
24368 // plane loop).24584 // plane loop).
24369 if let Some(ii) = interintra_mode {24585 if let Some(ii) = interintra_mode {
24586+ flush_recon(fctx, y, u, v);
24370 if write_w != write_h {24587 if write_w != write_h {
24371 INTERINTRA_RECT_HITS.with(|c| c.set(c.get() + 1));24588 INTERINTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
24372 }24589 }
@@ -24454,7 +24671,7 @@ fn decode_inter_block(
24454 .124671 .1
24455 };24672 };
24456 if skip {24673 if skip {
24457- y.reconstruct_mc_rect(24674+ push_mc_rect(0,
24458 px,24675 px,
24459 py,24676 py,
24460 side,24677 side,
@@ -24464,7 +24681,7 @@ fn decode_inter_block(
24464 &vec![0i32; side * side], fctx,24681 &vec![0i32; side * side], fctx,
24465 );24682 );
24466 if has_chroma {24683 if has_chroma {
24467- u.reconstruct_mc_rect(24684+ push_mc_rect(1,
24468 cpx,24685 cpx,
24469 cpy,24686 cpy,
24470 chroma_side,24687 chroma_side,
@@ -24473,7 +24690,7 @@ fn decode_inter_block(
24473 &pred_u,24690 &pred_u,
24474 &vec![0i32; chroma_side * chroma_side], fctx,24691 &vec![0i32; chroma_side * chroma_side], fctx,
24475 );24692 );
24476- v.reconstruct_mc_rect(24693+ push_mc_rect(2,
24477 cpx,24694 cpx,
24478 cpy,24695 cpy,
24479 chroma_side,24696 chroma_side,
@@ -25216,7 +25433,7 @@ fn decode_inter_block(
25216 set_palette_pred(window, fctx);25433 set_palette_pred(window, fctx);
25217 }25434 }
25218 let tu_grid = if skip {25435 let tu_grid = if skip {
25219- y.reconstruct(25436+ push_intra(0,
25220 tu_px,25437 tu_px,
25221 tu_py,25438 tu_py,
25222 tx_px,25439 tx_px,
@@ -25286,7 +25503,7 @@ fn decode_inter_block(
25286 for plane_idx in 1..3 {25503 for plane_idx in 1..3 {
25287 let buf: &mut PlaneBuf<'static> = if plane_idx == 1 { &mut *u } else { &mut *v };25504 let buf: &mut PlaneBuf<'static> = if plane_idx == 1 { &mut *u } else { &mut *v };
25288 let cu_grid = if skip {25505 let cu_grid = if skip {
25289- buf.reconstruct(25506+ push_intra(plane_idx,
25290 cu_x,25507 cu_x,
25291 cu_y,25508 cu_y,
25292 cu_tx,25509 cu_tx,
@@ -25356,7 +25573,7 @@ fn decode_inter_block(
25356 if let Some(buf) = &palette_y_buf {25573 if let Some(buf) = &palette_y_buf {
25357 set_palette_pred(buf.clone(), fctx);25574 set_palette_pred(buf.clone(), fctx);
25358 }25575 }
25359- y.reconstruct(25576+ push_intra(0,
25360 px,25577 px,
25361 py,25578 py,
25362 side,25579 side,
@@ -25369,11 +25586,11 @@ fn decode_inter_block(
25369 smooth_neighbor, fctx,25586 smooth_neighbor, fctx,
25370 );25587 );
25371 }25588 }
25372- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));25589+ let ac = alpha.map(|_| cfl_src(px, py, side));
25373 if let Some((ub, _)) = &palette_uv_bufs {25590 if let Some((ub, _)) = &palette_uv_bufs {
25374 set_palette_pred(ub.clone(), fctx);25591 set_palette_pred(ub.clone(), fctx);
25375 }25592 }
25376- u.reconstruct(25593+ push_intra(1,
25377 cpx,25594 cpx,
25378 cpy,25595 cpy,
25379 chroma_side,25596 chroma_side,
@@ -25381,14 +25598,14 @@ fn decode_inter_block(
25381 angle_delta_uv,25598 angle_delta_uv,
25382 reach,25599 reach,
25383 &vec![0i32; chroma_side * chroma_side],25600 &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)),
25385 None,25602 None,
25386 smooth_neighbor_uv, fctx,25603 smooth_neighbor_uv, fctx,
25387 );25604 );
25388 if let Some((_, vb)) = &palette_uv_bufs {25605 if let Some((_, vb)) = &palette_uv_bufs {
25389 set_palette_pred(vb.clone(), fctx);25606 set_palette_pred(vb.clone(), fctx);
25390 }25607 }
25391- v.reconstruct(25608+ push_intra(2,
25392 cpx,25609 cpx,
25393 cpy,25610 cpy,
25394 chroma_side,25611 chroma_side,
@@ -25396,7 +25613,7 @@ fn decode_inter_block(
25396 angle_delta_uv,25613 angle_delta_uv,
25397 reach,25614 reach,
25398 &vec![0i32; chroma_side * chroma_side],25615 &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)),
25400 None,25617 None,
25401 smooth_neighbor_uv, fctx,25618 smooth_neighbor_uv, fctx,
25402 );25619 );
@@ -25437,7 +25654,7 @@ fn decode_inter_block(
25437 smooth_neighbor, fctx,25654 smooth_neighbor, fctx,
25438 )?25655 )?
25439 };25656 };
25440- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));25657+ let ac = alpha.map(|_| cfl_src(px, py, side));
25441 if let Some((ub, _)) = &palette_uv_bufs {25658 if let Some((ub, _)) = &palette_uv_bufs {
25442 set_palette_pred(ub.clone(), fctx);25659 set_palette_pred(ub.clone(), fctx);
25443 }25660 }
@@ -25458,7 +25675,7 @@ fn decode_inter_block(
25458 chroma_side,25675 chroma_side,
25459 chroma_tx,25676 chroma_tx,
25460 base_q_idx,25677 base_q_idx,
25461- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),25678+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
25462 None,25679 None,
25463 None,25680 None,
25464 smooth_neighbor_uv, fctx,25681 smooth_neighbor_uv, fctx,
@@ -25483,7 +25700,7 @@ fn decode_inter_block(
25483 chroma_side,25700 chroma_side,
25484 chroma_tx,25701 chroma_tx,
25485 base_q_idx,25702 base_q_idx,
25486- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),25703+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
25487 None,25704 None,
25488 None,25705 None,
25489 smooth_neighbor_uv, fctx,25706 smooth_neighbor_uv, fctx,
@@ -26094,7 +26311,7 @@ fn decode_inter_sub8_split4(
26094 // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which26311 // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which
26095 // `read_inter_plane`'s `plane_idx == 0` arm already assumes).26312 // `read_inter_plane`'s `plane_idx == 0` arm already assumes).
26096 if skip {26313 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);
26098 neighbours.record_mi_luma_rect(lmi, B4, B4, &vec![0i32; B4 * B4]);26315 neighbours.record_mi_luma_rect(lmi, B4, B4, &vec![0i32; B4 * B4]);
26099 } else {26316 } else {
26100 let around = neighbours.around_mi(lmi, B4);26317 let around = neighbours.around_mi(lmi, B4);
@@ -26209,8 +26426,8 @@ fn decode_inter_sub8_split4(
26209 }26426 }
26210 }26427 }
26211 let (u_grid, v_grid) = if last_skip {26428 let (u_grid, v_grid) = if last_skip {
26212- u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx);26429+ push_mc(1, cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx);
26213- v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx);26430+ push_mc(2, cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx);
26214 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])26431 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
26215 } else {26432 } else {
26216 let around = neighbours.around_mi(group_mi, 8);26433 let around = neighbours.around_mi(group_mi, 8);
@@ -26439,7 +26656,7 @@ fn decode_intra_sub8_leaf(
26439 );26656 );
26440 if skip {26657 if skip {
26441 let zeros = vec![0i32; 16];26658 let zeros = vec![0i32; 16];
26442- y.reconstruct(26659+ push_intra(0,
26443 tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None, filter_intra,26660 tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None, filter_intra,
26444 smooth_neighbor, fctx,26661 smooth_neighbor, fctx,
26445 );26662 );
@@ -26481,7 +26698,7 @@ fn decode_intra_sub8_leaf(
26481 // fixes `txb_skip_ctx` at 0 (`luma_skip_ctx: None`) -- the same square26698 // fixes `txb_skip_ctx` at 0 (`luma_skip_ctx: None`) -- the same square
26482 // reader [`decode_leaf_split4`] uses.26699 // reader [`decode_leaf_split4`] uses.
26483 if skip {26700 if skip {
26484- y.reconstruct(26701+ push_intra(0,
26485 px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra,26702 px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra,
26486 smooth_neighbor, fctx,26703 smooth_neighbor, fctx,
26487 );26704 );
@@ -26519,7 +26736,7 @@ fn decode_intra_sub8_leaf(
26519 } else {26736 } else {
26520 let grid_levels = if skip {26737 let grid_levels = if skip {
26521 let zeros = vec![0i32; bw * bh];26738 let zeros = vec![0i32; bw * bh];
26522- y.reconstruct_rect(26739+ push_intra_rect(0,
26523 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,26740 px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
26524 smooth_neighbor, fctx,26741 smooth_neighbor, fctx,
26525 );26742 );
@@ -26554,7 +26771,7 @@ fn decode_intra_sub8_leaf(
26554 plane_q_delta(0, fctx).1,26771 plane_q_delta(0, fctx).1,
26555 tx_type,26772 tx_type,
26556 );26773 );
26557- y.reconstruct_rect(26774+ push_intra_rect(0,
26558 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,26775 px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
26559 smooth_neighbor, fctx,26776 smooth_neighbor, fctx,
26560 );26777 );
@@ -26649,26 +26866,26 @@ fn decode_intra_sub8_leaf(
26649 // needs `bsize >= BLOCK_8X8`), so the group always clears.26866 // needs `bsize >= BLOCK_8X8`), so the group always clears.
26650 record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);26867 record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);
26651 26868
26652- let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));26869+ let ac = alpha.map(|_| cfl_src(gpx, gpy, 8));
26653 let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if skip {26870 let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if skip {
26654 if alpha.is_some() {26871 if alpha.is_some() {
26655 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));26872 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
26656 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));26873 SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
26657 }26874 }
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);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);
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);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);
26660 (vec![0i32; 16], vec![0i32; 16])26877 (vec![0i32; 16], vec![0i32; 16])
26661 } else {26878 } else {
26662 let chroma_around = neighbours.around_mi(group_mi, 8);26879 let chroma_around = neighbours.around_mi(group_mi, 8);
26663 let ug = read_plane(26880 let ug = read_plane(
26664 dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,26881 dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode,
26665 angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx,26882 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,
26667 )?;26884 )?;
26668 let vg = read_plane(26885 let vg = read_plane(
26669 dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,26886 dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode,
26670 angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx,26887 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,
26672 )?;26889 )?;
26673 (ug, vg)26890 (ug, vg)
26674 };26891 };
@@ -27067,7 +27284,7 @@ fn decode_inter_sub8_rect2(
27067 }27284 }
27068 }27285 }
27069 if skip {27286 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);
27071 neighbours.record_mi_luma_rect(lmi, bw, bh, &vec![0i32; bw * bh]);27288 neighbours.record_mi_luma_rect(lmi, bw, bh, &vec![0i32; bw * bh]);
27072 neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx);27289 neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx);
27073 } else {27290 } else {
@@ -27233,8 +27450,8 @@ fn decode_inter_sub8_rect2(
27233 }27450 }
27234 }27451 }
27235 let (u_grid, v_grid) = if last_skip {27452 let (u_grid, v_grid) = if last_skip {
27236- u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx);27453+ push_mc(1, cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx);
27237- v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx);27454+ push_mc(2, cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx);
27238 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])27455 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
27239 } else {27456 } else {
27240 let around = neighbours.around_mi(group_mi, 8);27457 let around = neighbours.around_mi(group_mi, 8);
@@ -28070,15 +28287,15 @@ fn decode_inter_block8(
28070 .128287 .1
28071 .is_some();28288 .is_some();
28072 if skip {28289 if skip {
28073- y.reconstruct_mc(px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx);28290+ push_mc(0, px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx);
28074- u.reconstruct_mc(28291+ push_mc(1,
28075 cpx,28292 cpx,
28076 cpy,28293 cpy,
28077 CHROMA_SIDE,28294 CHROMA_SIDE,
28078 &pred_u,28295 &pred_u,
28079 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,28296 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
28080 );28297 );
28081- v.reconstruct_mc(28298+ push_mc(2,
28082 cpx,28299 cpx,
28083 cpy,28300 cpy,
28084 CHROMA_SIDE,28301 CHROMA_SIDE,
@@ -28697,6 +28914,7 @@ fn decode_inter_block8(
28697 // Non-wedge interintra blend, mutually exclusive with OBMC (the28914 // Non-wedge interintra blend, mutually exclusive with OBMC (the
28698 // motion_mode symbol is not read for an interintra block).28915 // motion_mode symbol is not read for an interintra block).
28699 if let Some(ii) = interintra_mode {28916 if let Some(ii) = interintra_mode {
28917+ flush_recon(fctx, y, u, v);
28700 interintra_blend(y, px, py, SIDE, SIDE, SIDE, ii, wedge_mask, &mut pred_y, fctx);28918 interintra_blend(y, px, py, SIDE, SIDE, SIDE, ii, wedge_mask, &mut pred_y, fctx);
28701 interintra_blend(28919 interintra_blend(
28702 u, cpx, cpy, CHROMA_SIDE, CHROMA_SIDE, CHROMA_SIDE, ii, wedge_mask, &mut pred_u, fctx,28920 u, cpx, cpy, CHROMA_SIDE, CHROMA_SIDE, CHROMA_SIDE, ii, wedge_mask, &mut pred_u, fctx,
@@ -28719,15 +28937,15 @@ fn decode_inter_block8(
28719 .128937 .1
28720 .is_some();28938 .is_some();
28721 if skip {28939 if skip {
28722- y.reconstruct_mc(px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx);28940+ push_mc(0, px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx);
28723- u.reconstruct_mc(28941+ push_mc(1,
28724 cpx,28942 cpx,
28725 cpy,28943 cpy,
28726 CHROMA_SIDE,28944 CHROMA_SIDE,
28727 &pred_u,28945 &pred_u,
28728 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,28946 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
28729 );28947 );
28730- v.reconstruct_mc(28948+ push_mc(2,
28731 cpx,28949 cpx,
28732 cpy,28950 cpy,
28733 CHROMA_SIDE,28951 CHROMA_SIDE,
@@ -29090,7 +29308,7 @@ fn decode_inter_block8(
29090 set_palette_pred(window, fctx);29308 set_palette_pred(window, fctx);
29091 }29309 }
29092 let tu_grid = if skip {29310 let tu_grid = if skip {
29093- y.reconstruct(29311+ push_intra(0,
29094 tu_px,29312 tu_px,
29095 tu_py,29313 tu_py,
29096 tx_px,29314 tx_px,
@@ -29143,7 +29361,7 @@ fn decode_inter_block8(
29143 if let Some(buf) = &palette_y_buf {29361 if let Some(buf) = &palette_y_buf {
29144 set_palette_pred(buf.clone(), fctx);29362 set_palette_pred(buf.clone(), fctx);
29145 }29363 }
29146- y.reconstruct(29364+ push_intra(0,
29147 px,29365 px,
29148 py,29366 py,
29149 SIDE,29367 SIDE,
@@ -29158,11 +29376,11 @@ fn decode_inter_block8(
29158 }29376 }
29159 // CfL's AC contribution is the luma this leaf just reconstructed,29377 // CfL's AC contribution is the luma this leaf just reconstructed,
29160 // averaged over the 4x4 chroma block (`cfl_ac_q3`, spec 7.11.5).29378 // 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));
29162 if let Some((ub, _)) = &palette_uv_bufs {29380 if let Some((ub, _)) = &palette_uv_bufs {
29163 set_palette_pred(ub.clone(), fctx);29381 set_palette_pred(ub.clone(), fctx);
29164 }29382 }
29165- u.reconstruct(29383+ push_intra(1,
29166 cpx,29384 cpx,
29167 cpy,29385 cpy,
29168 CHROMA_SIDE,29386 CHROMA_SIDE,
@@ -29170,14 +29388,14 @@ fn decode_inter_block8(
29170 angle_delta_uv,29388 angle_delta_uv,
29171 reach,29389 reach,
29172 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],29390 &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)),
29174 None,29392 None,
29175 smooth_neighbor_uv, fctx,29393 smooth_neighbor_uv, fctx,
29176 );29394 );
29177 if let Some((_, vb)) = &palette_uv_bufs {29395 if let Some((_, vb)) = &palette_uv_bufs {
29178 set_palette_pred(vb.clone(), fctx);29396 set_palette_pred(vb.clone(), fctx);
29179 }29397 }
29180- v.reconstruct(29398+ push_intra(2,
29181 cpx,29399 cpx,
29182 cpy,29400 cpy,
29183 CHROMA_SIDE,29401 CHROMA_SIDE,
@@ -29185,7 +29403,7 @@ fn decode_inter_block8(
29185 angle_delta_uv,29403 angle_delta_uv,
29186 reach,29404 reach,
29187 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],29405 &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)),
29189 None,29407 None,
29190 smooth_neighbor_uv, fctx,29408 smooth_neighbor_uv, fctx,
29191 );29409 );
@@ -29234,7 +29452,7 @@ fn decode_inter_block8(
29234 smooth_neighbor, fctx,29452 smooth_neighbor, fctx,
29235 )?29453 )?
29236 };29454 };
29237- let ac = alpha.map(|_| cfl_ac_q3(y, px, py, SIDE));29455+ let ac = alpha.map(|_| cfl_src(px, py, SIDE));
29238 if let Some((ub, _)) = &palette_uv_bufs {29456 if let Some((ub, _)) = &palette_uv_bufs {
29239 set_palette_pred(ub.clone(), fctx);29457 set_palette_pred(ub.clone(), fctx);
29240 }29458 }
@@ -29255,7 +29473,7 @@ fn decode_inter_block8(
29255 CHROMA_SIDE,29473 CHROMA_SIDE,
29256 TX4,29474 TX4,
29257 base_q_idx,29475 base_q_idx,
29258- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),29476+ alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
29259 None,29477 None,
29260 None,29478 None,
29261 smooth_neighbor_uv, fctx,29479 smooth_neighbor_uv, fctx,
@@ -29280,7 +29498,7 @@ fn decode_inter_block8(
29280 CHROMA_SIDE,29498 CHROMA_SIDE,
29281 TX4,29499 TX4,
29282 base_q_idx,29500 base_q_idx,
29283- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),29501+ alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
29284 None,29502 None,
29285 None,29503 None,
29286 smooth_neighbor_uv, fctx,29504 smooth_neighbor_uv, fctx,
@@ -29819,6 +30037,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
29819 // key-frame tile loop runs).30037 // key-frame tile loop runs).
29820 let mut sb128_none = false;30038 let mut sb128_none = false;
29821 for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) {30039 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);
29822 if row_start {30042 if row_start {
29823 neighbours.start_row();30043 neighbours.start_row();
29824 }30044 }
@@ -32162,6 +32382,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
32162 }32382 }
32163 }32383 }
32164 }32384 }
32385+ flush_recon(fctx, &mut y, &mut u, &mut v);
32165 32386
32166 if tile_num == tile_info.context_update_tile_id {32387 if tile_num == tile_info.context_update_tile_id {
32167 result_cdfs = cdfs;32388 result_cdfs = cdfs;