forge
Explore
Log in

Don't you dare go Hollow

ec-av1: 4:4:4 inter chroma units inherit their own quadrant's luma tx_type

Browse files at this commit

dc2a1dde2791c30f75b1e27b4cfda905c407ae92Ahmet Kaan GümüşParent: e772a72
The 64x64 four-unit chroma arm (ss 0/0, chroma_side > chroma_tx) handed all
four TX_32X32 units the block-level luma_tx_type -- the TOP-LEFT luma leaf's
coded type. libaom's av1_get_tx_type (blockd.h:1287-1297) instead reads the map
cell at the chroma unit's own position scaled back to luma, and a luma leaf
that coded nothing is stamped DCT_DCT there (decodetxb.c:199-203), so every
unit sitting over a skipped luma quadrant was reconstructed with the wrong
transform.

leaf_tx_types was only collected under , so at 64 it was empty and
there was nothing to resolve from; it is now collected at every size, both
copies of the arm resolve per quadrant through the shared
covering_leaf_tx_type (extracted from the three inline copies that already
existed -- one convention, not four), and two counters record the route and
the cases where the resolved type DIFFERS from the block-level one.

Witness pinned as fixtures/444_quad_leaf_tx_type.obu (27933 B, sha256
a06c9f7a0862252f6ab7ebdcec340d0602e730e38089365f14747db37f8e78d5): decode-order
frames 1/2/3 went from 777/640/554 wrong V samples to byte-exact, and the
per-unit type census against aomdec's EC_DQCOEFF goes from 4 disagreements to
0 of 136. Reverting only the per-quadrant resolve turns the new gate red on
frame 1 with 777 bytes differing.

The new gate asserts the DIFFERS count (8 on the witness), not the route count
(96) -- a route counter fired on the one block of an earlier no-op port that
changed zero pixels. A 4:2:0 control asserts both counters stay at 0.
crates/ec-av1/fixtures/444_quad_leaf_tx_type.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+126 -50
@@ -13703,16 +13703,7 @@ fn decode_intrabc_128rect(
1370313703 // covering its own quadrant (all of this chunk's
1370413704 // leaves are read by now).
1370513705 let unit_rel_mi = (unit_mi.0 - mi_r, unit_mi.1 - mi_c);
13706- let covering = leaf_tx_types
13707- .iter()
13708- .copied()
13709- .find(|&(lr, lc, lw, lh, _)| {
13710- lr <= unit_rel_mi.0
13711- && unit_rel_mi.0 < lr + lh / MI
13712- && lc <= unit_rel_mi.1
13713- && unit_rel_mi.1 < lc + lw / MI
13714- })
13715- .map(|(_, _, _, _, t)| t);
13706+ let covering = covering_leaf_tx_type(&leaf_tx_types, unit_rel_mi);
1371613707 // The prediction window is the block's own square
1371713708 // `cside` buffer with the unit's true per-axis
1371813709 // position inside it.
@@ -37597,6 +37588,70 @@ const fn sub16_to_mi(t: (usize, usize)) -> (usize, usize) {
3759737588 (t.0 * (SUB / MI), t.1 * (SUB / MI))
3759837589 }
3759937590
37591+/// The luma transform leaf a chroma unit inherits its `tx_type` from
37592+/// (libaom `av1_get_tx_type`, `blockd.h:1287-1297`): an INTER block's chroma
37593+/// unit never codes a `tx_type` symbol of its own, so the type is read out
37594+/// of `xd->tx_type_map` at the chroma unit's own position scaled back to luma
37595+/// (`blk_row << ss_y`, `blk_col << ss_x`). `leaves` is the block's coded
37596+/// transform tree in decode order, `(row, col, tw, th, tx_type)` with
37597+/// `(row, col)` in MI relative to the block and `(tw, th)` in PIXELS;
37598+/// `rel_mi` is the chroma unit's own luma-relative top-left MI cell. One
37599+/// function serves the 128x128 mu-chunk tail and the 64x64 arms alike -- the
37600+/// lookup is the same rule, so a second inline copy would be a second
37601+/// convention.
37602+///
37603+/// A leaf that coded nothing resolves to `DctDct` here exactly as libaom's
37604+/// `decodetxb.c:199-203` stamps `DCT_DCT` into that leaf's map cell on the
37605+/// `all_zero` path: a chroma unit over a SKIPPED luma quadrant must NOT
37606+/// inherit the block-level (top-left leaf) type.
37607+fn covering_leaf_tx_type(
37608+ leaves: &[(usize, usize, usize, usize, TxType)],
37609+ rel_mi: (usize, usize),
37610+) -> Option<TxType> {
37611+ leaves
37612+ .iter()
37613+ .copied()
37614+ // leaf (row, col) are mi but (tw, th) are px (the rect leaf path
37615+ // divides by MI too)
37616+ .find(|&(lr, lc, lw, lh, _)| {
37617+ lr <= rel_mi.0 && rel_mi.0 < lr + lh / MI && lc <= rel_mi.1 && rel_mi.1 < lc + lw / MI
37618+ })
37619+ .map(|(_, _, _, _, t)| t)
37620+}
37621+
37622+thread_local! {
37623+ /// lane-av1444chr: how many chroma units resolved their `tx_type` from the
37624+ /// luma leaf covering their OWN quadrant instead of the block-level
37625+ /// (`first_tx_type`) one -- the route this lane corrected.
37626+ /// `CHROMA_SPLIT_TX_HITS` cannot attribute its bumps to it: every split
37627+ /// chroma unit bumps that one.
37628+ pub(crate) static CHROMA_QUAD_LEAF_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
37629+}
37630+
37631+thread_local! {
37632+ /// Of those, how many resolved a type that DIFFERS from the block-level one
37633+ /// -- the exact condition lane-av1444chr measured wrong: over a luma leaf
37634+ /// that coded nothing the map cell is `DCT_DCT` while the top-left leaf's
37635+ /// is `IDTX`. A gate proving the corrected route fired is NOT enough on
37636+ /// its own (a block whose four leaves agree changes zero pixels); this is
37637+ /// the number that says the route changed an answer.
37638+ pub(crate) static CHROMA_QUAD_LEAF_TX_DIFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
37639+}
37640+
37641+/// [`CHROMA_QUAD_LEAF_TX_HITS`]: chroma units that took their type from the
37642+/// covering luma leaf.
37643+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
37644+pub(crate) fn chroma_quad_leaf_tx_hits() -> usize {
37645+ CHROMA_QUAD_LEAF_TX_HITS.with(std::cell::Cell::get)
37646+}
37647+
37648+/// [`CHROMA_QUAD_LEAF_TX_DIFF_HITS`]: chroma units whose covering leaf's type
37649+/// differs from the block-level one.
37650+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
37651+pub(crate) fn chroma_quad_leaf_tx_diff_hits() -> usize {
37652+ CHROMA_QUAD_LEAF_TX_DIFF_HITS.with(std::cell::Cell::get)
37653+}
37654+
3760037655 fn decode_inter_block(
3760137656 dec: &mut SymbolDecoder,
3760237657 cdfs: &mut Cdfs,
@@ -39188,12 +39243,13 @@ fn decode_inter_block(
3918839243 if idx == 0 {
3918939244 first_tx_type = tu_tx_type;
3919039245 }
39191- // lane-av1-444-128: the per-unit chroma inheritance in
39192- // the chunk tail resolves each unit's own tx_type from
39193- // the luma leaf covering its quadrant.
39194- if side > 64 {
39195- leaf_tx_types.push((row, col, tw, th, tu_tx_type));
39196- }
39246+ // lane-av1444chr: EVERY luma leaf's coded type, at
39247+ // every block size (see the single-reference twin
39248+ // below) -- the chroma units resolve their own
39249+ // quadrant's leaf, and a leaf that coded NOTHING is
39250+ // `DctDct` exactly as libaom's `decodetxb.c:199-203`
39251+ // stamps `DCT_DCT` into that leaf's map cell.
39252+ leaf_tx_types.push((row, col, tw, th, tu_tx_type));
3919739253 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
3919839254 // lane-sb128c r1: libaom's `decode_token_recon_block`
3919939255 // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
@@ -39314,19 +39370,8 @@ fn decode_inter_block(
3931439370 // leaves are read by now).
3931539371 let unit_rel_mi =
3931639372 (unit_mi.0 - at_mi.0, unit_mi.1 - at_mi.1);
39317- let covering = leaf_tx_types
39318- .iter()
39319- .copied()
39320- // leaf (row, col) are mi but
39321- // (tw, th) are px (the rect
39322- // leaf path divides by MI too)
39323- .find(|&(lr, lc, lw, lh, _)| {
39324- lr <= unit_rel_mi.0
39325- && unit_rel_mi.0 < lr + lh / MI
39326- && lc <= unit_rel_mi.1
39327- && unit_rel_mi.1 < lc + lw / MI
39328- })
39329- .map(|(_, _, _, _, t)| t);
39373+ let covering =
39374+ covering_leaf_tx_type(&leaf_tx_types, unit_rel_mi);
3933039375 // The prediction buffer is
3933139376 // `chroma_stride`-strided (the
3933239377 // plane block's own width at
@@ -39558,6 +39603,19 @@ fn decode_inter_block(
3955839603 for cc in 0..mu_units_n {
3955939604 let cu_mi = (rmi + cr * (cu_tx / MI), cmi + cc * (cu_tx / MI));
3956039605 let cu_around = neighbours.around_mi(cu_mi, cu_tx);
39606+ // Per-quadrant inheritance, as in the
39607+ // single-reference twin: the covering luma
39608+ // leaf's OWN coded type, `DctDct` where that
39609+ // leaf coded nothing.
39610+ let cu_rel_mi = (cr * (cu_tx / MI), cc * (cu_tx / MI));
39611+ let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi)
39612+ .unwrap_or(luma_tx_type);
39613+ if covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi).is_some() {
39614+ hit!(CHROMA_QUAD_LEAF_TX_HITS);
39615+ if cu_tx_type != luma_tx_type {
39616+ hit!(CHROMA_QUAD_LEAF_TX_DIFF_HITS);
39617+ }
39618+ }
3956139619 let cu_grid = read_inter_plane(
3956239620 dec,
3956339621 cdfs,
@@ -39572,7 +39630,7 @@ fn decode_inter_block(
3957239630 cu_tx,
3957339631 base_q_idx,
3957439632 src.offset(cr * cu_tx * chroma_side + cc * cu_tx),
39575- Some(luma_tx_type),
39633+ Some(cu_tx_type),
3957639634 Some(3),
3957739635 fctx,
3957839636 )?
@@ -40928,12 +40986,19 @@ fn decode_inter_block(
4092840986 if idx == 0 {
4092940987 first_tx_type = tu_tx_type;
4093040988 }
40931- // lane-av1-444-128: the per-unit chroma inheritance in
40932- // the chunk tail resolves each unit's own tx_type from
40933- // the luma leaf covering its quadrant.
40934- if side > 64 {
40935- leaf_tx_types.push((row, col, tw, th, tu_tx_type));
40936- }
40989+ // lane-av1444chr: EVERY luma leaf's coded type, at
40990+ // every block size -- the chroma units below resolve
40991+ // their own quadrant's leaf, and at 64x64 that is
40992+ // this very loop's leaves (`av1_get_tx_type`,
40993+ // blockd.h:1287-1297, scales the CHROMA 4x4 position
40994+ // back to luma). It used to be collected only for
40995+ // `side > 64`, so the 64x64 four-unit arm below had
40996+ // nothing to resolve from and handed all four units
40997+ // the block-level (top-left leaf) type. A leaf that
40998+ // coded NOTHING is `DctDct` here exactly as libaom's
40999+ // `decodetxb.c:199-203` stamps `DCT_DCT` into that
41000+ // leaf's map cell on the `all_zero` path.
41001+ leaf_tx_types.push((row, col, tw, th, tu_tx_type));
4093741002 neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
4093841003 // lane-sb128c r1: libaom's `decode_token_recon_block`
4093941004 // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
@@ -41054,19 +41119,8 @@ fn decode_inter_block(
4105441119 // leaves are read by now).
4105541120 let unit_rel_mi =
4105641121 (unit_mi.0 - at_mi.0, unit_mi.1 - at_mi.1);
41057- let covering = leaf_tx_types
41058- .iter()
41059- .copied()
41060- // leaf (row, col) are mi but
41061- // (tw, th) are px (the rect
41062- // leaf path divides by MI too)
41063- .find(|&(lr, lc, lw, lh, _)| {
41064- lr <= unit_rel_mi.0
41065- && unit_rel_mi.0 < lr + lh / MI
41066- && lc <= unit_rel_mi.1
41067- && unit_rel_mi.1 < lc + lw / MI
41068- })
41069- .map(|(_, _, _, _, t)| t);
41122+ let covering =
41123+ covering_leaf_tx_type(&leaf_tx_types, unit_rel_mi);
4107041124 // The prediction buffer is
4107141125 // `chroma_stride`-strided (the
4107241126 // plane block's own width at
@@ -41304,6 +41358,28 @@ fn decode_inter_block(
4130441358 for cc in 0..mu_units_n {
4130541359 let cu_mi = (rmi + cr * (cu_tx / MI), cmi + cc * (cu_tx / MI));
4130641360 let cu_around = neighbours.around_mi(cu_mi, cu_tx);
41361+ // `av1_get_tx_type` (blockd.h:1287-1297): an
41362+ // inter block's chroma unit never codes a
41363+ // `tx_type`; it reads the map cell at its OWN
41364+ // position scaled back to luma
41365+ // (`blk_row << ss_y`, `blk_col << ss_x`),
41366+ // which is the coded type of the luma leaf
41367+ // covering this unit's top-left mi cell --
41368+ // `DctDct` when that leaf coded nothing
41369+ // (`decodetxb.c:199-203`). The block-level
41370+ // `luma_tx_type` is only the TOP-LEFT leaf's
41371+ // type, so handing it to all four units
41372+ // mistyped every unit sitting over a skipped
41373+ // or differently-typed luma quadrant.
41374+ let cu_rel_mi = (cr * (cu_tx / MI), cc * (cu_tx / MI));
41375+ let cu_tx_type = covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi)
41376+ .unwrap_or(luma_tx_type);
41377+ if covering_leaf_tx_type(&leaf_tx_types, cu_rel_mi).is_some() {
41378+ hit!(CHROMA_QUAD_LEAF_TX_HITS);
41379+ if cu_tx_type != luma_tx_type {
41380+ hit!(CHROMA_QUAD_LEAF_TX_DIFF_HITS);
41381+ }
41382+ }
4130741383 let cu_grid = read_inter_plane(
4130841384 dec,
4130941385 cdfs,
@@ -41318,7 +41394,7 @@ fn decode_inter_block(
4131841394 cu_tx,
4131941395 base_q_idx,
4132041396 src.offset(cr * cu_tx * chroma_side + cc * cu_tx),
41321- Some(luma_tx_type),
41397+ Some(cu_tx_type),
4132241398 Some(3),
4132341399 fctx,
4132441400 )?
crates/ec-av1/src/stream.rsmodified+102 -1
@@ -2671,7 +2671,6 @@ pub(crate) mod tests {
26712671 );
26722672 }
26732673
2674-
26752674 /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the
26762675 /// old gate `a_frame_using_quantisation_matrices_is_refused_by_name` is
26772676 /// its mirror image -- its own panic said "flip this gate to a witness"
@@ -18343,6 +18342,108 @@ pub(crate) mod tests {
1834318342 );
1834418343 }
1834518344
18345+ /// lane-av1444chr: a 4:4:4 INTER chroma unit inherits the `tx_type` of
18346+ /// the luma leaf covering its OWN quadrant, not the block-level (top-left
18347+ /// leaf) one. `av1_get_tx_type` (`blockd.h:1287-1297`) reads
18348+ /// `xd->tx_type_map` at the chroma unit's own position scaled back to
18349+ /// luma, and `read_coeffs`' `all_zero` arm stamps `DCT_DCT` into that
18350+ /// leaf's cell (`decodetxb.c:199-203`) -- so a chroma unit sitting over a
18351+ /// luma leaf that coded NOTHING must reconstruct as DCT_DCT even when the
18352+ /// block's top-left leaf is `IDTX`.
18353+ ///
18354+ /// The fixture is the report's witness pinned into `fixtures/`:
18355+ /// `testsrc2 128x128` yuv444p 4 frames, aomenc `--profile=1 --cq-level=20
18356+ /// --cpu-used=2 --sb-size=64 --min-partition-size=64
18357+ /// --max-partition-size=64 --passes=1 --end-usage=q --threads=1 --row-mt=0
18358+ /// --lag-in-frames=0 --kf-max-dist=100 --limit=4 --obu`; 27933 bytes,
18359+ /// sha256 `a06c9f7a0862252f6ab7ebdcec340d0602e730e38089365f14747db37f8e78d5`.
18360+ /// Every inter block is a whole 64x64 (min=max partition 64) whose luma
18361+ /// var-tx tree is four TX_32X32 leaves, so each block's chroma plane is
18362+ /// four TX_32X32 units -- one per leaf.
18363+ ///
18364+ /// Pre-fix, decode-order frames 1/2/3 differ from the oracle in 777/640/554
18365+ /// V samples (luma and U exact) and the per-unit type census disagrees at
18366+ /// exactly the units over the skipped leaf: V(0,32) of block mi(0,0) in
18367+ /// frame 1, V(64,96) of block mi(16,16) in every inter frame. Post-fix all
18368+ /// 136 non-empty inter units agree with the oracle's `EC_DQCOEFF` type and
18369+ /// every frame is byte-exact.
18370+ ///
18371+ /// The non-vacuity bar is the DIFFERS counter, not the route counter: a
18372+ /// route counter fires on every four-unit chroma read (96 of them here)
18373+ /// and stayed green through a no-op fix that changed zero pixels, because
18374+ /// on a block whose four leaves agree the per-quadrant resolve and the
18375+ /// block-level value are the same answer. The number that says the resolve
18376+ /// CHANGED something is 8 on this stream -- the four skipped-leaf quadrants
18377+ /// (two of them in decode-order frame 1), each resolved once per chroma
18378+ /// plane -- and it must be 0 on the 4:2:0 control below, since the arm is
18379+ /// unreachable at 4:2:0.
18380+ #[test]
18381+ fn a_pinned_444_inter_stream_chroma_units_inherit_their_own_quadrants_tx_type() {
18382+ const NAME: &str =
18383+ "a_pinned_444_inter_stream_chroma_units_inherit_their_own_quadrants_tx_type";
18384+ const FIXTURE_LEN: usize = 27933;
18385+ const FIXTURE_FNV: u64 = 0x85fa_830b_8800_90df;
18386+ let _gate_lock = lock_gate_counters();
18387+ if !have_aomenc() {
18388+ eprintln!(
18389+ "SKIP {NAME}: no aomenc/aomdec oracle at {}",
18390+ aomenc_path().display()
18391+ );
18392+ return;
18393+ }
18394+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
18395+ .join("fixtures/444_quad_leaf_tx_type.obu");
18396+ let stream = std::fs::read(&path)
18397+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
18398+ assert_eq!(stream.len(), FIXTURE_LEN, "{NAME}: fixture length moved");
18399+ assert_eq!(fnv1a64(&stream), FIXTURE_FNV, "{NAME}: fixture bytes moved");
18400+
18401+ let quad0 = crate::decode::chroma_quad_leaf_tx_hits();
18402+ let diff0 = crate::decode::chroma_quad_leaf_tx_diff_hits();
18403+ let (frames, hidden) = decode_all_frames_vs_oracle(&stream, NAME);
18404+ let quad = crate::decode::chroma_quad_leaf_tx_hits() - quad0;
18405+ let diff = crate::decode::chroma_quad_leaf_tx_diff_hits() - diff0;
18406+ assert_eq!(
18407+ frames, 4,
18408+ "{NAME}: expected 4 decode-order frames ({hidden} hidden)"
18409+ );
18410+ assert!(
18411+ quad >= 2 * diff && quad > 0,
18412+ "{NAME}: no chroma unit took its type from the covering luma leaf \
18413+ (quad {quad}, differs {diff}) -- the corrected route never ran"
18414+ );
18415+ assert!(
18416+ diff >= 2,
18417+ "{NAME}: the per-quadrant resolve never CHANGED an answer (diff {diff}; measured 4 \
18418+ on this stream, 2 of them in decode-order frame 1). A route counter alone is not a \
18419+ witness: it fires on every four-unit chroma read, including the \
18420+ blocks whose four leaves all agree -- the exact shape a no-op fix looked green on."
18421+ );
18422+ eprintln!("{NAME}: quad-resolved chroma units {quad}, of which {diff} differed");
18423+
18424+ // 4:2:0 control: the same decode, same counters, zero differences --
18425+ // the four-unit arm is the 4:4:4 (`ss 0/0`) route only.
18426+ let control = std::fs::read(
18427+ std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
18428+ .join("fixtures/av1_192x128_8bit_intra64_in_inter.obu"),
18429+ )
18430+ .unwrap_or_else(|e| panic!("{NAME}: reading the 4:2:0 control: {e}"));
18431+ let c_quad0 = crate::decode::chroma_quad_leaf_tx_hits();
18432+ let c_diff0 = crate::decode::chroma_quad_leaf_tx_diff_hits();
18433+ let c_frames = decode_stream(&control)
18434+ .unwrap_or_else(|e| panic!("{NAME}: the 4:2:0 control no longer decodes: {e}"))
18435+ .len();
18436+ let c_quad = crate::decode::chroma_quad_leaf_tx_hits() - c_quad0;
18437+ let c_diff = crate::decode::chroma_quad_leaf_tx_diff_hits() - c_diff0;
18438+ assert!(c_frames > 0, "{NAME}: the 4:2:0 control decoded no frames");
18439+ assert_eq!(
18440+ (c_quad, c_diff),
18441+ (0, 0),
18442+ "{NAME}: the 4:2:0 control fired the 4:4:4 four-unit route ({c_quad} units, {c_diff} \
18443+ differing) -- the counter is not specific to the route it claims to witness"
18444+ );
18445+ }
18446+
1834618447 /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT`
1834718448 /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r1
1834818449 /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs
lanes/av1444chr.report.mdadded+201 -0
@@ -0,0 +1,201 @@
1+# lane-av1444chr — 4:4:4 chroma per-quadrant tx_type (H2 fixed) + lossless key-frame chroma localization (H3)
2+
3+Branch `lane-av1444chr` (worktree `~/.cache/wt/av1444chr`), base `4155c7c7`.
4+Oracle `~/.cache/aom-oracle/build/{aomdec,aomenc}` (instrumented).
5+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1444chr`.
6+
7+## H2 — FIXED. Per-quadrant `tx_type` inheritance for 4:4:4 inter chroma units
8+
9+### Witness (pinned)
10+
11+`crates/ec-av1/fixtures/444_quad_leaf_tx_type.obu`, 27933 bytes,
12+sha256 `a06c9f7a0862252f6ab7ebdcec340d0602e730e38089365f14747db37f8e78d5`,
13+fnv1a64 `0x85fa830b880090df`.
14+
15+Recipe (reproduces the sha bit-for-bit on this box):
16+
17+```
18+ffmpeg -f lavfi -i "testsrc2=size=128x128:rate=25" -frames:v 4 -pix_fmt yuv444p -f yuv4mpegpipe - src.y4m
19+aomenc --codec=av1 --profile=1 --cq-level=20 --cpu-used=2 --sb-size=64 \
20+ --min-partition-size=64 --max-partition-size=64 --passes=1 --end-usage=q \
21+ --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 --obu -o w.obu src.y4m
22+```
23+
24+### The site identification Main asked for (three block-level-type sites instrumented)
25+
26+`decode_inter_block` contains TWO structurally duplicated chroma arm chains — the
27+compound branch and the single-reference branch. The charter's line number
28+(`~39591` pre-revert) is the COMPOUND copy. Instrumenting all six sites
29+(env-gated, since removed) with `mi= side= cside= ctx= blk_type= leaves=`:
30+
31+| site | hits on the witness |
32+|---|---|
33+| compound `rect` / `quad4` / `whole` | 0 / **1** / 0 |
34+| single-ref `srect` / `squad4` / `swhole` | 0 / **12** / 0 |
35+
36+So `quad4` (the 4:4:4 four-unit arm) IS the live site — but only in its
37+**single-reference** copy, 12 times (4 blocks x 3 inter frames). The compound
38+copy fires exactly once, on one block whose four leaves all agree: that is why
39+the earlier port looked like a no-op. Each dump also showed
40+`side=64 cside=64 ctx=32`, i.e. the 64x64 `chroma_side > chroma_tx` arm with
41+`chroma_tx=32` — the four-TX_32X32-per-plane shape.
42+
43+### Root (measured, not assumed)
44+
45+1. Every inter block here is a whole 64x64 (min=max partition 64) whose luma
46+ var-tx tree is four TX_32X32 leaves in raster order. `leaf_tx_types` was
47+ collected ONLY under `if side > 64`, so at 64 it was empty and the arm
48+ handed all four chroma units the block-level `luma_tx_type` = the top-left
49+ leaf's type.
50+2. Per-unit type census, ours (`EC_TRACE_UNIT`, non-empty units in decode
51+ order) vs the oracle's `EC_DQCOEFF`, paired 1:1 after skipping frame 0's
52+ 45 intra-frame units (136 inter units on each side, counts equal):
53+ **pre-fix 4 disagreements, all V plane, all where the covering luma leaf
54+ coded nothing** — V(0,32) of block mi(0,0) in frame 1, V(64,96) of block
55+ mi(16,16) in each of the three inter frames. Post-fix **136/136 agree**.
56+3. Our own `EC_TRACE_TXTYPE` shows the covering leaf of exactly those quadrants
57+ returning `DctDct` (the `all_zero` stamp, mirroring `decodetxb.c:199-203`),
58+ while the block-level type is `Idtx`. That is the whole defect: a chroma
59+ unit over a SKIPPED luma quadrant inherited the block's `IDTX` instead of
60+ the map cell's `DCT_DCT`.
61+
62+### The fix
63+
64+- `covering_leaf_tx_type(leaves, rel_mi)` — one function, extracted from the
65+ three inline copies that already existed (the 128 mu-chunk tail in both
66+ copies and the intrabc-128rect path), so there is no second convention.
67+- `leaf_tx_types.push(...)` is now unconditional in both copies (the `side > 64`
68+ gate is gone).
69+- Both four-unit arms resolve per quadrant:
70+ `covering_leaf_tx_type(&leaf_tx_types, (cr * cu_tx/MI, cc * cu_tx/MI))`
71+ with `.unwrap_or(luma_tx_type)` as the fallback for a block that coded a
72+ single luma unit (no vartx tree, so no leaves collected).
73+
74+### Bar
75+
76+- **Red-before by mutation**: reverting only the live arm's resolve
77+ (`let cu_tx_type = luma_tx_type;`) turns the new gate red with
78+ `decode-order frame 1 of 4 (4 shown, 0 hidden) differs from the oracle at
79+ byte 36635 (ours 127 vs 126), 777 bytes differ` — the report's 777 wrong V
80+ samples. Restored: green.
81+- **Identity green** (each run as a single named test, `--nocapture`, no SKIP
82+ lines): `a_lossless_444_min_partition64_inter_stream_decodes_pixel_exact`,
83+ `a_lossless_444_defaultp_inter_strip_stream_decodes_byte_exact`,
84+ `a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact`,
85+ `a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact`,
86+ `a_real_aomenc_rect_strip_palette_decodes_pixel_exact` — 5/5 ok.
87+ NOTE: the three sweep gate names in the charter
88+ (`a_real_aomenc_odd_coded_dimension_streams_decode_pixel_exact`,
89+ `a_lossless_444_10bit_inter_stream_decodes_pixel_exact`,
90+ `a_444_12bit_inter_sequence_decodes_pixel_exact`) DO NOT EXIST in this tree;
91+ the closest existing gates from each family were run instead. The 32-attempt
92+ `a_real_aomenc_inter_sequence_with_a_16_level_rect_leaf_decodes_pixel_exact`
93+ was NOT run locally (multi-encode sweep — server/Main territory).
94+- **New gate**: `stream::tests::a_pinned_444_inter_stream_chroma_units_inherit_their_own_quadrants_tx_type`
95+ (fixtures/444_quad_leaf_tx_type.obu, length + fnv pinned, oracle compare via
96+ the length-asserting `decode_all_frames_vs_oracle`, 4 frames, 0 hidden).
97+ Measured on the witness: `quad-resolved chroma units 96, of which 8 differed`
98+ — 96 = 4 blocks x 4 units x 2 planes x 3 inter frames; the 8 = the four
99+ skipped-leaf quadrants (two of them in frame 1) resolved once per plane.
100+ The gate asserts `diff >= 2` and, per Main's non-vacuity correction, uses the
101+ DIFFERS number rather than the route counter: the route counter fires on all
102+ 96 reads and stayed green through the earlier no-op port. A 4:2:0 control
103+ (`fixtures/av1_192x128_8bit_intra64_in_inter.obu`, sha256
104+ `e4cff46cb1700527c68efc866db27a2835705e949d646f73f0c9df577d594bd6`) asserts
105+ both counters stay at exactly 0.
106+
107+### Class sweep (same rule, other sites)
108+
109+- The two 128x128 mu-chunk tails and the intrabc-128rect path now call the
110+ shared helper instead of three inline copies of the same search (pure code
111+ move, no behaviour change).
112+- `read_inter_rect_chroma` (the `rect_tu || non-square chroma plane` sibling)
113+ still passes the block-level type to its units. Measured unreachable on five
114+ 4:4:4 rect-enabled recipes (testsrc2 128x128/192x128, cq 20/24/28/30/40,
115+ rect + 1to4 + tx-size-search + sb 64/128): the arm fires 13-43 times per
116+ stream but `multi` (nx*ny > 1, the only case where units could sit over
117+ different leaves) is **0 on every one**, and all five streams are
118+ pixel-exact against aomdec. Left unchanged deliberately rather than
119+ speculatively re-signaturing a shared helper; if a witness ever shows
120+ `multi` with mixed leaf types, that is where the same fix goes.
121+
122+## H3 — LOCALIZED, not fixed. Lossless 4:4:4 key-frame chroma
123+
124+### Witness used
125+
126+The charter's sha256 (`87b0d1a5…`, `--lossless=1 --tile-columns=1 --cpu-used=2`,
127+256x128 testsrc2 yuv444p) did not reproduce from the flags as given: the encode
128+is not bit-reproducible across the flag variants tried (68142 B
129+`7b8d4d44…`, 67332 B `04de36a6…`, 75378 B `fe9eab1a…` for
130+`--passes=1`/`--threads=1 --row-mt=0 --lag-in-frames=0`). I used the plain
131+`--profile=1 --lossless=1 --tile-columns=1 --cpu-used=2 --limit=6` encode
132+(68142 B, sha256 `7b8d4d442c4a847314b7bc8c26af79bae1b3e32b22b41eebef4c2dcacf895a57`),
133+which reproduces the SAME SIGNATURE: luma exact in all six frames, 59-73 wrong U
134+and 103-139 wrong V samples per frame, deltas ±1, confined to two small bands —
135+chroma (108..123, 24..31) and (236..255, 56..67) in frame 0.
136+
137+### What is measured
138+
139+1. **Not coefficients.** Every affected unit's residual is ZERO on our side
140+ (`OUR_LLCHROMA`, all 16-value grids zero for the units at x=112..124,
141+ y=24/28) and the oracle agrees: for the block covering the first band
142+ (mi(6,28), a 16x8 block at (24,112)) `EC_COEFF_STEP tag=all_zero ... =1` on
143+ all eight chroma units with empty `EC_DQCOEFF`. So the WHT is not involved
144+ and neither side codes a residual there.
145+2. **It is the intra chroma PREDICTION.** Scoped to frame 0 only (the stream
146+ cut to its first shown frame; 98304 bytes both sides, lengths asserted),
147+ `EC_PRED`/`EC_PREDOUT8` vs our `OUR_PRED` compared per unit:
148+ - U px(108,24) oracle sum 267 vs ours 245
149+ - U px(112,24) 243 vs 236, px(112,28) 1731 vs 1707
150+ - U px(116,24) 240 vs 248, px(120,24) 248 vs 251
151+ - V px(116,28), px(120,28), px(124,28)
152+ Every other unit in the window matches by sum, row0 and col0, and the LUMA
153+ of the same blocks matches exactly.
154+3. **Shape of the divergence.** In every divergent unit the TOP row agrees
155+ (`row0=[17,17,16,16]` vs oracle `17,17,16,16`) and the difference is in the
156+ left column's lower entries — e.g. px(108,24) col0 oracle `17,11,3,32` vs
157+ ours `17,11,3,29`; px(112,24) oracle `16,14,7,32` vs ours `16,14,9,24`. The
158+ first three left samples agree, the last one(s) do not.
159+4. The affected units are TU rows 2 and 3 of 4x16/16x8 chroma blocks in
160+ `decode_rect_split`'s lossless per-4x4 walk
161+ (`RECT_SPLIT_LOSSLESS_CHROMA444_HITS`): row_off 0/1 match, row_off 2/3 do
162+ not, in every block of the band.
163+
164+### Where that points, and what is still open
165+
166+The first divergent unit is the third TU row of the leftmost block of the band
167+(chroma x=108..111, y=24..31), and its only disagreeing input is the BOTTOM
168+left-edge sample — i.e. a reconstructed pixel from the block to its left at
169+(x=107, y=27). Everything above and to the left of that agrees, the residual
170+is zero, and the mode is per-block (one symbol, shared by all four TU rows).
171+So the open question is narrow and answerable with the next probe: **which
172+source our lossless 4x4 chroma walk feeds the TU rows below the first as their
173+`above`/`left` edge** — the reconstructed rows inside the block, or a stale /
174+wrongly-anchored neighbour column. Two concrete next steps, both cheap:
175+(a) dump the reconstructed left column and above row the walk hands to
176+`read_plane` for px(108,24) on both sides (`push_intra`'s edge gather is where
177+the divergence must show up), and (b) re-check the same comparison with the
178+walk's `span_x/span_y` reach for rows > 0 — the `lane-av1-llband` note in that
179+walk already records one span/step bug at 4:4:4 (the 8-px 4:2:0 step), so a
180+second, row-dependent one in the same walk is the most likely home.
181+
182+Not fixed, deliberately: the root is not bounded to a named line yet, and
183+guessing would have burned the lane's remaining budget without a measurement.
184+
185+### Rung gaps found (worth a follow-up lane, not fixed here)
186+
187+- Our `OUR_PRED` rung (decode.rs ~19390 / ~19530) carries no PLANE field —
188+ `PlaneBuf::reconstruct*` does not know it — so a per-unit prediction diff
189+ has to disambiguate U from V by value matching. The oracle's `EC_PREDOUT8`
190+ has the same gap the other way: it prints `sum/row0/col0` but NOT the mode for
191+ non-directional 8-bit units (`EC_PREDND` prints the mode but is HBD-only), so
192+ a directional/non-directional disagreement is currently only inferable.
193+- A temporary plane-tagged `OUR_MODE` rung in `read_plane` was used for this
194+ analysis and removed before the commit; it is a 6-line addition worth landing
195+ in a follow-up.
196+
197+## Not run here (Main's validation)
198+
199+Full suite, the 32-attempt `…16_level_rect_leaf…` sweep, the 4:2:0/10-bit/12-bit
200+sweep families, and the server stages. Local runs were single named tests only, per
201+the lane's local-scope rule.