forge
Explore
Log in

Don't you dare go Hollow

Merge commit '75b3a1d' into lane-midcut

Browse files at this commit

4516c32ab9ca8e52c48c3e5f62124081d48d052aAhmet Kaan GümüşParent: a0c69513e2b507
crates/ec-av1/examples/decode_probe.rsmodified+4 -0
@@ -79,6 +79,10 @@ fn main() {
79 println!(79 println!(
80 "rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}"80 "rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}"
81 );81 );
82+ // lane-inter128intra r1: the 128 root's HORZ/VERT half coded INTRA in
83+ // an INTER frame -- the arm this round implemented.
84+ let i128 = ec_av1::stream::intra128_in_inter_counters();
85+ println!("intra128_in_inter: 128x64={} 64x128={}", i128[0], i128[1]);
82 let sb = ec_av1::stream::sb128_rect_counters();86 let sb = ec_av1::stream::sb128_rect_counters();
83 println!(87 println!(
84 "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}",88 "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}",
crates/ec-av1/src/decode.rsmodified+286 -16
@@ -5428,14 +5428,14 @@ impl Neighbours {
5428 left_coded |= left.level != 0;5428 left_coded |= left.level != 0;
5429 vote += dc_vote(left.dc);5429 vote += dc_vote(left.dc);
5430 }5430 }
5431- if plane == 0 && std::env::var_os("EC_DCDUMP").is_some() {5431+ if std::env::var_os("EC_DCDUMP").is_some() {
5432 let ab: Vec<String> = (0..w_mi)5432 let ab: Vec<String> = (0..w_mi)
5433- .map(|k| format!("{:?}/{}", self.above[mi_c + k][0].dc, self.above[mi_c + k][0].level))5433+ .map(|k| format!("{:?}/{}", self.above[mi_c + k][plane].dc, self.above[mi_c + k][plane].level))
5434 .collect();5434 .collect();
5435 let lf: Vec<String> = (0..h_mi)5435 let lf: Vec<String> = (0..h_mi)
5436- .map(|k| format!("{:?}/{}", self.left[mi_r + k][0].dc, self.left[mi_r + k][0].level))5436+ .map(|k| format!("{:?}/{}", self.left[mi_r + k][plane].dc, self.left[mi_r + k][plane].level))
5437 .collect();5437 .collect();
5438- eprintln!("EC_DCDUMP mi=({mi_r},{mi_c}) wh=({w},{h}) vote={vote} above=[{}] left=[{}]", ab.join(","), lf.join(","));5438+ eprintln!("EC_DCDUMP mi=({mi_r},{mi_c}) plane={plane} wh=({w},{h}) vote={vote} above=[{}] left=[{}]", ab.join(","), lf.join(","));
5439 }5439 }
5440 (above_coded, left_coded, vote)5440 (above_coded, left_coded, vote)
5441 })5441 })
@@ -7466,6 +7466,56 @@ fn decode_intra_rect_in_inter(
7466 });7466 });
7467 return Ok(());7467 return Ok(());
7468 }7468 }
7469+ // lane-inter128intra r1: the 128 superblock's PARTITION_HORZ/VERT half
7470+ // coded INTRA inside an inter frame. `size_group_lookup` (common_data.h:61)
7471+ // puts BLOCK_128X64/64X128/128X128 in group 3 and
7472+ // `max_txsize_rect_lookup` caps them at TX_64X64, i.e. the same
7473+ // `tx_size_cat3` row [`decode_block_128rect`] already reads -- so the whole
7474+ // block decodes through the very body the KEY FRAME path proves for this
7475+ // shape (square 64x64 luma units, one TX_32X32 chroma unit per 64x64 mu
7476+ // chunk on the offset-10 txb_skip rows, per-TU prediction, the mu-chunk
7477+ // `Reach` rule and the frame-edge write clip). The only inter-frame
7478+ // differences live inside that body: the mode-info read
7479+ // ([`INTRA_IN_INTER_MODE`] -> `y_mode[3]` plus the `skip` this caller
7480+ // already read), the `tx_depth` context (the real TXFM_CONTEXT bands) and
7481+ // the `set_txfm_ctxs` publication. CfL (>32), filter intra (>32) and
7482+ // palette (>64) do not exist at this size and are refused by name there.
7483+ // lane-inter128intra r1: OPT-IN ONLY (`EC_INTRA128_IN_INTER=1`) until a
7484+ // gate exists. The body below is believed right (it is the key frame's own
7485+ // proven body plus the three inter-frame differences), but the three 1080p
7486+ // cuts that reach this shape reach it AFTER a pre-existing desync (see the
7487+ // lane report: their frame 2 diverges from aomdec inside the superblock at
7488+ // mi(0,320), long before mi(128,416)), and no aomenc recipe found so far
7489+ // emits a 128-root HORZ/VERT half coded intra in an inter frame -- so
7490+ // nothing can currently prove this arm. A refusal is lifted only with a
7491+ // gate (COMMON), so the default path still refuses by name below.
7492+ if bw.max(bh) == 128 && std::env::var_os("EC_INTRA128_IN_INTER").is_some() {
7493+ if allow_screen_content_tools {
7494+ return Err(unsupported(
7495+ "a HORZ/VERT intra strip in a screen-content frame (palette syntax \
7496+ is consumed for square blocks only)",
7497+ ));
7498+ }
7499+ INTRA_IN_INTER_MODE.with(|c| c.set(Some((3, skip))));
7500+ let res = decode_block_128rect(
7501+ dec,
7502+ cdfs,
7503+ neighbours,
7504+ (r, c),
7505+ bw,
7506+ bh,
7507+ y,
7508+ u,
7509+ v,
7510+ base_q_idx,
7511+ ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get),
7512+ allow_screen_content_tools,
7513+ TX_SELECT_INTER.with(std::cell::Cell::get),
7514+ REDUCED_TX_SET_INTER.with(std::cell::Cell::get),
7515+ );
7516+ INTRA_IN_INTER_MODE.with(|c| c.set(None));
7517+ return res;
7518+ }
7469 let (size_group, tx_cat) = match (bw.min(bh), bw.max(bh)) {7519 let (size_group, tx_cat) = match (bw.min(bh), bw.max(bh)) {
7470 (8, 16) => (1usize, 1usize),7520 (8, 16) => (1usize, 1usize),
7471 (16, 32) => (2, 2),7521 (16, 32) => (2, 2),
@@ -7570,6 +7620,16 @@ fn decode_intra_rect_in_inter(
7570 return Ok(());7620 return Ok(());
7571 }7621 }
7572 let mode = dec.symbol(&mut cdfs.y_mode[size_group]);7622 let mode = dec.symbol(&mut cdfs.y_mode[size_group]);
7623+ // lane-t900 r1: this arm read six mode symbols with no ladder rung of its
7624+ // own, so a cross-decoder bisection could only see the block's first
7625+ // coefficient. Same names/format as [`read_tx_size`]'s rung.
7626+ let step_trace = std::env::var_os("EC_TRACE_MODE_STEP").is_some();
7627+ if step_trace {
7628+ eprintln!(
7629+ "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=y_mode val={mode} grp={size_group} rng={}",
7630+ dec.debug_state().0
7631+ );
7632+ }
7573 if mode >= 13 {7633 if mode >= 13 {
7574 return Err(unsupported(7634 return Err(unsupported(
7575 "an intra mode this decoder does not code (round 2)",7635 "an intra mode this decoder does not code (round 2)",
@@ -7595,6 +7655,13 @@ fn decode_intra_rect_in_inter(
7595 } else {7655 } else {
7596 dec.symbol(&mut cdfs.uv_mode_no_cfl[mode])7656 dec.symbol(&mut cdfs.uv_mode_no_cfl[mode])
7597 };7657 };
7658+ if step_trace {
7659+ eprintln!(
7660+ "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=uv_mode val={uv_mode} cfl={} rng={}",
7661+ u8::from(cfl_allowed),
7662+ dec.debug_state().0
7663+ );
7664+ }
7598 if (9..=12).contains(&uv_mode) {7665 if (9..=12).contains(&uv_mode) {
7599 SMOOTH_UV_HITS.with(|h| h.set(h.get() + 1));7666 SMOOTH_UV_HITS.with(|h| h.set(h.get() + 1));
7600 }7667 }
@@ -7652,7 +7719,7 @@ fn decode_intra_rect_in_inter(
7652 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]),7719 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]),
7653 _ => dec.symbol(&mut cdfs.tx_size_cat3[ctx]),7720 _ => dec.symbol(&mut cdfs.tx_size_cat3[ctx]),
7654 };7721 };
7655- if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {7722+ if step_trace {
7656 eprintln!(7723 eprintln!(
7657 "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat={tx_cat} rng={}",7724 "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat={tx_cat} rng={}",
7658 dec.debug_state().07725 dec.debug_state().0
@@ -7831,8 +7898,26 @@ fn decode_block_rect(
7831 // pinned HORZ quadrant were wrong from their very first pixel, and why our7898 // pinned HORZ quadrant were wrong from their very first pixel, and why our
7832 // range after the read equalled the oracle's range for the whole block.7899 // range after the read equalled the oracle's range for the whole block.
7833 let depth = if tx_select {7900 let depth = if tx_select {
7834- let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh);7901+ // lane-t900 r2: on an INTER frame `get_tx_size_context` reads the real
7835- dec.symbol(&mut cdfs.tx_size_cat2[ctx])7902+ // `TXFM_CONTEXT` bands ([`tx_size_context_txfm_rect`], what the 2:1 and
7903+ // the 16x4 intra-in-inter strips already do); the key frame's
7904+ // deblock-grid approximation is only right where those bands were never
7905+ // written. Measured on the 10-bit 1920x792 128-superblock stream,
7906+ // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read
7907+ // `tx_size_cat2` row 1 where libaom reads row 2.
7908+ let ctx = if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() {
7909+ tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh)
7910+ } else {
7911+ tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh)
7912+ };
7913+ let d = dec.symbol(&mut cdfs.tx_size_cat2[ctx]);
7914+ if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
7915+ eprintln!(
7916+ "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat=2 rng={}",
7917+ dec.debug_state().0
7918+ );
7919+ }
7920+ d
7836 } else {7921 } else {
7837 07922 0
7838 };7923 };
@@ -8315,7 +8400,13 @@ fn decode_leaf_rect(
8315 // a constant `false`.8400 // a constant `false`.
8316 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c);8401 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c);
8317 let depth = if tx_select {8402 let depth = if tx_select {
8318- let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh);8403+ // lane-t900 r2 (sibling sweep): the in-inter `TXFM_CONTEXT` band read
8404+ // every other rect reader now does -- a no-op on a key frame.
8405+ let ctx = if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() {
8406+ tx_size_context_txfm_rect(neighbours, leaf_mi, bw, bh)
8407+ } else {
8408+ tx_size_context_rect(neighbours, leaf_mi, bw, bh)
8409+ };
8319 // lane-rectsplitx r1: `bsize_to_tx_size_cat` (libaom `blockd.h`,8410 // lane-rectsplitx r1: `bsize_to_tx_size_cat` (libaom `blockd.h`,
8320 // `bsize_to_tx_size_depth_table`) is 2 for BLOCK_16X8/BLOCK_8X16, so8411 // `bsize_to_tx_size_depth_table`) is 2 for BLOCK_16X8/BLOCK_8X16, so
8321 // the category is 1 -- NOT the 2 the 32x16 strips read. Same symbol8412 // the category is 1 -- NOT the 2 the 32x16 strips read. Same symbol
@@ -8647,11 +8738,37 @@ fn decode_block_rect4(
8647 uv_mode8738 uv_mode
8648 };8739 };
8649 let depth = if tx_select {8740 let depth = if tx_select {
8650- let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh);8741+ // lane-t900 r2: on an INTER frame `get_tx_size_context` reads the real
8651- dec.symbol(&mut cdfs.tx_size_cat2[ctx])8742+ // `TXFM_CONTEXT` bands ([`tx_size_context_txfm_rect`], what the 2:1 and
8743+ // the 16x4 intra-in-inter strips already do); the key frame's
8744+ // deblock-grid approximation is only right where those bands were never
8745+ // written. Measured on the 10-bit 1920x792 128-superblock stream,
8746+ // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read
8747+ // `tx_size_cat2` row 1 where libaom reads row 2.
8748+ let ctx = if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() {
8749+ tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh)
8750+ } else {
8751+ tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh)
8752+ };
8753+ let d = dec.symbol(&mut cdfs.tx_size_cat2[ctx]);
8754+ if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
8755+ eprintln!(
8756+ "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat=2 rng={}",
8757+ dec.debug_state().0
8758+ );
8759+ }
8760+ d
8652 } else {8761 } else {
8653 08762 0
8654 };8763 };
8764+ // lane-t900 r1: this strip's own `set_txfm_ctxs` when it is an intra
8765+ // block of an INTER frame -- see [`publish_txfm_bands_if_in_inter`].
8766+ publish_txfm_bands_if_in_inter(
8767+ neighbours,
8768+ (mi_r, mi_c),
8769+ depth_to_tx_wh(bw, bh, depth),
8770+ (bw, bh),
8771+ );
8655 if depth != 0 {8772 if depth != 0 {
8656 // lane-rectsplitx r1: the per-transform-unit walk, at this strip's8773 // lane-rectsplitx r1: the per-transform-unit walk, at this strip's
8657 // real mi position (strips 1 and 3 of a HORZ_4 start 8 px into a8774 // real mi position (strips 1 and 3 of a HORZ_4 start 8 px into a
@@ -9157,7 +9274,16 @@ fn decode_rect4_16_strip(
9157 } else {9274 } else {
9158 tx_size_context_rect(neighbours, lmi, bw, bh)9275 tx_size_context_rect(neighbours, lmi, bw, bh)
9159 };9276 };
9160- dec.symbol(&mut cdfs.tx_size_cat1[ctx])9277+ let d = dec.symbol(&mut cdfs.tx_size_cat1[ctx]);
9278+ if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
9279+ eprintln!(
9280+ "EC_ISTEP mi_row={} mi_col={} name=tx_depth val={d} ctx={ctx} cat=1 rng={}",
9281+ lmi.0,
9282+ lmi.1,
9283+ dec.debug_state().0
9284+ );
9285+ }
9286+ d
9161 } else {9287 } else {
9162 09288 0
9163 };9289 };
@@ -9634,7 +9760,18 @@ fn decode_block_rect64(
9634 };9760 };
9635 let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));9761 let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));
9636 let depth = if tx_select {9762 let depth = if tx_select {
9637- let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh);9763+ // lane-t900 r2: on an INTER frame `get_tx_size_context` reads the real
9764+ // `TXFM_CONTEXT` bands ([`tx_size_context_txfm_rect`], what the 2:1 and
9765+ // the 16x4 intra-in-inter strips already do); the key frame's
9766+ // deblock-grid approximation is only right where those bands were never
9767+ // written. Measured on the 10-bit 1920x792 128-superblock stream,
9768+ // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read
9769+ // `tx_size_cat2` row 1 where libaom reads row 2.
9770+ let ctx = if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() {
9771+ tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh)
9772+ } else {
9773+ tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh)
9774+ };
9638 // lane-rectsplit r1: `bsize_to_tx_size_cat` (libaom `decodemv.c`)9775 // lane-rectsplit r1: `bsize_to_tx_size_cat` (libaom `decodemv.c`)
9639 // counts `sub_tx_size_map` steps from the block's own max rect9776 // counts `sub_tx_size_map` steps from the block's own max rect
9640 // transform down to TX_4X4, minus one -- BLOCK_64X32's chain9777 // transform down to TX_4X4, minus one -- BLOCK_64X32's chain
@@ -9642,10 +9779,25 @@ fn decode_block_rect64(
9642 // steps, so this level's category is 3 (the same one a 64x64 square9779 // steps, so this level's category is 3 (the same one a 64x64 square
9643 // block uses), not the 2 a 32x16 strip uses. Reading the cat-2 CDF9780 // block uses), not the 2 a 32x16 strip uses. Reading the cat-2 CDF
9644 // here was a wrong-table read of a real symbol.9781 // here was a wrong-table read of a real symbol.
9645- dec.symbol(&mut cdfs.tx_size_cat3[ctx])9782+ let d = dec.symbol(&mut cdfs.tx_size_cat3[ctx]);
9783+ if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
9784+ eprintln!(
9785+ "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat=3 rng={}",
9786+ dec.debug_state().0
9787+ );
9788+ }
9789+ d
9646 } else {9790 } else {
9647 09791 0
9648 };9792 };
9793+ // lane-t900 r1: this strip's own `set_txfm_ctxs` when it is an intra
9794+ // block of an INTER frame -- see [`publish_txfm_bands_if_in_inter`].
9795+ publish_txfm_bands_if_in_inter(
9796+ neighbours,
9797+ (mi_r, mi_c),
9798+ depth_to_tx_wh(bw, bh, depth),
9799+ (bw, bh),
9800+ );
9649 if depth != 0 {9801 if depth != 0 {
9650 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));9802 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
9651 // lane-rectsplit r1/r4: the superblock-level strip splits its9803 // lane-rectsplit r1/r4: the superblock-level strip splits its
@@ -11657,6 +11809,15 @@ thread_local! {
11657 /// Those blocks by resolved intra `tx_depth` (0 = TX_64X64 units,11809 /// Those blocks by resolved intra `tx_depth` (0 = TX_64X64 units,
11658 /// 1 = TX_32X32, 2 = TX_16X16) -- proof the depth symbol is really read.11810 /// 1 = TX_32X32, 2 = TX_16X16) -- proof the depth symbol is really read.
11659 pub(crate) static INTRA_SB128_DEPTH_HITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) };11811 pub(crate) static INTRA_SB128_DEPTH_HITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) };
11812+ /// lane-inter128intra r1: the same shapes decoded on the INTER block path
11813+ /// (an intra-coded PARTITION_HORZ/VERT half of a 128 superblock inside an
11814+ /// inter frame) -- (128x64, 64x128).
11815+ pub(crate) static INTRA128_IN_INTER_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
11816+}
11817+
11818+/// [`INTRA128_IN_INTER_HITS`], for a gate's own before/after delta.
11819+pub(crate) fn intra128_in_inter_hits() -> [usize; 2] {
11820+ INTRA128_IN_INTER_HITS.with(std::cell::Cell::get)
11660 }11821 }
11661 11822
11662 /// [`INTRA_SB128_HORZ_HITS`] / [`INTRA_SB128_VERT_HITS`] /11823 /// [`INTRA_SB128_HORZ_HITS`] / [`INTRA_SB128_VERT_HITS`] /
@@ -11748,8 +11909,17 @@ fn decode_block_128rect(
11748 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c);11909 let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c);
11749 // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or11910 // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or
11750 // not. `bsize_to_tx_size_cat(BLOCK_128X64)` is 3 (see this fn's doc).11911 // not. `bsize_to_tx_size_cat(BLOCK_128X64)` is 3 (see this fn's doc).
11912+ let in_inter = INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some();
11751 let depth = if tx_select {11913 let depth = if tx_select {
11752- let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh);11914+ // lane-inter128intra r1: on an INTER frame `get_tx_size_context` reads
11915+ // the real `TXFM_CONTEXT` bands, and compares them against
11916+ // `tx_size_wide/high[max_txsize_rect_lookup[bsize]]` -- TX_64X64 for
11917+ // every 128-axis block, hence the `min(64)`.
11918+ let ctx = if in_inter {
11919+ tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw.min(64), bh.min(64))
11920+ } else {
11921+ tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh)
11922+ };
11753 dec.symbol(&mut cdfs.tx_size_cat3[ctx])11923 dec.symbol(&mut cdfs.tx_size_cat3[ctx])
11754 } else {11924 } else {
11755 011925 0
@@ -11941,7 +12111,25 @@ fn decode_block_128rect(
11941 logical_tx as u8,12111 logical_tx as u8,
11942 0,12112 0,
11943 );12113 );
11944- if bw > bh {12114+ if in_inter {
12115+ // `set_txfm_ctxs(tx_size, n4_w, n4_h, skip && is_inter, xd)`
12116+ // (libaom `decodeframe.c` `decode_block`) runs for EVERY block of an
12117+ // inter frame, intra ones included: an intra block stamps its
12118+ // TRANSFORM size over its own footprint in both TXFM_CONTEXT bands.
12119+ // A key frame has no var-tx tree and its readers use the deblock grid,
12120+ // so this is the inter path's alone.
12121+ txfm_partition_update_rect(
12122+ neighbours,
12123+ (mi_r, mi_c),
12124+ (logical_tx, logical_tx),
12125+ (bw, bh),
12126+ );
12127+ INTRA128_IN_INTER_HITS.with(|c| {
12128+ let mut h = c.get();
12129+ h[usize::from(bw < bh)] += 1;
12130+ c.set(h);
12131+ });
12132+ } else if bw > bh {
11945 INTRA_SB128_HORZ_HITS.with(|c| c.set(c.get() + 1));12133 INTRA_SB128_HORZ_HITS.with(|c| c.set(c.get() + 1));
11946 } else {12134 } else {
11947 INTRA_SB128_VERT_HITS.with(|c| c.set(c.get() + 1));12135 INTRA_SB128_VERT_HITS.with(|c| c.set(c.get() + 1));
@@ -12958,7 +13146,13 @@ fn decode_leaf_rect8(
12958 // and desynced the tile at the very first rect leaf (class13146 // and desynced the tile at the very first rect leaf (class
12959 // `symbol-consumption-gap`).13147 // `symbol-consumption-gap`).
12960 let depth = if tx_select {13148 let depth = if tx_select {
12961- let ctx = tx_size_context_rect(neighbours, lmi, bw, bh);13149+ // lane-t900 r2 (sibling sweep): the in-inter `TXFM_CONTEXT` band
13150+ // read every other rect reader now does -- a no-op on a key frame.
13151+ let ctx = if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() {
13152+ tx_size_context_txfm_rect(neighbours, lmi, bw, bh)
13153+ } else {
13154+ tx_size_context_rect(neighbours, lmi, bw, bh)
13155+ };
12962 dec.symbol(&mut cdfs.tx_size_cat0[ctx])13156 dec.symbol(&mut cdfs.tx_size_cat0[ctx])
12963 } else {13157 } else {
12964 013158 0
@@ -13673,6 +13867,46 @@ fn txfm_partition_update(
13673 /// [`txfm_partition_update`] for a rectangular transform (lane-inter4 r2):13867 /// [`txfm_partition_update`] for a rectangular transform (lane-inter4 r2):
13674 /// the left column records `tx_size_high` over the parent's own height and13868 /// the left column records `tx_size_high` over the parent's own height and
13675 /// the above row records `tx_size_wide` over its width.13869 /// the above row records `tx_size_wide` over its width.
13870+/// libaom `set_txfm_ctxs` + `txfm_partition_update` (`decodeframe.c`, end of
13871+/// `decode_token_recon_block`): EVERY block of an inter frame publishes its
13872+/// TRANSFORM size into both `TXFM_CONTEXT` bands, intra blocks included. The
13873+/// key frame writes neither (its readers use the deblock grid), so the
13874+/// key-frame bodies reused by [`decode_intra_rect_in_inter`] have to do it
13875+/// themselves when they run inside an inter frame. The 2:1 and 16x4 arms do it
13876+/// at the call site (the transform size comes back to them); the 1:4 arms
13877+/// ([`decode_block_rect4`] / [`decode_block_rect64`]) keep their size inside,
13878+/// so they call this where their own depth resolves. A no-op on a key frame
13879+/// ([`INTRA_IN_INTER_MODE`] unset), where those bands are not read at all.
13880+///
13881+/// lane-t900 r1 root cause: the HORZ_4 32x8 intra strip at mi(0,312) of an
13882+/// inter frame left `left_txfm[0]` at a stale 32 where libaom's own
13883+/// `set_txfm_ctxs` writes 8, so the intra 8x16 block at mi(0,320) read
13884+/// `tx_size_cat1` row 1 instead of row 0 -- same depth VALUE, different CDF,
13885+/// range 39156 where the reference has 54736 (class tx-grid-published-block-side
13886+/// / early-return-skips-tail).
13887+fn publish_txfm_bands_if_in_inter(
13888+ n: &mut Neighbours,
13889+ at_mi: (usize, usize),
13890+ (tx_w, tx_h): (usize, usize),
13891+ (bw, bh): (usize, usize),
13892+) {
13893+ if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_none() {
13894+ return;
13895+ }
13896+ let (mi_r, mi_c) = at_mi;
13897+ txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh));
13898+ for i in 0..bw / MI {
13899+ if let Some(cell) = n.above_txfm.get_mut(mi_c + i) {
13900+ *cell = tx_w as u8;
13901+ }
13902+ }
13903+ for i in 0..bh / MI {
13904+ if let Some(cell) = n.left_txfm.get_mut(mi_r + i) {
13905+ *cell = tx_h as u8;
13906+ }
13907+ }
13908+}
13909+
13676 fn txfm_partition_update_rect(13910 fn txfm_partition_update_rect(
13677 n: &mut Neighbours,13911 n: &mut Neighbours,
13678 (mi_r, mi_c): (usize, usize),13912 (mi_r, mi_c): (usize, usize),
@@ -22761,6 +22995,28 @@ fn decode_inter_block(
22761 } else {22995 } else {
22762 Vec::new()22996 Vec::new()
22763 };22997 };
22998+ // libaom `av1_reset_entropy_context` / `av1_set_entropy_contexts`:
22999+ // `nplanes = 1 + (num_planes - 1) * xd->is_chroma_ref` -- a block that is
23000+ // NOT the chroma reference of its 4:2:0 pair codes no chroma transform at
23001+ // all, so it leaves its neighbours' CHROMA coefficient contexts exactly as
23002+ // it found them. `record_rect_mi`/`record_split_luma_rect_mi` below write
23003+ // all three planes unconditionally, and for such a strip the chroma grids
23004+ // are all-zero (see the `!has_chroma` arm above) -- that wiped the real
23005+ // left-neighbour chroma state, so the PAIR's own `all_zero` then read
23006+ // `txb_skip_ctx` one row low (lane-t900 r3, 10-bit 1920x792 stream,
23007+ // mi(40,220): base 1 where libaom gathers 2). Snapshot and restore is
23008+ // equivalent to not writing them, without threading a flag through both
23009+ // recorders.
23010+ let saved_chroma_ctx = (!has_chroma).then(|| {
23011+ let (w_mi, h_mi) = (write_w / MI, write_h / MI);
23012+ let left: Vec<[Neighbour; 2]> = (0..h_mi)
23013+ .filter_map(|k| neighbours.left.get(at.0 + k).map(|s| [s[1], s[2]]))
23014+ .collect();
23015+ let above: Vec<[Neighbour; 2]> = (0..w_mi)
23016+ .filter_map(|k| neighbours.above.get(at.1 + k).map(|s| [s[1], s[2]]))
23017+ .collect();
23018+ (left, above)
23019+ });
22764 if vartx_leaves.is_some() {23020 if vartx_leaves.is_some() {
22765 // Plane 0 is already correct per transform unit23021 // Plane 0 is already correct per transform unit
22766 // ([`Neighbours::record_mi_luma`] above); this writes everything else23022 // ([`Neighbours::record_mi_luma`] above); this writes everything else
@@ -22794,6 +23050,20 @@ fn decode_inter_block(
22794 &[luma_grid, u_grid, v_grid],23050 &[luma_grid, u_grid, v_grid],
22795 );23051 );
22796 }23052 }
23053+ if let Some((left, above)) = saved_chroma_ctx {
23054+ for (k, v) in left.into_iter().enumerate() {
23055+ if let Some(slot) = neighbours.left.get_mut(at.0 + k) {
23056+ slot[1] = v[0];
23057+ slot[2] = v[1];
23058+ }
23059+ }
23060+ for (k, v) in above.into_iter().enumerate() {
23061+ if let Some(slot) = neighbours.above.get_mut(at.1 + k) {
23062+ slot[1] = v[0];
23063+ slot[2] = v[1];
23064+ }
23065+ }
23066+ }
22797 if let Some((s, u_state, v_state)) = pair_chroma {23067 if let Some((s, u_state, v_state)) = pair_chroma {
22798 let (pw, ph) = if s.horz { (16usize, 8usize) } else { (8, 16) };23068 let (pw, ph) = if s.horz { (16usize, 8usize) } else { (8, 16) };
22799 let round_up_even = |n: usize| n.div_ceil(2) * 2;23069 let round_up_even = |n: usize| n.div_ceil(2) * 2;
crates/ec-av1/src/stream.rsmodified+6 -0
@@ -160,6 +160,12 @@ pub fn intra_sb128_counters() -> (usize, usize, [usize; 3]) {
160 crate::decode::intra_sb128_hits()160 crate::decode::intra_sb128_hits()
161 }161 }
162 162
163+/// lane-inter128intra r1: the 128 root's HORZ/VERT half coded INTRA inside an
164+/// INTER frame -- (128x64 blocks, 64x128 blocks).
165+pub fn intra128_in_inter_counters() -> [usize; 2] {
166+ crate::decode::intra128_in_inter_hits()
167+}
168+
163 /// lane-sb128c r9: the four AB shapes at the 128 root, in `PARTITION_HORZ_A`,169 /// lane-sb128c r9: the four AB shapes at the 128 root, in `PARTITION_HORZ_A`,
164 /// `_HORZ_B`, `_VERT_A`, `_VERT_B` order (key and inter tile paths share the170 /// `_HORZ_B`, `_VERT_A`, `_VERT_B` order (key and inter tile paths share the
165 /// counter -- it is bumped where the root symbol resolves).171 /// counter -- it is bumped where the root symbol resolves).
lanes/inter128intra-r1.report.mdadded+149 -0
@@ -0,0 +1,149 @@
1+# lane-inter128intra r1 -- the 128-root HORZ/VERT half coded INTRA in an inter frame
2+
3+Branch `lane-inter128intra` (base main `5dd3dcb`), commit `5c114d5`,
4+worktree `edith_codecs-inter128intra`,
5+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter128intra`.
6+
7+## Verdict up front
8+
9+The arm is IMPLEMENTED but **not gated and therefore not lifted**: it decodes
10+only under `EC_INTRA128_IN_INTER=1`, the named refusal is untouched on the
11+default path, `refusal_inventory.rs` / `gate_coverage.rs` are unchanged. Two
12+findings force that:
13+
14+1. **The charter's film premise is a downstream artifact** (class
15+ `refusal-from-own-desync`): on `t900` the 128x64 intra arrival at
16+ mi(128,416) sits *after* a pre-existing entropy desync in the same frame.
17+2. **No aomenc recipe found emits the shape**: 3 recipes x 4 cq values produced
18+ ZERO 128-root HORZ/VERT halves in an inter frame (`inter_128x64=0` on the
19+ decoder side), so there is nothing to gate on yet.
20+
21+## Measurement (step 1, before any edit)
22+
23+`EC_OBMCREC=1 decode_probe` on the three 2 s cuts of the 10-bit 1920x792
24+128-superblock stream:
25+
26+| cut | shape | mi | skip |
27+|---|---|---|---|
28+| t900 | 128x64 | (128,416) | false |
29+| t5400 | 128x64 | (192,0) | false |
30+| t8100 | 128x64 | (192,0) | false |
31+
32+EVIDENCE: ~/.cache/rectres-tmp/{t900,t5400,t8100}.obu | EC_OBMCREC=1 decode_probe per cut | 3/3 arrive as a non-skip 128x64, premise shape confirmed
33+
34+## Cross-decoder ladder -- the premise is stale
35+
36+`t900` truncated to its first 2 frames (`census6/trunc.py`,
37+`~/.cache/inter128intra-tmp/t900_2.obu`, 85285 B), ours
38+`EC_TRACE_MODE_STEP=1` vs `~/.cache/aom-oracle/build/aomdec`
39+`EC_TRACE_MODE=1 EC_TRACE_MODE_STEP=1`:
40+
41+- **Key frame exact**: the ordered `EC_IMODE mi_row/mi_col` sequence is
42+ identical for all 2704 blocks (ours has 184 extra lines, all from frame 2's
43+ intra-in-inter blocks, which aomdec does not print at all).
44+- **Frame 2 last common symbol**: `mi_row=24 mi_col=312 name=tx_depth rng=38975`
45+ -- byte-identical in both traces.
46+- **First divergence**: the very next superblock, mi(0,320) (pixel 1280,0).
47+ aomdec reads INTRA `tx_depth` for small blocks --
48+ `(0,320) val=1 ctx=0 cat=1 rng=54736`, `(0,322) rng=53468`, `(0,324)`,
49+ `(2,324)`, `(4,320)`, `(5,320)`… -- while ours reads var-tx
50+ `txfm_split_rect mi=(2,324) ctx=12 rng=53248` then
51+ `txfm_split mi=(4,324) ctx=13 rng=46998`, i.e. we take that block as INTER
52+ where libaom has intra. None of our three rng values (53248 / 46998 / 37590)
53+ occurs anywhere in the reference's frame-2 trace.
54+- mi(0,320) is decoded **hundreds of blocks before** mi(128,416) in the same
55+ frame, and main's build walks the same path (it refuses only later, at
56+ mi(128,416)) -- so the desync is PRE-EXISTING on main `5dd3dcb`, not caused by
57+ this lane, and the "128x64 intra in an inter frame" shape at that mi is what
58+ the desync produced.
59+
60+EVIDENCE: ~/.cache/inter128intra-tmp/{ours.trace,aom.trace,o.f2,a.f2} | trunc t900 to 2 frames, EC_TRACE_MODE_STEP ours vs instrumented aomdec | key frame 2704/2704 blocks identical; frame 2 diverges at SB mi(0,320), last common rng=38975 at mi(24,312)
61+
62+## What changed (all inert unless `EC_INTRA128_IN_INTER=1`)
63+
64+- `crates/ec-av1/src/decode.rs:7389` `decode_intra_rect_in_inter`: new
65+ `bw.max(bh) == 128` arm -- sets `INTRA_IN_INTER_MODE = Some((3, skip))`
66+ (`size_group_lookup` common_data.h:61 puts BLOCK_128X64/64X128/128X128 in
67+ group 3, verified in the oracle tree) and calls the key frame's own
68+ `decode_block_128rect`, whose `tx_size_cat3` row is already the category a
69+ 128-axis block reads (`max_txsize_rect_lookup` caps at TX_64X64).
70+- `crates/ec-av1/src/decode.rs:11609` `decode_block_128rect`: the `tx_depth`
71+ context comes from `tx_size_context_txfm_rect(.., bw.min(64), bh.min(64))`
72+ when the block is intra-in-inter (libaom `get_tx_size_context` compares the
73+ TXFM_CONTEXT bands against `tx_size_wide/high[max_txsize_rect_lookup[bsize]]`
74+ = 64 here), and the block publishes `set_txfm_ctxs` over its own footprint
75+ (`txfm_partition_update_rect`) -- the two inter-frame differences the key
76+ frame does not have. Key-frame behaviour is untouched (`in_inter == false`).
77+- `crates/ec-av1/src/decode.rs:11519` `INTRA128_IN_INTER_HITS` +
78+ `crates/ec-av1/src/stream.rs:156` `intra128_in_inter_counters()` +
79+ `crates/ec-av1/examples/decode_probe.rs:81` prints
80+ `intra128_in_inter: 128x64=.. 64x128=..`.
81+
82+## Recipe sweep -- aomenc never picked the shape
83+
84+`--sb-size=128 --min-partition-size=64 --enable-rect-partitions=1
85+--kf-max-dist=100 --end-usage=q --cpu-used=0 --lag-in-frames=0 --limit=6`
86+over 256x256 8-bit sources:
87+
88+| source | cq | frames | intra128_in_inter | inter_128x64 |
89+|---|---|---|---|---|
90+| full-frame temporal noise (`noise=alls=90:allf=t+u:all_seed=43`) | 32 | 6 OK | 0 | 0 |
91+| same | 55 | 6 OK | 0 | 0 |
92+| static gray + two 256x64 noise bands at y=64,192 (forces a HORZ split with one intra half) | 20 | 6 OK | 0 | 0 |
93+| same | 45 | 6 OK | 0 | 0 |
94+
95+The decoder-side `inter_128x64` counter is 0 in every arm: aomenc did not
96+choose the 128-root HORZ/VERT partition in an inter frame at all, so this is a
97+partition-choice problem, not an intra/inter one -- a gate needs either a
98+recipe that produces the partition first, or the film-prefix fixture route
99+(blocked by the desync above).
100+
101+EVIDENCE: ~/.cache/inter128intra-tmp/{g_32,g_55,h_20,h_45}.obu | aomenc 4 arms + decode_probe | 4/4 decode OK 6 frames, 128-root rect partitions 0/4
102+
103+## Film cuts (10-bit 1920x792 128-SB, 2 s each)
104+
105+| cut | default (refusal untouched) | with `EC_INTRA128_IN_INTER=1` |
106+|---|---|---|
107+| t900 | intra-coded 128x64 block on the inter block path | Golomb tail; 128x64=0 (desync kills it inside the first such block) |
108+| t5400 | intra-coded 128x64 block on the inter block path | Golomb tail; 128x64=453 64x128=20 |
109+| t6300 | Golomb tail (unchanged from main) | Golomb tail; 0 |
110+| t8100 | intra-coded 128x64 block on the inter block path | Golomb tail; 128x64=30 |
111+
112+The opt-in numbers are NOT a capability claim: every one of those blocks is
113+downstream of the same class of upstream desync proven for t900, and the
114+"Golomb tail" wall is itself a desync symptom (`refusal-hides-a-defect`).
115+
116+EVIDENCE: ~/.cache/rectres-tmp/{t900,t5400,t6300,t8100}.obu | decode_probe with and without EC_INTRA128_IN_INTER=1 | default stop strings identical to main; opt-in advances past the shape into a Golomb wall
117+
118+## Suite
119+
120+`cargo test -p ec-av1 --lib` under systemd unit
121+`inter128intra-suite-r1-1788367879` (MemoryMax=10G),
122+log `$HOME/.cache/inter128intra-suite.log`: **424 passed; 1 failed; 37 ignored** in 702 s.
123+
124+The single failure is
125+`real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal`
126+("the rectangular var-tx leaf arm never fired 32x16=0 16x32=0, 0 refusals") --
127+PRE-EXISTING and already recorded on the base of the previous lane
128+(lanes/obmcrec-r1.report.md, verified there in a detached worktree on
129+`beecb64`); the totals here are byte-identical to that round's. This lane's
130+whole diff is inert without `EC_INTRA128_IN_INTER=1`, which no test sets, so it
131+cannot move any counter. Every gate named in the charter (`sb128`,
132+`intra_rect_block`, `gathered_edge`, `refusal_inventory`, `gate_coverage`) is
133+inside those 424 passes.
134+
135+## Residue
136+
137+- fix-now (own lane, blocks this one): the frame-2 desync at SB mi(0,320) of
138+ the 2 s cut at 900 s -- last common symbol mi(24,312) `tx_depth` rng=38975,
139+ first divergence one superblock later where aomdec has intra blocks with
140+ `cat=1` at (0,320)/(0,322)/(0,324)/(2,324) and ours reads var-tx
141+ `txfm_split_rect` at (2,324). Truncated 2-frame witness pinned at
142+ `~/.cache/inter128intra-tmp/t900_2.obu`; both traces kept next to it.
143+- deferred: the gate for this arm -- needs a recipe that makes aomenc pick a
144+ 128-root HORZ/VERT partition in an INTER frame (0/4 attempts here), or a film
145+ prefix whose counter is > 0 with the stream proven exact up to it (blocked by
146+ the desync above).
147+- accepted: `128x128` NONE intra-in-inter was not swept -- it never reaches
148+ `decode_intra_rect_in_inter` (that path is entered only when
149+ `write_w != side`), so it is a different call site with its own residue.
lanes/t900-r1.handoff.mdadded+100 -0
@@ -0,0 +1,100 @@
1+# lane-t900 r1 handoff -- 1:4 intra strips in an inter frame never published their TXFM_CONTEXT bands
2+
3+Branch `lane-t900` (base main `5dd3dcb`), worktree `edith_codecs-t900`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-t900`.
5+Witness: `~/.cache/inter128intra-tmp/t900_2.obu` (2-frame cut of the 10-bit
6+1920x792 128-superblock stream at 900 s). Ladders regenerated in one round in
7+`~/.cache/t900-tmp/` (`o3.trace` ours `EC_TRACE_PART=1 EC_TRACE_MODE_STEP=1
8+EC_TRACE_MODE=1`, `aom.trace` aomdec `EC_TRACE=1 EC_TRACE_MODE=1
9+EC_TRACE_MODE_STEP=1`).
10+
11+## First diverging element -- before
12+
13+Last common symbol: `mi(24,312) tx_depth rng=38975` (filter-intra 32x32).
14+First differing element, one superblock later:
15+
16+| | ours | aomdec |
17+|---|---|---|
18+| `mi(0,320)` `tx_depth` (BLOCK_8X16, cat 1) | val=1 **ctx=1** rng=**39156** | val=1 **ctx=0** rng=**54736** |
19+
20+Same VALUE, different CDF ROW -> different range. `EC_TXCTX mi=0,320
21+own=8x16 ... left_txfm=32 left=true` -- our left TXFM band held 32 where
22+libaom's `set_txfm_ctxs` had written 8.
23+
24+## Root cause
25+
26+The block left of `mi(0,320)` is the first 32x8 strip of a `PARTITION_HORZ_4`
27+at `mi(0,312)` -- an INTRA strip inside an INTER frame, decoded through the
28+key frame's own body (`decode_block_rect4`). libaom runs `set_txfm_ctxs` +
29+`txfm_partition_update` for EVERY block of an inter frame, intra ones
30+included; the 2:1 arm and the 16x4 arm of `decode_intra_rect_in_inter` do that
31+at their call sites (the transform size comes back to them), but the **1:4
32+arms** (`decode_block_rect4` for 32x8/8x32, `decode_block_rect64` for
33+64x16/16x64) keep the size inside and published nothing, so both bands stayed
34+stale across the strip's footprint for the rest of the frame.
35+Classes: `tx-grid-published-block-side`, `early-return-skips-tail`.
36+
37+## Fix (path:line, this branch)
38+
39+- `crates/ec-av1/src/decode.rs` `publish_txfm_bands_if_in_inter()` (new, next
40+ to `txfm_partition_update_rect`): `txfm_partition_update_rect` + both
41+ `above_txfm`/`left_txfm` band writes, a no-op unless `INTRA_IN_INTER_MODE`
42+ is set (key frames unchanged, bands unread there).
43+- called right after the depth symbol resolves in `decode_block_rect4`
44+ (32x8/8x32) and in `decode_block_rect64` (64x16/16x64) -- depth 0 included,
45+ which is the measured case.
46+- three new `EC_TRACE_MODE_STEP` rungs in `decode_intra_rect_in_inter`
47+ (`y_mode`, `uv_mode`, `tx_depth` with ctx/cat): that arm read six mode
48+ symbols with no rung of its own, so a bisection could previously only see
49+ the block's first coefficient.
50+
51+## Ladder -- after
52+
53+`mi(0,320)` `tx_depth val=1 ctx=0 cat=1 rng=54736` == aomdec;
54+`mi(0,322)` `rng=53468` == aomdec; next partition `mi(0,324) bsize=6 rng=36404`
55+== aomdec. The superblock at mi(0,320) now matches element for element.
56+
57+Next difference in the deduped range ladder is at `mi(0,152)` (ours@15464 /
58+aom@19643): aomdec prints `motion_mode val=2` (WARPED_CAUSAL) + `interp` for
59+the 32x16 HORZ half, ours prints `txfm_split_rect` -- but BOTH decoders are
60+back at `rng=37626` on the next block `mi(4,152)` and at `rng=37736` for its
61+mv, so this is a RUNG-SET artifact (ours reads motion_mode without a rung),
62+not a proven divergence. Confirm with a rung before treating it as a defect.
63+
64+## State of the cut
65+
66+- default path: `decode_probe` now walks frame 2 to the known 128x64 wall --
67+ `REFUSED: an intra-coded 128x64 block on the inter block path` (that arrival
68+ is no longer downstream of a desync; the r1 report's "premise is a
69+ downstream artifact" verdict is now STALE).
70+- `EC_INTRA128_IN_INTER=1`: **`OK: 1 frames decoded, 1920x792`,
71+ `intra128_in_inter: 128x64=15`** -- the whole 2-frame cut decodes, where r1
72+ measured a Golomb-tail wall with 128x64=0.
73+
74+## Next step (in order)
75+
76+1. Pixel-compare the 2-frame cut vs ffmpeg (`EC_PROBE_OUT16`, census6/run6.sh
77+ recipe) with and without `EC_INTRA128_IN_INTER=1`.
78+2. Re-run the full 2 s cuts `~/.cache/rectres-tmp/{t900,t5400,t6300,t8100}.obu`
79+ (frames, stop string, per-frame exact).
80+3. If the firing frame is exact, pin the smallest exact prefix
81+ (census4/trunc.py) as `crates/ec-av1/fixtures/reelc_intra128_witness.obu`
82+ (`git add -f` + sha256), gate every plane / every decode-order frame with a
83+ hard counter assert, lift the refusal, drop `EC_INTRA128_IN_INTER`, update
84+ `refusal_inventory.rs` + `gate_coverage.rs`.
85+4. Full suite as a systemd unit (COMMON recipe). NOT RUN this round.
86+5. Sibling sweep owed: every other caller of `decode_block_rect4` /
87+ `decode_block_rect64` under `INTRA_IN_INTER_MODE`, and the same
88+ publication question for `decode_block_rect` (2:1 key-frame body) if it is
89+ ever reached in-inter.
90+
91+## Deviations
92+
93+- Charter forbids rebase/merge, COMMON requires rebasing onto main first: the
94+ charter wins, so this branch is still on `5dd3dcb` and does NOT carry main's
95+ `5d81a67` (vartxsplit) commits. The coordinator's note that main fixed
96+ `decode_block_rect4`'s three exits refers to the frame36 r2 work already in
97+ this base (`6202717`); that fix covers the SPLIT/return tails, not the
98+ inter-frame band publication fixed here -- verified by the measured stale
99+ `left_txfm=32`.
100+- Suite not run (coordinator instruction). `cargo check -p ec-av1` clean.
lanes/t900-r2.handoff.mdadded+136 -0
@@ -0,0 +1,136 @@
1+# lane-t900 r2 handoff -- in-inter rect tx-depth context; next wall is the chroma txb_skip ctx
2+
3+Branch `lane-t900`, worktree `edith_codecs-t900`,
4+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-t900` (a second `-t900-b` dir was
5+used for `cargo check` while the suite unit held the first).
6+
7+## STEP 1 -- merge of main `5d81a67` (commit `85ce8ff`)
8+
9+One conflict, `crates/ec-av1/src/decode.rs`, in the 2:1 intra-in-inter
10+`tx_depth` rung: HEAD's cached `step_trace` bool vs main's inline
11+`std::env::var_os("EC_TRACE_MODE_STEP")`. Resolved to HEAD's `step_trace`
12+(same condition, one env read per block instead of per symbol).
13+
14+Publication per exit: NOT one write per exit, but every write is IDENTICAL.
15+`publish_txfm_bands_if_in_inter` sits right after the depth symbol in
16+`decode_block_rect4` / `decode_block_rect64` and covers every later exit;
17+frame36's `txfm_partition_update_rect` tails sit before the split arms'
18+`return Ok(...)`. Both write `depth_to_tx_wh(bw, bh, depth)` over the same
19+(bw,bh) footprint, so the split arms write the same bytes twice -- idempotent,
20+no double-update hazard. Left as-is deliberately (removing either one loses a
21+different exit). `publish_txfm_bands_if_in_inter` itself also duplicates
22+`txfm_partition_update_rect`'s two loops with the same values; harmless.
23+
24+`cargo check -p ec-av1`: clean. Re-ladder of `t900_2.obu` after the merge:
25+`mi(0,320) tx_depth val=1 ctx=0 cat=1 rng=54736` still == aomdec, r1's fix
26+survived the merge.
27+
28+## STEP 2 -- ROOT CAUSE FOUND AND FIXED (commit after this file)
29+
30+The in-inter `tx_depth` CDF row of a 1:4 strip came from the KEY FRAME's
31+deblock-grid approximation (`tx_size_context_rect`) instead of the real
32+`TXFM_CONTEXT` bands (`tx_size_context_txfm_rect`). The 2:1 arm
33+(decode.rs:7660) and the 16x4 strip (`decode_rect4_16_strip`) already switched
34+on `INTRA_IN_INTER_MODE`; `decode_block_rect4`, `decode_block_rect64`,
35+`decode_block_rect` and (sweep) `decode_leaf_rect`, `decode_leaf_rect8` did
36+not.
37+
38+Measured on the 2-frame cut (10-bit 1920x792, 128-superblock), decode-order
39+frame 1: the 32x8 `PARTITION_HORZ_4` strip at mi(48,176) read `tx_size_cat2`
40+row 1 where libaom reads row 2 (`EC_TXCTX ... above_px=16 left_px=32 ctx=1`
41+vs aomdec `ctx=2`). Ladder before: sustained divergence from mi(48,176).
42+Ladder after: exact through mi(40,221) (`tx_depth val=0 ctx=2 cat=1
43+rng=40539` == aomdec), ~230 more oracle symbols.
44+
45+New rungs added so a ladder can see the symbol at all (this is what made r1's
46+bisection stop one block short): `EC_ISTEP ... name=tx_depth val= ctx= cat=`
47+in `decode_block_rect4` (cat 2), `decode_block_rect` (cat 2),
48+`decode_block_rect64` (cat 3), `decode_rect4_16_strip` (cat 1).
49+
50+## NEXT DIVERGENCE (exact, do not re-bisect)
51+
52+Block mi(40,222): strip 2 of a `PARTITION_VERT_4` of the 16x16 at mi(40,220)
53+(four 4x16 strips, cols 220..223; strip 0 inter, 1..3 intra-in-inter).
54+Everything through strip 1's luma TU matches. The first differing symbol is
55+strip 1's CHROMA `all_zero` (txb_skip):
56+
57+| | ours | aomdec |
58+|---|---|---|
59+| plane 1 `all_zero` (entry rng=37582) | ctx base **1** -> rng **37384** | ctx **9** (= base 2 + chroma offset 7) -> rng **51992** |
60+| plane 2 `all_zero` | ctx base 1 -> rng 36800 | ctx 9 -> rng 33312 |
61+
62+Same VALUES (1 then 0), different CDF ROW. Our chroma skip ctx is built at
63+`decode_rect4_16_strip`'s chroma call (`let skip_ctx = usize::from(around[plane].0)
64++ usize::from(around[plane].1)`, decode.rs ~9480, feeding `read_coeffs_rect`
65+with `TxbSet::ChromaRect8x4`): the base is 1 where libaom's `get_txb_ctx`
66+gathers 2. The suspect is the chroma entropy-context map an INTER neighbour
67+writes (the strip's left/above chroma neighbour here is an inter block), i.e.
68+class `new-map-ignores-tile-edge` / `context-read-from-one-cell` on the chroma
69+side -- verify with `EC_DCDUMP`/`around_mi_rect` on the pair mi, and check
70+whether the inter chroma TU path records that map at all. Reproduce:
71+
72+ systemd-run --user --scope -q -p MemoryMax=6G env EC_INTRA128_IN_INTER=1 \
73+ EC_TRACE_COEFF=1 <target>/release/examples/decode_probe \
74+ ~/.cache/inter128intra-tmp/t900_2.obu 2>&1 | grep -n 'entry=37582'
75+
76+ (oracle: `EC_TRACE_COEFF=1 ~/.cache/aom-oracle/build/aomdec --codec=av1 \
77+ -o /dev/null ~/.cache/inter128intra-tmp/t900_2.obu`, line ~475902.)
78+
79+## Film state (decode-order frame compare vs instrumented aomdec, EC_AV1_FINAL_DUMP)
80+
81+| cut | aomdec frames | ours | f0 | first differing frame |
82+|---|---|---|---|---|
83+| 2-frame cut of the 900 s cut | 2 | OK 1 shown | EXACT | 1 (1924240 B, was 2134171 B before the fix) |
84+| 2 s at 900 s | 267 | REFUSED Golomb tail after 2 | EXACT | 1 |
85+| 2 s at 5400 s | 275 | REFUSED Golomb tail after 10 | EXACT | 1 |
86+| 2 s at 6300 s | 125 | (run cut short) | EXACT | 1 |
87+
88+So the intra128 witness route is still blocked: no cut is exact through a
89+frame that fires `intra128_in_inter`, therefore NO fixture was pinned, NO
90+refusal was lifted, and `refusal_inventory.rs` / `gate_coverage.rs` are
91+untouched. `EC_INTRA128_IN_INTER` remains opt-in.
92+
93+## Suite
94+
95+Unit `t900-suite-r2-1788370358` (MemoryMax=10G), log `$HOME/.cache/t900-suite.log`,
96+was still running at the turn cap and is INCOMPLETE. What it had produced:
97+`a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus_decode_pixel_exact`
98+**FAILED** (no panic text captured yet -- the log was mid-run). That gate is
99+the prime suspect for the `decode_block_rect64` / `decode_leaf_rect*` arms of
100+the ctx switch: re-run it FIRST
101+
102+ CARGO_TARGET_DIR=$HOME/.cache/cargo-target-t900 EC_NOMEMGUARD=1 \
103+ EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib \
104+ a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus -- --nocapture
105+
106+and, if it is this lane's change, bisect the switch per reader (rect4 alone is
107+the measured one; rect64 / rect / leaf_rect / leaf_rect8 were a class sweep
108+with no measurement of their own -- reverting those four is the cheap
109+fallback). Note the sweep commit is SEPARATE from the measured rect4/rect64
110+commit for exactly that reason.
111+
112+## Next step list
113+
114+1. Re-run the failing 16x4/rect64 gate; if red from this lane, bisect the five
115+ ctx switches (rect4 is measured; the other four are unmeasured sweep).
116+2. Full suite as a systemd unit (COMMON recipe) and compare totals with
117+ 424 passed / 1 pre-existing failure / 37 ignored.
118+3. Fix the chroma txb_skip ctx above; re-run the decode-order compare
119+ (`~/.cache/t900-tmp/cmp.sh <name> <obu>`, aomdec+ours EC_AV1_FINAL_DUMP,
120+ per-frame byte diff) on `t900_2.obu` until frame 1 is exact.
121+4. Only then: pin the smallest exact firing prefix (census4/trunc.py) as
122+ `crates/ec-av1/fixtures/reelc_intra128_witness.obu` (`git add -f`, hash
123+ twice), gate every plane of every decode-order frame with a hard
124+ `intra128_in_inter` counter assert, lift the refusal, drop
125+ `EC_INTRA128_IN_INTER`, update `refusal_inventory.rs` + `gate_coverage.rs`.
126+5. Re-probe `~/.cache/reelc-0-10s.obu` (not run this round).
127+
128+## Artifacts
129+
130+- `~/.cache/t900-tmp/cmp.sh` -- decode-order frame compare (aomdec vs ours).
131+- `~/.cache/t900-tmp/{aom_full.trace,ours_full.trace}` -- mode/part ladders,
132+ same round; `{aom_coeff.trace,ours_coeff.trace}` -- `EC_TRACE_COEFF` ladders.
133+- `~/.cache/t900-tmp/cuts.log` -- the film table above.
134+- Ladder matcher: greedy in-order match on `(mi_row, mi_col, name, rng)` of
135+ `EC_ISTEP` lines with a 200-entry window -- `difflib` on the deduped rng
136+ sequence is USELESS here (our extra rungs make every hunk an insert).
lanes/t900-r3.handoff.mdadded+127 -0
@@ -0,0 +1,127 @@
1+# lane-t900 r3 handoff -- the non-chroma-reference inter block wiped its neighbours' chroma coefficient contexts
2+
3+Branch `lane-t900`, tip `f9720de` (merge of main `243f125` = `d61ac08`, then
4+the fix). Worktree `edith_codecs-t900`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-t900`
5+(a second `-t900-b` dir carried the release `decode_probe` while the gate unit
6+held the first).
7+
8+## STEP 0 -- merge of main `243f125` (commit `d61ac08`)
9+
10+Clean auto-merge, no conflicts (decode.rs + stream.rs + refusal_inventory.rs).
11+`cargo check -p ec-av1`: clean.
12+
13+Gates, unit `t900-gates-r3-1788370694`, log `$HOME/.cache/t900-gates-r3.log`,
14+filter `rect64_corner_tus hidden_arf refusal_inventory gate_coverage 1to4`:
15+**23 passed; 0 failed; 4 ignored** (122 s). Named ones:
16+`a_10bit_film_frames_with_rect64_corner_tus_decode_pixel_exact ... ok`,
17+`a_10bit_film_hidden_arf_with_split_superblock_strips_decodes_pixel_exact ... ok`,
18+every `refusal_inventory::*` and `gate_coverage::*` ok. So r2's five ctx
19+switches did NOT need bisecting -- the r2 red was the pre-rename gate, and the
20+renamed gate (rect64 asserts only) is green as merged. No revert was made.
21+
22+IMPORTANT for reproduction: main's re-added 16x4 refusal means this cut needs
23+**both** `EC_INTRA128_IN_INTER=1` and `EC_INTRA16X4_DECODE=1`; with only the
24+first, `t900_2.obu` stops at the intra 16x4/4x16-in-inter refusal.
25+
26+## ROOT CAUSE (fixed, `f9720de`)
27+
28+libaom codes no chroma transform for a block that is not the chroma reference
29+of its 4:2:0 pair -- `av1_reset_entropy_context`:
30+`nplanes = 1 + (num_planes - 1) * xd->is_chroma_ref` -- so such a block leaves
31+the above/left CHROMA entropy contexts untouched. Our INTER block reader
32+(`decode.rs`, the `record_split_luma_rect_mi` / `record_rect_mi` pair right
33+before the `pair_chroma` block, ~line 22955) wrote all three planes
34+unconditionally, and for a non-chroma-reference strip the chroma grids are the
35+all-zero ones built in the `!has_chroma` arm. So the EVEN 4x16 strip of the
36+`PARTITION_VERT_4` at mi(40,220) cleared the real left-neighbour chroma state,
37+and the PAIR's own `all_zero` then read `txb_skip_ctx` one row low.
38+
39+Measured, decode-order frame 1 of the 2-frame cut
40+`~/.cache/inter128intra-tmp/t900_2.obu` (10-bit 1920x792, 128 SB):
41+
42+| | before | after | aomdec |
43+|---|---|---|---|
44+| chroma `all_zero`, entry rng 37582 | ctx base 1 -> rng 37384 | ctx base **2** -> rng **51992** | ctx 9 (2+7) -> **51992** |
45+
46+`EC_DCDUMP` (now dumping all three planes, not plane 0 only -- without the
47+chroma cells the wipe is invisible) showed it directly: at strip 220's own
48+luma read `left[40..43][1] = Some(true)/1`; at strip 221's read the same cells
49+are `None/0`. The wiper is between them, i.e. strip 220's record.
50+
51+Fix shape: snapshot planes 1/2 of the block's left/above cells when
52+`!has_chroma` and restore them after the recorders run -- equivalent to not
53+writing them, without threading a flag through both recorders.
54+
55+Sibling sweep (class `context-read-from-one-cell` / `new-map-ignores-tile-edge`):
56+`decode_rect4_16_strip` writes chroma only under `if has_chroma`; the sub8
57+intra rect reader early-returns on `!has_chroma` before its chroma block;
58+`decode_leaf_rect8`/`decode_leaf_split4` use `record_mi_luma*` (plane 0 only).
59+The inter reader was the only unguarded site.
60+
61+## LADDER STATE -- the whole 2-frame cut is now ENTROPY-EXACT
62+
63+Deduped `(all_zero value, rng)` sequence, ours vs instrumented aomdec, both
64+frames: **15865 symbols in each, identical value and range in order, no
65+mismatch**. (Do not diff `tag=eob` across decoders: aomdec prints an eob line
66+where our `read_plane` path prints none; the first "mismatch" at index 25 is
67+that rung-set gap, not a divergence.)
68+
69+## DECODE-ORDER COMPARE (`~/.cache/t900-tmp/cmp.sh`, both under EC_AV1_FINAL_DUMP)
70+
71+`t900_2.obu`: f0 EXACT, f1 differs by **114374 bytes** (was 1924240 before
72+this fix, 2134171 before r2's). The pre-loop-filter dumps (`EC_AV1_PREFILT_DUMP16`,
73+`~/.cache/t900-tmp/d_pf/`) differ too: f0 0 px, f1 105282 px. So what remains
74+is **reconstruction, not entropy** -- Y 82345 px max |d| 111, U 15362 max 148,
75+V 15073 max 162; dominant delta +1 (43448 px), then -1 (9742).
76+
77+## NEXT STEP (exact, do not re-bisect)
78+
79+First differing block in DECODE order (superblock (0,7), x896..1023 y0..127 --
80+every earlier superblock is pixel-exact in the prefilter dump):
81+
82+* frame 1, mi(24,248) = px(992,96), `EC_PART bsize=9 value=1` (32x32
83+ PARTITION_HORZ -> two 32x16), top half `mode=13` (NEARESTMV) `ref0=5`
84+ `mv0=(-166,354)` `motion_mode=0` `interp=0`, no `tx_depth` rung => skip
85+ (pure prediction).
86+* Its 32x16 top half is off by **exactly -2 on every one of the 512 pixels**
87+ (aom - ours = -2, no dither at all); the bottom 32x16 (rows 112..127, which
88+ does carry residual) is a dithered mix of 0/-1/-2.
89+* NOTE the trace disagreement worth one check first: aomdec prints
90+ `ref1=0` (INTRA_FRAME => interintra) for this block where OUR `EC_MODE_VAL`
91+ prints `ref1=-1` (none), and our counters do report
92+ `rect_wedge ... interintra=[5,6,2,4,0,0]` (4 of them 32x16). Either our
93+ print normalises INTRA_FRAME to -1, or we are not applying interintra on
94+ this block at all -- resolve that before touching the convolve. A uniform
95+ (dither-free) offset over a whole skip block means a DC-only difference:
96+ an unapplied/extra interintra blend term or an offset in the 10-bit
97+ convolve rounding chain, NOT a filter-tap error (taps would dither).
98+* A hand-rolled 8-tap REGULAR prediction from the (exact) f0 reference at
99+ mv (-20.75, +44.25) did NOT reproduce either decoder's pixels, so the
100+ position/convention of that hand check was wrong -- do not trust it.
101+
102+Not this shape: there is NO intra 16x4/4x16 strip in superblock (0,7)
103+(`EC_INTRA16X4=1` list: nearest are mi cols 320+/172-175), and only 30 of the
104+107 strips in the frame overlap a diff at all -- the reconstruction defect is
105+NOT the 16x4 shape.
106+
107+`intra128_in_inter` is now **0** on this cut (it was 15 in r2, before the
108+chroma-ctx fix): those 128x64 intra-in-inter arrivals were desync artifacts,
109+exactly like wit16x4's phantom counters. So STEP 2 of the r3 charter (pin a
110+`reelc_intra128_witness.obu`, lift the refusal) has **no witness on this cut**
111+and must not be attempted from it. `EC_INTRA128_IN_INTER` stays opt-in;
112+`refusal_inventory.rs` / `gate_coverage.rs` untouched this round.
113+
114+## Not run this round
115+
116+Full suite (coordinator: no suite), the four 2 s cuts
117+(`~/.cache/rectres-tmp/{t900,t5400,t6300,t8100}.obu`) after the fix, and the
118+`~/.cache/reelc-0-10s.obu` re-probe.
119+
120+## Artifacts
121+
122+`~/.cache/t900-tmp/`: `cmp.sh` (now points at the `-t900-b` probe and passes
123+both env vars), `ours2.trace` (`EC_TRACE_COEFF` after the fix),
124+`ours_dc.trace` (`EC_DCDUMP`), `ours3.mode` (`EC_TRACE_MODE`/`EC_TRACE_PART`),
125+`i16.log` (`EC_INTRA16X4` strip list), `aom_coeff.trace` / `aom_full.trace`
126+(aomdec, r2, still valid -- entropy unchanged on that side),
127+`d_pf/` (prefilter dumps both decoders), `d_t900_2/` (final dumps).