From 0b7aabe049dcf54366a424973dc11fde5ca7e1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 30 Sep 2026 19:57:10 +0300 Subject: [PATCH] av1txctxband2: correct the band-overwrite counter's doc to what the predicate actually measures A refutation pass (lane av1txctxband2, reviewer) reproduced every load-bearing claim of the band fix -- the libaom either/or, the RECT twin, the named missing write at mi=(78,110), per-plane per-frame exatness on both 640x480 cells under a proven-live comparator, the 457907-read ladder with a comparator shown to bite, and the mutation (removing only the set_txfm_ctxs call reds the gate and returns the cell to the reported Golomb refusal) -- and falsified ONE documentation claim, which is corrected here. The counter's predicate is `!intra_only && any covered above-band cell != pub_above`, which counts a FIRST WRITE into a tile column still at TXFM_CTX_INIT as well as a genuine replacement of an earlier block's size. Measured on committed fixtures: 420_lossless_tallinter_8x16.obu fires 48 with every covered column still at init (the old doc predicted 0 on exactly such a stream), 420_lossless_arf_1to4_320x240_5f.obu fires 320 with 53 first touches, and 183 of the pin's 944 are first touches. The count remains a decision that a reader can act on, so the gate keeps its teeth and no behaviour changes; only the doc's narrower causal reading ("overwrote a size some earlier block left") was wrong and is now replaced with the measured one plus the refutation's numbers. --- crates/ec-av1/src/decode.rs | 49 +++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 6397ede3..3e62dd0a 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -29941,14 +29941,23 @@ fn read_block_tx_size( 4 }; // The gate's non-vacuity arm, on the DECISION, sampled BEFORE the - // write: this publish OVERWRITES a size some earlier block of the same - // frame had left in one of the columns it covers -- the only way a - // later `get_tx_size_context` / `txfm_partition_context` reader can - // see it. On a frame whose blocks all sit in lossless segments nothing - // reads either band (libaom's `read_tx_size` returns before - // `get_tx_size_context`, and the var-tx tree is gated on - // `!xd->lossless`), so a wholly-lossless stream whose inter blocks are - // all non-skip leaves this at zero. + // write: this publish CHANGES at least one of the above-band cells it + // covers -- the cell did not already hold `pub_above`, so a later + // `get_tx_size_context` / `txfm_partition_context` reader in the same + // tile column reads a value the publish produced. + // + // CORRECTED 2026-09-30 (refutation pass `lanes/refute-av1txctxband2`): + // an earlier version of this comment, and of the static's doc, claimed + // the write counts only when it OVERWRITES "a size some earlier block + // had left", and that a wholly-lossless all-non-skip stream leaves it + // at zero. MEASURED FALSE: 420_lossless_tallinter_8x16.obu fires 48, + // ALL with every covered column still at `TXFM_CTX_INIT` -- a first + // write into a fresh tile column counts here too, because the test is + // "the cell did not already hold this value", not "some block wrote a + // different value earlier". Of the pin's 944 fires, 183 are that + // first-touch case. The count is still a decision (no reader, no + // intra-only frame, no unchanged column), so the gate keeps its teeth; + // only the doc's stronger reading was wrong. let overwrote = !fctx.intra_only.with(std::cell::Cell::get) && (0..side_mi).any(|i| n.above_txfm.get(at_mi.1 + i) != Some(&pub_above)); set_txfm_ctxs(n, at_mi, 4, side_mi, side_mi, skip && is_inter); @@ -34821,14 +34830,24 @@ thread_local! { /// doing. pub(crate) static SUB8_LOSSLESS_NO_VARTX: std::cell::Cell = const { std::cell::Cell::new(0) }; /// lane-av1txctxband2: SQUARE lossless blocks on an INTER frame whose - /// `set_txfm_ctxs` publish CHANGED an above-band cell -- i.e. the write - /// overwrote a size some earlier block of the same frame had left, which - /// is the only way a later `get_tx_size_context` / - /// `txfm_partition_context` reader can see it. Zero on an intra-only + /// `set_txfm_ctxs` publish CHANGED at least one above-band cell it covers + /// (the cell did not already hold the published size), so a later + /// `get_tx_size_context` / `txfm_partition_context` reader in the same + /// tile column reads a value this publish produced. Zero on an intra-only /// frame (where `fill_lf_grid_rect_inner` publishes the same 4x4 value at - /// the same footprint) and on a wholly-lossless stream whose inter blocks - /// are all non-skip (nothing reads either band there), so a gate cannot - /// look armed by merely decoding a lossless fixture. + /// the same footprint). + /// + /// CORRECTED 2026-09-30 (refutation pass `lanes/refute-av1txctxband2`): + /// this doc previously claimed the hit meant "overwrote a size some + /// earlier block left" and that a wholly-lossless all-non-skip stream + /// leaves it at zero. MEASURED FALSE -- `420_lossless_tallinter_8x16.obu` + /// fires **48**, all of them first touches of a column still at + /// `TXFM_CTX_INIT`; `420_lossless_arf_1to4_320x240_5f.obu` fires 320, 53 of + /// them first touches. Of the pin's 944, **183 are first-touch**. The + /// predicate tests "the cell did not already hold this value", which is + /// the decision that matters (no reader, no intra-only frame, no unchanged + /// column still reads 0), but it is NOT the strictly narrower causal claim + /// the old text made. pub(crate) static LOSSLESS_SQ_TXFM_BAND_OVERWRITE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; }