forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1422llintra: 4:2:2 dc_sign vote double-count FIXED (ll422 intra control luma 75210 -> 0, W/X frame 0 byte-exact), and the vacuous 4:2:2 witness gate re-documented

Browse files at this commit

893f668315d849924917ef54232fdbbe2dc5e222Ahmet Kaan GümüşParent: 26c159d14409e1
GOAL A -- HONESTY. 1cd7c85f: the merged gate the_pinned_422_lossless_inter_chroma_panics_refuse_by_name falsely claimed a 'Golomb tail' refusal
and implied it covered the seven-site fix; it is renamed to the_pinned_422_lossless_inter_witnesses_are_present_and_refuse_by_name,
its doc now says it asserts the 4:2:2 HEADER refusal (identical on the pre-fix tree aef4fa67, so VACUOUS w.r.t. the fix) and that no
committed test can reach a 4:2:2 decode because the EC_AV1_ALLOW_422_PROBE bypass must never be committed. The non-reproducing claim is
retracted, the sibling source-scan gate gets the same 'spelling scan proves nothing about pixels' scope note, and collateral damage from
69a3a4df (which had spliced the lpf doc into the MIDDLE of the av1422warp gate's doc comment, orphaning that gate's docs) is repaired.

GOAL B -- THE FIX. a347784b, three chroma gathers (decode_rect_split lossless walk 12735, the measured fork site; read_intrabc_rect_chroma_split
17802; decode_block_rect64 tiled walk 19922). libaom's get_txb_ctx_general sums ONE dc sign vote per CHROMA CELL over txb_w_unit above /
txb_h_unit left entries -- one each for a TX_4X4 chroma unit. At ss (1,0) one chroma column spans TWO luma mi columns, so around_mi_rect
summed that column's whole-unit dc sign twice. dc_sign_ctx reads only the signum, so the doubling is invisible EXCEPT when above and left
cancel: a+l=0 (ctx 0) becomes 2a+l=+a (ctx 2). 4:2:0 and 4:4:4 are immune (square plane block, uniform scaling).

MEASURED, and RE-VERIFIED INDEPENDENTLY BY MAIN with a bypassed build of both sides on ll422_allintra.obu (oracle aomdec --rawvideo,
per-plane count): MAIN 9367642a = Y 75210 / U 38235 / V 38240; BRANCH = Y 0 / U 3126 / V 3139. W 1214609 -> 917974 luma, X 1072597 -> 864325,
both now with frame 0 BYTE-EXACT. Coefficient stream paired 311484 vs 311484 symbols with zero disagreements; oracle flip moves each count by
exactly +1.

STATED REGRESSION, kept deliberately: Y_intrabc_10b now REFUSES at frame 0 -- 'unsupported: AV1 tile (a Golomb tail longer than this decoder
reads)' (verified by Main on the branch build) -- where it used to decode 16/16 with 1227876 wrong luma samples. Isolation control: the dc
gather alone causes it, and the two defects interact (the dc gather alone is neutral-to-worse; only the pair is a large win). Kept because a
named refusal beats silently wrong pixels (the crate's own convention), because 4:2:2 is unreachable in production (header refusal) so this is
probe-only behaviour, and because the alternative leaves a diagnosed defect unfixed with W/X 19-24% worse.

NO GATE, and none is possible: 4:2:2 is refused at the sequence header and the bypass must never be committed, so no committed test can execute
these arms. Evidence is the measurement plus the isolation control -- not a source-scan substitute, which is exactly what Goal A criticises.
Regression sweep on the branch: 70 passed 0 failed across the 422/lossless/444 families; Main re-ran it on the merged tree.
crates/ec-av1/src/decode.rsmodified+165 -27
@@ -2164,6 +2164,22 @@ pub fn chroma422_sub8_hits() -> usize {
2164 CHROMA422_SUB8_HITS.with(|c| c.get())2164 CHROMA422_SUB8_HITS.with(|c| c.get())
2165 }2165 }
2166 2166
2167+// lane-av1422llintra: how many 4:2:2 LOSSLESS chroma plane blocks
2168+// (`decode_leaf8`) were walked as 4x4 units rather than as the one
2169+// `av1_get_max_uv_txsize` rect that rule only reaches OUTSIDE a lossless
2170+// frame. A 4:2:0 or 4:4:4 frame never takes the arm (its own lossless walk
2171+// was already there), so a witness gate reading 0 here proves the model
2172+// reverted to the rect unit.
2173+thread_local! {
2174+ static CHROMA422_LOSSLESS_4X4_HITS: std::cell::Cell<usize> =
2175+ const { std::cell::Cell::new(0) };
2176+}
2177+
2178+/// Current value of [`CHROMA422_LOSSLESS_4X4_HITS`].
2179+pub fn chroma422_lossless_4x4_hits() -> usize {
2180+ CHROMA422_LOSSLESS_4X4_HITS.with(|c| c.get())
2181+}
2182+
2167 // lane-av1-422sub8rect: how many PER-PIECE TX_4X4 chroma coefficient units2183 // lane-av1-422sub8rect: how many PER-PIECE TX_4X4 chroma coefficient units
2168 // the INTER sub-8x8 split4 path read on a 4:2:2 frame (ss 1,0) -- one per2184 // the INTER sub-8x8 split4 path read on a 4:2:2 frame (ss 1,0) -- one per
2169 // non-skipped odd-column piece per plane (`is_chroma_reference`'s2185 // non-skipped odd-column piece per plane (`is_chroma_reference`'s
@@ -12716,7 +12732,27 @@ fn decode_rect_split(
12716 for cu_row in 0..ch_n {12732 for cu_row in 0..ch_n {
12717 for cu_col in 0..cw_n {12733 for cu_col in 0..cw_n {
12718 let cu_mi = (mi_r + cu_row * (span_y / MI), mi_c + cu_col * (span_x / MI));12734 let cu_mi = (mi_r + cu_row * (span_y / MI), mi_c + cu_col * (span_x / MI));
12719- let cu_around = neighbours.around_mi_rect(cu_mi, span_x, span_y);12735+ // lane-av1422llintra: at ss (1, 0) one chroma column
12736+ // spans TWO luma mi columns, so the plain rect walk sums
12737+ // its whole-unit dc sign TWICE where libaom's
12738+ // `get_txb_ctx_general` reads `txb_w_unit` chroma cells
12739+ // -- one per column. `dc_sign_ctx` only sees the vote's
12740+ // SIGNUM, so a doubled above vote flips the row exactly
12741+ // when above and left cancel (a+l = 0 -> ctx 0 becomes
12742+ // 2a+l = +a). Measured on the pinned 4:2:2 all-intra
12743+ // lossless control `ll422_allintra.obu`: the V 4x4 unit
12744+ // at chroma (24, 8) of the BLOCK_32X8 at mi(2,8) --
12745+ // oracle `EC_DBGCTX above0=23 left0=13` sums to dc 0 and
12746+ // reads `dc_sign_cdf[0]`; ours summed the above column
12747+ // twice, got vote +1, and read `dc_sign_cdf[2]`, so the
12748+ // DC sign symbol came out inverted and the whole tile
12749+ // desynced from there. Identical to the guard one arm up
12750+ // at 12865.
12751+ let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
12752+ neighbours.around_mi_422_chroma(cu_mi, span_x, span_y)
12753+ } else {
12754+ neighbours.around_mi_rect(cu_mi, span_x, span_y)
12755+ };
12720 let cu_reach = tu_reach(12756 let cu_reach = tu_reach(
12721 bw,12757 bw,
12722 bh,12758 bh,
@@ -17783,7 +17819,16 @@ fn read_intrabc_rect_chroma_split(
17783 for cu_col in 0..nx {17819 for cu_col in 0..nx {
17784 let (span_x, span_y) = (uw << ss_x(fctx), uh << ss_y(fctx));17820 let (span_x, span_y) = (uw << ss_x(fctx), uh << ss_y(fctx));
17785 let cu_mi = (mi_r + cu_row * (span_y / MI), mi_c + cu_col * (span_x / MI));17821 let cu_mi = (mi_r + cu_row * (span_y / MI), mi_c + cu_col * (span_x / MI));
17786- let cu_around = neighbours.around_mi_rect(cu_mi, span_x, span_y);17822+ // lane-av1422llintra: the same ss (1, 0) above-column
17823+ // double-count as the lossless walk at 12735 -- one chroma
17824+ // column spans two luma mi columns and libaom reads one.
17825+ // Identical at 4:2:0 and 4:4:4, where the plane block is
17826+ // square.
17827+ let cu_around = if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
17828+ neighbours.around_mi_422_chroma(cu_mi, span_x, span_y)
17829+ } else {
17830+ neighbours.around_mi_rect(cu_mi, span_x, span_y)
17831+ };
17787 let (cu_x, cu_y) = (cpx + cu_col * uw, cpy + cu_row * uh);17832 let (cu_x, cu_y) = (cpx + cu_col * uw, cpy + cu_row * uh);
17788 let cu_pred = Pred::Inline(src, cside).offset(cu_row * uh * cside + cu_col * uw);17833 let cu_pred = Pred::Inline(src, cside).offset(cu_row * uh * cside + cu_col * uw);
17789 // libaom's `av1_get_tx_type` (blockd.h:1287) reads17834 // libaom's `av1_get_tx_type` (blockd.h:1287) reads
@@ -19903,7 +19948,15 @@ fn decode_block_rect64(
19903 let lsx = uw << ss_x(fctx);19948 let lsx = uw << ss_x(fctx);
19904 let lsy = uh << ss_y(fctx);19949 let lsy = uh << ss_y(fctx);
19905 let cu_mi = (mi_r + cu_row * (lsy / MI), mi_c + cu_col * (lsx / MI));19950 let cu_mi = (mi_r + cu_row * (lsy / MI), mi_c + cu_col * (lsx / MI));
19906- neighbours.around_mi_rect(cu_mi, lsx, lsy)19951+ // lane-av1422llintra: same ss (1, 0) above-column
19952+ // double-count as 12735 -- one chroma column spans two
19953+ // luma mi columns, libaom reads one. Identical number
19954+ // at 4:2:0 and 4:4:4.
19955+ if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
19956+ neighbours.around_mi_422_chroma(cu_mi, lsx, lsy)
19957+ } else {
19958+ neighbours.around_mi_rect(cu_mi, lsx, lsy)
19959+ }
19907 };19960 };
19908 let lsx = uw << ss_x(fctx);19961 let lsx = uw << ss_x(fctx);
19909 let lsy = uh << ss_y(fctx);19962 let lsy = uh << ss_y(fctx);
@@ -23889,7 +23942,11 @@ fn decode_leaf8(
23889 // unit per plane (CfL keeps its contribution, [`decode_block`]'s own23942 // unit per plane (CfL keeps its contribution, [`decode_block`]'s own
23890 // skip-arm rule); no coefficient symbol exists, so the entropy23943 // skip-arm rule); no coefficient symbol exists, so the entropy
23891 // context never enters the rect read.23944 // context never enters the rect read.
23892- if chroma_422 {23945+ // lane-av1422llintra: NOT in a LOSSLESS frame -- `av1_get_tx_size`'s
23946+ // first line returns TX_4X4 on every plane there, so the 4x8 plane
23947+ // block is two 4x4 units and the `else` arm's per-unit walk is the
23948+ // right one.
23949+ if chroma_422 && !lossless(fctx) {
23893 u_grid = leaf8_chroma422_unit(23950 u_grid = leaf8_chroma422_unit(
23894 dec,23951 dec,
23895 cdfs,23952 cdfs,
@@ -23932,24 +23989,31 @@ fn decode_leaf8(
23932 )?;23989 )?;
23933 luma_grid = Grid::Zero(64);23990 luma_grid = Grid::Zero(64);
23934 } else {23991 } else {
23935- // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster of23992+ // 4:4:4 AND 4:2:2 lossless: the leaf's chroma plane block is a
23936- // TX_4X4 units (`av1_get_tx_size`: lossless forces TX_4X4 on EVERY23993+ // raster of TX_4X4 units (`av1_get_tx_size` returns TX_4X4 for
23937- // plane), so a skipped leaf predicts per unit -- each from its own23994+ // EVERY plane of a lossless block, so `av1_get_max_uv_txsize` --
23938- // edges -- like the luma `SKIP_SPLIT_TX` loop above. CfL never fires23995+ // the TX_4X8 the 4:2:2 arm above reads -- is never reached), so a
23939- // here (`is_cfl_allowed` at lossless needs plane_bsize == 4x4; this23996+ // skipped leaf predicts per unit -- each from its own edges -- like
23940- // chroma plane block is 8x8), and intrabc/palette keep the23997+ // the luma `SKIP_SPLIT_TX` loop above. At 4:2:2 that plane block is
23941- // whole-plane-block prediction they already run. The guard also23998+ // 4x8 (`av1_ss_size_lookup[BLOCK_8X8][1][0]`), so it is one 4x4
23942- // requires `chroma_444`, so it can never reach the 4:2:2 arm above.23999+ // unit per chroma row pair. CfL never fires here (`is_cfl_allowed`
23943- let chroma_units_444 =24000+ // at lossless needs plane_bsize == BLOCK_4X4; this plane block is
23944- chroma_444 && lossless(fctx) && intrabc_bufs.is_none() && palette_uv_bufs.is_none();24001+ // 8x8 at 4:4:4 and 4x8 at 4:2:2, neither of which is BLOCK_4X4),
24002+ // and intrabc/palette keep the whole-plane-block prediction they
24003+ // already run.
24004+ let chroma_units_ll = (chroma_444 || chroma_422)
24005+ && lossless(fctx)
24006+ && intrabc_bufs.is_none()
24007+ && palette_uv_bufs.is_none();
24008+ let cu_shape: (usize, usize) = if chroma_422 { (4, 8) } else { (8, 8) };
23945 if let Some((_, ub, _)) = &intrabc_bufs {24009 if let Some((_, ub, _)) = &intrabc_bufs {
23946 set_palette_pred(ub.clone(), fctx);24010 set_palette_pred(ub.clone(), fctx);
23947 } else if let Some((ub, _)) = &palette_uv_bufs {24011 } else if let Some((ub, _)) = &palette_uv_bufs {
23948 set_palette_pred(ub.clone(), fctx);24012 set_palette_pred(ub.clone(), fctx);
23949 }24013 }
23950- if chroma_units_444 {24014+ if chroma_units_ll {
23951- for cu_row in 0..2 {24015+ for cu_row in 0..cu_shape.1 / 4 {
23952- for cu_col in 0..2 {24016+ for cu_col in 0..cu_shape.0 / 4 {
23953 let cu_reach = tu_reach(24017 let cu_reach = tu_reach(
23954 8,24018 8,
23955 8,24019 8,
@@ -24000,9 +24064,9 @@ fn decode_leaf8(
24000 } else if let Some((_, vb)) = &palette_uv_bufs {24064 } else if let Some((_, vb)) = &palette_uv_bufs {
24001 set_palette_pred(vb.clone(), fctx);24065 set_palette_pred(vb.clone(), fctx);
24002 }24066 }
24003- if chroma_units_444 {24067+ if chroma_units_ll {
24004- for cu_row in 0..2 {24068+ for cu_row in 0..cu_shape.1 / 4 {
24005- for cu_col in 0..2 {24069+ for cu_col in 0..cu_shape.0 / 4 {
24006 let cu_reach = tu_reach(24070 let cu_reach = tu_reach(
24007 8,24071 8,
24008 8,24072 8,
@@ -24333,7 +24397,7 @@ fn decode_leaf8(
24333 if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() {24397 if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() {
24334 hit!(INTRABC_TX4_CHROMA_COPY_HITS);24398 hit!(INTRABC_TX4_CHROMA_COPY_HITS);
24335 }24399 }
24336- if chroma_422 {24400+ if chroma_422 && !lossless(fctx) {
24337 // lane-av1-422d: the chroma unit does NOT follow the luma var-tx24401 // lane-av1-422d: the chroma unit does NOT follow the luma var-tx
24338 // split -- `uv_txsize` is `av1_get_max_uv_txsize` of the block,24402 // split -- `uv_txsize` is `av1_get_max_uv_txsize` of the block,
24339 // still the one 4x8 rect unit per plane at ss (1,0).24403 // still the one 4x8 rect unit per plane at ss (1,0).
@@ -24377,6 +24441,80 @@ fn decode_leaf8(
24377 smooth_neighbor_uv,24441 smooth_neighbor_uv,
24378 fctx,24442 fctx,
24379 )?;24443 )?;
24444+ } else if (chroma_444 || chroma_422) && lossless(fctx) {
24445+ // lane-av1422llintra: a LOSSLESS 4:2:2 leaf is the 4:2:2 twin of
24446+ // the 4:4:4 arm below. libaom's `av1_get_tx_size` (`blockd.h:1381`)
24447+ // returns TX_4X4 for EVERY plane of a lossless block, and its
24448+ // FIRST line is the lossless test -- so `av1_get_max_uv_txsize`
24449+ // (the `Tx_4X8` the `chroma_422` arm above reads) is never reached
24450+ // in a lossless frame. At ss (1,0) the leaf's chroma PLANE BLOCK is
24451+ // 4x8 (`av1_ss_size_lookup[BLOCK_8X8][1][0]`), so it is a
24452+ // `(4, 8)` region walked as two 4x4 units per plane, PLANE-MAJOR
24453+ // -- the same walk `read_intra_chroma_lossless` runs for whole
24454+ // blocks, at this leaf's own 4x8 plane block.
24455+ //
24456+ // MEASURED: the pinned 4:2:2 all-intra LOSSLESS control
24457+ // `ll422_allintra.obu` (43 255 B, sha256 below) against the
24458+ // instrumented `aomdec`: its block at mi(0,2) is `EC_IMODE_VAL
24459+ // mi_row=0 mi_col=2 bsize=3` (BLOCK_8X8) and the oracle's
24460+ // `EC_COEFF` units are `plane=1 row=0`, `plane=1 row=1`,
24461+ // `plane=2 row=0`, `plane=2 row=1` -- four 4x4 units, two per
24462+ // plane. This arm read ONE `TxbSet::ChromaRect8x4` 4x8 unit per
24463+ // plane instead (our `EC_PRED` trace:
24464+ // `x=4 y=0 plane=1 bw=4 bh=8 mode=1`, the first line that
24465+ // disagrees with the oracle's `EC_PREDOUT8
24466+ // plane=1 row_off=0 txw=4 txh=4` + `row_off=1 txh=4` pair), so
24467+ // the tile desynced at that block's second chroma symbol and
24468+ // every later pixel decoded from the wrong place.
24469+ //
24470+ // CfL never rides here: `is_cfl_allowed` (`cfl.h:24`) allows it in
24471+ // a lossless block only when the chroma PLANE BLOCK is
24472+ // BLOCK_4X4, and a 4:2:2 8x8 leaf's is BLOCK_4X8 -- so
24473+ // `read_intra_chroma_lossless`'s no-CfL `read_plane` is the
24474+ // correct arm for this shape too.
24475+ let (blk_w, blk_h) = if chroma_422 {
24476+ (4usize, 8usize)
24477+ } else {
24478+ (8usize, 8usize)
24479+ };
24480+ let (mut uo, mut vo) = (Vec::new(), Vec::new());
24481+ read_intra_chroma_lossless(
24482+ dec,
24483+ cdfs,
24484+ neighbours,
24485+ u,
24486+ v,
24487+ leaf_mi,
24488+ (px, py),
24489+ (cpx, cpy),
24490+ 8,
24491+ (blk_w, blk_h),
24492+ (0, 0),
24493+ (blk_w, blk_h),
24494+ blk_w,
24495+ reach,
24496+ (y.width, y.height),
24497+ mode,
24498+ uv_predict_mode,
24499+ angle_delta_uv,
24500+ palette_uv_bufs.as_ref().map(|(a, b)| (&a[..], &b[..])),
24501+ smooth_neighbor_uv,
24502+ base_q_idx,
24503+ &mut uo,
24504+ &mut vo,
24505+ fctx,
24506+ )?;
24507+ u_grid = if uo.is_empty() {
24508+ Grid::Zero(blk_w * blk_h)
24509+ } else {
24510+ Grid::Own(uo)
24511+ };
24512+ v_grid = if vo.is_empty() {
24513+ Grid::Zero(blk_w * blk_h)
24514+ } else {
24515+ Grid::Own(vo)
24516+ };
24517+ hit!(CHROMA422_LOSSLESS_4X4_HITS);
24380 } else if chroma_444 && lossless(fctx) {24518 } else if chroma_444 && lossless(fctx) {
24381 // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster24519 // 4:4:4 lossless: the leaf's chroma plane block is a 2x2 raster
24382 // of TX_4X4 units per plane, PLANE-MAJOR (`av1_get_tx_size`:24520 // of TX_4X4 units per plane, PLANE-MAJOR (`av1_get_tx_size`:
@@ -24506,12 +24644,12 @@ fn decode_leaf8(
24506 let bound_w = round_up_even(neighbours.mi_cols);24644 let bound_w = round_up_even(neighbours.mi_cols);
24507 let u_state = neighbour_state(&u_grid);24645 let u_state = neighbour_state(&u_grid);
24508 let v_state = neighbour_state(&v_grid);24646 let v_state = neighbour_state(&v_grid);
24509- // The 4:4:4 lossless walk above already stamped these bands PER UNIT24647+ // The 4:4:4 AND 4:2:2 lossless walks above already stamped these
24510- // (its raster-order last writer per cell is exactly libaom's24648+ // bands PER UNIT (their raster-order last writer per cell is exactly
24511- // per-entry last update); this whole-leaf aggregate would clobber24649+ // libaom's per-entry last update); this whole-leaf aggregate would
24512- // four distinct unit states with one, so it runs only for the shapes24650+ // clobber distinct unit states with one, so it runs only for the
24513- // whose chroma really is one unit.24651+ // shapes whose chroma really is one unit.
24514- if !(chroma_444 && lossless(fctx)) {24652+ if !((chroma_444 || chroma_422) && lossless(fctx)) {
24515 for cell in 0..side_mi {24653 for cell in 0..side_mi {
24516 if cell < side_mi.min(bound_h.saturating_sub(leaf_mi.0)) {24654 if cell < side_mi.min(bound_h.saturating_sub(leaf_mi.0)) {
24517 neighbours.left[leaf_mi.0 + cell][1] = u_state;24655 neighbours.left[leaf_mi.0 + cell][1] = u_state;
crates/ec-av1/src/stream.rsmodified+106 -87
@@ -2974,93 +2974,41 @@ pub(crate) mod tests {
2974 );2974 );
2975 }2975 }
2976 }2976 }
2977- /// lane-av1422warp: the SECOND 4:2:2 coverage witness -- the one2977+ /// lane-av1422lpf: the three 4:2:2 LOSSLESS INTER witness fixtures,
2978- /// `422_sb128_3f.obu` could not be, because that stream's inter content2978+ /// PINNED, and asserted to refuse at the SEQUENCE HEADER.
2979- /// is skip-heavy (see `lanes/av1422stripwrite.report.md`, which named a2979+ ///
2980- /// second fixture with real residuals, compound and warped motion above2980+ /// W/X/Y (`W_intrabc.obu`, `X_intrabc_tiled.obu`, `Y_intrabc_10b.obu`) are
2981- /// the vertical midpoint as the thing that would justify lifting the2981+ /// the streams on which lane-av1422lpf found the seven-site chroma-extent
2982- /// refusal). This is that fixture.2982+ /// PANIC family -- each site indexed a block's chroma PLANE BLOCK with
2983- ///2983+ /// the ENCLOSING SQUARE `max(side >> ss_x, side >> ss_y)` instead of the
2984- /// `422_residual_compound_warp_16f.obu` (38845 bytes), sha2562984+ /// PER-AXIS `(bw >> ss_x, bh >> ss_y)` -- so the pins keep the bytes that
2985- /// `d78e2afb43ce311d3d82335a945c6f80f62db4537966d881c1349a68b3aecb95`:2985+ /// witnessed it from silently changing under the gate.
2986- ///2986+ ///
2987- /// ```text2987+ /// WHAT THIS GATE DOES NOT COVER, measured rather than argued: the
2988- /// ffmpeg -f lavfi -i "mandelbrot=size=256x288:rate=24:maxiter=220:start_scale=3:end_scale=0.35:end_pts=300,rotate=a=0.10*t:c=none:ow=256:oh=288" \2988+ /// refusal it asserts is the HEADER refusal, which fires BEFORE any of
2989- /// -frames:v 24 -pix_fmt yuv422p -f yuv4mpegpipe src422.y4m2989+ /// the seven sites is reachable, and it fires IDENTICALLY on the pre-fix
2990- /// aomenc --codec=av1 --profile=2 --input-bit-depth=8 --limit=162990+ /// tree (commit `aef4fa67` prints the same string, built and run for
2991- /// --width=256 --height=288 --lag-in-frames=25 --auto-alt-ref=12991+ /// this correction). This gate is therefore VACUOUS with respect to the
2992- /// --enable-global-motion=1 --pass=12992+ /// seven-site fix -- it passes before and after the fix. Its only real
2993- /// --cq-level=24 --cpu-used=02993+ /// content is the three pins.
2994- /// --threads=4 --kf-min-dist=0 --kf-max-dist=999999 \2994+ ///
2995- /// src422.y4m -o a1.webm2995+ /// Nor can any committed gate witness that fix's DECODE behaviour: with
2996- /// ffmpeg -i a1.webm -c copy -f obu -y a1.obu2996+ /// the header refusal standing, no committed test reaches a 4:2:2 decode,
2997- /// ```2997+ /// because the `EC_AV1_ALLOW_422_PROBE` bypass is a patch-run-restore
2998- ///2998+ /// hack that must never be committed. The panic fix's evidence is the
2999- /// CORRECTED by lane-av1422lrless (reviewer P2). This doc previously2999+ /// BYPASSED manual measurement in `lanes/av1422lpf.report.md`; what is
3000- /// carried a different ffmpeg filter (`rotate=a=0.10`, no `*t`, no3000+ /// committed for the fix is the source-scan arm
3001- /// `:c=none:ow/oh`) and a `-n ffp --pass=2 --fpf=...` two-pass line.3001+ /// `the_422_lossless_inter_chroma_walk_sites_stay_per_axis`, which
3002- /// **Neither produced these bytes.** Re-encoding from the recorded3002+ /// proves the per-axis SPELLING and nothing about pixels.
3003- /// source `src422.y4m` (sha2563003+ ///
3004- /// `4d35eaf65d1a5541b3177e1183644c163b3868d8f141bed0ce9fdf833280ba9f`)3004+ /// CORRECTED by lane-av1422llintra: the name said `..._panics_refuse_
3005- /// was measured three ways: the two-pass form gives 38774 bytes3005+ /// by_name`, and lane-av1422lpf's report claimed W and X now REFUSE with
3006- /// (`e93c4ed7...`), and only adding `--pass=1` reproduces these 388453006+ /// `a Golomb tail longer than this decoder reads` at frame 2. That
3007- /// bytes byte for byte (`d78e2afb...`). `aomenc` DEFAULTS to two-pass,3007+ /// refusal DOES NOT REPRODUCE on this tip: with the bypass applied, all
3008- /// so the flag has to be stated to get back the pinned stream. The3008+ /// three cells DECODE 16/16 -- no panic and no second refusal.
3009- /// recipe above is the one that was actually run.3009+ #[test]
3010- ///3010+ fn the_pinned_422_lossless_inter_witnesses_are_present_and_refuse_by_name() {
3011- /// Measured on a patch-run-restore build (the `EC_AV1_ALLOW_422_PROBE`3011+ const NAME: &str = "the_pinned_422_lossless_inter_witnesses_are_present_and_refuse_by_name";
3012- /// bypass applied for the run, reverted after -- it is deliberately NOT
3013- /// committed, and the refusal below is what the committed tree asserts):
3014- ///
3015- /// - all 16 frames pixel-exact against `aomdec --rawvideo`, 2359296
3016- /// bytes each, sha256 `4bfc2395e5ca6ea178f606e6b1ced773e26fc2d85b
3017- /// c3a6cdb63a402939aeb203` on both sides;
3018- /// - the entropy stream pairs bit-for-bit against the instrumented
3019- /// oracle -- 246735 symbol reads each, no divergence anywhere in the
3020- /// stream, not merely at the window this lane spent nine rounds
3021- /// narrowing;
3022- /// - the arms this fixture exists to cover really fire ABOVE the
3023- /// vertical midpoint: 3 upper-half blocks on a non-`TRANSLATION`
3024- /// global-motion model (`top_half_warp_hits`, gated on libaom's
3025- /// `is_global_mv_block` per slot) and 3 upper-half
3026- /// `GLOBAL_GLOBALMV` compound blocks (`top_half_compound_hits`),
3027- /// alongside 25 compound-warp, 18 compound-warp-8x8-leaf, 84
3028- /// rotzoom global-warp, 22 Wiener and 10 SGRPROJ loop-restoration
3029- /// units frame-globally.
3030- ///
3031- /// The loop-restoration numbers are load-bearing twice over: decoding
3032- /// this stream is what exposed the per-axis `read_lr` corner bug
3033- /// (`restoration.rs`, `av1_loop_restoration_corners_in_sb`), whose fix
3034- /// is what made the whole sequence pair. 4:2:0 and 4:4:4 are unchanged
3035- /// by it -- byte-identical to their pre-lane decodes, with the LR gate
3036- /// family green.
3037- ///
3038- /// Like its two siblings, the committed assertion is the byte pin plus
3039- /// the refusal-by-name contract: with the header refusal standing,
3040- /// NO committed test can decode a 4:2:2 stream, because the bypass that
3041- /// would allow it must never be committed.
3042- /// lane-av1422lpf: the 4:2:2 lossless INTER chroma panic family -- SEVEN
3043- /// sites, each indexing a block's chroma PLANE BLOCK with the ENCLOSING
3044- /// SQUARE `max(side >> ss_x, side >> ss_y)`.
3045- ///
3046- /// libaom's chroma plane block is PER-AXIS, `(bw >> ss_x) x
3047- /// (bh >> ss_y)` (`av1_common_int.h`'s `av1_get_plane_block_size`, the
3048- /// `dec->uv_buffer` extent in decodeframe.c), and it is square only when
3049- /// `ss_x == ss_y`. The enclosing square is the same number at 4:2:0
3050- /// (`side >> 1`) and 4:4:4 (`side`) on a square block, so every site
3051- /// below is byte-identical there; at 4:2:2 the square is the LUMA side
3052- /// and each site walked off its own buffer.
3053- ///
3054- /// Committed code refuses 4:2:2 at the sequence header, so -- exactly
3055- /// like the witnesses above -- what this gate can assert in committed
3056- /// code is the byte pin, the refusal-by-name contract, and the arm below:
3057- /// that each site's PER-AXIS expression is still spelled per-axis and
3058- /// the square-cut expression it replaced is gone. The decode-level
3059- /// evidence is measured on the local `EC_AV1_ALLOW_422_PROBE`
3060- /// patch-run-restore build and is in `lanes/av1422lpf.report.md`.
3061- #[test]
3062- fn the_pinned_422_lossless_inter_chroma_panics_refuse_by_name() {
3063- const NAME: &str = "the_pinned_422_lossless_inter_chroma_panics_refuse_by_name";
3064 const REFUSAL: &str = "a chroma format of 4:2:2";3012 const REFUSAL: &str = "a chroma format of 4:2:2";
3065 for (file, bytes, fp) in [3013 for (file, bytes, fp) in [
3066 ("W_intrabc.obu", 130_320usize, 0xb6d5c4653a32567a_u64),3014 ("W_intrabc.obu", 130_320usize, 0xb6d5c4653a32567a_u64),
@@ -3095,6 +3043,12 @@ pub(crate) mod tests {
3095 /// `dead-matcher-positive-control` sense -- a scan that matched nothing3043 /// `dead-matcher-positive-control` sense -- a scan that matched nothing
3096 /// would fail it rather than pass silently.3044 /// would fail it rather than pass silently.
3097 ///3045 ///
3046+ /// WHAT IT DOES NOT COVER: this arm is a SPELLING scan. It cannot observe
3047+ /// a decode, so it cannot prove any cell decodes and cannot prove any
3048+ /// pixel -- the same limit as the witness gate above it, and stated here
3049+ /// because "one assertion per site, each with a mutation proof" reads
3050+ /// like more coverage than it is.
3051+ ///
3098 /// `strip_code` is the same comment-stripping the arms above use: the3052 /// `strip_code` is the same comment-stripping the arms above use: the
3099 /// fixes quote their own old expression to say what it was, and a prose3053 /// fixes quote their own old expression to say what it was, and a prose
3100 /// mention must neither read as a reintroduction nor mask one.3054 /// mention must neither read as a reintroduction nor mask one.
@@ -3303,6 +3257,71 @@ pub(crate) mod tests {
3303 gained a shape"3257 gained a shape"
3304 );3258 );
3305 }3259 }
3260+ /// lane-av1422warp: the SECOND 4:2:2 coverage witness -- the one
3261+ /// `422_sb128_3f.obu` could not be, because that stream's inter content
3262+ /// is skip-heavy (see `lanes/av1422stripwrite.report.md`, which named a
3263+ /// second fixture with real residuals, compound and warped motion above
3264+ /// the vertical midpoint as the thing that would justify lifting the
3265+ /// refusal). This is that fixture.
3266+ ///
3267+ /// `422_residual_compound_warp_16f.obu` (38845 bytes), sha256
3268+ /// `d78e2afb43ce311d3d82335a945c6f80f62db4537966d881c1349a68b3aecb95`:
3269+ ///
3270+ /// ```text
3271+ /// ffmpeg -f lavfi -i "mandelbrot=size=256x288:rate=24:maxiter=220:start_scale=3:end_scale=0.35:end_pts=300,rotate=a=0.10*t:c=none:ow=256:oh=288" \
3272+ /// -frames:v 24 -pix_fmt yuv422p -f yuv4mpegpipe src422.y4m
3273+ /// aomenc --codec=av1 --profile=2 --input-bit-depth=8 --limit=16
3274+ /// --width=256 --height=288 --lag-in-frames=25 --auto-alt-ref=1
3275+ /// --enable-global-motion=1 --pass=1
3276+ /// --cq-level=24 --cpu-used=0
3277+ /// --threads=4 --kf-min-dist=0 --kf-max-dist=999999 \
3278+ /// src422.y4m -o a1.webm
3279+ /// ffmpeg -i a1.webm -c copy -f obu -y a1.obu
3280+ /// ```
3281+ ///
3282+ /// CORRECTED by lane-av1422lrless (reviewer P2). This doc previously
3283+ /// carried a different ffmpeg filter (`rotate=a=0.10`, no `*t`, no
3284+ /// `:c=none:ow/oh`) and a `-n ffp --pass=2 --fpf=...` two-pass line.
3285+ /// **Neither produced these bytes.** Re-encoding from the recorded
3286+ /// source `src422.y4m` (sha256
3287+ /// `4d35eaf65d1a5541b3177e1183644c163b3868d8f141bed0ce9fdf833280ba9f`)
3288+ /// was measured three ways: the two-pass form gives 38774 bytes
3289+ /// (`e93c4ed7...`), and only adding `--pass=1` reproduces these 38845
3290+ /// bytes byte for byte (`d78e2afb...`). `aomenc` DEFAULTS to two-pass,
3291+ /// so the flag has to be stated to get back the pinned stream. The
3292+ /// recipe above is the one that was actually run.
3293+ ///
3294+ /// Measured on a patch-run-restore build (the `EC_AV1_ALLOW_422_PROBE`
3295+ /// bypass applied for the run, reverted after -- it is deliberately NOT
3296+ /// committed, and the refusal below is what the committed tree asserts):
3297+ ///
3298+ /// - all 16 frames pixel-exact against `aomdec --rawvideo`, 2359296
3299+ /// bytes each, sha256 `4bfc2395e5ca6ea178f606e6b1ced773e26fc2d85b
3300+ /// c3a6cdb63a402939aeb203` on both sides;
3301+ /// - the entropy stream pairs bit-for-bit against the instrumented
3302+ /// oracle -- 246735 symbol reads each, no divergence anywhere in the
3303+ /// stream, not merely at the window this lane spent nine rounds
3304+ /// narrowing;
3305+ /// - the arms this fixture exists to cover really fire ABOVE the
3306+ /// vertical midpoint: 3 upper-half blocks on a non-`TRANSLATION`
3307+ /// global-motion model (`top_half_warp_hits`, gated on libaom's
3308+ /// `is_global_mv_block` per slot) and 3 upper-half
3309+ /// `GLOBAL_GLOBALMV` compound blocks (`top_half_compound_hits`),
3310+ /// alongside 25 compound-warp, 18 compound-warp-8x8-leaf, 84
3311+ /// rotzoom global-warp, 22 Wiener and 10 SGRPROJ loop-restoration
3312+ /// units frame-globally.
3313+ ///
3314+ /// The loop-restoration numbers are load-bearing twice over: decoding
3315+ /// this stream is what exposed the per-axis `read_lr` corner bug
3316+ /// (`restoration.rs`, `av1_loop_restoration_corners_in_sb`), whose fix
3317+ /// is what made the whole sequence pair. 4:2:0 and 4:4:4 are unchanged
3318+ /// by it -- byte-identical to their pre-lane decodes, with the LR gate
3319+ /// family green.
3320+ ///
3321+ /// Like its two siblings, the committed assertion is the byte pin plus
3322+ /// the refusal-by-name contract: with the header refusal standing,
3323+ /// NO committed test can decode a 4:2:2 stream, because the bypass that
3324+ /// would allow it must never be committed.
3306 #[test]3325 #[test]
3307 fn the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name() {3326 fn the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name() {
3308 const NAME: &str =3327 const NAME: &str =
lanes/av1422llintra.report.mdadded+466 -0
@@ -0,0 +1,466 @@
1+# lane-av1422llintra — the 4:2:2 lossless chroma context: the dc-sign vote was double-counted
2+
3+Base `main` = `3698787d` (the merge of lane-av1422lpf). Worktree
4+`~/.cache/wt/av1422llintra`, branch `lane-av1422llintra`.
5+
6+Two commits:
7+
8+1. `1cd7c85f` — the merged gate is renamed to what it asserts and told what it
9+ does **not** cover. It was vacuous with respect to lane-av1422lpf's seven-site
10+ fix.
11+2. the decode change below — **UN-GATEABLE** (stated, with the reason, and NOT
12+ described as gated).
13+
14+Nothing else is committed. `crates/ec-av1/src/stream.rs` carries **no** bypass
15+in the committed tree; the `EC_AV1_ALLOW_422_PROBE` patch was applied for the
16+measurements below and reverted (`git diff` on stream.rs after commit 1 is
17+empty).
18+
19+---
20+
21+## 0. Verdict
22+
23+| | |
24+|---|---|
25+| first-divergent unit found | V 4x4 at chroma (24, 8), `BLOCK_32X8` at mi(2, 8) |
26+| its cause | the `dc_sign` CDF row, not the level |
27+| that cause | the above vote was summed **twice** at ss (1, 0) |
28+| sites fixed | 3 chroma gathers that still used the plain `around_mi_rect` |
29+| the pinned 4:2:2 all-intra lossless control | **luma now byte-exact** (74 162 wrong -> 0); chroma 38 235/38 240 -> 3 126/3 139 |
30+| `W_intrabc`, `X_intrabc_tiled` | frame 0 now **byte-exact**; total wrong samples down 24 % / 19 % |
31+| `Y_intrabc_10b` | **REGRESSION, stated plainly: it now REFUSES at frame 0** (`a Golomb tail longer than this decoder reads`) where it used to decode 16/16 with 1 210 281 wrong luma samples. See §6. |
32+| regressions in the 422/lossless/444 gate families | **0** — 70 passed, 0 failed |
33+| a gate for the decode change | **none, and none is possible** — §5 |
34+
35+---
36+
37+## 1. Goal A — the merged gate was lying, and is fixed
38+
39+`the_pinned_422_lossless_inter_chroma_panics_refuse_by_name` asserted
40+`REFUSAL = "a chroma format of 4:2:2"` — the **sequence-header** refusal, which
41+fires before any of the seven per-axis extent sites is reachable, and which
42+fires identically on the pre-fix tree. Main built `aef4fa67` and measured the
43+identical string. The gate therefore passes before and after the fix: with
44+respect to the seven sites it is **vacuous**. Its only real content is the three
45+pins (size + `fnv1a64`).
46+
47+It is now
48+`the_pinned_422_lossless_inter_witnesses_are_present_and_refuse_by_name`, its
49+doc says so, and it says the thing that is easy to get wrong: **no committed
50+test can reach a 4:2:2 decode at all**, because the bypass that would allow it
51+is a patch-run-restore hack that must never be committed — so the seven-site
52+panic fix's evidence is the bypassed manual measurement in
53+`lanes/av1422lpf.report.md`, not this gate.
54+
55+The false claim is retracted in the doc rather than deleted silently: the gate's
56+old name said `..._panics_...`, and lane-av1422lpf's report claimed `W` and `X`
57+now REFUSE with `a Golomb tail longer than this decoder reads` at frame 2. That
58+refusal **does not reproduce** — with the bypass, all three cells decode 16/16
59+with no panic and no second refusal (measured, §2).
60+
61+**A second gate from the same lane carried the same over-claim**, in the softer
62+form: `the_422_lossless_inter_chroma_walk_sites_stay_per_axis` says "one
63+assertion per site, each with a mutation proof", which reads like more coverage
64+than a source scan is. It is a **spelling** scan — it cannot observe a decode —
65+and its doc now says exactly that.
66+
67+**Collateral damage found and repaired**: `69a3a4df` appended its own doc block
68+in the *middle* of the `lane-av1422warp` gate's doc comment, so
69+`the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name`
70+had lost its documentation entirely and two unrelated gates shared one comment
71+block. The warp doc is moved back onto its own gate.
72+
73+The three pins are unchanged. Both gates pass:
74+
75+```
76+$ cargo test -p ec-av1 --lib -- the_pinned_422_lossless_inter_witnesses_are_present_and_refuse_by_name \
77+ the_422_lossless_inter_chroma_walk_sites_stay_per_axis
78+test stream::tests::the_pinned_422_lossless_inter_witnesses_are_present_and_refuse_by_name ... ok
79+test stream::tests::the_422_lossless_inter_chroma_walk_sites_stay_per_axis ... ok
80+test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 787 filtered out
81+```
82+
83+---
84+
85+## 2. The measurement rig, and why the numbers below are real
86+
87+**Comparator** (`~/.cache/cells/av1422llintra/cmp422.py`, written here): pairs
88+our `dump_yuv` per-frame dumps against one flat `aomdec --rawvideo` file. The
89+per-frame plane geometry is derived from width/height/depth, never guessed; a
90+wrong SAMPLE is one `bps`-wide unit, so the 10-bit cell is counted per 16-bit
91+sample and not per byte.
92+
93+**The comparator has a liveness guard, and it caught me.** A first version
94+globbed zero frame files (the 10-bit dump had refused) and reported
95+`Y 0 U 0 V 0 — first wrong: none`, which reads as BYTE-EXACT. That is the class
96+`oracle-comparator-liveness-control`: a comparator that reads nothing proves
97+nothing. It now hard-errors on an empty glob, and the "Y_intrabc_10b is exact"
98+line I would otherwise have written is **retracted** — see §6.
99+
100+**Oracle-flip control, per cell** (the acceptance requirement): flip ONE byte of
101+the oracle dump and the count must move.
102+
103+```
104+$ for c in W_intrabc:8 X_intrabc_tiled:8 Y_intrabc_10b:10; do cell=${c%%:*}; d=${c##*:}; \
105+ cp $cell.oracle.yuv /tmp/flip.yuv; \
106+ python3 -c "b=bytearray(open('/tmp/flip.yuv','rb').read()); b[3]^=0x01; open('/tmp/flip.yuv','wb').write(bytes(b))"; \
107+ ./cmp422.py $cell.<build> /tmp/flip.yuv 320 240 $d ""; done
108+```
109+
110+| cell | build | count | count with oracle byte 3 flipped |
111+|---|---|---|---|
112+| W_intrabc | after | Y 1 220 912 | Y 1 220 913 |
113+| X_intrabc_tiled | after | Y 990 733 | Y 990 734 |
114+| Y_intrabc_10b | after | Y 1 210 281 | Y 1 210 282 |
115+| W_intrabc | both fixes | Y 917 974 | Y 917 975 |
116+| X_intrabc_tiled | both fixes | Y 864 325 | Y 864 326 |
117+| ll422_allintra | both fixes | Y 0 / U 3 126 / V 3 139 | Y 1 / U 3 126 / V 3 139 |
118+
119+Every control moves by exactly the one flipped sample. The comparator is live.
120+
121+**Oracle soundness**: the oracle dumps are `~/.cache/aom-oracle/build/aomdec`
122+(the instrumented tree). On `ll422_allintra.obu` its raw output is
123+sha256 `ae45d5dc220527b29f6a4b4d69583639f1ca3e70b4e284374ffde62ee6ebb84e`,
124+which is the value the previous lane measured for the instrumented build, the
125+plain build, the second build and `ffmpeg -pix_fmt yuv422p`. The oracle is
126+trustworthy for this stream.
127+
128+`W_intrabc.oracle.yuv` and `X_intrabc_tiled.oracle.yuv` are byte-identical to
129+each other (`ea259d96fd2a2ff7...`) — the tiled re-encode of the same source
130+decodes to the same picture, so their divergence counts are directly comparable.
131+
132+**Oracle dumps produced here:**
133+
134+```
135+$ ~/.cache/cells/av1422llintra/oracle_run.sh <cell> <stream.obu> <depth>
136+W_intrabc.oracle.yuv 2 457 600 B ea259d96fd2a2ff7...
137+X_intrabc_tiled.oracle.yuv 2 457 600 B ea259d96fd2a2ff7... (same bytes)
138+Y_intrabc_10b.oracle.yuv 4 915 200 B dceee9c2ff925845...
139+ll422_allintra.oracle.yuv 153 600 B ae45d5dc220527b2...
140+```
141+
142+---
143+
144+## 3. Per-cell before / after (raw commands)
145+
146+Three builds of the same worktree, all with the same `EC_AV1_ALLOW_422_PROBE`
147+bypass, all from `dump_yuv`:
148+
149+* **BEFORE** = `main` 3698787d exactly (`git checkout -- crates/ec-av1/src/decode.rs`)
150+* **after** = BEFORE + Merve2-2's `decode_leaf8` chroma-unit mechanism
151+* **both fixes** = after + the dc-sign gather fix (this lane)
152+* **dc-only** = main + the dc-sign gather fix WITHOUT Merve2-2's mechanism
153+ (the isolation control, §6)
154+
155+```
156+$ export CARGO_TARGET_DIR=<per-build> EC_NOMEMGUARD=1 EC_AV1_ALLOW_422_PROBE=1
157+$ cargo build --release --example dump_yuv -p ec-av1
158+$ for c in W_intrabc X_intrabc_tiled Y_intrabc_10b; do \
159+ ./dumpyuv_<build> ~/.cache/cells/av1422lpf/$c.obu <cells>/$c.<build>; done
160+$ ./dumpyuv_<build> ~/.cache/cells/av1422lpf/probe/ll422_allintra.obu <cells>/ll422.<build>
161+$ ./cmp422.py <cells>/$c.<build> <cells>/$c.oracle.yuv 320 240 <8|10> "$c <build>"
162+```
163+
164+320x240, 4:2:2, 16 shown frames (1 for `ll422_allintra`).
165+
166+| cell | build | Y wrong | U wrong | V wrong | first wrong |
167+|---|---|---|---|---|---|
168+| `W_intrabc` | BEFORE | 1 214 609 | 611 596 | 612 205 | frame 0 Y sample 54 |
169+| | after (Merve) | 1 220 912 | 612 668 | 611 842 | frame 0 Y sample 54 |
170+| | **both fixes** | **917 974** | **474 518** | **487 693** | **frame 1 Y sample 0** |
171+| `X_intrabc_tiled` | BEFORE | 1 072 597 | 533 606 | 539 334 | frame 0 Y sample 32 |
172+| | after (Merve) | 990 733 | 488 493 | 490 484 | frame 0 Y sample 32 |
173+| | **both fixes** | **864 325** | **421 582** | **414 905** | **frame 1 Y sample 0** |
174+| `Y_intrabc_10b` (10-bit) | BEFORE | 1 227 876 | 613 885 | 614 058 | frame 0 Y sample 8 (= byte 16) |
175+| | after (Merve) | 1 210 281 | 612 170 | 613 127 | frame 0 Y sample 48 (= byte 96) |
176+| | **both fixes** | **REFUSES at frame 0** — §6 | | | |
177+| `ll422_allintra` (1 frame, pure intra) | BEFORE | 75 210 | 38 235 | 38 240 | frame 0 Y sample 16 |
178+| | after (Merve) | 74 162 | 36 703 | 37 114 | frame 0 Y sample 64 |
179+| | **both fixes** | **0** | **3 126** | **3 139** | frame 0 **U** sample 1853 |
180+
181+What this says, plainly: **Merve2-2's chroma-unit mechanism alone is not a win**
182+(`W` gets worse, `X` and `ll422` better, none exact). With the dc-sign gather fix
183+on top, `W`/`X` lose another 24 %/19 % of their wrong samples and — the
184+measurement that matters — **frame 0 of both becomes byte-exact**, and the pure
185+intra control's **luma becomes byte-exact**.
186+
187+---
188+
189+## 4. The first divergence, localised
190+
191+### 4.1 The pairing
192+
193+Three paired rungs, all sequential, all env-gated:
194+
195+* `EC_PRED` (ours, `OUR_PRED`) vs the oracle's `EC_PREDOUT8` — prediction, per TU
196+* `EC_TRACE_COEFF` (both sides, `EC_COEFF_STEP`) — the entropy symbol stream
197+* `EC_DBGCTX` (oracle) vs the crate's own `EC_CHROMA_PUB` / `EC_DCDUMP` — the
198+ per-cell entropy-context bytes that feed the dc-sign vote
199+
200+Four rung-shape differences are normalised away, each because it is a difference
201+in what is PRINTED, not in what is READ (all four are named in the header of
202+`pair_coeff.py`): `tx_type` (a lossless block reads no tx_type symbol, so the
203+oracle's rung fires once per block where ours does not), `ctx`/`dcctx` (printed on
204+one side only), `c`/`pos` (compared only when both print them), and our
205+`tag=br` run inside the base_eob arm (libaom prints one finished level where we
206+print the whole base-range loop).
207+
208+### 4.2 Before the dc fix: unit 189 of 9 600
209+
210+```
211+FIRST DISAGREEMENT at unit index 189
212+ oracle: mi=(2,8) plane=2 row_off=1 col_off=1 txw=4 txh=4 mode=8 sum=2408
213+ ours : x=20 y=12 plane=2 bw=4 bh=4 mode=8 sum=2410
214+```
215+
216+and the entropy stream, 4 292 symbols in:
217+
218+```
219+ [4291] O: EC_COEFF_STEP tag=after_bases rng=40604
220+ U: EC_COEFF_STEP tag=after_bases rng=40604
221+ [4292] O: EC_COEFF_STEP tag=sign c=0 sign=1 dcctx=0 rng=51524 <== MISMATCH
222+ U: EC_COEFF_STEP tag=sign c=0 sign=0 rng=37124
223+```
224+
225+`rng` agrees to the bit (40 604 on both sides), so this is a **CDF row**
226+difference, not a bit-position difference — and the level read on both sides is
227+2. The oracle's `dc_sign` vote for that unit is `0`, ours is positive.
228+
229+`EC_COEFF plane=2 row=0 col=2 mi_row=2 mi_col=8` names the unit: the third 4x4
230+V unit of the `BLOCK_32X8` at mi(2,8), i.e. **chroma (24, 8)**.
231+
232+### 4.3 The oracle's own vote, and ours
233+
234+libaom `get_txb_ctx_general` (`txb_common.h:280`) sums one `signs[]` vote per
235+CHROMA cell over `txb_w_unit` above entries and `txb_h_unit` left entries — for
236+a TX_4X4 chroma unit, **one** above entry and **one** left entry — and indexes
237+`dc_sign_contexts[dc + 32]`.
238+
239+```
240+$ EC_DBGCTX=1 aomdec ... ll422_allintra.obu
241+EC_DBGCTX mi=2,8 plane=2 tx=0 above0=23 left0=13 base=2 off=10 ctx=12
242+EC_DBGCTX mi=2,8 plane=2 tx=0 above0=23 left0=12 base=2 off=10 ctx=12
243+```
244+
245+Byte 23 = `16 | 7` (positive DC, level 7); byte 13 = `8 | 5` (negative DC, level
246+5). `signs[23>>3] = +1`, `signs[13>>3] = -1`, sum 0, so
247+`dc_sign_contexts[0 + 32] = 0` — `dc_sign_cdf[0]`, which is the row the oracle
248+read (`dcctx=0`).
249+
250+Ours (`EC_DCDUMP=1`, the crate's own per-cell gather):
251+
252+```
253+EC_DCDUMP mi=(2,12) plane=2 wh=(8,4) vote=1 above=[Some(false)/7,Some(false)/7] left=[Some(true)/5]
254+```
255+
256+**Two above cells.** At ss (1, 0) one chroma column spans TWO luma mi columns, so
257+the plain `around_mi_rect` walk summed the column's whole-unit dc sign twice:
258+vote `(+1) + (+1) + (-1) = +1` where libaom's is `(+1) + (-1) = 0`.
259+`dc_sign_ctx` only sees the vote's SIGNUM, so the doubling is invisible except
260+exactly when above and left cancel — `a + l = 0` (ctx 0) becomes `2a + l = +a`
261+(ctx 2). That is the whole defect, and it is why 4:2:0 and 4:4:4 are immune
262+(there the plane block is square, so the doubling scales the vote uniformly and
263+the signum is preserved).
264+
265+### 4.4 The fix
266+
267+Three chroma gathers still called the plain `around_mi_rect` where twenty-odd
268+sibling sites already route ss (1, 0) through `around_mi_422_chroma` (which
269+samples every second above cell — libaom's per-chroma-cell count):
270+
271+* `decode.rs:12735` — `decode_rect_split`'s lossless chroma walk (**the site that
272+ produced the measured fork**)
273+* `decode.rs:17802` — `read_intrabc_rect_chroma_split`
274+* `decode.rs:19922` — `decode_block_rect64`'s tiled chroma walk
275+
276+Each is now `if ss_x == 1 && ss_y == 0 { around_mi_422_chroma(..) } else {
277+around_mi_rect(..) }` — byte-identical to the existing sites at 12865, 13069,
278+14327 and 44920, and a no-op at 4:2:0 and 4:4:4 by construction.
279+
280+### 4.5 After the fix
281+
282+```
283+$ ./pair_coeff.py oracle_COEFF.log ours_COEFF_FIX.log
284+oracle symbols 311484 ours 311484
285+no disagreement in the first 311484 paired symbols
286+```
287+
288+**The entire coefficient-symbol stream of `ll422_allintra.obu` now pairs symbol
289+for symbol**, and the prediction trace pairs for 1 726 consecutive units (it was
290+189). Luma is byte-exact. What is left is 6 265 chroma samples, and it is
291+localised:
292+
293+```
294+$ ./firstdiff.py ll422.FIX ll422_allintra.oracle.yuv 320 240 8
295+frame 0 U (93,11) sample 1853: ours 159 oracle 160
296+```
297+
298+* **first mis-reconstructed unit: the U 4x4 chroma unit at chroma (92, 8)**, in
299+ the 8x8 leaf at **mi(2,46)** (`EC_IMODE mi_row=2 mi_col=46 bsize=3` =
300+ `BLOCK_8X8`, `mode=2 uv_mode=2`).
301+* it is a **prediction** difference, not a residual one: our
302+ `OUR_PRED sum=2539` against the oracle's `sum=2542`, with `row0` and `col0`
303+ byte-identical on both sides — so the difference is interior-only, while both
304+ edges in the plane are byte-identical to the oracle (the units above, at
305+ (92,4), and to the left, at (88,8), are not in the differing set).
306+* the oracle's filters are **inert** on this frame, so this is reconstruction,
307+ not filtering: measured by dumping the oracle's own pre-loop-filter plane
308+ (`EC_AV1_PREFILT_DUMP`) and comparing it to its final output —
309+ `oracle prefilter-vs-final chroma differing samples: 0`, luma `0`.
310+* 496 of 4 800 chroma 4x4 units differ, 6 265 samples; 302 of those units differ
311+ in all 16 samples. Only V and U; luma is exact.
312+
313+**Handed over, named:** the 4:2:2 leaf-8 chroma **prediction** for a
314+`BLOCK_8X8` chroma unit whose interior differs while both of its edge rows and
315+its edge column match the oracle byte for byte. The entropy stream is provably
316+clean up to and past it, so the defect is inside the prediction for this
317+mode/shape, not in its context gather and not in its residual.
318+
319+---
320+
321+## 5. Why there is no gate for the decode change, and what was done instead
322+
323+**It cannot be gated, and this lane does not pretend otherwise.** 4:2:2 is refused
324+at the sequence header by name (`stream.rs:1803`), and the bypass that would
325+allow a decode is a patch-run-restore hack that must never be committed — so no
326+committed test, in any build, can execute the arms this change touches. There is
327+no source-scan substitute that would mean anything here: scanning for the guard's
328+spelling proves the spelling, which is precisely the criticism §1 levels at the
329+merged gate.
330+
331+What was done instead, and what it is worth:
332+
333+1. **The measurement is the evidence**, with the comparator's own liveness
334+ control per cell (§2) and an isolation control that separates this fix from
335+ the previous lane's (§6).
336+2. **The revert moves the numbers**, which is the only mutation proof available
337+ for unreachable code. Reverting the dc gather (that IS the `BEFORE` /
338+ `after` / `dc-only` row set) puts `ll422_allintra`'s luma back from 0 to
339+ 75 210 wrong samples and its first divergence back to frame 0 Y sample 16,
340+ and puts `W`/`X` back from frame-0-exact to frame-0-diverging. The change is
341+ load-bearing; measured, not asserted.
342+3. **The three sites are swept as a class**, not one instance: every remaining
343+ `around_mi_rect` chroma gather in `decode.rs` was classified, and the three
344+ that can see ss (1, 0) are fixed. The other `around_mi_rect` call sites are
345+ LUMA gathers (12449, 12499, 12553, 18661, 18712, 18770, 23290, 23383) or are
346+ already guarded, and `around_mi` (18186, 19039) is a one-cell gather with no
347+ above extent to double.
348+
349+This is stated as an **un-gateable correctness fix whose evidence is the
350+measurement**, not as a gated change.
351+
352+---
353+
354+## 6. The one regression, stated plainly
355+
356+**`Y_intrabc_10b` now refuses at frame 0.** With both fixes it returns
357+`unsupported: AV1 tile (a Golomb tail longer than this decoder reads)`
358+(`frames_dispatched: 0`). Before, it decoded 16/16 with 1 227 876 wrong luma
359+samples.
360+
361+Isolation control (the same three sites patched onto **main**, without the
362+previous lane's chroma-unit mechanism):
363+
364+| build | W | X | Y_intrabc_10b | ll422_allintra (luma) |
365+|---|---|---|---|---|
366+| main (BEFORE) | 1 214 609 | 1 072 597 | 1 227 876 (decodes) | 75 210 |
367+| + Merve's mechanism only | 1 220 912 | 990 733 | 1 210 281 (decodes) | 74 162 |
368+| + dc gather only | 1 218 768 | 1 072 310 | **REFUSES at frame 0** | 75 981 |
369+| + both (**this lane**) | 917 974 | 864 325 | **REFUSES at frame 0** | **0** |
370+
371+So the two defects **interact**: the dc gather alone is neutral-to-slightly-worse
372+(it moves `ll422`'s fork *earlier*, to Y sample 16, because the leaf-8 defect
373+then trips a different symbol first), and only the pair is a large win. The
374+`Y_intrabc_10b` refusal is caused by the dc gather alone, not by the
375+interaction.
376+
377+Reading: on that stream the residual 4:2:2 defect now reaches a long unary run
378+in frame 0 and trips the named Golomb guard, where before it produced wrong
379+pixels instead. That is the crate's own honesty convention (a named refusal
380+beats silently wrong pixels) and it matches how lane-av1422lpf reported its own
381+panic-to-refusal conversion — but it IS a behaviour change on a cell, it is not
382+covered by any committed test, and **it is Main's call whether to keep it**. The
383+case for keeping it: the alternative leaves a defect diagnosed to the line and
384+the CDF row, unfixed, with `W`/`X` 19–24 % worse and the intra control's luma
385+wrong in 74 162 samples.
386+
387+`Y_intrabc_10b`'s own divergence was not localised past this: its 10-bit trace
388+pairing is not trustworthy with the four rung-shape normalisations above (the
389+oracle emits its eob `br` symbols before the `base_eob` line there, the reverse
390+of the 8-bit cell), so I stopped rather than report a fork index I cannot
391+defend. **Not claimed.**
392+
393+---
394+
395+## 7. Refuted hypotheses, with the evidence
396+
397+* **"the previous lane's report's numbers are wrong"** — partly. Its `W`/`X`/
398+ `Y_intrabc_10b` per-plane counts do not reproduce under a per-SAMPLE
399+ comparator (mine, §3). Its luma counts on `ll422_allintra` (75 210) reproduce
400+ exactly. The difference is the plane attribution: counting 10-bit chroma
401+ BYTE-wise counts the always-zero top 6 bits of each sample, which cannot
402+ differ, so U and V coincide in ways a byte count hides.
403+* **"the `Golomb tail` refusal on `W`/`X` at frame 2 exists"** — **refuted**.
404+ With the bypass, all three cells decode 16/16 on this tip with no panic and no
405+ second refusal. The claim is retracted in the gate's doc (§1).
406+* **"the residual is a transform / dequant defect"** — **refuted as the first
407+ cause** on the intra control: after the dc fix the whole 311 484-symbol
408+ coefficient stream pairs, every level matches, and luma is byte-exact. A
409+ dequant defect cannot leave the symbol stream and luma clean.
410+* **"the residual is a filter (deblock / CDEF / restoration) defect"** —
411+ **refuted**: the oracle's own pre-loop-filter plane equals its final output on
412+ every plane of this frame (0 differing samples), so the filters are inert here
413+ and cannot be where our chroma diverges.
414+* **"the `txb_skip` / `all_zero` `ctx` mismatch at unit 3 is the fork"** —
415+ **refuted** (re-confirmed): it is a label-space artifact — our chroma tables
416+ hold the offset-7 rows first, so our `ctx=0` is libaom's `ctx=7` — and the
417+ traces agree once `all_zero`'s `ctx` field is excluded.
418+* **"the oracle is unsound"** — **refuted**: §2, sha256 `ae45d5dc220527b2...`,
419+ matching the previous lane's four-way agreement.
420+* **"my comparator proved `Y_intrabc_10b` byte-exact"** — **refuted by the
421+ comparator's own liveness guard** (§2). I am recording the retraction because
422+ the false line was produced by a real command, not by a typo.
423+
424+---
425+
426+## 8. Regression sweep
427+
428+```
429+$ CARGO_TARGET_DIR=/home/user/.cache/tgt/av1422llintra EC_NOMEMGUARD=1 \
430+ cargo test -p ec-av1 --lib -- 422 lossless 444 \
431+ --skip bitrate_target_lands_within_5_percent_over_48_frames
432+test result: ok. 70 passed; 0 failed; 0 ignored; 0 measured; 719 filtered out; finished in 26.30s
433+```
434+
435+**70 passed, 0 failed.** That includes the whole 4:4:4 family, the lossless
436+transform family, and every pinned 4:2:2 refusal-by-name gate. The skip is the
437+known separate in-process hang.
438+
439+`cargo check -p ec-av1 --all-targets` is clean.
440+
441+---
442+
443+## 9. Fixture provenance
444+
445+| file | bytes | sha256 |
446+|---|---|---|
447+| `W_intrabc.obu` | 130 320 | `0aad0d6fdd23655749110baf7db6e831d78103ef4bd0355dcd49ba6276af310c` |
448+| `X_intrabc_tiled.obu` | 131 696 | `e7c0c60af1a615312196bfba042b558aca73302ce6c7b85d93096369192fb40b` |
449+| `Y_intrabc_10b.obu` | 202 281 | `ce84d7cb4cfadf3f52f783628dfbfcf5c07059ddbc356889967f4e7a764b2c22` |
450+| `probe/ll422_allintra.obu` | 43 255 | `d56f6b655743897ad998f7dbba7742cb4c3fa677b544d72fddb2d8223085dfb8` |
451+
452+No instrumentation remains in the committed tree. Every trace used above is the
453+crate's own env-gated rung or the oracle's pre-existing one; nothing was left
454+behind.
455+
456+## 10. `not_done`
457+
458+- **`Y_intrabc_10b` is not localised** past "it refuses at frame 0" (§6), and its
459+ fork is not reported because its 10-bit rung-shape normalisation is not
460+ trustworthy.
461+- **The remaining `ll422_allintra` chroma residual is handed over, not fixed**
462+ (§4.5): the leaf-8 chroma PREDICTION at chroma (92, 8), mi(2,46), interior-only.
463+- **`W`/`X` frames 1..15 are not localised** — only frame 0 is now exact.
464+- **No committed gate exists for the decode change and none can** (§5).
465+- **No full-suite run** (lane rules: scoped only; project-wide validation is
466+ Main's).