forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-av1444rect'

Browse files at this commit

0d240a7af9b15d055e7406cd3531f813e92c8c47Ahmet Kaan GümüşParent: 048a859a654932
crates/ec-av1/fixtures/420_intrabc_rect4_witness.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_intrabc_rect4_witness.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_lossy_rect4_inter_witness.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+124 -12
@@ -5504,6 +5504,61 @@ pub(crate) fn intra_rect4_strip_in_inter_hits(shape: usize) -> usize {
5504 INTRA_RECT4_IN_INTER_HITS.with(|c| c.get()[shape])5504 INTRA_RECT4_IN_INTER_HITS.with(|c| c.get()[shape])
5505 }5505 }
5506 5506
5507+// lane-av1444rect: how many 1:4 inter strips at `ss_x == 0` read their chroma
5508+// coefficient context over the STRIP'S OWN extent instead of the 4:2:0 pair's
5509+// (see [`decode_inter_block`]'s `around_c`). `is_chroma_reference`
5510+// (av1_common_int.h:1454) is unconditionally true at ss (0,0), so no pair
5511+// exists there; the counter keeps a 4:4:4 1:4-strip gate from passing
5512+// vacuously (a 4:2:0 stream of the same content leaves it at 0). It proves
5513+// REACH only, never that the fix bites -- that is the gate's byte compare and
5514+// its mutation, not this count (skill://ec-av1-pipeline-gate-counters).
5515+thread_local! {
5516+ static RECT4_INTER_OWN_CHROMA444_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
5517+}
5518+
5519+/// Current value of [`RECT4_INTER_OWN_CHROMA444_HITS`].
5520+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
5521+pub(crate) fn rect4_inter_own_chroma444_hits() -> usize {
5522+ RECT4_INTER_OWN_CHROMA444_HITS.with(std::cell::Cell::get)
5523+}
5524+
5525+/// Resets [`RECT4_INTER_OWN_CHROMA444_HITS`] before a decode.
5526+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
5527+pub(crate) fn reset_rect4_inter_own_chroma444_hits() {
5528+ RECT4_INTER_OWN_CHROMA444_HITS.with(|c| c.set(0));
5529+}
5530+
5531+// lane-av1444rect r2: how many intra-BC 1:4 strips at `ss (0,0)` took the
5532+// own-chroma arm of [`decode_rect4_16_intrabc`]'s `own444`. A 4:2:0 / 4:2:2
5533+// stream of the same recipe leaves it at 0, which is what makes it the
5534+// 4:4:4-only route.
5535+//
5536+// WHAT THIS COUNTER IS NOT: it is NOT evidence that the fix bites, and it
5537+// never was. A route counter fires identically before and after a change that
5538+// changes nothing downstream, so a non-zero count proves REACH and nothing
5539+// more. On this lane it is also armed deliberately OUTSIDE the `own444`
5540+// expression, so that the mutation (`own444 = false`) still increments it and
5541+// the red comes from the pixel/entropy arm instead. The evidence that the ss
5542+// gate bites is the measured fork move -- first entropy fork read 11750 ->
5543+// 12465, luma first wrong sample 164416 -> 205264, 455240 -> 390380 total --
5544+// not this count. See skill://ec-av1-pipeline-gate-counters: a counter needs
5545+// a DIFFERS-style assertion to carry a claim.
5546+thread_local! {
5547+ static INTRABC_RECT4_OWN_CHROMA444_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
5548+}
5549+
5550+/// Current value of [`INTRABC_RECT4_OWN_CHROMA444_HITS`].
5551+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
5552+pub(crate) fn intrabc_rect4_own_chroma444_hits() -> usize {
5553+ INTRABC_RECT4_OWN_CHROMA444_HITS.with(std::cell::Cell::get)
5554+}
5555+
5556+/// Resets [`INTRABC_RECT4_OWN_CHROMA444_HITS`] before a decode.
5557+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
5558+pub(crate) fn reset_intrabc_rect4_own_chroma444_hits() {
5559+ INTRABC_RECT4_OWN_CHROMA444_HITS.with(|c| c.set(0));
5560+}
5561+
5507 // lane-intra14 r1: set while an INTRA block of an INTER frame is decoded5562 // lane-intra14 r1: set while an INTRA block of an INTER frame is decoded
5508 // through one of the key-frame rect readers ([`decode_block_rect4`],5563 // through one of the key-frame rect readers ([`decode_block_rect4`],
5509 // [`decode_block_rect64`]). `Some((size_group, skip))` tells5564 // [`decode_block_rect64`]). `Some((size_group, skip))` tells
@@ -16548,10 +16603,42 @@ fn decode_rect4_16_intrabc(
16548 pred_y[row * side..][..bw].copy_from_slice(&pred_y_dense[row * bw..][..bw]);16603 pred_y[row * side..][..bw].copy_from_slice(&pred_y_dense[row * bw..][..bw]);
16549 }16604 }
16550 16605
16551- let (pw, ph) = if horz { (16usize, 8usize) } else { (8, 16) };16606+ // lane-av1444rect r2 (the class this lane named, second instance): the
16552- let (cw, ch) = (pw / 2, ph / 2);16607+ // pair geometry below is the 4:2:0 one and was applied at every `ss`. At
16608+ // ss (0,0) `is_chroma_reference` (av1_common_int.h:1454) is
16609+ // unconditionally true -- the strip is its own chroma reference, there is
16610+ // no pair, and its chroma plane block IS the strip: 16x4 (HORZ_4) / 4x16
16611+ // (VERT_4) at the strip's own origin, with its coefficient context read
16612+ // over that same extent. The old constants instead predicted and coded an
16613+ // 8x4 block at `(lmi - 1) * MI / 2`, a quarter of the position.
16614+ //
16615+ // MEASURED on a `testsrc2` 640x480 `--tune-content=screen --enable-intrabc=1
16616+ // --enable-palette=1 --cq-level=60 --min-partition-size=4
16617+ // --max-partition-size=64 --sb-size=64 --profile=1` stream (1016 B, 17
16618+ // intrabc 16x4 strips at ss (0,0)): 455240 of 921600 samples wrong, the
16619+ // entropy fork at read 11750 (`decodetxb.c:158`, the chroma `txb_skip`).
16620+ // `--enable-intrabc=0` at the same settings is byte-exact, and the 4:2:0
16621+ // twin of the same recipe is byte-exact.
16622+ //
16623+ // 4:2:0 and 4:2:2 keep every constant below verbatim -- the arm is gated on
16624+ // the full ss (0,0), not on a per-axis shift, so `pw / 2` and the literal
16625+ // halving are untouched for both.
16626+ let own444 = ss_x(fctx) == 0 && ss_y(fctx) == 0;
16627+ if ss_x(fctx) == 0 && ss_y(fctx) == 0 && has_chroma {
16628+ hit!(INTRABC_RECT4_OWN_CHROMA444_HITS);
16629+ }
16630+ let (pw, ph) = if own444 {
16631+ (bw, bh)
16632+ } else if horz {
16633+ (16usize, 8usize)
16634+ } else {
16635+ (8, 16)
16636+ };
16637+ let (cw, ch) = if own444 { (bw, bh) } else { (pw / 2, ph / 2) };
16553 let pair_mi = if has_chroma {16638 let pair_mi = if has_chroma {
16554- if horz {16639+ if own444 {
16640+ lmi
16641+ } else if horz {
16555 (lmi.0 - 1, lmi.1)16642 (lmi.0 - 1, lmi.1)
16556 } else {16643 } else {
16557 (lmi.0, lmi.1 - 1)16644 (lmi.0, lmi.1 - 1)
@@ -16560,7 +16647,11 @@ fn decode_rect4_16_intrabc(
16560 lmi16647 lmi
16561 };16648 };
16562 let (cpx, cpy) = if has_chroma {16649 let (cpx, cpy) = if has_chroma {
16563- (pair_mi.1 * MI / 2, pair_mi.0 * MI / 2)16650+ if own444 {
16651+ (px, py)
16652+ } else {
16653+ (pair_mi.1 * MI / 2, pair_mi.0 * MI / 2)
16654+ }
16564 } else {16655 } else {
16565 (0, 0)16656 (0, 0)
16566 };16657 };
@@ -40939,17 +41030,38 @@ fn decode_inter_block(
40939 // ([`Neighbours::around_mi_422_chroma`]) -- and the same41030 // ([`Neighbours::around_mi_422_chroma`]) -- and the same
40940 // reroute catches 4:2:2 VERT: its (8, 16) pair span's41031 // reroute catches 4:2:2 VERT: its (8, 16) pair span's
40941 // above side covers one chroma column per two luma mi41032 // above side covers one chroma column per two luma mi
40942- // columns, the identical double-count. The plain per-mi41033+ // columns, the identical double-count.
40943- // gather survives only where the ss gate excludes it:41034+ //
40944- // the 4:2:0 pair merge (16, 8) and every 4:4:4 shape.41035+ // lane-av1444rect (H1, MEASURED): the (16, 8) / (8, 16) pair
41036+ // extent was reached at ss (0,0) too, where no pair exists.
41037+ // At 4:4:4 `is_chroma_reference` (av1_common_int.h:1454)
41038+ // reduces BOTH parity clauses to `!subsampling_y` /
41039+ // `!subsampling_x`, so every block is its own chroma
41040+ // reference: a HORZ_4 16x4 strip codes its OWN 16x4 chroma
41041+ // and the setter above already gave it `pair_mi == at_mi`.
41042+ // Its coefficient context is therefore the strip's own,
41043+ // which is exactly the `around` gathered one screen above
41044+ // as `around_mi_rect(at_mi, write_w, write_h)`. The pair
41045+ // gather read one EXTRA luma mi row of LEFT chroma context
41046+ // (`ph = 8` covers left[8] and left[9], a 4-px strip only
41047+ // left[8]), so the U unit's `get_txb_ctx` saw a neighbour
41048+ // libaom does not have and forked the arithmetic coder: the
41049+ // 6441-byte 4:4:4 lossy cq-20 stream, frame 1, mi(8,16)
41050+ // read our `txb_skip_ctx` 1 (0 above + 1 left) where the
41051+ // oracle read offset-7 row 7 (ctx_base 0).
40945 let around_c = match strip_chroma {41052 let around_c = match strip_chroma {
41053+ // lane-av1444rect: the arm `is_chroma_reference` makes the
41054+ // ONLY correct choice at ss_x 0 -- no pair exists, the
41055+ // extent is the strip's own. Counted so a 4:4:4 1:4-strip
41056+ // gate can prove it exercised this route (a 4:2:0 stream
41057+ // of the same content reads 0).
41058+ Some(_) if ss_x(fctx) == 0 => {
41059+ hit!(RECT4_INTER_OWN_CHROMA444_HITS);
41060+ around
41061+ }
40946 Some(s) if s.has_chroma => {41062 Some(s) if s.has_chroma => {
40947 let (pw, ph) = if s.horz {41063 let (pw, ph) = if s.horz {
40948- if ss_x(fctx) == 1 && ss_y(fctx) == 0 {41064+ if ss_y(fctx) == 0 { (16, 4) } else { (16, 8) }
40949- (16, 4)
40950- } else {
40951- (16, 8)
40952- }
40953 } else {41065 } else {
40954 (8, 16)41066 (8, 16)
40955 };41067 };
crates/ec-av1/src/stream.rsmodified+292 -0
@@ -6927,6 +6927,298 @@ pub(crate) mod tests {
6927 }6927 }
6928 }6928 }
6929 6929
6930+ /// lane-av1444rect (H1): the 4:4:4 LOSSY cell with a 1:4 (HORZ_4 /
6931+ /// VERT_4) partition -- the largest correctness gap the chroma-format
6932+ /// sweep left, and the first 4:4:4 lossy exactness gate in the crate.
6933+ ///
6934+ /// **The defect.** `decode_inter_block`'s `around_c` gathered a 1:4
6935+ /// strip's chroma coefficient context at the 4:2:0 PAIR extent
6936+ /// (`(16, 8)` HORZ / `(8, 16)` VERT) with no `ss` gate, so at ss (0,0)
6937+ /// it read one extra luma mi row of LEFT chroma context. At 4:4:4
6938+ /// `is_chroma_reference` (av1_common_int.h:1454) reduces both parity
6939+ /// clauses to `!subsampling_y` / `!subsampling_x`, so every block is its
6940+ /// own chroma reference and no pair exists: the strip codes its own
6941+ /// 16x4 chroma over its own context. Our U unit's `get_txb_ctx` then saw
6942+ /// a neighbour libaom does not have, and the arithmetic coder forked.
6943+ ///
6944+ /// **The recipe** (sha256
6945+ /// `77f727e76d81fe48cd03709f799131677c04869b163e18d78e96bc742ec69153`,
6946+ /// 6441 bytes, 2 frames, `testsrc2 128x96 rate=25` yuv444p):
6947+ /// ```text
6948+ /// ffmpeg -f lavfi -i "testsrc2=size=128x96:rate=25" -frames:v 2 \
6949+ /// -pix_fmt yuv444p -f yuv4mpegpipe - | \
6950+ /// aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q --cq-level=20 \
6951+ /// --cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0 \
6952+ /// --kf-max-dist=100 --limit=2 - out.obu
6953+ /// ```
6954+ /// (`rate=25` is load-bearing: `testsrc2`'s pattern is time-parameterised,
6955+ /// so `rate=1` produces a different, already-exact stream.)
6956+ ///
6957+ /// Red before the fix: frame 1, 8884 of 36864 samples wrong, first at
6958+ /// Y(91,32); the first wrong symbol was read 26263 of the frame, both
6959+ /// sides at mi (8,16) -- ours a luma-shaped `txb_skip` row (our
6960+ /// re-indexed chroma ctx 1), the oracle `decodetxb.c:158` on the U plane
6961+ /// with `txb_skip_ctx = 7`.
6962+ ///
6963+ /// Non-vacuity, three ways: the pinned stream must really be ss (0,0)
6964+ /// (asserted through the oracle aomdec's own sequence header, below);
6965+ /// `decode::rect4_inter_own_chroma444_hits()` must be non-zero, so the
6966+ /// 1:4-strip route the fix sits on really ran; and the SAME source and
6967+ /// flags at 4:2:0 must leave that counter at zero, which is what makes
6968+ /// it the 4:4:4-only route rather than a tally every strip bumps.
6969+ #[test]
6970+ fn a_444_lossy_rect4_inter_stream_decodes_pixel_exact() {
6971+ const NAME: &str = "a_444_lossy_rect4_inter_stream_decodes_pixel_exact";
6972+ const FIXTURE_LEN: usize = 6441;
6973+ const FIXTURE_FNV: u64 = 0x0436_8b2d_2e91_72b0;
6974+ const W: usize = 128;
6975+ const H: usize = 96;
6976+ const FRAMES: usize = 2;
6977+ let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
6978+ .join("fixtures/444_lossy_rect4_inter_witness.obu");
6979+ let stream = std::fs::read(&obu).unwrap_or_else(|e| {
6980+ panic!(
6981+ "{NAME}: pinned fixture {} is missing ({e}) -- the gate cannot run, \
6982+ which is a failure, not a skip",
6983+ obu.display()
6984+ )
6985+ });
6986+ assert_eq!(stream.len(), FIXTURE_LEN, "{NAME}: fixture length moved");
6987+ assert_eq!(fnv1a64(&stream), FIXTURE_FNV, "{NAME}: fixture bytes moved");
6988+
6989+ let _guard = lock_gate_counters();
6990+ crate::decode::reset_rect4_inter_own_chroma444_hits();
6991+ let frames = decode_stream(&stream).unwrap_or_else(|e| {
6992+ panic!("{NAME}: the pinned 4:4:4 lossy stream no longer decodes cleanly: {e}")
6993+ });
6994+ let own_chroma = crate::decode::rect4_inter_own_chroma444_hits();
6995+ assert!(
6996+ own_chroma > 0,
6997+ "{NAME}: no 1:4 inter strip read its chroma context over its own \
6998+ extent -- the corrected route never ran (class gate-blind-to-feature)"
6999+ );
7000+ assert_eq!(frames.len(), FRAMES, "{NAME}: frame count");
7001+ for (i, f) in frames.iter().enumerate() {
7002+ assert_eq!((f.width, f.height), (W, H), "{NAME}: frame {i} dimensions");
7003+ // At 4:4:4 the chroma planes are full resolution. A decoder that
7004+ // kept the 4:2:0 extent would hand quarter-size chroma planes to
7005+ // the byte compare below, which cannot pass -- but say so here
7006+ // rather than let the compare stand in for the shape claim.
7007+ assert_eq!(
7008+ f.u.len(),
7009+ W * H,
7010+ "{NAME}: frame {i} chroma plane is {} samples; at 4:4:4 it must be \
7011+ full resolution ({W}x{H})",
7012+ f.u.len()
7013+ );
7014+ }
7015+ if aomdec_path().is_file() {
7016+ let (decoded, _hidden) = decode_all_frames_vs_oracle(&stream, NAME);
7017+ eprintln!(
7018+ "{NAME}: {decoded} frame(s) byte-exact vs aomdec, {own_chroma} \
7019+ own-extent 1:4 chroma gather(s)"
7020+ );
7021+ } else {
7022+ eprintln!("{NAME}: no oracle aomdec, pixel arm skipped");
7023+ }
7024+
7025+ // The specificity arm: the SAME source, flags and 1:4 partitions at
7026+ // 4:2:0 must not touch the 4:4:4-only route. If a later change made
7027+ // the counter fire everywhere, this arm is what catches it.
7028+ if !have_aomenc() {
7029+ eprintln!("{NAME}: no aomenc, 4:2:0 specificity arm skipped");
7030+ return;
7031+ }
7032+ let source = format!("testsrc2=size={W}x{H}:rate=25");
7033+ let y4m = Command::new("ffmpeg")
7034+ .args([
7035+ "-v",
7036+ "error",
7037+ "-f",
7038+ "lavfi",
7039+ "-i",
7040+ &source,
7041+ "-frames:v",
7042+ "2",
7043+ "-pix_fmt",
7044+ "yuv420p",
7045+ "-strict",
7046+ "-1",
7047+ "-f",
7048+ "yuv4mpegpipe",
7049+ "-",
7050+ ])
7051+ .stdin(Stdio::null())
7052+ .stdout(Stdio::piped())
7053+ .stderr(Stdio::piped())
7054+ .output()
7055+ .expect("ffmpeg failed to run");
7056+ assert!(
7057+ y4m.status.success(),
7058+ "{NAME}: ffmpeg refused the 4:2:0 control source: {}",
7059+ String::from_utf8_lossy(&y4m.stderr)
7060+ );
7061+ let out = run_with_stdin(
7062+ Command::new(aomenc_path()).args([
7063+ "--codec=av1",
7064+ "--passes=1",
7065+ "--end-usage=q",
7066+ "--cq-level=20",
7067+ "--cpu-used=2",
7068+ "--threads=1",
7069+ "--row-mt=0",
7070+ "--lag-in-frames=0",
7071+ "--kf-max-dist=100",
7072+ "--limit=2",
7073+ "--obu",
7074+ "-o",
7075+ "-",
7076+ "-",
7077+ ]),
7078+ &y4m.stdout,
7079+ );
7080+ assert!(
7081+ out.status.success(),
7082+ "{NAME}: aomenc refused the 4:2:0 control recipe: {}",
7083+ String::from_utf8_lossy(&out.stderr)
7084+ );
7085+ crate::decode::reset_rect4_inter_own_chroma444_hits();
7086+ decode_stream(&out.stdout)
7087+ .unwrap_or_else(|e| panic!("{NAME}: the 4:2:0 control stream was refused: {e}"));
7088+ let (h4, v4, _, _) = crate::decode::inter16_rect4_counters();
7089+ // The control must actually code 1:4 inter strips, or it says nothing
7090+ // about the arm the fix touches. Measured: 16 HORZ_4, 28 VERT_4.
7091+ assert!(
7092+ h4 + v4 > 0,
7093+ "{NAME}: the 4:2:0 control coded NO 1:4 inter strip ({h4} HORZ_4, {v4} \
7094+ VERT_4) -- the identity arm below would say nothing about 1:4 strips"
7095+ );
7096+ assert_eq!(
7097+ crate::decode::rect4_inter_own_chroma444_hits(),
7098+ 0,
7099+ "{NAME}: the 4:2:0 control fired the ss_x-0 own-extent route -- the route \
7100+ is not specific to the 4:4:4 cell it was fixed for"
7101+ );
7102+ // The identity half: the fix adds an arm gated on `ss_x == 0`, so a
7103+ // 4:2:0 stream must stay byte-exact through it. This is the arm that
7104+ // would go red if the new arm were ever widened past ss_x 0.
7105+ if aomdec_path().is_file() {
7106+ decode_all_frames_vs_oracle(&out.stdout, &format!("{NAME}-420"));
7107+ }
7108+ eprintln!("{NAME}: 4:2:0 control {h4} HORZ_4 / {v4} VERT_4 strips, 0 own-extent gathers");
7109+ }
7110+
7111+ /// lane-av1444rect r2 — the SAME class as the gate above, second
7112+ /// instance: `decode_rect4_16_intrabc` applied the 4:2:0 pair geometry at
7113+ /// ss (0,0), where `is_chroma_reference` makes an intra-BC 1:4 strip its
7114+ /// own chroma reference. It predicted and coded an 8x4 chroma block at
7115+ /// `(lmi - 1) * MI / 2` where libaom codes 16x4 at the strip's origin.
7116+ ///
7117+ /// **This is a PROGRESS gate, not an exactness gate, and it says so.** The
7118+ /// 4:4:4 intra-BC cell is still divergent: after the ss gate the LUMA
7119+ /// plane is exact to sample 205264 (it was 164416) and the entropy fork
7120+ /// moves from read 11750 to 12465, but both CHROMA planes still first
7121+ /// diverge at index 20532 and 390380 of 921600 samples are wrong. So the
7122+ /// assertion is a prefix floor on the plane the gate actually moved —
7123+ /// which only ever grows, and which the next lane's fix cannot turn red —
7124+ /// and the untouched chroma divergence is named, never asserted exact.
7125+ ///
7126+ /// Recipe (both fixtures, one frame, `testsrc2 640x480 r=25`):
7127+ /// ```text
7128+ /// aomenc --codec=av1 --bit-depth=8 --input-bit-depth=8 --passes=1
7129+ /// --end-usage=q --cpu-used=0 --lag-in-frames=0 --kf-max-dist=1
7130+ /// --limit=1 --threads=1 --enable-rect-partitions=1
7131+ /// --enable-1to4-partitions=1 --min-partition-size=4
7132+ /// --max-partition-size=64 --sb-size=64 --tune-content=screen
7133+ /// --enable-intrabc=1 --enable-palette=1 --cq-level=60
7134+ /// --enable-tx-size-search=0 --obu [--profile=1] -o out.obu src.y4m
7135+ /// ```
7136+ /// 4:4:4 (1016 B, sha256 7fe888ed…) carries 17 intrabc 16x4 strips at
7137+ /// ss (0,0); the 4:2:0 twin (890 B, sha256 d01352af…) is byte-exact and
7138+ /// is the identity arm — the ss gate cannot reach it, and the whole frame
7139+ /// is compared with the length asserted first.
7140+ #[test]
7141+ fn a_444_intrabc_rect4_reads_its_own_chroma_plane_block() {
7142+ const NAME: &str = "a_444_intrabc_rect4_reads_its_own_chroma_plane_block";
7143+ const W: usize = 640;
7144+ const H: usize = 480;
7145+ const PS: usize = W * H;
7146+ let read = |name: &str, file: &str, len: usize, fnv: u64| -> Vec<u8> {
7147+ let path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
7148+ .join(format!("fixtures/{file}"));
7149+ let bytes = std::fs::read(&path).unwrap_or_else(|e| {
7150+ panic!(
7151+ "{name}: pinned fixture {} is missing ({e}) -- a failure, not a skip",
7152+ path.display()
7153+ )
7154+ });
7155+ assert_eq!(bytes.len(), len, "{name}: {file} length moved");
7156+ assert_eq!(fnv1a64(&bytes), fnv, "{name}: {file} bytes moved");
7157+ bytes
7158+ };
7159+ let stream444 = read(
7160+ NAME,
7161+ "444_intrabc_rect4_witness.obu",
7162+ 1016,
7163+ 0x27c2_fad5_4047_2994,
7164+ );
7165+ let stream420 = read(
7166+ NAME,
7167+ "420_intrabc_rect4_witness.obu",
7168+ 890,
7169+ 0x57ec_3da2_a63b_403a,
7170+ );
7171+
7172+ let _guard = lock_gate_counters();
7173+ crate::decode::reset_intrabc_rect4_own_chroma444_hits();
7174+ let frames = decode_stream(&stream444)
7175+ .unwrap_or_else(|e| panic!("{NAME}: the pinned 4:4:4 stream was refused: {e}"));
7176+ let own = crate::decode::intrabc_rect4_own_chroma444_hits();
7177+ assert!(
7178+ own > 0,
7179+ "{NAME}: no intra-BC 1:4 strip coded its own chroma plane block -- the \
7180+ corrected route never ran (class gate-blind-to-feature)"
7181+ );
7182+ assert_eq!(frames.len(), 1, "{NAME}: frame count");
7183+
7184+ // The identity arm FIRST and in full: the 4:2:0 twin must stay
7185+ // byte-exact. `decode_all_frames_vs_oracle` asserts the two frame
7186+ // lengths match before it compares anything -- the check whose absence
7187+ // turned an out-of-window divergence into a reported EXACT in this
7188+ // lane's own round 1.
7189+ if aomdec_path().is_file() {
7190+ decode_all_frames_vs_oracle(&stream420, &format!("{NAME}-420"));
7191+ crate::decode::reset_intrabc_rect4_own_chroma444_hits();
7192+ decode_stream(&stream420)
7193+ .unwrap_or_else(|e| panic!("{NAME}: the 4:2:0 twin was refused: {e}"));
7194+ assert_eq!(
7195+ crate::decode::intrabc_rect4_own_chroma444_hits(),
7196+ 0,
7197+ "{NAME}: the 4:2:0 twin fired the ss (0,0)-only route"
7198+ );
7199+
7200+ // NO 4:4:4 pixel assert here, and deliberately so. The cell is
7201+ // still divergent (390380 of 921600 samples; both chroma planes
7202+ // first wrong at index 20532, x=52 y=32; entropy fork read 12465
7203+ // at mi (90,108)) and an assertion of the form "our output is
7204+ // wrong by exactly N" would encode the defect as expected
7205+ // behaviour -- the shape this suite refuses everywhere else, and
7206+ // one that outlives the memory of why. The true assertions this
7207+ // gate can make today are the two above: the route is reached at
7208+ // 4:4:4 and is not reached at 4:2:0, and the 4:2:0 twin is
7209+ // byte-exact. The open chroma root and its numbers live in
7210+ // lanes/av1444rect.report.md §6, not in an assertion.
7211+ eprintln!(
7212+ "{NAME}: {own} own-chroma intra-BC strip(s) at 4:4:4, 0 at 4:2:0; \
7213+ 4:2:0 twin byte-exact; 4:4:4 intra-BC CHROMA still OPEN \
7214+ (U/V first wrong at index 20532, entropy fork read 12465 at \
7215+ mi (90,108)) -- see lanes/av1444rect.report.md \u{00a7}6"
7216+ );
7217+ } else {
7218+ eprintln!("{NAME}: no oracle aomdec, pixel arm skipped");
7219+ }
7220+ }
7221+
6930 /// lane-av1lrflush: the pipelined loop-restoration band release flushes7222 /// lane-av1lrflush: the pipelined loop-restoration band release flushes
6931 /// RU row 0 on the inter frame whose top superblock row carries a7223 /// RU row 0 on the inter frame whose top superblock row carries a
6932 /// 128-root rect -- the exact shape lanes/av1444sb.report.md r2 named as7224 /// 128-root rect -- the exact shape lanes/av1444sb.report.md r2 named as
lanes/av1444rect.report.mdadded+501 -0
@@ -0,0 +1,501 @@
1+# lane-av1444rect — H1 (4:4:4 lossy + a 1:4 partition) and the class, round 2
2+
3+**Tree.** `lane-av1444rect` off `4155c7c7`, worktree `~/.cache/wt/av1444rect`.
4+Round 1: `f92776ba` (H1 fix + gate + fixture), `bd0d0c37` (report).
5+Round 2: the class's second instance, `decode_rect4_16_intrabc`, plus a
6+retraction (§5) and a progress gate (§6). Read §5 before quoting any H3 number
7+from this report.
8+
9+## 1. Root cause
10+
11+`decode_inter_block`'s `around_c` — the gather that decides a 1:4 inter
12+strip's chroma **coefficient context** — chose the 4:2:0 PAIR extent with no
13+`ss` gate:
14+
15+```rust
16+// crates/ec-av1/src/decode.rs, decode_inter_block
17+let around_c = match strip_chroma {
18+ Some(s) if s.has_chroma => {
19+ let (pw, ph) = if s.horz {
20+ if ss_x(fctx) == 1 && ss_y(fctx) == 0 { (16, 4) } else { (16, 8) }
21+ } else { (8, 16) };
22+ ...
23+ neighbours.around_mi_rect(s.pair_mi, pw, ph)
24+ }
25+ _ => around,
26+};
27+```
28+
29+At ss (0,0) no pair exists. `is_chroma_reference` (av1_common_int.h:1454):
30+
31+```c
32+int ref_pos = ((mi_row & 0x01) || !(bh & 0x01) || !subsampling_y) &&
33+ ((mi_col & 0x01) || !(bw & 0x01) || !subsampling_x);
34+```
35+
36+At 4:4:4 `!subsampling_y` and `!subsampling_x` are both true, so `ref_pos`
37+is **unconditionally true**: every block is its own chroma reference. A
38+HORZ_4 16x4 strip codes its OWN 16x4 chroma (the `strip_chroma` setter at
39+`decode.rs:50840` already gives it `pair_mi == at_mi` for exactly this
40+reason), and its context extent is the strip's own 4 px.
41+
42+The pair gather used `ph = 8`, which makes `around_mi_rect` walk
43+`left[mi_r]` **and** `left[mi_r + 1]`. The strip's own 4-px extent walks
44+`left[mi_r]` only. So the U unit's `get_txb_ctx` OR-ed in a left chroma
45+neighbour that does not exist, `txb_skip_ctx` came out 1 where libaom's is
46+offset-7 row 7, and the arithmetic coder forked.
47+
48+**The fix** is one match arm, gated on the same `ss` the plane geometry is:
49+
50+```rust
51+Some(_) if ss_x(fctx) == 0 => { hit!(RECT4_INTER_OWN_CHROMA444_HITS); around }
52+```
53+
54+`around` is the block's own `around_mi_rect(at_mi, write_w, write_h)`, which
55+at ss 0 IS the chroma block's extent. The horz `(16, 4)` sub-branch also
56+loses its now-redundant `ss_x == 1 &&` conjunct (it is unreachable at
57+ss_x 0, where the new arm has already returned).
58+
59+**Class: `ss-gate-missing-on-a-4:2:0-pair-geometry`.** A 4:2:0 pair extent
60+(or anchor) hardcoded on a path that also runs at ss (0,0), where
61+`is_chroma_reference` makes the pair non-existent. The 4:2:0 reduction of
62+the expression is the tell.
63+
64+### Class sweep (same batch)
65+
66+| site | verdict |
67+|---|---|
68+| `decode_inter_block` `around_c` | **the defect** — fixed |
69+| `decode_rect4_16_strip` (intra key-frame 1:4), `decode.rs:17308` | already ss-gated (`if ss_x == 0 && ss_y == 0 { (lmi, bw, bh) }`, the `lane-av1-444` row) |
70+| `decode_rect4_16_intrabc` (`decode.rs:16466`) | **same class, still open** — see §6 |
71+| `read_inter_rect_chroma`, `decode_block_rect4/64`, the 128-root mu-chunk arm | already ss-parameterised (`uw << ss_x`, `chunk_chroma_w = 64 >> ss_x`) |
72+
73+## 2. Localization, measured
74+
75+**Fixture.** `aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q
76+--cq-level=20 --cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0
77+--kf-max-dist=100 --limit=2` over `ffmpeg -f lavfi -i
78+"testsrc2=size=128x96:rate=25" -frames:v 2 -pix_fmt yuv444p -f
79+yuv4mpegpipe`.
80+
81+6441 B, sha256 `77f727e76d81fe48cd03709f799131677c04869b163e18d78e96bc742ec69153`,
82+FNV-1a64 `0x04368b2d2e9172b0`. Pinned at
83+`crates/ec-av1/fixtures/444_lossy_rect4_inter_witness.obu`.
84+
85+`rate=25` is load-bearing and the sweep report did not say so: `testsrc2`'s
86+pattern is time-parameterised, so `rate=1` yields a different 8121-byte
87+stream that decodes exactly. The report's 6441 B / 8884-wrong / Y(91,32)
88+numbers reproduce only at `rate=25`.
89+
90+**Red before.** frame 0 exact; frame 1: 8884 of 36864 samples wrong, first at
91+Y(91,32).
92+
93+**Symbol fork.** `EC_SYMR` both sides, aligned 1:1 on
94+`(nsymbs, symbol, post_rng, 32768 - our_icdf0)`: reads 0..26262 pair
95+exactly, read **26263** diverges, both sides at mi (8,16):
96+
97+| | site | read |
98+|---|---|---|
99+| oracle | `decodetxb.c:158` (the `txb_skip` read) | plane 1 (U), `txb_skip_ctx` **7**, symbol 1 (all-zero) |
100+| ours | `read_inter_plane_rect` (a 16x4 **chroma** unit) | re-indexed ctx **1**, symbol 0 |
101+
102+**The report's "ours reads a second LUMA unit" is refuted.** That came from
103+`read_coeffs_rect`'s `tag=all_zero plane=0` label, which the report itself
104+flagged as hardcoded. A per-unit trace (`plane`, `w`, `h`, `txb_skip_ctx`,
105+`around`) shows the block is a **16x4 inter strip** at (64,32) and our
106+decoder reads exactly the unit the oracle reads — one luma 16x4 at bit 3706,
107+then one U 16x4 at bit 3719. The fork is a **context row**, not a unit
108+count. Same conclusion Agent06-3 reached independently on H5 from the other
109+half of the same formula.
110+
111+**Root-of-context, measured** with `EC_DCDUMP` + `EC_CHROMA_PUB`: at the
112+U unit our gather reported `left[9][plane 1].level = 7` (one extra luma mi
113+row). The oracle's `get_txb_ctx` there reads `ctx_base 0` →
114+`txb_skip_ctx = 0 + 7`.
115+
116+## 3. The fix, measured
117+
118+| | frame 0 | frame 1 |
119+|---|---|---|
120+| before | exact | 8884/36864 wrong, first Y(91,32) |
121+| after | exact | **byte-exact** |
122+
123+2/2 frames byte-exact against the instrumented `aomdec`
124+(`EC_AV1_FINAL_DUMP`, decode order).
125+
126+**Counter.** `decode::rect4_inter_own_chroma444_hits()` — 9 on the pinned
127+witness, 0 on the 4:2:0 control of the same source and flags.
128+
129+## 4. Gate
130+
131+`a_444_lossy_rect4_inter_stream_decodes_pixel_exact`
132+(`crates/ec-av1/src/stream.rs`). The first exactness gate for the 4:4:4
133+**LOSSY** cell — the whole committed 4:4:4 base was lossless 8-bit.
134+
135+- pinned fixture, length + FNV asserted;
136+- chroma planes asserted full resolution (the 4:4:4 shape claim, stated
137+ rather than left to the byte compare to imply);
138+- byte-for-byte through `decode_all_frames_vs_oracle` (oracle aomdec);
139+- non-vacuity: the counter must be non-zero, so the corrected route ran;
140+- specificity: the same source and flags at 4:2:0 code 16 HORZ_4 + 28 VERT_4
141+ strips (asserted, so the arm cannot pass for the wrong reason), leave the
142+ counter at 0, and are themselves compared byte-for-byte against aomdec —
143+ the arm that goes red if the new arm is ever widened past `ss_x == 0`.
144+
145+**Mutation proof.** Restoring the old pair arm with the counter left in
146+place:
147+
148+```
149+decode-order frame 1 of 2 differs from the oracle at byte 4187
150+(ours 35 vs 38), 8884 bytes differ
151+```
152+
153+— the same 8884 and the same Y(91,32) as the original red, so the gate
154+catches this defect and not a near-miss of it.
155+
156+Second direction: widening the arm to `Some(_)` leaves the 4:2:0 control at
157+0 gathers, because at ss_x 1 a 1:4 strip's chroma reaches
158+`decode_inter_block` through a different caller and never sets
159+`inter_strip_chroma`. That is why the identity proof is the 4:2:0 **oracle
160+compare**, not the counter: the counter proves the 4:4:4 route fired, the
161+oracle compare proves nothing else moved.
162+
163+## 5. Identity and the sweep's other divergences
164+
165+Green against this `decode.rs`:
166+
167+- the crate's whole `444` family — 9 tests;
168+- `rect_strip` family — 10 tests;
169+- `a_real_aomenc_inter_sequence_with_a_16_level_rect_leaf_decodes_pixel_exact`;
170+- all **three new chroma-format-sweep gates**, run in the sweep worktree
171+ `~/.cache/wt/av1fmt` with this `decode.rs` copied in and the sweep tree
172+ restored afterwards:
173+ `a_lossless_444_10bit_inter_stream_decodes_pixel_exact`,
174+ `a_444_12bit_inter_sequence_decodes_pixel_exact`,
175+ `a_real_aomenc_odd_coded_dimension_streams_decode_pixel_exact`.
176+
177+Same-class recipes re-measured:
178+
179+| recipe | size | before | after |
180+|---|---|---|---|
181+| **H1** 4:4:4 lossy cq20 `--limit=2` | 6441 B | frame 1: 8884 wrong | **byte-exact** |
182+| H1 control `--enable-rect-partitions=0` | 6529 B | exact | exact |
183+| **H2** 4:4:4 lossy `--sb-size=64 --min/max-partition-size=64`, 4 f | 21830 B | frames 0-1 exact, from frame 2 608 wrong, U/V only, first U(2,31) | **unchanged** — still 608 wrong, U/V only |
184+| **H3** 4:4:4 lossless `--tile-columns=1` 256x128, 6 f | 77847 B | sweep reported 90 chroma wrong in frame 0 | **byte-exact, 6/6** |
185+
186+**H2 is not this class and is not fixed here.** Its entropy decode is
187+bit-identical over 140820 reads (the sweep measured it), so it is
188+reconstruction arithmetic, not a context: the `av1_get_adjusted_tx_size`
189+clamp on a 4:4:4 chroma TX_32X64 is still the prime suspect. Re-measured
190+here to prove the class claim above: H2's numbers are bit-identical before
191+and after, so this fix neither caused nor cured it.
192+
193+> **Derive the length, do not copy the multiplier.** The re-measurement
194+> below writes `assert len(ours) == 2 * len(ref)`. That factor is a
195+> **coincidence of 4:4:4 against 4:2:0 at the same geometry** — our `dump_yuv`
196+> emits `u16` per sample while the oracle's 8-bit dump is `u8`, so the factor is
197+> the bits-per-sample ratio and has nothing to do with chroma. At 4:2:2, at a
198+> high bit depth, or on any fixture where the two sides do not agree on bit
199+> depth, `2 *` is simply wrong. Compute the expected byte length from the plane
200+> extents and the two bit depths (and assert the oracle's dump length against
201+> that, not against a constant) before comparing anything.
202+
203+**H3: RETRACTED — my first claim was void, Agent142-2's measurement stands.**
204+I reported this stream "byte-exact 6/6". It is not. My throwaway compare
205+script hardcoded the frame geometry to 128x96 (the H1 fixture's) and
206+derived the sample count as 3·128·96 = 36864; I fed it a 256×128 witness
207+without overriding the size, so it compared only the **top-left 36864
208+samples** of each 98304-sample frame and declared the frame exact. The
209+defect sits at x ≥ 108, outside the window. A prefix compare passes
210+exactly when the defect is outside the prefix.
211+
212+- fixture sha256 `87b0d1a5b3044552fc1fae839e868c30fdc0bebe79f8b3a3104030ffea24ab50`,
213+ 77847 B, `testsrc2 256x128 rate=25` yuv444p, `--limit=6 --kf-max-dist=100
214+ --threads=1 --row-mt=0 --lag-in-frames=0 --passes=1 --end-usage=q
215+ --lossless=1 --tile-columns=1 --cpu-used=2` — byte-identical to
216+ Agent142-2's witness A, so this is a harness bug, not a different-ffmpeg
217+ story;
218+- re-measured with the correct geometry on this tip: **63–162 wrong chroma
219+ samples in every one of the six frames, first at U(110,26)**, luma exact
220+ — Agent142-2's "29–103 wrong, x ≥ 108, luma exact", reproduced;
221+- their second witness (75446 B, no `--cpu-used`,
222+ `65e94e91c56178d21f5c8441877d0dbfbee17bce0916e971fbe6c51677c9891e`)
223+ reproduces the sweep's original H3 signature (frame 0 only, 12 U + 40 V,
224+ first U(237,58)) and is bit-identical before and after this fix.
225+
226+**H3 is not cured by this fix and is not in this lane.** No H3 gate is
227+pinned here. Agent142-2 owns it. The lesson is in §7: a per-frame byte
228+compare must assert the two frame lengths match before comparing, and must
229+not be handed a fixture whose geometry it does not know.
230+
231+**H5 (lane-av1h5, Agent06-3): out of scope and structurally disjoint.** The
232+new arm lives inside `match strip_chroma`, which is `Some` only from the
233+single setter the PARTITION_HORZ_4 / VERT_4 16x4 / 4x16 `inter_piece` loop
234+runs; a BLOCK_128X128 unsplit root never reaches it.
235+
236+## 6. The same class, second instance: `decode_rect4_16_intrabc`
237+
238+Round 1 left this open on inspection, noting it "needs a 4:4:4 witness I had
239+no budget to produce". Round 2 produced the witness. **It is live, not
240+latent.**
241+
242+**Witness.** `testsrc2 640x480 r=25` yuv444p, `aomenc --tune-content=screen
243+--enable-intrabc=1 --enable-palette=1 --cq-level=60 --enable-tx-size-search=0
244+--min-partition-size=4 --max-partition-size=64 --sb-size=64
245+--enable-rect-partitions=1 --enable-1to4-partitions=1 --cpu-used=0
246+--kf-max-dist=1 --limit=1 --profile=1` — 1016 B, sha256 `7fe888ed…`, carrying
247+**17 intrabc 16x4 strips at ss (0,0)**.
248+
249+**Controls, same recipe each:**
250+
251+| arm | verdict |
252+|---|---|
253+| 4:4:4, intrabc on | 455240 / 921600 wrong, first Y(576,256) |
254+| 4:4:4, `--enable-intrabc=0` | **byte-exact** |
255+| 4:2:0 twin, intrabc on (890 B, sha256 `d01352af…`) | **byte-exact** |
256+| 4:4:4 with `--enable-1to4-partitions=0` and `--enable-rect-partitions=0` | 455240 wrong — the defect does NOT need a 1:4 or rect partition |
257+
258+So the divergence is intra-BC-at-4:4:4 in general; `decode_rect4_16_intrabc`
259+is one site in it, not all of it.
260+
261+**The site.** `decode.rs:16489`: `(pw, ph) = if horz { (16, 8) } else { (8, 16) }`,
262+`pair_mi = lmi - 1`, `cpx = pair_mi.1 * MI / 2`. At ss (0,0) that predicts and
263+codes an 8x4 chroma block a quarter of the way off, where libaom codes a 16x4
264+at the strip's own origin.
265+
266+**Round 2's change.** One `own444 = ss_x == 0 && ss_y == 0` gate on
267+`(pw, ph)`, `(cw, ch)`, `pair_mi` and `(cpx, cpy)`. 4:2:0 and 4:2:2 keep every
268+constant verbatim, so the arm cannot reach them.
269+
270+**Measured, per plane:**
271+
272+| | before | after |
273+|---|---|---|
274+| first entropy fork | read **11750**, mi (78,128) | read **12465**, mi (90,108) |
275+| luma first wrong | 164416 (Y 576,256) | **205264** (Y 464,320) |
276+| luma differing | 95872 | 51716 |
277+| U first wrong | 20532 | 20532 (untouched) |
278+| V first wrong | 20532 | 20532 (untouched) |
279+| total differing | 455240 | 390380 |
280+
281+**A partial improvement, NOT a fix, and the report says so.** The ss gate
282+moves the luma divergence 40948 samples later and the entropy fork 715 reads
283+later; both chroma planes are untouched. 390380 of 921600 samples are still
284+wrong. No exactness is claimed — "the divergence moved" is evidence that the
285+geometry was wrong, not that the new geometry is right.
286+
287+### Gate
288+
289+`a_444_intrabc_rect4_reads_its_own_chroma_plane_block` — deliberately **not**
290+an exactness gate. It asserts nothing about the 4:4:4 pixels:
291+
292+- both fixtures pinned (length + FNV);
293+- non-vacuity: `intrabc_rect4_own_chroma444_hits()` is non-zero on the 4:4:4
294+ witness (18) and zero on the 4:2:0 twin, so the route the ss gate sits on is
295+ proven to run and proven to be ss-specific;
296+- identity: the 4:2:0 twin is compared byte-for-byte through
297+ `decode_all_frames_vs_oracle`, which asserts the two frame lengths match
298+ before comparing;
299+- the open chroma divergence — 390380 of 921600 wrong, U and V both first wrong
300+ at index 20532, entropy fork read 12465 at mi (90,108) — is named in a comment
301+ and in the test's output line, and **never asserted**.
302+
303+**A prefix-floor assert was written here first and removed.** It asserted the
304+luma plane is byte-exact to sample 205264 — i.e. that our output is wrong by
305+exactly N past that point. That encodes a defect as expected behaviour, the
306+shape this suite refuses everywhere else, and it is a red-if-fixed assertion.
307+Removed rather than kept as a regression guard. The red-before for the ss gate
308+itself was measured instead, as an entropy measurement: `own444 = false` puts
309+the first fork back at read 11750 / luma sample 164416, and 12465 / 205264
310+with it.
311+
312+### Round 3 — the chroma root is narrowed, not landed
313+
314+The follow-up named two candidates; **measurement eliminates both**:
315+
316+| candidate | verdict |
317+|---|---|
318+| (a) `sub8_leaf_chroma444`'s single `around_mi_rect(lmi, bw, bh)` reused for both planes | its `square` arm reads through `read_plane`, and a per-unit trace of every coefficient entry point (`read_plane`, `read_coeffs`, `read_coeffs_rect`) shows **no such unit at the fork's bit position** |
319+| (b) the non-lossless rect arm's offset | that arm's `read_coeffs_rect` calls fire at msac bits 1912–2097, nowhere near the fork |
320+
321+**The fork, localized to a call shape.** Instrumenting all three coefficient
322+entry points pins read 12465 to a `read_coeffs_rect` call with **w=4, h=8,
323+`skip_ctx`=0** at bit 6893, at mi (90,108) — a 4x8 rect unit where the oracle is
324+on a chroma `txb_skip` (`decodetxb.c:158`, symbol 1). Which caller and which
325+plane is not yet established.
326+
327+### Round 4 — the unit census: it is NOT an ordering defect
328+
329+Main's neighbour lanes both warned that a chroma-only, ordering-suspect defect
330+should be checked by COUNTING units first (Agent10-2's H5 was a token-order
331+blowup, 16x too many chroma walks). Counted on the 1016 B witness, one frame:
332+
333+| | ours | oracle |
334+|---|---|---|
335+| total coefficient unit reads | 2688 | 2395 |
336+| luma (square reader) | 1213 | 1309 |
337+| chroma (square reader) | 636 | 543 per plane, 1086 total |
338+| rect-unit reads (`read_coeffs_rect`) | 839 | (subsumed above) |
339+
340+The oracle's 2395 `EC_COEFF_STEP tag=all_zero` lines are per
341+`av1_read_coeffs_txb` call and are NOT skipped on eob=0, so the two sides are
342+counting the same thing. The counts are in the same range — no 16x blowup, no
343+missing order. **The intra-BC 4:4:4 chroma defect is not a token-order
344+defect**, which is what Main asked to rule out before chasing a value-level
345+root, and it is the second independent lane to reach that conclusion about a
346+4:4:4 chroma fork (Agent10-2's own 128-root turn, Agent142-2's H2/H3 census).
347+
348+There IS an asymmetry worth recording for whoever continues: we read 636
349+square chroma units against the oracle's 1086, and 2052 luma reads against its
350+1309. The luma side is pixel-exact to sample 205264, so the luma surplus is
351+most likely a counting-shape difference (our var-tx leaves versus libaom's
352+unit walk) rather than a walk defect; it is NOT established either way, and I
353+am not claiming it.
354+
355+**Handed back, not landed.** The remaining 4:4:4 intra-BC defect is a **4x8
356+rect coefficient unit**, present with 1:4 and rect partitions both disabled,
357+and it is neither of the two candidates the follow-up named. Landing a partial
358+is out of scope for this round, so the merge candidate is the H1 fix (exact,
359+gated, mutation-proven) plus the measured `own444` gate on the intra-BC 1:4
360+geometry, and the chroma root goes on as a fresh task with the numbers above.
361+
362+**The fastest next measurement** (Agent142-2, from the H2 round): the per-unit
363+`txtype` census from the oracle's `idct.c` rung. On H2 it found the fault in
364+one pass — two chroma units whose `txtype` differed from what the block-level
365+type implied, on a frame where every luma unit was IDTX, so "luma is exact"
366+carried no information. This cell has exactly that asymmetry (entropy fork on
367+a chroma unit, luma clean), so the census decides in about a minute whether
368+the fork is a coefficient-read problem or a type/extent problem — the only
369+fork left in this cell.
370+
371+## 7. Residue handed on, not fixed here
372+
373+- **4:4:4 intra-BC chroma** — a 4x8 rect coefficient unit: read 12465,
374+ mi (90,108), `read_coeffs_rect(w=4, h=8, skip_ctx=0)` at bit 6893; U and V
375+ first wrong at index 20532. Per §6; both originally-named candidates
376+ eliminated by measurement, so this needs a fresh start, not a continuation.
377+- **H2** and **H3** are with Agent24-2 as of this writing (Agent142-2's round
378+ closed with the census committed); §5's retraction is the record they need.
379+- **H4** — 4:4:4 lossless + tile rows, hard divergence. Own lane; untouched.
380+- **H5** — 4:4:4 10-bit lossless 128 root, chroma band/offset term. Agent06-3.
381+- **H6** — 12-bit 4:4:4 needs a smoothed source. Coverage caveat, not a defect.
382+
383+**The prior, adopted from Agent142-2's round 4.** 4:4:4 chroma defects in this
384+decoder cluster in the **sub-8 and strip/partition unit walks, not in the
385+64x64 whole-block paths**. The 64x64 whole-block 4:4:4 paths are exact in every
386+cell closed so far; the odd-dimension 66x66 control is exact; 4:2:0 12-bit
387+tiles and superres are exact. Everything divergent is a 4:4:4 cell whose
388+chroma is split into units smaller than the block, or where a partial-frame
389+geometry applies. It matches what is left here — a 4x8 rect unit, not a strip
390+— and it reframes the earlier "it is the 1:4 reader" guess as wrong.
391+
392+The sharper frame is Agent142-2's: **a value whose scope is wrong at the point
393+it is consumed.** Both candidates this lane chased were that mistake, just not
394+at the site — one had a per-plane extent that was not at the fork at all, the
395+other fired 4800 msac bits away.
396+
397+## 8. Scope confirmation (Agent00-2's ablation — FIRST VERSION RETRACTED)
398+
399+**This section was published wrong and is corrected here.** The first version
400+of it recorded a four-arm ablation in which `4e151813` alone was EXACT 4/4 on
401+both of Agent00-2's cells, concluding the two fixes were independent and that
402+this lane's fix did not reach them. That arm never ran: the tree was reset with
403+`git checkout -- <files>`, which restores from the INDEX, and the index still
404+held both cherry-picks — so that arm silently re-measured the both-commits
405+tree, and cargo saw byte-identical sources so it did not even relink. The
406+conclusion was a phantom. **The claim "this lane's fix does not reach those two
407+cells" is retracted; the opposite is true.**
408+
409+The corrected 2x2, re-run by Agent00-2 with `git reset --hard 4155c7c7` and a
410+verified rebuild (binary mtime printed) at every arm, on their pinned fixtures,
411+4/4 decode-order frames vs aomdec:
412+
413+| arm | odd444_130x122 | sr444 (256x128) |
414+|---|---|---|
415+| base | DIVERGENT f3 11521 | DIVERGENT f2 25296 + f3 51108 |
416+| base + rung + `4e151813` | DIVERGENT f3 11521 | DIVERGENT f2 25296 + f3 51108 — byte-identical to base |
417+| base + rung + `f92776ba` (this lane) | **EXACT 4/4** | **EXACT 4/4** |
418+| base + rung + `4e151813` + `f92776ba` | EXACT 4/4 | EXACT 4/4 |
419+
420+Three consequences, all of which enlarge this lane's scope rather than narrow
421+it:
422+
423+1. **Both cells are this class, and `f92776ba` alone fixes them.** `4e151813`
424+ contributes nothing to either: the divergence counts are identical to base
425+ with and without it, because its two `tu_reach` call sites both sit inside
426+ `decode_rect4_16_strip`'s `if lossless_pair {` arm while both cells are
427+ 4:4:4 LOSSY cq-20 on the `} else if skip {` path at `decode.rs:17579`.
428+2. **`f92776ba` does not depend on `4e151813`.** It applies and goes green on
429+ `4155c7c7` on its own, so merge order is free and nothing else is a
430+ prerequisite.
431+3. **Red-before on both cells**, with the counter left in place: mutating the
432+ `Some(_) if ss_x(fctx) == 0 => around` arm back to the 4:2:0 pair extent
433+ `(16, 8)` gives sr444 76404 samples with first wrong Y(192,0) — the sweep's
434+ exact number — and odd444_130x122 9203 samples, first wrong Y(100,32) on
435+ frame 3.
436+
437+So the 4:4:4 lossy class now has two more independent witnesses at geometries
438+and depths this lane's 128x96 gate does not cover (130x122, a partial-frame
439+right edge; 256x128, with CDEF and LR live on the last two frames). One
440+correction to the sweep's own matrix, from Agent00-2's report: its "4:4:4
441+superres" cell turns out not to be a superres cell at all, and that one is
442+EXACT.
443+
444+**Method notes carried over** (still valid; the retraction was in the ablation,
445+not in the instrumentation):
446+
447+- The first wrong SYMBOL is invisible in the `EC_MODE` ladder because that
448+ print carries no `bsize`. What localizes these cells is the per-superblock
449+ decode-order pixel map of the pre-filter dump — the first wrong superblock in
450+ decode order is the one whose above-neighbour context then forks the NEXT
451+ block's `ref0`. On sr444 f2 that is SBcol2/SBrow0, first wrong pixel (128,48)
452+ = mi(12,32) with the mode identical on both sides, and the `ref0` fork (LAST
453+ vs our GOLDEN) lands on the very next block, mi(13,32). A pixel error cannot
454+ cause a mode fork, so the same bsize/footprint error has to feed both.
455+- **`git checkout -- <files>` does not reset a tree to a commit.** It restores
456+ from the INDEX, so any staged cherry-pick survives it and the "arm" measures
457+ the tree you thought you had removed. A per-arm ablation needs
458+ `git reset --hard <base>` and a rebuild whose binary mtime is printed, or it
459+ measures nothing. This bit me twice in one session: here, and earlier when a
460+ temporary trace landed in the main checkout instead of the lane worktree
461+ because the edit tool resolved a relative path against the workspace root.
462+
463+## 9. Method notes for the next lane
464+
465+- **A route counter is not proof a fix bites.** This lane learned it the hard
466+ way: a counter can fire identically before and after a change that changes
467+ nothing downstream, so a non-zero count proves REACH and nothing more. Both
468+ counters this lane added carry that warning in their own doc comment, and
469+ the intra-BC one is deliberately armed OUTSIDE the `own444` expression so the
470+ mutation still increments it and the red lands on the pixel/entropy arm
471+ instead. What carries the claim is the measured fork move and the mutation
472+ red. Rule now in skill://ec-av1-pipeline-gate-counters: a counter needs a
473+ DIFFERS-style assertion before it can carry a claim.
474+- `testsrc2` is time-parameterised: any sweep recipe quoting it must pin
475+ `rate`, or the fixture is not reproducible. `rate=1` vs `rate=25` on
476+ 128x96 yuv444p is the difference between an 8121-byte exact stream and
477+ the 6441-byte divergent one.
478+- `read_coeffs_rect`'s `EC_COEFF_STEP tag=all_zero` prints a hardcoded
479+ `plane=0`. It has now mis-attributed a chroma read as a luma one in two
480+ independent reports. The oracle's `EC_COEFF_STEP` prints the real plane.
481+ Pair the two traces by the msac `post_rng` (both sides print it after the
482+ read) rather than by line index.
483+- `EC_AV1_TELL ... label=block_entry` prints the msac bit position at each
484+ `decode_inter_block` entry, and the oracle's `EC_SYMR` `pre` third field
485+ is our bit position minus a constant 15. That pair joins the two symbol
486+ streams to a block without any new instrumentation.
487+- `EC_DCDUMP` already dumps the above/left entropy contexts per plane;
488+ `#[track_caller]` on `Neighbours::around_mi_rect` names the gather site
489+ in one line if you ever need to attribute one again.
490+- **A byte compare that truncates to `min(len(ours), len(ref))` is a PREFIX
491+ compare, and a prefix compare passes exactly when the defect is outside the
492+ prefix.** This lane reported an H3 stream "byte-exact 6/6" that way: the
493+ throwaway script carried the H1 fixture's 128x96 geometry, so it compared
494+ 36864 of 98304 samples and the divergence at x >= 108 was invisible. Agent142-2
495+ caught it. **Every ours-vs-oracle compare must assert the two lengths are
496+ equal before it compares anything**, must not be handed a fixture whose
497+ geometry it does not know, and must clear BOTH sides' scratch files between
498+ runs (mine cleared `aom.*` and not `ours.*`, a stale-file hazard sitting right
499+ next to the truncation bug). The crate's own
500+ `decode_all_frames_vs_oracle` does assert `got.len() != want.len()`, which is
501+ why the committed gates in this lane were never exposed to it.