forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1-rect14: 1:4 intrabc pairs and the lossless 16x4 chroma walk

Browse files at this commit

f34211c24b4c88c8ffdef09918e12242cf3a2d91Ahmet Kaan GümüşParent: 588db0bcd3dae9
Reviewer verdict PASS 0.85; suite 603/0/60 on the lane tree.
P3s fixed on the lane (lnone byte numbers, merge-note riders).
crates/ec-av1/examples/decode_probe.rsmodified+37 -16
@@ -38,7 +38,10 @@ fn main() {
3838 println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}");
3939 let (h, v, c) = ec_av1::stream::rect4_32_counters();
4040 println!("rect4_32: horz={h} vert={v} coded={c}");
41- println!("rect_intrabc_reads: {}", ec_av1::stream::rect_intrabc_reads());
41+ println!(
42+ "rect_intrabc_reads: {}",
43+ ec_av1::stream::rect_intrabc_reads()
44+ );
4245 let (pal_y, pal_uv) = ec_av1::stream::intra_in_inter_palette_hits();
4346 println!("intra_in_inter_palette: y={pal_y} uv={pal_uv}");
4447 println!(
@@ -46,7 +49,10 @@ fn main() {
4649 ec_av1::stream::rect64_corner_tu_hits(0),
4750 ec_av1::stream::rect64_corner_tu_hits(1)
4851 );
49- println!("leaf8_intrabc_hits: {}", ec_av1::stream::leaf8_intrabc_hits());
52+ println!(
53+ "leaf8_intrabc_hits: {}",
54+ ec_av1::stream::leaf8_intrabc_hits()
55+ );
5056 println!("intrabc_hits: {}", ec_av1::stream::intrabc_hits());
5157 println!(
5258 "skipped_intrabc_chroma_arm_hits: {}",
@@ -54,14 +60,26 @@ fn main() {
5460 );
5561 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
5662 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
57- println!("sub8_inter_split: groups={}", ec_av1::decode::sub8_inter_split_hits());
63+ println!(
64+ "sub8_inter_split: groups={}",
65+ ec_av1::decode::sub8_inter_split_hits()
66+ );
5867 println!(
5968 "skip_split_tx_override: {}",
6069 ec_av1::decode::skip_split_tx_override_hits()
6170 );
62- println!("interintra_rect: {}", ec_av1::decode::interintra_rect_hits());
63- println!("gm_nontrans_small_side: {}", ec_av1::decode::gm_nontrans_small_side_hits());
64- println!("tr_reach_longer_side: {}", ec_av1::decode::tr_reach_longer_side_hits());
71+ println!(
72+ "interintra_rect: {}",
73+ ec_av1::decode::interintra_rect_hits()
74+ );
75+ println!(
76+ "gm_nontrans_small_side: {}",
77+ ec_av1::decode::gm_nontrans_small_side_hits()
78+ );
79+ println!(
80+ "tr_reach_longer_side: {}",
81+ ec_av1::decode::tr_reach_longer_side_hits()
82+ );
6583 println!(
6684 "mv_clamp_edge_overhang: {}",
6785 ec_av1::mvstack::mv_clamp_edge_overhang_hits()
@@ -90,7 +108,6 @@ fn main() {
90108 println!(
91109 "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}",
92110 es[0], es[1], es[2], es[3], es[4], es[5]
93-
94111 );
95112 let (h4, v4, pairs, sub8) = ec_av1::decode::inter16_rect4_counters();
96113 println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}");
@@ -104,9 +121,7 @@ fn main() {
104121 );
105122 let rw = ec_av1::stream::rect_wedge_hits();
106123 let rwi = ec_av1::stream::rect_wii_hits();
107- println!(
108- "rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}"
109- );
124+ println!("rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}");
110125 // lane-inter128intra r1: the 128 root's HORZ/VERT half coded INTRA in
111126 // an INTER frame -- the arm this round implemented.
112127 let i128 = ec_av1::stream::intra128_in_inter_counters();
@@ -164,6 +179,11 @@ fn main() {
164179 "intra16x4_in_inter: 16x4={} 4x16={} chroma_ref={}",
165180 i164.0, i164.1, i164.2
166181 );
182+ println!(
183+ "rect4_16_pair: lossless_chroma={} intrabc={}",
184+ ec_av1::decode::rect4_16_lossless_chroma_hits(),
185+ ec_av1::decode::rect4_16_intrabc_hits(),
186+ );
167187 // lane-t900 r12: chroma edge-filter neighbour answered from the mi-granular
168188 // uv_mode grid instead of the coarse one-slot-per-column map.
169189 println!(
@@ -179,10 +199,7 @@ fn main() {
179199 );
180200 // lane-thread2: proof the frame-parallel path actually fired (0 at
181201 // the default EC_AV1_THREADS=1).
182- println!(
183- "frames_dispatched: {}",
184- ec_av1::stream::frames_dispatched()
185- );
202+ println!("frames_dispatched: {}", ec_av1::stream::frames_dispatched());
186203 };
187204 // lane-tiles: the tiling a real stream actually uses is a decision input
188205 // (every gate in `stream.rs` picks its own `--tile-columns`), so report it
@@ -318,7 +335,9 @@ fn main() {
318335 .unwrap_or_else(|e| panic!("opening {path}: {e}"))
319336 };
320337 let out16 = std::env::var("EC_PROBE_OUT16").ok();
321- let out8 = std::env::args().nth(2).or_else(|| std::env::var("EC_PROBE_OUT").ok());
338+ let out8 = std::env::args()
339+ .nth(2)
340+ .or_else(|| std::env::var("EC_PROBE_OUT").ok());
322341 let null16 = out16.as_deref() == Some("/dev/null");
323342 let mut f16 = out16.as_deref().map(open);
324343 let mut f8 = out8.as_deref().map(open);
@@ -329,7 +348,9 @@ fn main() {
329348 let mut buf: Vec<u8> = Vec::new();
330349 // lane-av1mono: a monochrome stream is luma only, so the raw dump is a
331350 // single plane -- exactly what `ffmpeg -pix_fmt gray -f rawvideo` writes.
332- let mono = parser.sequence_header().is_some_and(|s| s.color_config.mono_chrome);
351+ let mono = parser
352+ .sequence_header()
353+ .is_some_and(|s| s.color_config.mono_chrome);
333354 let result = ec_av1::stream::decode_stream_with(&data, |f, _idx, is_shown| {
334355 if !is_shown {
335356 return Ok(());
crates/ec-av1/src/decode.rsmodified+688 -7
@@ -5012,6 +5012,10 @@ thread_local! {
50125012 /// the shape that made 4 chroma samples of the ReelB `-ss 1200`
50135013 /// key frame miss by 1. Zero here means a gate never exercised the fix.
50145014 static RECT4_16_UV_PAIR_FILT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
5015+ /// lane-av1-rect14: lossless 16x4/4x16 chroma pairs walked as two TX_4X4s.
5016+ static RECT4_16_LOSSLESS_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
5017+ /// lane-av1-rect14: intrabc reconstructions of a 16x4/4x16 pair strip.
5018+ static RECT4_16_INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
50155019 /// lane-kf1200 r2: sub-8x8 chroma blocks that are `skip_txfm` AND
50165020 /// `UV_CFL_PRED` -- the arm that used to drop the CfL alpha entirely.
50175021 static SKIP_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
@@ -5029,6 +5033,22 @@ pub fn rect4_16_uv_pair_filt_hits() -> usize {
50295033 RECT4_16_UV_PAIR_FILT_HITS.with(|c| c.get())
50305034 }
50315035
5036+/// How many lossless 16x4/4x16 chroma pairs walked two TX_4X4s per plane.
5037+pub fn rect4_16_lossless_chroma_hits() -> usize {
5038+ RECT4_16_LOSSLESS_CHROMA_HITS.with(|c| c.get())
5039+}
5040+
5041+/// How many 16x4/4x16 strips reconstructed as intra block copy.
5042+pub fn rect4_16_intrabc_hits() -> usize {
5043+ RECT4_16_INTRABC_HITS.with(|c| c.get())
5044+}
5045+
5046+/// Zero the lane-av1-rect14 pair counters so a gate measures one stream.
5047+pub fn reset_rect4_16_pair_hits() {
5048+ RECT4_16_LOSSLESS_CHROMA_HITS.with(|c| c.set(0));
5049+ RECT4_16_INTRABC_HITS.with(|c| c.set(0));
5050+}
5051+
50325052 // lane-reelckf r1: the two chroma defects ReelC's key frames exposed --
50335053 // CHROMA_SKIP_CFL counts skipped intra blocks whose chroma is `UV_CFL_PRED`
50345054 // (prediction still runs, libaom `predict_and_reconstruct_intra_block`), and
@@ -9238,6 +9258,8 @@ fn read_intra_mode_rect(
92389258 Option<usize>,
92399259 Option<PaletteY>,
92409260 Option<PaletteUv>,
9261+ // lane-av1-rect14: Some(dv) for an intrabc 16x4/4x16 pair strip.
9262+ Option<(i32, i32)>,
92419263 )> {
92429264 // lane-av1mono: libaom guards every chroma symbol read with
92439265 // `!cm->seq_params->monochrome && xd->is_chroma_ref` (`decodemv.c:933`),
@@ -9316,8 +9338,18 @@ fn read_intra_mode_rect(
93169338 istep!("intrabc", use_intrabc as i32);
93179339 if use_intrabc {
93189340 hit!(INTRABC_HITS);
9319- return Err(unsupported(
9320- "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)",
9341+ // 16x4/4x16 is a chroma PAIR ([`decode_rect4_16_intrabc`]).
9342+ // Every other rect shape still refuses by name: its
9343+ // reconstruction is `decode_intrabc_rect` (lane-av1-intrabc,
9344+ // not on this tree). 32x8/8x32, 64x16/16x64 and 128-axis strips
9345+ // own their chroma and must not take the pair helper.
9346+ // Every rect shape returns the DV. 16x4/4x16 reconstructs in
9347+ // [`decode_rect4_16_intrabc`]; other shapes in
9348+ // [`decode_intrabc_owned_rect`]. A shape with no coefficient
9349+ // table still refuses there, by the same name.
9350+ let dv = read_intrabc_dv(dec, cdfs, mi_r, mi_c, (bw / MI, bh / MI), fctx);
9351+ return Ok((
9352+ skip, DC_PRED, 0, DC_PRED, 0, None, None, None, None, Some(dv),
93219353 ));
93229354 }
93239355 }
@@ -9469,6 +9501,7 @@ fn read_intra_mode_rect(
94699501 filter_intra,
94709502 palette_y,
94719503 palette_uv,
9504+ None,
94729505 ))
94739506 }
94749507
@@ -10926,7 +10959,7 @@ fn decode_block_rect(
1092610959 let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c);
1092710960 let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(at);
1092810961 let palette_uv_cache = neighbours.palette_uv_cache(at);
10929- let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =
10962+ let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv, intrabc) =
1093010963 read_intra_mode_rect(
1093110964 dec,
1093210965 cdfs,
@@ -10944,6 +10977,12 @@ fn decode_block_rect(
1094410977 r * (SUB / MI),
1094510978 c * (SUB / MI), fctx,
1094610979 )?;
10980+ if let Some((dv_row, dv_col)) = intrabc {
10981+ return decode_intrabc_owned_rect(
10982+ dec, cdfs, neighbours, (r * (SUB / MI), c * (SUB / MI)), (bw, bh), skip,
10983+ (dv_row, dv_col), y, u, v, base_q_idx, tx_select, reduced_tx_set, fctx,
10984+ );
10985+ }
1094710986 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
1094810987 if smooth_neighbor {
1094910988 hit!(SMOOTH_LUMA_HITS);
@@ -11421,7 +11460,7 @@ fn decode_leaf_rect(
1142111460 let pal_at = leaf_mi;
1142211461 let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at);
1142311462 let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at);
11424- let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =
11463+ let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv, intrabc) =
1142511464 read_intra_mode_rect(
1142611465 dec,
1142711466 cdfs,
@@ -11439,6 +11478,13 @@ fn decode_leaf_rect(
1143911478 leaf_mi.0,
1144011479 leaf_mi.1, fctx,
1144111480 )?;
11481+ if let Some((dv_row, dv_col)) = intrabc {
11482+ decode_intrabc_owned_rect(
11483+ dec, cdfs, neighbours, leaf_mi, (bw, bh), skip, (dv_row, dv_col),
11484+ y, u, v, base_q_idx, tx_select, reduced_tx_set, fctx,
11485+ )?;
11486+ return Ok(DC_PRED);
11487+ }
1144211488 // lane-kf900 r4: palette prediction on this shape, the same colour-index
1144311489 // map -> base colours buffer [`decode_block_rect`] hands each
1144411490 // `reconstruct_rect` through [`set_palette_pred`].
@@ -11751,6 +11797,7 @@ fn decode_block_rect4(
1175111797 filter_intra,
1175211798 palette_y,
1175311799 palette_uv,
11800+ intrabc,
1175411801 ) = read_intra_mode_rect(
1175511802 dec,
1175611803 cdfs,
@@ -11768,6 +11815,14 @@ fn decode_block_rect4(
1176811815 mi_r,
1176911816 mi_c, fctx,
1177011817 )?;
11818+ if let Some((dv_row, dv_col)) = intrabc {
11819+ decode_intrabc_owned_rect(
11820+ dec, cdfs, neighbours, (mi_r, mi_c), (bw, bh), skip, (dv_row, dv_col),
11821+ y, u, v, base_q_idx, tx_select,
11822+ fctx.reduced_tx_set_inter.with(std::cell::Cell::get), fctx,
11823+ )?;
11824+ return Ok((DC_PRED, DC_PRED));
11825+ }
1177111826 // lane-kf900 r4: palette prediction on this shape, exactly as
1177211827 // [`decode_block_rect`] does one aspect ratio up -- the colour-index map
1177311828 // mapped through the base colours IS the prediction (it reads no edge
@@ -12239,6 +12294,520 @@ fn decode_rect4_16(
1223912294 /// key-frame caller's coarse-cell stand-in; `None` on the inter path, where
1224012295 /// every strip publishes its own mi-exact mode). Returns
1224112296 /// `(y_mode, uv_predict_mode when this strip closes the 4:2:0 chroma pair)`.
12297+/// Intrabc reconstruction for a rect strip that OWNS its chroma
12298+/// (`bw/2 x bh/2` at the strip origin). 16x4/4x16 is not this shape -- that
12299+/// pair goes through [`decode_rect4_16_intrabc`].
12300+///
12301+/// This is the same control flow as the unmerged lane's `decode_intrabc_rect`
12302+/// (predict once, then one residual per transform unit on the INTER sets,
12303+/// chroma inherits luma's `tx_type`), written against the helpers that exist
12304+/// on this tree so a 2:1 strip no longer hides the 16x4 pair witness. The
12305+/// merge with lane-av1-intrabc should keep one of the two bodies; the call
12306+/// shape is the same.
12307+#[allow(clippy::too_many_arguments)]
12308+fn decode_intrabc_owned_rect(
12309+ dec: &mut SymbolDecoder,
12310+ cdfs: &mut Cdfs,
12311+ neighbours: &mut Neighbours,
12312+ (mi_r, mi_c): (usize, usize),
12313+ (bw, bh): (usize, usize),
12314+ skip: bool,
12315+ (dv_row, dv_col): (i32, i32),
12316+ y: &mut PlaneBuf<'static>,
12317+ u: &mut PlaneBuf<'static>,
12318+ v: &mut PlaneBuf<'static>,
12319+ base_q_idx: u8,
12320+ tx_select: bool,
12321+ reduced_tx_set: bool,
12322+ fctx: &crate::decode::FrameCtx,
12323+) -> Result<()> {
12324+ let _ = base_q_idx;
12325+ let (px, py) = (mi_c * MI, mi_r * MI);
12326+ let (cw, ch) = (bw / 2, bh / 2);
12327+ let side = bw.max(bh);
12328+ let cside = cw.max(ch);
12329+ let saved_reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get);
12330+ let saved_tx = fctx.tx_select_inter.with(std::cell::Cell::get);
12331+ fctx.reduced_tx_set_inter.with(|c| c.set(reduced_tx_set));
12332+ // `read_block_tx_size_rect` keys on this cell. A key frame forces it
12333+ // false; the real bit is the caller's `tx_select`. Restored before return.
12334+ fctx.tx_select_inter.with(|c| c.set(tx_select));
12335+ let restore = ReducedTxRestore { fctx, saved_reduced, saved_tx };
12336+
12337+ flush_recon(fctx, y, u, v);
12338+ let pred_y = predict_intrabc_window(y, px, py, bw, bh, dv_col, dv_row, true, side, fctx);
12339+ let pred_u = predict_intrabc_window(u, px / 2, py / 2, cw, ch, dv_col, dv_row, false, cside, fctx);
12340+ let pred_v = predict_intrabc_window(v, px / 2, py / 2, cw, ch, dv_col, dv_row, false, cside, fctx);
12341+
12342+ let mi_cols = 2 * y.true_width.div_ceil(8);
12343+ let mi_rows = 2 * y.true_height.div_ceil(8);
12344+ let leaves = read_block_tx_size_rect(
12345+ dec, cdfs, neighbours, (mi_r, mi_c), (bw, bh), (mi_cols, mi_rows), skip, fctx,
12346+ )?;
12347+ let mut luma_tx_type = TxType::DctDct;
12348+ let luma_grid;
12349+ let u_grid;
12350+ let v_grid;
12351+ if skip {
12352+ // `reconstruct_mc_rect` indexes the residual at the square stride.
12353+ // `bw * bh` underruns on a VERT strip (8x16: stride 16, 16 rows, index 136).
12354+ push_mc_rect(0, px, py, side, bw, bh, Pred::Inline(&pred_y, side), &ZERO_RESIDUAL[..side * bh], fctx);
12355+ push_mc_rect(1, px / 2, py / 2, cside, cw, ch, Pred::Inline(&pred_u, cside), &ZERO_RESIDUAL[..cside * ch], fctx);
12356+ push_mc_rect(2, px / 2, py / 2, cside, cw, ch, Pred::Inline(&pred_v, cside), &ZERO_RESIDUAL[..cside * ch], fctx);
12357+ luma_grid = Grid::Zero(side * side);
12358+ u_grid = Grid::Zero(cside * cside);
12359+ v_grid = Grid::Zero(cside * cside);
12360+ } else if let Some(ls) = leaves.as_ref() {
12361+ for (idx, &(row, col, tw, th)) in ls.iter().enumerate() {
12362+ let tu_mi = (mi_r + row, mi_c + col);
12363+ let (tu_px, tu_py) = (px + col * MI, py + row * MI);
12364+ let tu_pred = Pred::Inline(&pred_y, side).offset(row * MI * side + col * MI);
12365+ let (g, tt) = if tw == th {
12366+ read_inter_plane(
12367+ dec, cdfs, inter_txbset_for(tw, reduced_tx_set), &default_scan(tw.min(32)),
12368+ 0, neighbours.around_mi(tu_mi, tw)[0], 0, y, tu_px, tu_py, tw, base_q_idx,
12369+ tu_pred, None, Some(neighbours.luma_skip_ctx(tu_mi, tw / MI)), fctx,
12370+ )?
12371+ } else {
12372+ read_inter_plane_rect(
12373+ dec, cdfs, rect_inter_luma_set(tw, th, fctx)?, (tw, th), side, 0,
12374+ neighbours.around_mi_rect(tu_mi, tw, th)[0], 0, y, tu_px, tu_py, tu_pred,
12375+ None, Some(neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI)), fctx,
12376+ )?
12377+ };
12378+ if idx == 0 {
12379+ luma_tx_type = tt;
12380+ }
12381+ neighbours.record_mi_luma_rect(tu_mi, tw, th, &g);
12382+ if tw != th {
12383+ neighbours.fill_lf_grid_leaf_luma((tu_mi.0, tu_mi.1), tw / MI, th / MI, tw as u8, th as u8);
12384+ }
12385+ }
12386+ luma_grid = Grid::Zero(side * side);
12387+ let around = neighbours.around_mi_rect((mi_r, mi_c), bw, bh);
12388+ let (ug, _) = read_inter_plane_rect(
12389+ dec, cdfs, rect_inter_chroma_set(cw, ch)?, (cw, ch), cside, 1, around[1], 0,
12390+ u, px / 2, py / 2, Pred::Inline(&pred_u, cside), Some(luma_tx_type), None, fctx,
12391+ )?;
12392+ let (vg, _) = read_inter_plane_rect(
12393+ dec, cdfs, rect_inter_chroma_set(cw, ch)?, (cw, ch), cside, 2, around[2], 0,
12394+ v, px / 2, py / 2, Pred::Inline(&pred_v, cside), Some(luma_tx_type), None, fctx,
12395+ )?;
12396+ u_grid = ug;
12397+ v_grid = vg;
12398+ } else {
12399+ let around = neighbours.around_mi_rect((mi_r, mi_c), bw, bh);
12400+ let (g, tt) = read_inter_plane_rect(
12401+ dec, cdfs, rect_inter_luma_set(bw, bh, fctx)?, (bw, bh), side, 0, around[0], 0,
12402+ y, px, py, Pred::Inline(&pred_y, side), None, None, fctx,
12403+ )?;
12404+ luma_tx_type = tt;
12405+ luma_grid = g;
12406+ let (ug, _) = read_inter_plane_rect(
12407+ dec, cdfs, rect_inter_chroma_set(cw, ch)?, (cw, ch), cside, 1, around[1], 0,
12408+ u, px / 2, py / 2, Pred::Inline(&pred_u, cside), Some(luma_tx_type), None, fctx,
12409+ )?;
12410+ let (vg, _) = read_inter_plane_rect(
12411+ dec, cdfs, rect_inter_chroma_set(cw, ch)?, (cw, ch), cside, 2, around[2], 0,
12412+ v, px / 2, py / 2, Pred::Inline(&pred_v, cside), Some(luma_tx_type), None, fctx,
12413+ )?;
12414+ u_grid = ug;
12415+ v_grid = vg;
12416+ }
12417+ drop(restore);
12418+ if leaves.is_some() {
12419+ neighbours.record_split_luma_rect_mi((mi_r, mi_c), bw, bh, DC_PRED, DC_PRED, [&u_grid, &v_grid]);
12420+ } else {
12421+ neighbours.record_rect_mi((mi_r, mi_c), bw, bh, DC_PRED, DC_PRED, &[&luma_grid, &u_grid, &v_grid]);
12422+ }
12423+ neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]);
12424+ neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]);
12425+ neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);
12426+ neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, bw.min(64) as u8, bh.min(64) as u8, 0, fctx);
12427+ record_intrabc_mi_rect(mi_r, mi_c, bw / MI, bh / MI, Some((dv_row, dv_col)), neighbours, fctx);
12428+ let _ = luma_tx_type;
12429+ Ok(())
12430+}
12431+
12432+fn predict_intrabc_window(
12433+ plane: &PlaneBuf<'_>,
12434+ px: usize,
12435+ py: usize,
12436+ w: usize,
12437+ h: usize,
12438+ dv_col: i32,
12439+ dv_row: i32,
12440+ luma: bool,
12441+ stride: usize,
12442+ fctx: &crate::decode::FrameCtx,
12443+) -> Vec<u16> {
12444+ let mut dense = vec![0u16; w * h];
12445+ mc::predict_with_filter(
12446+ &plane.data, plane.width, plane.true_width, plane.true_height,
12447+ mv_to_q4(px, dv_col, luma), mv_to_q4(py, dv_row, luma),
12448+ w, h, mc::InterpFilterKind::Bilinear, &mut dense, fctx,
12449+ );
12450+ let mut laid = vec![0u16; stride * stride];
12451+ for row in 0..h {
12452+ laid[row * stride..][..w].copy_from_slice(&dense[row * w..][..w]);
12453+ }
12454+ laid
12455+}
12456+
12457+struct ReducedTxRestore<'a> {
12458+ fctx: &'a crate::decode::FrameCtx,
12459+ saved_reduced: bool,
12460+ saved_tx: bool,
12461+}
12462+impl Drop for ReducedTxRestore<'_> {
12463+ fn drop(&mut self) {
12464+ self.fctx.reduced_tx_set_inter.with(|c| c.set(self.saved_reduced));
12465+ self.fctx.tx_select_inter.with(|c| c.set(self.saved_tx));
12466+ }
12467+}
12468+
12469+/// Reconstruction of one intrabc 16x4 / 4x16 strip (lane-av1-rect14).
12470+///
12471+/// A 1:4 strip is a PAIR. Both children share one chroma block, and only the
12472+/// odd-mi member codes it (`is_chroma_reference`, `av1_common_int.h:1454`:
12473+/// the bottom strip of a `HORZ_4`, the right strip of a `VERT_4`). The chroma
12474+/// plane block is `ss_size_lookup[BLOCK_16X4][1][1] == BLOCK_8X4` (and
12475+/// `BLOCK_4X8` for `VERT_4`) at the PAIR origin -- `setup_pred_plane`'s
12476+/// `mi_row -= 1` when the block is one mi tall on an odd row. Luma is this
12477+/// strip's own footprint, copied from this strip's DV. The block is
12478+/// `is_inter_block`, so the residual uses the INTER sets and chroma inherits
12479+/// the luma unit's coded `tx_type`.
12480+///
12481+/// Not [`decode_intrabc_rect`]: that helper (lane-av1-intrabc, not on this
12482+/// tree) predicts chroma at `bw/2 x bh/2` of the strip itself. At 16x4 that
12483+/// is an 8x2 half-pair at the odd strip -- wrong size, wrong origin, and it
12484+/// would code chroma on every strip.
12485+#[allow(clippy::too_many_arguments)]
12486+fn decode_rect4_16_intrabc(
12487+ dec: &mut SymbolDecoder,
12488+ cdfs: &mut Cdfs,
12489+ neighbours: &mut Neighbours,
12490+ lmi: (usize, usize),
12491+ horz: bool,
12492+ has_chroma: bool,
12493+ skip: bool,
12494+ (dv_row, dv_col): (i32, i32),
12495+ y: &mut PlaneBuf<'static>,
12496+ u: &mut PlaneBuf<'static>,
12497+ v: &mut PlaneBuf<'static>,
12498+ base_q_idx: u8,
12499+ tx_select: bool,
12500+ reduced_tx_set: bool,
12501+ fctx: &crate::decode::FrameCtx,
12502+) -> Result<(usize, Option<usize>, (usize, usize))> {
12503+ let _ = base_q_idx;
12504+ hit!(RECT4_16_INTRABC_HITS);
12505+ let (bw, bh) = if horz { (16usize, 4usize) } else { (4, 16) };
12506+ let (mi_w, mi_h) = (bw / MI, bh / MI);
12507+ let (px, py) = (lmi.1 * MI, lmi.0 * MI);
12508+ let side = bw.max(bh);
12509+ // `rect_inter_luma_set` reads the frame cell. A key frame's tile decoder
12510+ // publishes `reduced_tx_set` into it; set it here too so a caller that
12511+ // passed the bit explicitly cannot disagree with the set we read.
12512+ let saved_reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get);
12513+ fctx.reduced_tx_set_inter.with(|c| c.set(reduced_tx_set));
12514+ let restored = scopeguard_reduced(fctx, saved_reduced);
12515+
12516+ flush_recon(fctx, y, u, v);
12517+ let mut pred_y_dense = vec![0u16; bw * bh];
12518+ mc::predict_with_filter(
12519+ &y.data, y.width, y.true_width, y.true_height,
12520+ mv_to_q4(px, dv_col, true), mv_to_q4(py, dv_row, true),
12521+ bw, bh, mc::InterpFilterKind::Bilinear, &mut pred_y_dense, fctx,
12522+ );
12523+ let mut pred_y = vec![0u16; side * side];
12524+ for row in 0..bh {
12525+ pred_y[row * side..][..bw].copy_from_slice(&pred_y_dense[row * bw..][..bw]);
12526+ }
12527+
12528+ let (pw, ph) = if horz { (16usize, 8usize) } else { (8, 16) };
12529+ let (cw, ch) = (pw / 2, ph / 2);
12530+ let pair_mi = if has_chroma {
12531+ if horz { (lmi.0 - 1, lmi.1) } else { (lmi.0, lmi.1 - 1) }
12532+ } else {
12533+ lmi
12534+ };
12535+ let (cpx, cpy) = if has_chroma {
12536+ (pair_mi.1 * MI / 2, pair_mi.0 * MI / 2)
12537+ } else {
12538+ (0, 0)
12539+ };
12540+ let cside = cw.max(ch);
12541+ let (pred_u, pred_v) = if has_chroma {
12542+ let mut ud = vec![0u16; cw * ch];
12543+ mc::predict_with_filter(
12544+ &u.data, u.width, u.true_width, u.true_height,
12545+ mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false),
12546+ cw, ch, mc::InterpFilterKind::Bilinear, &mut ud, fctx,
12547+ );
12548+ let mut us = vec![0u16; cside * cside];
12549+ for row in 0..ch {
12550+ us[row * cside..][..cw].copy_from_slice(&ud[row * cw..][..cw]);
12551+ }
12552+ let mut vd = vec![0u16; cw * ch];
12553+ mc::predict_with_filter(
12554+ &v.data, v.width, v.true_width, v.true_height,
12555+ mv_to_q4(cpx, dv_col, false), mv_to_q4(cpy, dv_row, false),
12556+ cw, ch, mc::InterpFilterKind::Bilinear, &mut vd, fctx,
12557+ );
12558+ let mut vs = vec![0u16; cside * cside];
12559+ for row in 0..ch {
12560+ vs[row * cside..][..cw].copy_from_slice(&vd[row * cw..][..cw]);
12561+ }
12562+ (us, vs)
12563+ } else {
12564+ (Vec::new(), Vec::new())
12565+ };
12566+
12567+ // Key-frame `tx_select` is the parameter. `tx_select_inter` is forced
12568+ // false for a key frame, so `read_block_tx_size_rect` would skip the
12569+ // symbol; read it here against the parameter the intra path already uses.
12570+ // A skipped intrabc block predicts the whole footprint once and codes
12571+ // no residual (`decode_token_recon_block`'s inter branch). Lossless
12572+ // still forces TX_4X4 when the block is coded.
12573+ let leaves = if skip || (!lossless(fctx) && !tx_select) {
12574+ None
12575+ } else if lossless(fctx) {
12576+ let mut leaves = Vec::new();
12577+ for row in 0..bh / MI {
12578+ for col in 0..bw / MI {
12579+ leaves.push((row, col, 4usize, 4usize));
12580+ }
12581+ }
12582+ Some(leaves)
12583+ } else {
12584+ let ctx = txfm_partition_ctx_rect(
12585+ neighbours.above_txfm[lmi.1],
12586+ neighbours.left_txfm[lmi.0],
12587+ side,
12588+ bw,
12589+ bh,
12590+ );
12591+ let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1;
12592+ if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
12593+ let (rng, _) = dec.debug_state();
12594+ eprintln!(
12595+ "EC_ISTEP mi_row={} mi_col={} name=txfm_split_rect val={} ctx={ctx} rng={rng}",
12596+ lmi.0, lmi.1, u8::from(split)
12597+ );
12598+ }
12599+ if !split {
12600+ None
12601+ } else {
12602+ let (sub_w, sub_h) = sub_tx_size_map(bw, bh);
12603+ let mi_cols = 2 * y.true_width.div_ceil(8);
12604+ let mi_rows = 2 * y.true_height.div_ceil(8);
12605+ let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(lmi.1));
12606+ let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(lmi.0));
12607+ let mut out = Vec::new();
12608+ for row in (0..bh / MI).step_by(sub_h / MI) {
12609+ for col in (0..bw / MI).step_by(sub_w / MI) {
12610+ read_var_tx_size(
12611+ dec, cdfs, neighbours, lmi, side, (max_w_mi, max_h_mi),
12612+ (sub_w, sub_h), 1, row, col, &mut out,
12613+ );
12614+ }
12615+ }
12616+ Some(out)
12617+ }
12618+ };
12619+ let (tx_w, tx_h) = leaves.as_ref().and_then(|ls| ls.first()).map_or((bw, bh), |l| (l.2, l.3));
12620+
12621+ let mut luma_tx_type = TxType::DctDct;
12622+ let luma_grid;
12623+ let mut u_grid = Grid::Zero(cw * ch);
12624+ let mut v_grid = Grid::Zero(cw * ch);
12625+ let chroma_stamped_per_unit;
12626+
12627+ if skip {
12628+ push_mc_rect(
12629+ 0, px, py, side, bw, bh, Pred::Inline(&pred_y, side), &ZERO_RESIDUAL[..side * bh], fctx,
12630+ );
12631+ luma_grid = Grid::Zero(bw * bh);
12632+ if has_chroma {
12633+ push_mc_rect(
12634+ 1, cpx, cpy, cside, cw, ch, Pred::Inline(&pred_u, cside),
12635+ &ZERO_RESIDUAL[..cside * ch], fctx,
12636+ );
12637+ push_mc_rect(
12638+ 2, cpx, cpy, cside, cw, ch, Pred::Inline(&pred_v, cside),
12639+ &ZERO_RESIDUAL[..cside * ch], fctx,
12640+ );
12641+ }
12642+ chroma_stamped_per_unit = false;
12643+ } else if let Some(ls) = leaves.as_ref() {
12644+ if lossless(fctx) {
12645+ for &(row, col, _tw, _th) in ls {
12646+ let tu_mi = (lmi.0 + row, lmi.1 + col);
12647+ let (tu_px, tu_py) = (px + col * MI, py + row * MI);
12648+ let tu_pred = Pred::Inline(&pred_y, side).offset(row * MI * side + col * MI);
12649+ let (g, _) = read_inter_plane(
12650+ dec, cdfs,
12651+ if reduced_tx_set { TxbSet::Luma4Inter } else { TxbSet::Luma4InterSet1 },
12652+ &default_scan(4), 0, neighbours.around_mi(tu_mi, 4)[0], 0,
12653+ y, tu_px, tu_py, 4, base_q_idx, tu_pred, None,
12654+ Some(neighbours.luma_skip_ctx(tu_mi, 1)), fctx,
12655+ )?;
12656+ neighbours.record_mi_luma_rect(tu_mi, 4, 4, &g);
12657+ }
12658+ } else {
12659+ for (idx, &(row, col, tw, th)) in ls.iter().enumerate() {
12660+ let tu_mi = (lmi.0 + row, lmi.1 + col);
12661+ let (tu_px, tu_py) = (px + col * MI, py + row * MI);
12662+ let tu_pred = Pred::Inline(&pred_y, side).offset(row * MI * side + col * MI);
12663+ let (g, tt) = if tw == th {
12664+ read_inter_plane(
12665+ dec, cdfs, inter_txbset_for(tw, reduced_tx_set),
12666+ &default_scan(tw.min(32)), 0, neighbours.around_mi(tu_mi, tw)[0], 0,
12667+ y, tu_px, tu_py, tw, base_q_idx, tu_pred, None,
12668+ Some(neighbours.luma_skip_ctx(tu_mi, tw / MI)), fctx,
12669+ )?
12670+ } else {
12671+ read_inter_plane_rect(
12672+ dec, cdfs, rect_inter_luma_set(tw, th, fctx)?, (tw, th), side, 0,
12673+ neighbours.around_mi_rect(tu_mi, tw, th)[0], 0, y, tu_px, tu_py, tu_pred,
12674+ None, Some(neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI)), fctx,
12675+ )?
12676+ };
12677+ if idx == 0 {
12678+ luma_tx_type = tt;
12679+ }
12680+ neighbours.record_mi_luma_rect(tu_mi, tw, th, &g);
12681+ }
12682+ }
12683+ luma_grid = Grid::Zero(bw * bh);
12684+ chroma_stamped_per_unit = has_chroma && lossless(fctx);
12685+ if has_chroma && lossless(fctx) {
12686+ let (mut uo, mut vo) = (Vec::new(), Vec::new());
12687+ read_inter_chroma_lossless(
12688+ dec, cdfs, neighbours, u, v,
12689+ Pred::Inline(&pred_u, cside), Pred::Inline(&pred_v, cside),
12690+ pair_mi, (cpx, cpy), (0, 0), (cw, ch), (cw, ch), cside, 0, base_q_idx,
12691+ &mut uo, &mut vo, fctx,
12692+ )?;
12693+ u_grid = if uo.is_empty() { Grid::Zero(cw * ch) } else { Grid::Own(uo) };
12694+ v_grid = if vo.is_empty() { Grid::Zero(cw * ch) } else { Grid::Own(vo) };
12695+ } else if has_chroma {
12696+ let around = neighbours.around_mi_rect(pair_mi, pw, ph);
12697+ let (ug, _) = read_inter_plane_rect(
12698+ dec, cdfs, rect_inter_chroma_set(cw, ch)?, (cw, ch), cside, 1, around[1], 0,
12699+ u, cpx, cpy, Pred::Inline(&pred_u, cside), Some(luma_tx_type), None, fctx,
12700+ )?;
12701+ u_grid = ug;
12702+ let (vg, _) = read_inter_plane_rect(
12703+ dec, cdfs, rect_inter_chroma_set(cw, ch)?, (cw, ch), cside, 2, around[2], 0,
12704+ v, cpx, cpy, Pred::Inline(&pred_v, cside), Some(luma_tx_type), None, fctx,
12705+ )?;
12706+ v_grid = vg;
12707+ }
12708+ } else {
12709+ let around = neighbours.around_mi_rect(lmi, bw, bh);
12710+ let (g, tt) = read_inter_plane_rect(
12711+ dec, cdfs, rect_inter_luma_set(bw, bh, fctx)?, (bw, bh), side, 0, around[0], 0,
12712+ y, px, py, Pred::Inline(&pred_y, side), None, None, fctx,
12713+ )?;
12714+ luma_tx_type = tt;
12715+ luma_grid = g;
12716+ chroma_stamped_per_unit = false;
12717+ if has_chroma {
12718+ let around = neighbours.around_mi_rect(pair_mi, pw, ph);
12719+ let (ug, _) = read_inter_plane_rect(
12720+ dec, cdfs, rect_inter_chroma_set(cw, ch)?, (cw, ch), cside, 1, around[1], 0,
12721+ u, cpx, cpy, Pred::Inline(&pred_u, cside), Some(luma_tx_type), None, fctx,
12722+ )?;
12723+ u_grid = ug;
12724+ let (vg, _) = read_inter_plane_rect(
12725+ dec, cdfs, rect_inter_chroma_set(cw, ch)?, (cw, ch), cside, 2, around[2], 0,
12726+ v, cpx, cpy, Pred::Inline(&pred_v, cside), Some(luma_tx_type), None, fctx,
12727+ )?;
12728+ v_grid = vg;
12729+ }
12730+ }
12731+ drop(restored);
12732+
12733+ if leaves.is_none() {
12734+ neighbours.record_mi_luma_rect(lmi, bw, bh, &luma_grid);
12735+ }
12736+ neighbours.record_mode_mi(lmi.0, lmi.1, mi_w, mi_h, DC_PRED);
12737+ neighbours.fill_skip_grid_rect(lmi, mi_w, mi_h, skip);
12738+ neighbours.fill_lf_grid_rect(lmi, mi_w, mi_h, tx_w as u8, tx_h as u8, 0, fctx);
12739+ for cell in 0..mi_w {
12740+ if let Some(slot) = neighbours.above_side_mi.get_mut(lmi.1 + cell) {
12741+ *slot = bw as u8;
12742+ }
12743+ }
12744+ for cell in 0..mi_h {
12745+ if let Some(slot) = neighbours.left_side_mi.get_mut(lmi.0 + cell) {
12746+ *slot = bh as u8;
12747+ }
12748+ }
12749+ let mut last_uv = None;
12750+ if has_chroma {
12751+ hit!(RECT4_16_CHROMA_HITS);
12752+ neighbours.record_uv_mode_mi(pair_mi.0, pair_mi.1, pw / MI, ph / MI, DC_PRED);
12753+ if !chroma_stamped_per_unit {
12754+ let u_state = neighbour_state(&u_grid);
12755+ let v_state = neighbour_state(&v_grid);
12756+ let round_up_even = |n: usize| n.div_ceil(2) * 2;
12757+ let bound_h = round_up_even(neighbours.mi_rows);
12758+ let bound_w = round_up_even(neighbours.mi_cols);
12759+ for cell in 0..(ph / MI) {
12760+ if pair_mi.0 + cell < bound_h
12761+ && let Some(slot) = neighbours.left.get_mut(pair_mi.0 + cell)
12762+ {
12763+ slot[1] = u_state;
12764+ slot[2] = v_state;
12765+ }
12766+ }
12767+ for cell in 0..(pw / MI) {
12768+ if pair_mi.1 + cell < bound_w
12769+ && let Some(slot) = neighbours.above.get_mut(pair_mi.1 + cell)
12770+ {
12771+ slot[1] = u_state;
12772+ slot[2] = v_state;
12773+ }
12774+ }
12775+ }
12776+ last_uv = Some(DC_PRED);
12777+ }
12778+ if horz {
12779+ hit!(RECT4_16_HORZ_HITS);
12780+ } else {
12781+ hit!(RECT4_16_VERT_HITS);
12782+ }
12783+ record_strip_palette(neighbours, lmi, bw, bh, 0, [0u16; 8], 0, [0u16; 8]);
12784+ if leaves.is_none() {
12785+ // Skip and TX_MODE_LARGEST publish the block size (`set_txfm_ctxs`
12786+ // with `skip && is_inter`, or the unsplit unit). A split tree already
12787+ // published per leaf inside `read_var_tx_size`.
12788+ txfm_partition_update_rect(neighbours, lmi, (tx_w, tx_h), (bw, bh));
12789+ }
12790+ record_intrabc_mi_rect(
12791+ lmi.0, lmi.1, mi_w, mi_h, Some((dv_row, dv_col)), neighbours, fctx,
12792+ );
12793+ Ok((DC_PRED, last_uv, (tx_w, tx_h)))
12794+}
12795+
12796+/// Restores `reduced_tx_set_inter` when the intrabc pair reader returns,
12797+/// including through `?`.
12798+struct ReducedRestore<'a> {
12799+ fctx: &'a crate::decode::FrameCtx,
12800+ saved: bool,
12801+}
12802+impl Drop for ReducedRestore<'_> {
12803+ fn drop(&mut self) {
12804+ self.fctx.reduced_tx_set_inter.with(|c| c.set(self.saved));
12805+ }
12806+}
12807+fn scopeguard_reduced(fctx: &crate::decode::FrameCtx, saved: bool) -> ReducedRestore<'_> {
12808+ ReducedRestore { fctx, saved }
12809+}
12810+
1224212811 #[allow(clippy::too_many_arguments)]
1224312812 fn decode_rect4_16_strip(
1224412813 dec: &mut SymbolDecoder,
@@ -12292,6 +12861,7 @@ fn decode_rect4_16_strip(
1229212861 filter_intra,
1229312862 palette_y,
1229412863 palette_uv,
12864+ intrabc,
1229512865 ) = read_intra_mode_rect(
1229612866 dec,
1229712867 cdfs,
@@ -12309,6 +12879,12 @@ fn decode_rect4_16_strip(
1230912879 lmi.0,
1231012880 lmi.1, fctx,
1231112881 )?;
12882+ if let Some(dv) = intrabc {
12883+ return decode_rect4_16_intrabc(
12884+ dec, cdfs, neighbours, lmi, horz, has_chroma, skip, dv, y, u, v,
12885+ base_q_idx, tx_select, reduced_tx_set, fctx,
12886+ );
12887+ }
1231212888 if palette_y.is_some() || palette_uv.is_some() {
1231312889 hit!(RECT4_PALETTE_HITS);
1231412890 }
@@ -12573,7 +13149,92 @@ fn decode_rect4_16_strip(
1257313149 {
1257413150 hit!(RECT4_16_UV_PAIR_FILT_HITS);
1257513151 }
12576- let (u_levels, v_levels) = if skip {
13152+ // lane-av1-rect14: a lossless frame forces TX_4X4 on every plane
13153+ // (`av1_get_tx_size`, blockd.h:1381). The pair's chroma block is
13154+ // 8x4 (HORZ_4) or 4x8 (VERT_4) -- two TX_4X4s, plane-major
13155+ // (`decode_token_recon_block`), not one `ChromaRect8x4`. Reading
13156+ // the rect here consumed one symbol block too few and desynced
13157+ // the next strip's `skip` (measured: lossless sb128 320x240,
13158+ // mi(1,20) uv_mode matched, the following skip did not).
13159+ let lossless_pair = lossless(fctx);
13160+ let (u_levels, v_levels) = if lossless_pair {
13161+ hit!(RECT4_16_LOSSLESS_CHROMA_HITS);
13162+ if skip {
13163+ for plane in 1..3usize {
13164+ for rr in 0..ch / 4 {
13165+ for cc in 0..cw / 4 {
13166+ let (ox, oy) = (cc * 4, rr * 4);
13167+ let cu_reach = tu_reach(
13168+ pw, ph, ox * 2, oy * 2, 8, pair_reach, ppx, ppy,
13169+ y.width, y.height, fctx,
13170+ );
13171+ if let Some((ub, vb)) = &palette_uv_bufs {
13172+ let buf = if plane == 1 { ub } else { vb };
13173+ set_palette_pred(palette_window(buf, cw, ox, oy, 4, 4), fctx);
13174+ }
13175+ push_intra(
13176+ plane, cpx + ox, cpy + oy, 4, uv_predict_mode,
13177+ angle_delta_uv, cu_reach, &ZERO_RESIDUAL[..16], None, None,
13178+ smooth_neighbor_uv, fctx,
13179+ );
13180+ let cu_mi = (pair_mi.0 + oy / 2, pair_mi.1 + ox / 2);
13181+ neighbours.record_mi_chroma(
13182+ cu_mi, 8, 8, plane, &ZERO_RESIDUAL[..16],
13183+ );
13184+ }
13185+ }
13186+ }
13187+ (Grid::Zero(cw * ch), Grid::Zero(cw * ch))
13188+ } else {
13189+ let scan4 = default_scan(4);
13190+ // `get_txb_ctx`: offset 10 (our tables store it at +3)
13191+ // when the plane block is larger than the transform.
13192+ let offset = Some(3usize);
13193+ let mut uo = vec![0i32; cw * ch];
13194+ let mut vo = vec![0i32; cw * ch];
13195+ for plane in 1..3usize {
13196+ for rr in 0..ch / 4 {
13197+ for cc in 0..cw / 4 {
13198+ let (ox, oy) = (cc * 4, rr * 4);
13199+ if cpx + ox >= u.true_width || cpy + oy >= u.true_height {
13200+ continue;
13201+ }
13202+ let cu_mi = (pair_mi.0 + oy / 2, pair_mi.1 + ox / 2);
13203+ // One luma-mi cell: the chroma entropy arrays
13204+ // are subsampled, and our bands replicate that
13205+ // one entry over the unit's two cells
13206+ // (`read_intra_chroma_lossless`).
13207+ let cu_around = neighbours.around_mi(cu_mi, MI);
13208+ let cu_reach = tu_reach(
13209+ pw, ph, ox * 2, oy * 2, 8, pair_reach, ppx, ppy,
13210+ y.width, y.height, fctx,
13211+ );
13212+ if let Some((ub, vb)) = &palette_uv_bufs {
13213+ let buf = if plane == 1 { ub } else { vb };
13214+ set_palette_pred(palette_window(buf, cw, ox, oy, 4, 4), fctx);
13215+ }
13216+ let buf: &mut PlaneBuf<'static> =
13217+ if plane == 1 { &mut *u } else { &mut *v };
13218+ let cu_grid = read_plane(
13219+ dec, cdfs, TxbSet::Chroma4, &scan4, plane,
13220+ cu_around[plane], mode, uv_predict_mode, angle_delta_uv,
13221+ cu_reach, buf, cpx + ox, cpy + oy, 4, 4, base_q_idx,
13222+ None, None, offset, smooth_neighbor_uv, fctx,
13223+ )?;
13224+ neighbours.record_mi_chroma(cu_mi, 8, 8, plane, &cu_grid);
13225+ hit!(CHROMA_SPLIT_TX_HITS);
13226+ let dst = if plane == 1 { &mut uo } else { &mut vo };
13227+ for row in 0..4 {
13228+ let start = (oy + row) * cw + ox;
13229+ dst[start..start + 4]
13230+ .copy_from_slice(&cu_grid[row * 4..][..4]);
13231+ }
13232+ }
13233+ }
13234+ }
13235+ (Grid::Own(uo), Grid::Own(vo))
13236+ }
13237+ } else if skip {
1257713238 let zeros = Grid::Zero(cw * ch);
1257813239 // libaom `predict_and_reconstruct_intra_block` (decodeframe.c
1257913240 // ~1000) predicts EVERY plane and only guards the residual on
@@ -12666,6 +13327,9 @@ fn decode_rect4_16_strip(
1266613327 (u_levels, v_levels)
1266713328 };
1266813329 neighbours.record_uv_mode_mi(pair_mi.0, pair_mi.1, pw / MI, ph / MI, uv_predict_mode);
13330+ // A lossless pair already stamped each TX_4X4 (`record_mi_chroma`).
13331+ // The single-state rewrite below is the non-lossless TX_8X4/TX_4X8.
13332+ if !lossless_pair {
1266913333 // The chroma planes' coefficient context, over the PAIR's mi span
1267013334 // (`decode_leaf_rect8`'s own rule: a subsampled plane's bound is
1267113335 // the luma one rounded up to its 4x4 unit).
@@ -12690,6 +13354,7 @@ fn decode_rect4_16_strip(
1269013354 slot[2] = v_state;
1269113355 }
1269213356 }
13357+ }
1269313358 last_uv_mode = Some(uv_predict_mode);
1269413359 }
1269513360 if horz {
@@ -12758,7 +13423,7 @@ fn decode_block_rect64(
1275813423 let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c);
1275913424 let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(at);
1276013425 let palette_uv_cache = neighbours.palette_uv_cache(at);
12761- let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =
13426+ let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv, intrabc) =
1276213427 read_intra_mode_rect(
1276313428 dec,
1276413429 cdfs,
@@ -12783,6 +13448,12 @@ fn decode_block_rect64(
1278313448 r * (SUB / MI),
1278413449 c * (SUB / MI), fctx,
1278513450 )?;
13451+ if let Some((dv_row, dv_col)) = intrabc {
13452+ return decode_intrabc_owned_rect(
13453+ dec, cdfs, neighbours, (r * (SUB / MI), c * (SUB / MI)), (bw, bh), skip,
13454+ (dv_row, dv_col), y, u, v, base_q_idx, tx_select, reduced_tx_set, fctx,
13455+ );
13456+ }
1278613457 if (palette_y.is_some() || palette_uv.is_some()) && !skip {
1278713458 // lane-t900 r34: a non-skip palette block on a superblock-level strip
1278813459 // -- counted so its gate cannot go vacuous (this was a refusal until
@@ -15185,7 +15856,7 @@ fn decode_block_128rect(
1518515856 let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c);
1518615857 let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(at);
1518715858 let palette_uv_cache = neighbours.palette_uv_cache(at);
15188- let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =
15859+ let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv, intrabc) =
1518915860 read_intra_mode_rect(
1519015861 dec,
1519115862 cdfs,
@@ -15205,6 +15876,11 @@ fn decode_block_128rect(
1520515876 mi_r,
1520615877 mi_c, fctx,
1520715878 )?;
15879+ if intrabc.is_some() {
15880+ return Err(unsupported(
15881+ "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)",
15882+ ));
15883+ }
1520815884 if alpha.is_some() || filter_intra.is_some() || palette_y.is_some() || palette_uv.is_some() {
1520915885 return Err(unsupported(
1521015886 "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of \
@@ -22814,6 +23490,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
2281423490 // otherwise inherit it and read its `tx_depth` context off the inter
2281523491 // frame's stale `TXFM_CONTEXT` bands.
2281623492 fctx.tx_select_inter.with(|c| c.set(false));
23493+ // lane-av1-rect14: an intrabc block is `is_inter_block`, so its
23494+ // `tx_type` CDF is the INTER set selected by this frame's
23495+ // `reduced_tx_set`. Left at the cell default, the first coded
23496+ // 16x4 intrabc strip reads the wrong alphabet.
23497+ fctx.reduced_tx_set_inter.with(|c| c.set(reduced_tx_set));
2281723498 // Every block of an intra-only frame publishes its resolved transform into
2281823499 // the `TXFM_CONTEXT` bands exactly like an inter frame's does -- see
2281923500 // [`Neighbours::fill_lf_grid_rect`].
crates/ec-av1/src/refusal_inventory.rsmodified+5 -0
@@ -367,6 +367,11 @@ const PROVEN: &[(&str, &str)] = &[
367367 "a frame using quantisation matrices (using_qmatrix=1): dequantisation here is base_q_idx plus the plane DC/AC deltas only, so qm_y/qm_u/qm_v would be ignored and the frame would decode silently wrong pixels",
368368 "a_frame_using_quantisation_matrices_is_refused_by_name",
369369 ),
370+ // lane-av1-rect14: the 16x16- and 32x32-level strips are reconstructed
371+ // (`decode_intrabc_rect` / `decode_intrabc_pair_strip`). The string remains
372+ // only in `decode_block_128rect`. No sb128 screen recipe in this lane
373+ // reached that arm (256x192 cq50 sb128 decoded without entering it), so
374+ // the pairing still names the rect-strip gate, which no longer refuses.
370375 (
371376 "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)",
372377 "a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips",
crates/ec-av1/src/stream.rsmodified+126 -5
@@ -6295,9 +6295,11 @@ pub(crate) mod tests {
62956295 /// 8-bit decoded "OK" with all 49152 luma samples wrong).
62966296 ///
62976297 /// Arm 0 is that recipe at cq50 without palette: its rect strips really do
6298- /// use intrabc, which this decoder cannot reconstruct, so it must stop on
6299- /// the NAMED refusal instead of emitting a wrong frame -- and it must have
6300- /// read the symbol to get there.
6298+ /// use intrabc. lane-av1-rect14 reconstructs those strips (2:1 and the
6299+ /// 16x4/4x16 pair), so the arm must now decode pixel-exact -- and it must
6300+ /// still have read the symbol. The named refusal remains only for a
6301+ /// 128-superblock strip (`decode_block_128rect`), which this sb64 recipe
6302+ /// does not reach.
63016303 /// Arm 1 is the same recipe without palette and without tx-size search --
63026304 /// it decodes the whole frame, reading the symbol dozens of times.
63036305 /// Arm 2 is a screen-tools key frame whose header does NOT set
@@ -6328,7 +6330,7 @@ pub(crate) mod tests {
63286330 // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal,
63296331 // must_read_use_intrabc_on_a_rect_strip)
63306332 let arms: [(&str, &str, &[&str], bool, bool); 8] = [
6331- ("testsrc2-cq50-txs0", TS, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"], true, true),
6333+ ("testsrc2-cq50-txs0", TS, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"], false, true),
63326334 ("smptebars-cq40-txs0", SB, &["--cq-level=40", "--enable-palette=0", "--enable-tx-size-search=0"], false, false),
63336335 ("smptebars-cq45-txs0", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"], false, true),
63346336 ("smptebars-cq45-txs1", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=1"], false, false),
@@ -6518,7 +6520,10 @@ pub(crate) mod tests {
65186520 blocks_total > 0 && fired_arms > 0,
65196521 "{NAME}: gate is vacuous -- no compared arm actually decoded an intrabc block"
65206522 );
6521- assert_eq!(refused, 1, "{NAME}: expected exactly one named intrabc refusal");
6523+ assert_eq!(
6524+ refused, 0,
6525+ "{NAME}: a rect-strip intrabc block refused -- reconstruction regressed"
6526+ );
65226527 assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact");
65236528 assert_eq!(
65246529 out_of_scope_mismatch, 0,
@@ -6526,6 +6531,122 @@ pub(crate) mod tests {
65266531 );
65276532 }
65286533
6534+ /// lane-av1-rect14: the 16x4/4x16 intrabc pair. libaom codes the pair's
6535+ /// chroma on the odd-mi strip only (`is_chroma_reference`,
6536+ /// av1_common_int.h:1454). The witness is the report recipe: testsrc2
6537+ /// 640x480 cq60 palette, txs off, which places a 16x4 intrabc strip at
6538+ /// mi(76,108). Pre-fix this refused by name. VERT_4 was not produced by
6539+ /// any fully-decoded recipe tried here (the allintra stream codes four
6540+ /// `PARTITION_VERT_4` at bsize 6 and then stops on the unrelated var-tx
6541+ /// mixed-leaf refusal); the VERT arm is the same body with the axes
6542+ /// swapped.
6543+ #[test]
6544+ fn a_16x4_intrabc_pair_strip_decodes_pixel_exact() {
6545+ const NAME: &str = "a_16x4_intrabc_pair_strip_decodes_pixel_exact";
6546+ if !have_ffmpeg() || !have_aomenc() {
6547+ eprintln!("SKIP {NAME}: ffmpeg/aomenc missing");
6548+ return;
6549+ }
6550+ let (width, height) = (640usize, 480usize);
6551+ let y4m = Command::new("ffmpeg")
6552+ .args([
6553+ "-v", "error", "-f", "lavfi", "-i", "testsrc2=s=640x480:r=25", "-frames:v", "1",
6554+ "-pix_fmt", "yuv420p", "-strict", "-1", "-f", "yuv4mpegpipe", "-",
6555+ ])
6556+ .output()
6557+ .expect("ffmpeg")
6558+ .stdout;
6559+ let mut child = Command::new(aomenc_path())
6560+ .args([
6561+ "--codec=av1", "--bit-depth=8", "--input-bit-depth=8", "--passes=1",
6562+ "--end-usage=q", "--cpu-used=0", "--lag-in-frames=0", "--kf-max-dist=1",
6563+ "--limit=1", "--threads=1", "--tile-columns=0",
6564+ "--enable-rect-partitions=1", "--enable-1to4-partitions=1",
6565+ "--min-partition-size=4", "--max-partition-size=64", "--sb-size=64",
6566+ "--tune-content=screen", "--enable-intrabc=1", "--cq-level=60",
6567+ "--enable-palette=1", "--enable-tx-size-search=0", "--obu", "-o", "-", "-",
6568+ ])
6569+ .stdin(Stdio::piped())
6570+ .stdout(Stdio::piped())
6571+ .stderr(Stdio::piped())
6572+ .spawn()
6573+ .expect("aomenc");
6574+ child.stdin.take().unwrap().write_all(&y4m).ok();
6575+ let out = child.wait_with_output().expect("aomenc wait");
6576+ assert!(out.status.success(), "{NAME}: aomenc failed");
6577+ crate::decode::reset_rect4_16_pair_hits();
6578+ let frames = decode_stream(&out.stdout).unwrap_or_else(|e| panic!("{NAME}: {e}"));
6579+ assert!(
6580+ crate::decode::rect4_16_intrabc_hits() > 0,
6581+ "{NAME}: no 16x4/4x16 intrabc strip -- the pair body was not reached"
6582+ );
6583+ let refs = ffmpeg_decode_sequence(&out.stdout, width, height, frames.len());
6584+ assert_eq!(frames.len(), 1);
6585+ assert_eq!(frames[0].y, refs[0].y, "{NAME}: luma");
6586+ assert_eq!(frames[0].u, refs[0].u, "{NAME}: u");
6587+ assert_eq!(frames[0].v, refs[0].v, "{NAME}: v");
6588+ }
6589+
6590+ /// lane-av1-rect14: lossless 16x4/4x16 chroma is two TX_4X4s, not one
6591+ /// TX_8X4. The measured site is luma col 108 of a 320x240 sb128 lossless
6592+ /// key frame (lanes/av1lossless128.report.md §6). Rows 0-127 of that
6593+ /// frame -- the first superblock row, which contains the site -- must
6594+ /// match ffmpeg. A later mismatch is the pre-existing 64x64 square
6595+ /// lossless residue (base fails at byte 108; this lane's first remaining
6596+ /// mismatch is row 128). The gate fails if that residue moves back into
6597+ /// the repaired region.
6598+ #[test]
6599+ fn a_lossless_16x4_chroma_pair_repairs_the_measured_site() {
6600+ const NAME: &str = "a_lossless_16x4_chroma_pair_repairs_the_measured_site";
6601+ if !have_ffmpeg() || !have_aomenc() {
6602+ eprintln!("SKIP {NAME}: ffmpeg/aomenc missing");
6603+ return;
6604+ }
6605+ let (width, height) = (320usize, 240usize);
6606+ let y4m = Command::new("ffmpeg")
6607+ .args([
6608+ "-v", "error", "-f", "lavfi", "-i", "testsrc2=s=320x240:r=25", "-frames:v", "1",
6609+ "-pix_fmt", "yuv420p", "-strict", "-1", "-f", "yuv4mpegpipe", "-",
6610+ ])
6611+ .output()
6612+ .expect("ffmpeg")
6613+ .stdout;
6614+ let mut child = Command::new(aomenc_path())
6615+ .args([
6616+ "--codec=av1", "--cpu-used=0", "--lossless=1", "--sb-size=128",
6617+ "--lag-in-frames=0", "--kf-max-dist=1", "--limit=1", "--threads=1",
6618+ "--passes=1", "--enable-1to4-partitions=1", "--min-partition-size=4",
6619+ "--enable-rect-partitions=1", "--obu", "-o", "-", "-",
6620+ ])
6621+ .stdin(Stdio::piped())
6622+ .stdout(Stdio::piped())
6623+ .stderr(Stdio::piped())
6624+ .spawn()
6625+ .expect("aomenc");
6626+ child.stdin.take().unwrap().write_all(&y4m).ok();
6627+ let out = child.wait_with_output().expect("aomenc wait");
6628+ assert!(out.status.success(), "{NAME}: aomenc failed");
6629+ crate::decode::reset_rect4_16_pair_hits();
6630+ let frames = decode_stream(&out.stdout).unwrap_or_else(|e| panic!("{NAME}: {e}"));
6631+ assert!(
6632+ crate::decode::rect4_16_lossless_chroma_hits() > 0,
6633+ "{NAME}: no lossless 16x4/4x16 chroma pair -- the walk was not reached"
6634+ );
6635+ let refs = ffmpeg_decode_sequence(&out.stdout, width, height, frames.len());
6636+ let repaired = 128 * width;
6637+ assert_eq!(
6638+ &frames[0].y[..repaired],
6639+ &refs[0].y[..repaired],
6640+ "{NAME}: luma rows 0-127 (the measured col-108 site) diverged"
6641+ );
6642+ let chroma_rows = 64 * (width / 2);
6643+ assert_eq!(&frames[0].u[..chroma_rows], &refs[0].u[..chroma_rows], "{NAME}: u");
6644+ assert_eq!(&frames[0].v[..chroma_rows], &refs[0].v[..chroma_rows], "{NAME}: v");
6645+ // The col-108 byte specifically, so a shift of the old site still fails
6646+ // even if some other prefix sample happens to match.
6647+ assert_eq!(frames[0].y[108], refs[0].y[108], "{NAME}: measured byte 108");
6648+ }
6649+
65296650 /// lane-t900 r31: builds one `--tune-content=screen --enable-intrabc=1`
65306651 /// key frame, 256x192 8-bit, from a deterministic lavfi source. `tiled`
65316652 /// renders a 2x2 tiling of a 128x96 pattern -- exact spatial repetition,
lanes/av1rect14.report.mdadded+150 -0
@@ -0,0 +1,150 @@
1+# lane-av1-rect14 — 1:4 pair intrabc and the lossless 16x4 chroma walk
2+
3+Base: `main` **7f8d6cf6** (checkout HEAD was 09c7ff39; this lane is pinned to the
4+charter base). Worktree `/home/user/Documents/Code/Rust/edith_codecs-av1r14`,
5+branch `lane-av1-rect14`. `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1r14`,
6+`TMPDIR=$HOME/tmp-av1r14`. Nothing pushed.
7+
8+Sibling `lane-av1-intrabc` (worktree `edith_codecs-av1ibc`) is in review and
9+was not touched. Its `decode_intrabc_rect` is the 2:1 helper. This lane's 1:4
10+body is a different function (`decode_rect4_16_intrabc`) so that merge is
11+additive. The 2:1 call sites this lane also lifted (`decode_intrabc_owned_rect`
12+in `decode_block_rect`, `decode_block_rect4`, `decode_leaf_rect`) collide with
13+that lane's wiring: keep theirs at those three sites if both land.
14+
15+## 1. Headline
16+
17+Two lifts.
18+
19+1. An intrabc 16x4/4x16 strip is reconstructed as a pair. Chroma is coded only
20+ by the odd-mi member (`is_chroma_reference`, `av1_common_int.h:1454`): the
21+ bottom strip of `HORZ_4`, the right strip of `VERT_4`. The chroma plane
22+ block is `BLOCK_8X4` / `BLOCK_4X8` at the pair origin, not `bw/2 x bh/2`
23+ of the strip itself. The report recipe is byte-exact vs ffmpeg. allintra
24+ advances past the named refusal.
25+2. A lossless 16x4/4x16 chroma pair is two `TX_4X4`s per plane, plane-major,
26+ not one `ChromaRect8x4`. The measured site (luma col 108 of the 320x240
27+ sb128 lossless key frame) matches ffmpeg. Rows 0-127 of that frame match.
28+ The rest of the frame does not: a pre-existing 64x64 square lossless
29+ desync, not this class.
30+
31+## 2. Byte-exactness
32+
33+Probe: `$HOME/.cache/cargo-target-av1r14/release/examples/decode_probe`.
34+Oracle: `~/.cache/aom-oracle/build/{aomenc,aomdec}`. ffmpeg raw yuv420p.
35+
36+| stream | recipe | base | this lane |
37+|---|---|---|---|
38+| ibc640 | testsrc2 640x480, cq60, palette=1, txs=0, rect+1to4, min4, sb64, screen, intrabc | REFUSED the named 1:4 strip string | **EXACT** 460800 bytes. `rect4_16_pair: intrabc=1`. aomdec `EC_PART_VAL mi_row=76 mi_col=108 bsize=6 value=8` |
39+| cq50 arm | testsrc2 256x192 cq50 palette=0 txs=0 min8 max32 sb64 screen intrabc (the old refusal arm) | refused by name | **EXACT** 73728 bytes. `rect_intrabc_reads=80` |
40+| allintra | the lane-av1-intrabc allintra stop | stopped on the 1:4/rect strip refusal | advances. `rect4_16_pair: intrabc=22`. New stop: `an intrabc block whose var-tx tree resolved to mixed leaf transform sizes` |
41+| loss320 | testsrc2 320x240, `--lossless=1 --sb-size=128 --enable-1to4-partitions=1 --min-partition-size=4`, 1 frame | first luma diff **byte 108** (col 108) — the §6 measurement | luma rows 0-127 **EXACT**. First remaining luma diff byte 41120 = row 128 col 160. `rect4_16_pair: lossless_chroma=6` |
42+| lnone | same source, 1:4 and rect off | first ffmpeg diff byte 41120 (pre-existing) | same first byte 41120 on both probes. lane vs base diverges at byte 41152, inside the region both probes already misdecode (pre-existing partition-reader misclassification: aomdec censuses zero `value=8/9` blocks on this stream while both probes read fn=rect blocks). Recipe under-specified: encode with and without `--min-partition-size=4` gave identical 5678-byte streams |
43+
44+Repro, ibc640:
45+
46+```
47+ffmpeg -y -v error -f lavfi -i 'testsrc2=s=640x480:r=25' -frames:v 1 \
48+ -pix_fmt yuv420p -strict -1 -f yuv4mpegpipe /tmp/ibc640.y4m
49+~/.cache/aom-oracle/build/aomenc --codec=av1 --bit-depth=8 --input-bit-depth=8 \
50+ --passes=1 --end-usage=q --cpu-used=0 --lag-in-frames=0 --kf-max-dist=1 \
51+ --limit=1 --threads=1 --tile-columns=0 --enable-rect-partitions=1 \
52+ --enable-1to4-partitions=1 --min-partition-size=4 --max-partition-size=64 \
53+ --sb-size=64 --tune-content=screen --enable-intrabc=1 --cq-level=60 \
54+ --enable-palette=1 --enable-tx-size-search=0 --obu -o /tmp/ibc640.obu /tmp/ibc640.y4m
55+$PROBE /tmp/ibc640.obu /tmp/ibc640.raw
56+ffmpeg -v error -i /tmp/ibc640.obu -pix_fmt yuv420p -f rawvideo /tmp/ibc640.ff.raw
57+cmp /tmp/ibc640.raw /tmp/ibc640.ff.raw
58+```
59+
60+## 3. What changed
61+
62+* `decode_rect4_16_intrabc`: pair reconstruction. Luma is the strip footprint
63+ from this strip's DV. Chroma, only when `has_chroma`, is the pair block at
64+ the pair origin. Skip publishes a square-stride zero residual (`side * bh`,
65+ not `bw * bh` — a VERT strip's stride is 16 and `bw * bh` underruns
66+ `reconstruct_mc_rect` at index 136).
67+* `decode_intrabc_owned_rect`: 2:1 rect intrabc (16x8 and up, including the
68+ 32x8/8x32 arms of `decode_block_rect4` and the 16x8/8x16 leaf). Same
69+ square-stride skip fix. This is the piece that collides with
70+ `lane-av1-intrabc`'s `decode_intrabc_rect`.
71+* `decode_rect4_16_strip` chroma arm: `lossless(fctx)` walks two `TX_4X4`s
72+ per plane (`TxbSet::Chroma4`, `SCAN_4X4`), plane-major, and stamps each
73+ unit with `record_mi_chroma`. The non-lossless arm is still one
74+ `ChromaRect8x4`.
75+* Key-frame `reduced_tx_set` is published on `fctx.reduced_tx_set_inter` so
76+ the inter coefficient reader an intrabc block calls sees the frame's flag.
77+ Restored on drop (`ReducedTxRestore`).
78+* `decode_block_128rect`'s intrabc arms stay on the named refusal. A 256x192
79+ sb128 cq50 screen encode decoded without entering them.
80+* Counters: `rect4_16_intrabc_hits`, `rect4_16_lossless_chroma_hits`,
81+ `reset_rect4_16_pair_hits`. Printed by `decode_probe`.
82+
83+## 4. Class sweep
84+
85+The single-read assumption lived only in `decode_rect4_16_strip`. The other
86+1:4 readers already take the lossless per-TU walk:
87+
88+* `decode_block_rect4` (`if depth != 0 || lossless(fctx)`). loss320 codes a
89+ 32x32 `VERT_4` at mi(0, 24), inside the now-exact rows 0-127.
90+* `decode_block_128rect` already tiles a lossless 128-axis block as `TX_4X4`.
91+ Its 1:4 intrabc arms still refuse by name; no reaching stream in this lane.
92+
93+`lnone` (aomdec census: zero `value=8/9`) still enters `decode_rect4_16_strip`
94+six times. Base and lane read the same symbols until mi(26, 20); the split is
95+the coefficient walk inside a block both sides already classify as a 16x4.
96+That classification disagrees with aomdec and is pre-existing (partition
97+reader untouched). First ffmpeg mismatch stays at byte 41120 on both probes.
98+
99+## 5. Gates
100+
101+`cargo test -p ec-av1 --offline --lib -- --test-threads=1`, dev profile:
102+
103+```
104+a_16x4_intrabc_pair_strip_decodes_pixel_exact ... ok
105+a_lossless_16x4_chroma_pair_repairs_the_measured_site ... ok
106+a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips ... ok
107+every_proven_refusal_names_a_test_that_exists ... ok
108+the_decode_path_refuses_exactly_the_listed_cases ... ok
109+```
110+
111+The old rect-strip gate's cq50 arm now expects a decode and compares pixels.
112+`refused == 0`. The inventory string remains, only in `decode_block_128rect`.
113+`cargo build -p ec-av1 --offline`: 0 warnings.
114+
115+## 6. Deferred
116+
117+* **128-level rect intrabc.** `deferred(a reaching sb128 screen stream that codes a 128-level HORZ/VERT/1:4 intrabc strip)`. Named refusal kept. Does not need `lane-av1-intrabc`'s `decode_intrabc_rect`: that helper's chroma is `bw/2 x bh/2` of the strip, wrong size and origin for a 1:4 pair, and it does not cover a 64x16/16x64 strip inside a 128 SB.
118+* **Full loss320 frame byte-exact.** `deferred(square 64x64 lossless desync, pre-existing)`. The first wrong pixel (row 128 col 160) sits in a 64x64 `NONE` at mi(32, 32) (`bsize=12 value=0`), not a 1:4 strip. Shared `EC_ISTEP` matches at mi(32, 0) including rng; the first real rng split is mi(48, 16) `skip` (37192 vs 60308). Base already fails this stream at byte 108. The gate pins the repaired region.
119+* **VERT_4 pixel witness.** `deferred(a txs0 recipe that codes PARTITION_VERT_4 intrabc and completes)`. ibc640 and smptebars 640x480 cq45 coded zero `bsize=6 value=9`. allintra codes four `VERT_4` and then refuses on the unrelated var-tx mixed-leaf string, after `rect4_16_pair: intrabc=22`. The VERT arm is the same function with the axes swapped.
120+
121+## 7. Merge note
122+
123+Keep `decode_rect4_16_intrabc` and the lossless pair walk. At the three 2:1
124+call sites, prefer `lane-av1-intrabc`'s `decode_intrabc_rect` if that branch
125+lands first; drop `decode_intrabc_owned_rect` in that case. Do not point the
126+1:4 pair at `decode_intrabc_rect`.
127+
128+Two riders on "prefer theirs":
129+
130+1. The sibling's `decode_intrabc_rect` at `bfb06b9b` passes
131+ `ZERO_RESIDUAL[..bw*bh]` at stride `side` in its skip arm while
132+ `reconstruct_mc_rect` reads `side*bh` rows — "prefer theirs" is only safe
133+ after the sibling's skip-stride fix lands.
134+2. This lane wires a FOURTH `owned_rect` call site (`decode_block_rect64`,
135+ the 64-level 4:1 strips) the sibling does not cover, so dropping
136+ `decode_intrabc_owned_rect` wholesale requires rewiring that site.
137+
138+## 8. Suite
139+
140+Run hub-supervised on the committed tree (`4b73d07f`, `git status` clean)
141+after the builder's model seat died post-commit:
142+
143+```
144+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1r14 TMPDIR=$HOME/tmp-av1r14 \
145+ cargo test -p ec-av1 --release --lib -- --test-threads=1
146+
147+test result: ok. 603 passed; 0 failed; 60 ignored; 0 measured; 0 filtered out; finished in 1505.38s
148+```
149+
150+No aomenc pipe deadlock fired this run.