forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1cflac: the cfl_ac_q3_at 4:4:4 premise is REFUTED, and it is now guarded

Browse files at this commit

f82a113b4e79b7668b5372098dde9dc378ddbde4Ahmet Kaan GümüşParent: 66148c5d6bb506
The inherited '188 rung hits at 4:4:4' does not reproduce: 0 hits on all 26 *444* pins, while
cfl_ac_ss's own 4:4:4 arm fires 1834 times and is byte-exact vs aomdec. cfl_ac_ss dispatches 4:4:4
and 4:2:2 to their own libaom bodies BEFORE the 4:2:0 fallthrough that owns cfl_ac_q3_at, so the
halving and the 2x2 average are correct at every reachable call site (the 4:2:0 total on the same
counter is 33752 - where the 188 almost certainly came from). No decode behaviour change: two gates
(the 4:4:4 arm>0 AND cfl_ac_q3_at==0 on one counter with per-plane 0/0/0 vs aomdec; a static closure
proving cfl_ac_q3_at is reached only through the 4:2:0 fallthrough), an oracle_plane_diffs helper and
per-arm counters. Mutation reds the gate, and in its naive half-extent form it PANICS (len 16, index
16) rather than mis-colouring - correcting the inherited 'silent wrongness' framing.
crates/ec-av1/examples/decode_probe.rsmodified+5 -0
@@ -34,6 +34,11 @@ fn main() {
3434 if !cfg!(feature = "gate-counters") {
3535 println!("counters disabled (built without the gate-counters feature)");
3636 }
37+ let [a444, a422, s420, r420] = ec_av1::decode::cfl_ac_arm_hits();
38+ println!(
39+ "cfl_ac: 444={a444} 422={a422} 420sq={s420} 420rect={r420} q3_at={}",
40+ ec_av1::decode::cfl_ac_q3_at_hits()
41+ );
3742 let (sc, dp) = ec_av1::decode::reelc_chroma_counters();
3843 println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}");
3944 println!(
crates/ec-av1/src/decode.rsmodified+37 -0
@@ -6000,6 +6000,35 @@ thread_local! {
60006000 static CFL_BLOCK_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
60016001 static UV_ANGLE_DELTA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
60026002 }
6003+// lane-av1cfl: which `cfl_ac_ss` arm ran, one bump per CfL block. The 4:4:4
6004+// arm is libaom `cfl_luma_subsampling_444_lbd_c` (1x1 luma per chroma sample)
6005+// and the 4:2:2 arm is `cfl_luma_subsampling_422_lbd_c`; only the last two
6006+// reach `cfl_ac_q3_at`'s 2x2 average, so these four are the reachability
6007+// evidence for that function's format-blind extent.
6008+thread_local! {
6009+ static CFL_AC_444_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
6010+ static CFL_AC_422_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
6011+ static CFL_AC_420_SQ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
6012+ static CFL_AC_420_RECT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
6013+ static CFL_AC_Q3_AT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
6014+}
6015+
6016+/// `[4:4:4, 4:2:2, 4:2:0 square, 4:2:0 rect]` [`cfl_ac_ss`] arm hits.
6017+pub fn cfl_ac_arm_hits() -> [usize; 4] {
6018+ [
6019+ CFL_AC_444_HITS.with(|c| c.get()),
6020+ CFL_AC_422_HITS.with(|c| c.get()),
6021+ CFL_AC_420_SQ_HITS.with(|c| c.get()),
6022+ CFL_AC_420_RECT_HITS.with(|c| c.get()),
6023+ ]
6024+}
6025+
6026+/// Entries into [`cfl_ac_q3_at`] itself -- the one arm whose extent is
6027+/// `bw / 2, bh / 2` and whose footprint is a 2x2 luma average. The gate
6028+/// proves it is reached ONLY at 4:2:0.
6029+pub fn cfl_ac_q3_at_hits() -> usize {
6030+ CFL_AC_Q3_AT_HITS.with(|c| c.get())
6031+}
60036032
60046033 /// Current value of [`CFL_BLOCK_HITS`].
60056034 #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
@@ -20121,6 +20150,7 @@ fn cfl_ac_ss(
2012120150 ss_y: usize,
2012220151 ) -> Vec<i32> {
2012320152 if ss_x == 0 && ss_y == 0 {
20153+ hit!(CFL_AC_444_HITS);
2012420154 let mut ac = vec![0i32; bw * bh];
2012520155 let mut sum = 0i32;
2012620156 for row in 0..bh {
@@ -20140,6 +20170,7 @@ fn cfl_ac_ss(
2014020170 // (`(a + b) >> 1` in Q3 is `(a + b) << 2`). A rect luma strip's chroma
2014120171 // is square here, and the 4:2:0 rect/square helpers below would halve
2014220172 // the height it must keep.
20173+ hit!(CFL_AC_422_HITS);
2014320174 let (cw, ch) = (bw >> 1, bh);
2014420175 let mut ac = vec![0i32; cw * ch];
2014520176 let mut sum = 0i32;
@@ -20158,8 +20189,10 @@ fn cfl_ac_ss(
2015820189 ac.iter_mut().for_each(|v| *v -= avg);
2015920190 ac
2016020191 } else if bw == bh {
20192+ hit!(CFL_AC_420_SQ_HITS);
2016120193 cfl_ac_q3(y, px, py, bw)
2016220194 } else {
20195+ hit!(CFL_AC_420_RECT_HITS);
2016320196 cfl_ac_q3_rect(y, px, py, bw, bh)
2016420197 }
2016520198 }
@@ -20171,6 +20204,10 @@ pub(crate) fn cfl_ac_q3_at(
2017120204 bh: usize,
2017220205 sample: impl Fn(usize, usize) -> i32,
2017320206 ) -> Vec<i32> {
20207+ hit!(CFL_AC_Q3_AT_HITS);
20208+ if crate::envflags::env_flag!("EC_HALVSWEEP") {
20209+ eprintln!("EC_HALV cfl_ac_q3_at px={px} py={py} bw={bw} bh={bh}");
20210+ }
2017420211 let (cw, ch) = (bw / 2, bh / 2);
2017520212 let mut ac = vec![0i32; cw * ch];
2017620213 let mut sum = 0i32;
crates/ec-av1/src/stream.rsmodified+397 -0
@@ -47709,6 +47709,403 @@ pub(crate) mod tests {
4770947709 }
4771047710 }
4771147711
47712+ /// lane-av1cfl: the 4:4:4 CfL AC body is a DIFFERENT function from the
47713+ /// 4:2:0 one, and this gate is the proof that the format-blind
47714+ /// `cfl_ac_q3_at` (`bw / 2, bh / 2`, a 2x2 luma average per chroma
47715+ /// sample) is reached only at 4:2:0.
47716+ ///
47717+ /// **The claim this closes.** `cfl_ac_q3_at` has no `fctx`/`ss`
47718+ /// parameter, so at 4:4:4 it would be wrong twice over: the chroma
47719+ /// extent equals the luma extent when `ss_x == ss_y == 0`, and libaom
47720+ /// averages 2x2 luma per chroma sample at 4:2:0 but 1x1 at 4:4:4
47721+ /// (`cfl_luma_subsampling_420_lbd_c` vs `cfl_luma_subsampling_444_lbd_c`,
47722+ /// `~/.cache/aom-oracle/src/av1/common/cfl.c:230` and `:257`). The
47723+ /// inherited report claimed "188 rung hits on the 4:4:4 set"
47724+ /// (`lanes/av1chromahalvings.report.md` r3.4). **It does not
47725+ /// reproduce**: the env-gated rung `EC_HALVSWEEP` in `cfl_ac_q3_at`,
47726+ /// swept over all 27 `*444*` pins, printed **0 hits on every one**,
47727+ /// while the 4:4:4 arm of `cfl_ac_ss` fired 4..312 times on the same
47728+ /// fixtures. The 4:4:4 CfL path is real and heavily exercised; it just
47729+ /// does not go through this function. `cfl_ac_ss` dispatches 4:4:4 and
47730+ /// 4:2:2 to their own transcriptions of libaom's 444/422 subsampling
47731+ /// bodies BEFORE the 4:2:0 fallthrough, and the fallthrough is the only
47732+ /// road to `cfl_ac_q3_at`.
47733+ ///
47734+ /// Two-sided on purpose. The 4:4:4 arm asserts `> 0` (the CfL path
47735+ /// fired, so the `== 0` below is a routing fact and not an absence of
47736+ /// CfL) and the 4:2:0 arm asserts `> 0` on the SAME counter (so the
47737+ /// counter is live and the 4:4:4 zero is not a dead one). Both arms
47738+ /// compare every decoded frame to the instrumented `aomdec`
47739+ /// plane by plane, and the 4:2:0 arm is the "unchanged" quote: its
47740+ /// per-plane mismatch counts must be 0/0/0.
47741+ ///
47742+ /// Provenance: both fixtures are aomenc-produced and already pinned
47743+ /// with sha256 by the gates named beside them. 4:4:4 lossy
47744+ /// `444_lossy_superres_mode2_256x128.obu` (16620 bytes, sha256
47745+ /// `c18496cf3b7db0feca9aa904024cec2115be80b5b94f87c848ac52f9b32ffd97`,
47746+ /// `testsrc2=size=256x128:rate=25 -pix_fmt yuv444p`, `--passes=1
47747+ /// --end-usage=q --cq-level=20 --cpu-used=2 --superres-mode=2
47748+ /// --limit=4 --obu`, 4 frames); 4:2:0 lossy
47749+ /// `420_intrabc_rect4_witness.obu` (890 bytes, sha256
47750+ /// `d01352af5059919cdce733abdcbae8e8240ac3c2a6190fa1bd96d3c6f945b979`).
47751+ #[test]
47752+ fn cfl_ac_444_routes_to_its_own_1x1_luma_body_and_420_to_the_2x2_average() {
47753+ const NAME: &str = "cfl_ac_444_routes_to_its_own_1x1_luma_body_and_420_to_the_2x2_average";
47754+ // (fixture, len, fnv1a64, sha256, (w, h), frames, cfL arm index, is_444)
47755+ const ARMS: [(&str, usize, u64, &str, (usize, usize), usize, usize, bool); 2] = [
47756+ (
47757+ "fixtures/444_lossy_superres_mode2_256x128.obu",
47758+ 16620,
47759+ 0x8cbb_36b2_5e0f_07ab,
47760+ "c18496cf3b7db0feca9aa904024cec2115be80b5b94f87c848ac52f9b32ffd97",
47761+ (256, 128),
47762+ 4,
47763+ 0,
47764+ true,
47765+ ),
47766+ (
47767+ "fixtures/420_intrabc_rect4_witness.obu",
47768+ 890,
47769+ 0x57ec_3da2_a63b_403a,
47770+ "d01352af5059919cdce733abdcbae8e8240ac3c2a6190fa1bd96d3c6f945b979",
47771+ (640, 480),
47772+ 1,
47773+ 2,
47774+ false,
47775+ ),
47776+ ];
47777+ let _guard = lock_gate_counters();
47778+ for (fixture, len, fnv, sha, (w, h), want_frames, arm_idx, is_444) in ARMS {
47779+ let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(fixture);
47780+ let stream = std::fs::read(&obu).unwrap_or_else(|e| {
47781+ panic!(
47782+ "{NAME}: pinned fixture {fixture} is missing ({e}) -- the gate cannot run, \
47783+ which is a failure, not a skip"
47784+ )
47785+ });
47786+ assert_eq!(stream.len(), len, "{NAME}: {fixture} length moved");
47787+ assert_eq!(fnv1a64(&stream), fnv, "{NAME}: {fixture} bytes moved");
47788+
47789+ // The arm counters are process-wide with no reset, so every read
47790+ // is a DELTA: a full-suite run has already put other streams'
47791+ // CfL blocks through this decoder, and an absolute count would be
47792+ // a non-vacuity assertion satisfied by residue.
47793+ let arms_before = crate::decode::cfl_ac_arm_hits();
47794+ let q3_before = crate::decode::cfl_ac_q3_at_hits();
47795+ let frames = decode_stream(&stream)
47796+ .unwrap_or_else(|e| panic!("{NAME}: {fixture} no longer decodes cleanly: {e}"));
47797+ let arms = crate::decode::cfl_ac_arm_hits();
47798+ let q3_delta = crate::decode::cfl_ac_q3_at_hits() - q3_before;
47799+ let arm_delta: Vec<usize> = (0..4).map(|i| arms[i] - arms_before[i]).collect();
47800+
47801+ // The arm this stream's format MUST take, and the count that
47802+ // proves the CfL path is live on it. At 4:4:4 that is arm 0
47803+ // (`cfl_luma_subsampling_444_lbd_c`'s 1x1 body); at 4:2:0 it is
47804+ // arm 2 (the square fallthrough into `cfl_ac_q3`).
47805+ assert!(
47806+ arm_delta[arm_idx] > 0,
47807+ "{NAME}: {fixture} ran {} 4:4:4 / {} 4:2:2 / {} 4:2:0-square / \
47808+ {} 4:2:0-rect CfL blocks; arm {arm_idx} is the one this format must \
47809+ take and it is ZERO -- the stream no longer exercises CfL, so the \
47810+ routing assertion below would be vacuous (class gate-blind-to-feature)",
47811+ arm_delta[0],
47812+ arm_delta[1],
47813+ arm_delta[2],
47814+ arm_delta[3],
47815+ );
47816+ if is_444 {
47817+ assert_eq!(
47818+ q3_delta, 0,
47819+ "{NAME}: {fixture} is 4:4:4 and entered the format-blind cfl_ac_q3_at \
47820+ {q3_delta} time(s) -- its extent is bw/2, bh/2 and its footprint is a \
47821+ 2x2 luma average, both wrong at ss (0,0) (libaom cfl.c:230 vs :257). \
47822+ Arm deltas {arm_delta:?}. Either cfl_ac_ss lost its 4:4:4 arm or a new \
47823+ caller reached cfl_ac_q3_at directly; both make this site LIVE"
47824+ );
47825+ assert_eq!(
47826+ (arm_delta[2], arm_delta[3]),
47827+ (0, 0),
47828+ "{NAME}: {fixture} is 4:4:4 but ran the 4:2:0 CfL arms -- the format test \
47829+ that keeps cfl_ac_q3_at format-blind has moved"
47830+ );
47831+ } else {
47832+ assert!(
47833+ q3_delta > 0,
47834+ "{NAME}: {fixture} is 4:2:0 and cfl_ac_q3_at was entered ZERO times \
47835+ (arm deltas {arm_delta:?}) -- the counter this gate proves 4:4:4 never \
47836+ touches is dead on 4:2:0 too, so the 4:4:4 assertion is a dead zero"
47837+ );
47838+ assert_eq!(
47839+ (arm_delta[0], arm_delta[1]),
47840+ (0, 0),
47841+ "{NAME}: {fixture} is 4:2:0 but ran a 4:4:4 or 4:2:2 CfL arm"
47842+ );
47843+ }
47844+ assert_eq!(frames.len(), want_frames, "{NAME}: {fixture} frame count");
47845+ for (i, f) in frames.iter().enumerate() {
47846+ assert_eq!(
47847+ (f.width, f.height),
47848+ (w, h),
47849+ "{NAME}: {fixture} frame {i} dimensions"
47850+ );
47851+ if is_444 {
47852+ assert_eq!(
47853+ f.u.len(),
47854+ w * h,
47855+ "{NAME}: {fixture} frame {i} chroma plane is {} samples; at 4:4:4 it \
47856+ must be full resolution ({w}x{h})",
47857+ f.u.len()
47858+ );
47859+ }
47860+ }
47861+ // Per-plane mismatch counts against the instrumented oracle, so
47862+ // the "4:2:0 unchanged" claim is a number rather than a claim.
47863+ if aomdec_available(NAME) {
47864+ let [y, u, v] = oracle_plane_diffs(
47865+ &stream,
47866+ NAME,
47867+ [frames[0].y.len(), frames[0].u.len(), frames[0].v.len()],
47868+ );
47869+ assert!(
47870+ y == 0 && u == 0 && v == 0,
47871+ "{NAME}: {fixture} differs from the oracle on {y}/{u}/{v} of the \
47872+ {w}x{h} Y/U/V samples -- sha256 {sha}"
47873+ );
47874+ eprintln!(
47875+ "{NAME}: {fixture} arm{arm_idx} {arm_delta:?}, cfl_ac_q3_at {q3_delta}, \
47876+ per-plane Y/U/V mismatches vs aomdec {y}/{u}/{v} of {w}x{h}; \
47877+ sha256 {sha}"
47878+ );
47879+ }
47880+ }
47881+ }
47882+
47883+ /// lane-av1cfl: the STATIC half of the same claim -- `cfl_ac_q3_at`'s
47884+ /// caller set, read out of the sources themselves, is what makes its
47885+ /// `bw / 2, bh / 2` extent and 2x2 luma footprint correct rather than
47886+ /// merely untested. The counter gate above measures that on two pinned
47887+ /// streams; this one survives a change no fixture would catch.
47888+ ///
47889+ /// **What is asserted, and why each part is load-bearing.**
47890+ ///
47891+ /// 1. `cfl_ac_q3_at` has exactly **three** call sites -- the two 4:2:0
47892+ /// wrappers `cfl_ac_q3` / `cfl_ac_q3_rect` in `decode.rs` and the
47893+ /// encoder's CfL candidate in `encode.rs`. A fourth would be a new
47894+ /// road to a format-blind body.
47895+ /// 2. Both `decode.rs` wrappers are called from **exactly one** function,
47896+ /// `cfl_ac_ss`, and only from its LAST two arms -- the ones after the
47897+ /// `ss_x == 0 && ss_y == 0` (4:4:4) and `ss_x == 1 && ss_y == 0`
47898+ /// (4:2:2) tests. So every decode-side entry is 4:2:0 by
47899+ /// construction, whatever a stream's header says.
47900+ /// 3. The encoder's call site is 4:2:0 because `Colour::color_config` and
47901+ /// `unspecified_color_config` both hardcode `subsampling_x: 1,
47902+ /// subsampling_y: 1` -- there is no 4:4:4 encoder colour config in the
47903+ /// crate. A future encoder that grows one must thread `ss` into this
47904+ /// call, and the `subsampling_x: 0` count going above zero is what
47905+ /// says so.
47906+ ///
47907+ /// (0, 1) needs no arm: `ec-av1-syntax` reads `subsampling_y` only when
47908+ /// `subsampling_x == 1` (`crates/ec-av1-syntax/src/sequence.rs:483-485`),
47909+ /// so the pair is structurally uncodable and the 4:2:0 fallthrough is the
47910+ /// only residual. 4:2:2 is refused at the sequence header.
47911+ #[test]
47912+ fn cfl_ac_q3_at_is_reached_only_through_the_420_fallthrough_of_cfl_ac_ss() {
47913+ const NAME: &str = "cfl_ac_q3_at_is_reached_only_through_the_420_fallthrough_of_cfl_ac_ss";
47914+ let decode = include_str!("decode.rs");
47915+ let encode = include_str!("encode.rs");
47916+
47917+ // (1) The call-site set, definition excluded. A declaration is
47918+ // preceded by "pub(crate) fn " / "fn "; a call is not.
47919+ let mut sites: Vec<&str> = Vec::new();
47920+ for src in [decode, encode] {
47921+ for (i, _) in src.match_indices("cfl_ac_q3_at(") {
47922+ if src[..i].ends_with("fn ") {
47923+ continue;
47924+ }
47925+ sites.push(if src == decode {
47926+ "decode.rs"
47927+ } else {
47928+ "encode.rs"
47929+ });
47930+ }
47931+ }
47932+ let mut per_file: std::collections::BTreeMap<&str, usize> =
47933+ std::collections::BTreeMap::new();
47934+ for s in &sites {
47935+ *per_file.entry(s).or_default() += 1;
47936+ }
47937+ assert_eq!(
47938+ per_file,
47939+ std::collections::BTreeMap::from([("decode.rs", 2), ("encode.rs", 1)]),
47940+ "{NAME}: cfl_ac_q3_at's call-site set changed -- {per_file:?} against an expected \
47941+ 2 in decode.rs (the cfl_ac_q3 / cfl_ac_q3_rect wrappers) and 1 in encode.rs (the \
47942+ encoder's CfL candidate). A new call site must thread the frame's subsampling in; \
47943+ the body is a 4:2:0 2x2 luma average over a bw/2 x bh/2 extent and is WRONG at \
47944+ 4:4:4 on both counts (libaom cfl_luma_subsampling_444_lbd_c is 1x1 over the full \
47945+ extent, cfl.c:257)"
47946+ );
47947+
47948+ // (2) Both wrappers have exactly one caller, and it is cfl_ac_ss.
47949+ let cfl_ac_ss_at = decode
47950+ .find("fn cfl_ac_ss(")
47951+ .expect("cfl_ac_ss is gone -- re-derive the fallthrough arms below");
47952+ for wrapper in ["cfl_ac_q3(", "cfl_ac_q3_rect("] {
47953+ let mut ats = Vec::new();
47954+ for (i, _) in decode.match_indices(wrapper) {
47955+ if decode[..i].ends_with("fn ") {
47956+ continue;
47957+ }
47958+ ats.push(i);
47959+ }
47960+ // The scan string carries its own open paren, so it cannot match
47961+ // `cfl_ac_q3_rect(` or `cfl_ac_q3_at(` -- those are `cfl_ac_q3`
47962+ // followed by `_`, not `(`. No prefix filter is needed.
47963+ assert_eq!(
47964+ ats.len(),
47965+ 1,
47966+ "{NAME}: `{wrapper}` is called {} time(s) outside its own definition, expected \
47967+ exactly 1 (from cfl_ac_ss) -- a second caller is a new road to the 4:2:0 \
47968+ average that this gate's counter arm measures only on 4:2:0",
47969+ ats.len()
47970+ );
47971+ assert!(
47972+ ats[0] > cfl_ac_ss_at && ats[0] < cfl_ac_ss_at + 4000,
47973+ "{NAME}: `{wrapper}`'s only call site is at byte {} and cfl_ac_ss is at {} -- \
47974+ the call has moved out of the 4:2:0 fallthrough into something that may be \
47975+ handed a 4:4:4 or 4:2:2 block",
47976+ ats[0],
47977+ cfl_ac_ss_at
47978+ );
47979+ }
47980+
47981+ // Inside cfl_ac_ss, the two format tests must come BEFORE both
47982+ // wrapper calls, and the wrappers must be the fallthrough -- a 4:4:4
47983+ // block returns from the first arm and never reaches either.
47984+ let body_end = decode[cfl_ac_ss_at..]
47985+ .find("\nfn ")
47986+ .expect("cfl_ac_ss must be a top-level fn")
47987+ + cfl_ac_ss_at;
47988+ let body = &decode[cfl_ac_ss_at..body_end];
47989+ let t444 = body.find("if ss_x == 0 && ss_y == 0 {").expect(
47990+ "cfl_ac_ss lost its 4:4:4 arm -- every 4:4:4 CfL block now falls into the \
47991+2:0 average",
47992+ );
47993+ let t422 = body
47994+ .find("} else if ss_x == 1 && ss_y == 0 {")
47995+ .expect("cfl_ac_ss lost its 4:2:2 arm -- a 4:2:2 block would take the 4:2:0 average");
47996+ let sq = body
47997+ .find("cfl_ac_q3(y, px, py, bw)")
47998+ .expect("cfl_ac_ss lost its 4:2:0 square fallthrough");
47999+ let rect = body
48000+ .find("cfl_ac_q3_rect(y, px, py, bw, bh)")
48001+ .expect("cfl_ac_ss lost its 4:2:0 rect fallthrough");
48002+ assert!(
48003+ t444 < t422 && t422 < sq && sq < rect,
48004+ "{NAME}: cfl_ac_ss's arm order moved (4:4:4 at {t444}, 4:2:2 at {t422}, 4:2:0 square \
48005+ at {sq}, 4:2:0 rect at {rect}) -- the format-blind 2x2 average must stay the \
48006+ FALLTHROUGH, after both format tests have had their chance to return"
48007+ );
48008+
48009+ // (3) The encoder's colour configs are 4:2:0 only.
48010+ for (src, label) in [
48011+ (encode, "encode.rs"),
48012+ (include_str!("encoder.rs"), "encoder.rs"),
48013+ ] {
48014+ let n = src.matches("subsampling_x: 0").count();
48015+ assert_eq!(
48016+ n, 0,
48017+ "{NAME}: {label} now builds a 4:4:4 ColorConfig ({n} site(s)) -- the encoder's \
48018+ cfl_ac_q3_at call (encode.rs) is a 4:2:0 2x2 average over a half extent and \
48019+ must thread ss before any encoder can emit one"
48020+ );
48021+ }
48022+ }
48023+
48024+ /// lane-av1cfl: per-plane sample-mismatch counts between this decoder's
48025+ /// final stored frames and the instrumented oracle's, summed over every
48026+ /// decode-order frame. Returns `[Y, U, V]`.
48027+ ///
48028+ /// [`decode_all_frames_vs_oracle`] panics on the first differing byte,
48029+ /// which names an offset but not WHICH PLANE the offset falls in -- and
48030+ /// for a chroma-scoped defect the plane split is the whole diagnosis
48031+ /// (luma byte-exact while U and V both diverge is the chroma-sizing
48032+ /// signature; all three diverging is not).
48033+ ///
48034+ /// `plane_samples` is each plane's own sample count in DECODE order
48035+ /// (`[Y, U, V]`) and is read off this decoder's own frame rather than
48036+ /// derived from the dimensions: at 4:2:0 the chroma planes are half-size
48037+ /// and at 4:4:4 full-size, and a helper that assumed one layout would
48038+ /// report every chroma byte as a luma byte. 8-bit only: the dump is one
48039+ /// byte per sample at 8-bit and two at 10/12.
48040+ fn oracle_plane_diffs(stream: &[u8], name: &str, plane_samples: [usize; 3]) -> [usize; 3] {
48041+ let dir = std::env::temp_dir().join(format!("ec-av1-{name}-planes-{}", std::process::id()));
48042+ let _ = std::fs::remove_dir_all(&dir);
48043+ std::fs::create_dir_all(&dir).expect("scratch dir");
48044+ let obu = dir.join("in.obu");
48045+ std::fs::write(&obu, stream).expect("writing the stream");
48046+ let aom_prefix = dir.join("aom");
48047+ let out = Command::new(aomdec_path())
48048+ .args(["--codec=av1", "-o"])
48049+ .arg(dir.join("out.y4m"))
48050+ .arg(&obu)
48051+ .env("EC_AV1_FINAL_DUMP", &aom_prefix)
48052+ .stdin(Stdio::null())
48053+ .stdout(Stdio::piped())
48054+ .stderr(Stdio::piped())
48055+ .output()
48056+ .expect("aomdec failed to run");
48057+ assert!(
48058+ out.status.success(),
48059+ "{name}: the oracle aomdec refused the stream: {}",
48060+ String::from_utf8_lossy(&out.stderr)
48061+ );
48062+ let mut oracle_frames = 0usize;
48063+ while std::path::PathBuf::from(format!("{}.f{oracle_frames}", aom_prefix.display()))
48064+ .is_file()
48065+ {
48066+ oracle_frames += 1;
48067+ }
48068+ assert!(
48069+ oracle_frames > 0,
48070+ "{name}: the oracle wrote no EC_AV1_FINAL_DUMP frames -- rung 12 of \
48071+ scripts/instrument-aom-oracle.sh is missing from {}",
48072+ aomdec_path().display()
48073+ );
48074+ let ours_prefix = dir.join("ours");
48075+ set_final_dump_prefix(Some(ours_prefix.display().to_string()));
48076+ let decoded = decode_stream(stream);
48077+ set_final_dump_prefix(None);
48078+ let _ = decoded.expect("the caller already decoded this stream cleanly");
48079+ let total: usize = plane_samples.iter().sum();
48080+ // Plane boundaries in the concatenated dump, in DECODE order.
48081+ let mut starts = [0usize; 3];
48082+ for p in 1..3 {
48083+ starts[p] = starts[p - 1] + plane_samples[p - 1];
48084+ }
48085+ let mut per_plane = [0usize; 3];
48086+ for i in 0..oracle_frames {
48087+ let want =
48088+ std::fs::read(format!("{}.f{i}", aom_prefix.display())).expect("oracle dump");
48089+ let got = std::fs::read(format!("{}.f{i}", ours_prefix.display())).expect("our dump");
48090+ assert_eq!(
48091+ got.len(),
48092+ total,
48093+ "{name}: decode-order frame {i} is {} bytes, expected {plane_samples:?} at 8-bit",
48094+ got.len()
48095+ );
48096+ for p in 0..3 {
48097+ let (a, b) = (starts[p], starts[p] + plane_samples[p]);
48098+ per_plane[p] += got[a..b]
48099+ .iter()
48100+ .zip(&want[a..b])
48101+ .filter(|(x, y)| x != y)
48102+ .count();
48103+ }
48104+ }
48105+ let _ = std::fs::remove_dir_all(&dir);
48106+ per_plane
48107+ }
48108+
4771248109 /// lane-av1444edge r3: the FIRST 4:4:4 superres cell in the crate, and
4771348110 /// the cell the chroma-format sweep's "4:4:4 superres" row was supposed
4771448111 /// to be.
lanes/av1cflac.report.mdadded+390 -0
@@ -0,0 +1,390 @@
1+---
2+name: lane-av1cflac
3+base: 3b691e13 (main at lane start; main has since moved to 3aa16dd1)
4+branch: lane-av1cflac
5+worktree: /home/user/.cache/wt/av1cflac
6+---
7+
8+# lane-av1cflac — `cfl_ac_q3_at` at 4:4:4: **PATH 2, UNREACHABLE.** The
9+# "188 rung hits on the 4:4:4 set" premise does not reproduce (0 on all 26
10+# `*444*` pins), the defect is real but latent, and it is now closed with two
11+# committed non-vacuous gates instead of a fix.
12+
13+**One line, because the whole lane turns on it:** the 4:4:4 CfL path never
14+reaches `cfl_ac_q3_at`; `cfl_ac_ss` gives 4:4:4 its own libaom-anchored 1x1
15+body, so `bw / 2, bh / 2` is correct at every reachable call site and no
16+behaviour change was made.
17+
18+---
19+
20+## 0. Verdict on the inherited premises
21+
22+| premise (charter / `lanes/av1chromahalvings.report.md` r3.4, r5.0) | status | evidence |
23+|---|---|---|
24+| `cfl_ac_q3_at` has no `fctx`/`ss` and `let (cw, ch) = (bw / 2, bh / 2);` | **TRUE** | `decode.rs:19946-19957` on this branch (definition `19946`, halving `19957`) |
25+| At 4:4:4 it would be wrong twice — extent, and 2x2-vs-1x1 footprint | **TRUE, latent** | §2 |
26+| "188 rung hits on the 4:4:4 set" | **FALSE — does not reproduce** | §1: **0 hits on 26/26** `*444*` fixtures |
27+| "the threading through the CfL call tree is what's missing" | **MOOT** | the tree is already ss-aware: `exec_intra` passes `ss_x(fctx), ss_y(fctx)` into `cfl_ac_ss` (`decode.rs:4423`), and `cfl_ac_ss` dispatches 4:4:4/4:2:2 to their own bodies BEFORE the 4:2:0 fallthrough that owns `cfl_ac_q3_at` (`decode.rs:19898`, `19913`, `19937`, `19940`) |
28+| the 4:2:2 arm's `(bw >> 1, bh)` is inert at 4:4:4 (do not "fix" it) | **TRUE, and inert everywhere** | §1.3: `CFL_AC_422_HITS == 0` on all 85 pins; 4:2:2 is refused at the sequence header (`stream.rs:1752`) |
29+| main carries an `EC_HALVSWEEP` rung for `cfl_ac_q3_at` | **FALSE** | main `edffad9e` carries ONE rung, `EC_HALV ibc_owned` (main `decode.rs:16854`; my branch predates that merge, so the rung is absent here); `grep -c 'EC_HALV cfl_ac_q3_at'` on main = 0. The cfl rung lived only on the superseded `lane-chromahalvings-r3` (`19890`). My lane keeps exactly one copy. |
30+
31+Also corrected for the ledger: the `stream.rs` hunk in
32+`/tmp/leak-main-010352.patch` (the moved `FRAMES` assert, the dropped
33+`rect_narrow_kern_hits()`) is **not mine** — I never opened `stream.rs` for
34+edit before that leak. The `decode.rs` hunk in it was.
35+
36+---
37+
38+## 1. RED-BEFORE: the 188 does not reproduce; the 4:4:4 CfL path is real and goes elsewhere
39+
40+### 1.1 The rung, swept over the whole 4:4:4 set
41+
42+The env-gated rung was taken from the superseded r3 branch (identical lines),
43+kept env-gated, and landed at `decode.rs:19953`:
44+
45+```rust
46+pub(crate) fn cfl_ac_q3_at(
47+ px: usize, py: usize, bw: usize, bh: usize,
48+ sample: impl Fn(usize, usize) -> i32,
49+) -> Vec<i32> {
50+ hit!(CFL_AC_Q3_AT_HITS);
51+ if crate::envflags::env_flag!("EC_HALVSWEEP") {
52+ eprintln!("EC_HALV cfl_ac_q3_at px={px} py={py} bw={bw} bh={bh}");
53+ }
54+ let (cw, ch) = (bw / 2, bh / 2);
55+```
56+
57+Commands (lane-private `CARGO_TARGET_DIR`, so no cross-worktree binary
58+clobber):
59+
60+```text
61+$ cd /home/user/.cache/wt/av1cflac
62+$ CARGO_TARGET_DIR=/home/user/.cache/tgt/av1cflac cargo build -p ec-av1 --example decode_probe
63+$ export EC_HALVSWEEP=1
64+$ for f in crates/ec-av1/fixtures/*444*.obu; do ... grep -c "EC_HALV cfl_ac_q3_at" ... done
65+```
66+
67+Raw output — **rung column is 0 on every one**; the bracketed column is the
68+new per-arm counter, which is what the rung could not see:
69+
70+```text
71+rung=0 444_intrabc_rect4_witness.obu [cfl_ac: 444=72 422=0 420sq=0 420rect=0 q3_at=0]
72+rung=0 444_leaf8_oob.obu [cfl_ac: 444=72 422=0 420sq=0 420rect=0 q3_at=0]
73+rung=0 444_lossy_rect4_inter_witness.obu [cfl_ac: 444=8 422=0 420sq=0 420rect=0 q3_at=0]
74+rung=0 444_lossy_rect4_odd_130x122.obu [cfl_ac: 444=14 422=0 420sq=0 420rect=0 q3_at=0]
75+rung=0 444_lossy_rect4_wide_256x128.obu [cfl_ac: 444=8 422=0 420sq=0 420rect=0 q3_at=0]
76+rung=0 444_lossy_superres_256x128_d12.obu [cfl_ac: 444=70 422=0 420sq=0 420rect=0 q3_at=0]
77+rung=0 444_lossy_superres_256x128_d12_10bit.obu[cfl_ac: 444=86 422=0 420sq=0 420rect=0 q3_at=0]
78+rung=0 444_lossy_superres_256x128_d12_12bit.obu[cfl_ac: 444=212 422=0 420sq=0 420rect=0 q3_at=0]
79+rung=0 444_lossy_superres_256x128_d9.obu [cfl_ac: 444=40 422=0 420sq=0 420rect=0 q3_at=0]
80+rung=0 444_lossy_superres_256x128_d9_12bit.obu [cfl_ac: 444=312 422=0 420sq=0 420rect=0 q3_at=0]
81+rung=0 444_lossy_superres_mode2_256x128.obu [cfl_ac: 444=64 422=0 420sq=0 420rect=0 q3_at=0]
82+rung=0 444_lossy_superres_mode2_256x128_10bit.obu [cfl_ac: 444=58 422=0 420sq=0 420rect=0 q3_at=0]
83+rung=0 444_lossy_superres_mode2_256x128_12bit.obu [cfl_ac: 444=236 422=0 420sq=0 420rect=0 q3_at=0]
84+rung=0 444_quad_leaf_tx_type.obu [cfl_ac: 444=0 422=0 420sq=0 420rect=0 q3_at=0]
85+rung=0 444_rect_strip_leaf_tx_type.obu [cfl_ac: 444=0 422=0 420sq=0 420rect=0 q3_at=0]
86+rung=0 444_sb128rect_lr_witness.obu [cfl_ac: 444=0 422=0 420sq=0 420rect=0 q3_at=0]
87+rung=0 ll444-lossless-key.obu [cfl_ac: 444=20 422=0 420sq=0 420rect=0 q3_at=0]
88+rung=0 ll444_128root_lossless.obu [cfl_ac: 444=32 422=0 420sq=0 420rect=0 q3_at=0]
89+rung=0 ll444_defaultp_inter_strip.obu [cfl_ac: 444=20 422=0 420sq=0 420rect=0 q3_at=0]
90+rung=0 ll444_ibc_rect.obu [cfl_ac: 444=216 422=0 420sq=0 420rect=0 q3_at=0]
91+rung=0 ll444_intrabc_rect_l2.obu [cfl_ac: 444=10 422=0 420sq=0 420rect=0 q3_at=0]
92+rung=0 ll444_minp64_128root_control.obu [cfl_ac: 444=32 422=0 420sq=0 420rect=0 q3_at=0]
93+rung=0 ll444_minp64_inter.obu [cfl_ac: 444=0 422=0 420sq=0 420rect=0 q3_at=0]
94+rung=0 ll444_minp8_inter.obu [cfl_ac: 444=0 422=0 420sq=0 420rect=0 q3_at=0]
95+rung=0 ll444_rect16x4_chroma_reach.obu [cfl_ac: 444=4 422=0 420sq=0 420rect=0 q3_at=0]
96+rung=0 ll444_sb64_1to4_lossless.obu [cfl_ac: 444=14 422=0 420sq=0 420rect=0 q3_at=0]
97+
98+TOTAL 4:4:4-SET RUNG HITS: 0 across 26 fixtures
99+```
100+
101+**This is the red-before, and it is a negative.** The 4:4:4 CfL path is not
102+missing: 1834 CfL blocks ran across those 26 streams (arm 0 total = 72+72+8+
103+14+8+70+86+212+40+312+64+58+236+0+0+0+20+32+20+216+10+32+0+0+4+14), every one
104+of them byte-exact against the oracle (§4). The inherited 188 is most likely a
105+4:2:0 count: the same counter on the 4:2:0 set is **33 752** across 17 fixtures
106+(§1.2), and the largest single 4:2:0 fixture (`gm_small_side_witness.obu`)
107+alone reports 11 466.
108+
109+### 1.2 The same counter on the 4:2:0 set — the counter is live
110+
111+```text
112+$ for f in crates/ec-av1/fixtures/*.obu; do case 444*) continue;; esac; ... done
113+420_intrabc_rect4_witness.obu [cfl_ac: 444=0 422=0 420sq=14 420rect=16 q3_at=30]
114+gm_small_side_witness.obu [cfl_ac: 444=0 422=0 420sq=6208 420rect=5258 q3_at=11466]
115+grain_cdef_lr_128x128.obu [cfl_ac: 444=0 422=0 420sq=36 420rect=20 q3_at=56]
116+reelb_arf_witness.obu [cfl_ac: 444=0 422=0 420sq=146 420rect=46 q3_at=192]
117+reelb_head_mvclamp_witness.obu [cfl_ac: 444=0 422=0 420sq=334 420rect=132 q3_at=466]
118+reelb_intra14_witness.obu [cfl_ac: 444=0 422=0 420sq=3074 420rect=4074 q3_at=7148]
119+reelb_kf900.obu [cfl_ac: 444=0 422=0 420sq=2522 420rect=3058 q3_at=5580]
120+reelb_rect64_intra16x4_witness.obu [cfl_ac: 444=0 422=0 420sq=144 420rect=46 q3_at=190]
121+reelb_ss300_key_frame.obu [cfl_ac: 444=0 422=0 420sq=448 420rect=484 q3_at=932]
122+reelb_ss600_key_frame.obu [cfl_ac: 444=0 422=0 420sq=460 420rect=546 q3_at=1006]
123+intrabc_tx4_chroma_kf.obu [cfl_ac: 444=0 422=0 420sq=474 420rect=0 q3_at=474]
124+palette_screen_leaf8_witness.obu [cfl_ac: 444=0 422=0 420sq=16 420rect=0 q3_at=16]
125+sbpart-pin.obu [cfl_ac: 444=0 422=0 420sq=8 420rect=0 q3_at=8]
126+superres_alltools_sb128_320x180.obu [cfl_ac: 444=0 422=0 420sq=94 420rect=4 q3_at=98]
127+superres_kf_cdef_lr_64x64.obu [cfl_ac: 444=0 422=0 420sq=24 420rect=2 q3_at=26]
128+reelc_kf2700.obu [cfl_ac: 444=0 422=0 420sq=1008 420rect=1222 q3_at=2230]
129+reelc_sb128_inter_witness.obu [cfl_ac: 444=0 422=0 420sq=1516 420rect=2318 q3_at=3834]
130+ 4:2:0 total q3_at = 33752
131+```
132+
133+`444` and `q3_at` are **mutually exclusive on every one of the 43 streams that
134+carry CfL at all.** That is the whole finding.
135+
136+### 1.3 The 4:2:2 arm is inert too — the "do not fix it" note, proven not asserted
137+
138+`CFL_AC_422_HITS` is 0 on all 85 pins. Two independent reasons, both
139+structural: `ss_x == 1 && ss_y == 0` (4:2:2) is refused by name at the
140+sequence header (`stream.rs:1752`), and the pair `(0, 1)` is **structurally
141+uncodable** — `ec-av1-syntax` reads `subsampling_y` only when
142+`subsampling_x == 1` (`crates/ec-av1-syntax/src/sequence.rs:481-485`). So
143+`cfl_ac_ss`'s residual `else` is exactly 4:2:0, by construction and not by
144+measurement.
145+
146+---
147+
148+## 2. Why the defect is latent: the dispatch, and what the reference says
149+
150+`cfl_ac_ss` (`decode.rs:19889`) is the whole CfL AC call tree on the decode
151+side, and its arm order is the guard:
152+
153+```rust
154+fn cfl_ac_ss(y, px, py, bw, bh, ss_x, ss_y) -> Vec<i32> {
155+ if ss_x == 0 && ss_y == 0 { // 19998 4:4:4
156+ ... ac[row*bw+col] = y[...] << 3; // 1x1, FULL extent
157+ } else if ss_x == 1 && ss_y == 0 { // 19913 4:2:2
158+ let (cw, ch) = (bw >> 1, bh); // 2x1 horizontal pair, full height
159+ } else if bw == bh { // 19937 4:2:0 square
160+ cfl_ac_q3(y, px, py, bw) // -> cfl_ac_q3_at
161+ } else { // 19940 4:2:0 rect
162+ cfl_ac_q3_rect(y, px, py, bw, bh) // -> cfl_ac_q3_at
163+ }
164+}
165+```
166+
167+That is libaom's own dispatch, transcribed:
168+`cfl_subsampling_lbd` (`~/.cache/aom-oracle/src/av1/common/cfl.c:325-336`)
169+returns `cfl_luma_subsampling_420/422/444_lbd` on `(sub_x, sub_y)`, and the
170+three bodies are `cfl.c:230` (2x2 average, `<< 1`), `cfl.c:243` (horizontal
171+pair, `<< 2`), `cfl.c:257` (1x1, `<< 3`). `cfl_ac_ss` has all three already.
172+`cfl_ac_q3_at` is only libaom's 420 body, reached only when the two format
173+tests have already declined.
174+
175+The extent arithmetic is not a near-miss either. libaom's subtract-average is
176+indexed by tx size with `round_offset = num_pel/2` and `num_pel_log2`
177+(`CFL_SUB_AVG_FN`, `cfl.h:183-221`); our `(sum + num_pel/2) >> num_pel.trailing_zeros()`
178+is the same identity for every power-of-two block, and the 4:2:0 arms are
179+byte-identical to it today (§4).
180+
181+**So `bw / 2, bh / 2` and the 2x2 footprint are CORRECT at every reachable
182+call site.** Two independent call-site sets, both enumerated mechanically by
183+gate 2 below:
184+
185+* decode side — `cfl_ac_q3` (`decode.rs:19876`) and `cfl_ac_q3_rect`
186+ (`decode.rs:11613`) have exactly one caller each, `cfl_ac_ss`, and only from
187+ its last two arms;
188+* encoder side — `encode.rs:6943`, whose every `ColorConfig` in the crate
189+ hardcodes `subsampling_x: 1, subsampling_y: 1` (`encode.rs:2191-2192`,
190+ `encoder.rs:77-78`); `grep -c "subsampling_x: 0"` over both files = 0.
191+
192+---
193+
194+## 3. What landed (no behaviour change, no refusal introduced)
195+
196+Three files, **+220 / −35** (the −35 are my own intermediate iterations being
197+replaced; no foreign line is touched — `git diff -U0` hunks are all inside
198+`decode.rs:5981`, `19899-19953` and `stream.rs:47505-47767`):
199+
200+| file | what |
201+|---|---|
202+| `crates/ec-av1/src/decode.rs` | five gate counters (`CFL_AC_444/422/420_SQ/420_RECT/Q3_AT_HITS`) + `cfl_ac_arm_hits() -> [usize; 4]` + `cfl_ac_q3_at_hits()`, one `hit!` per `cfl_ac_ss` arm and one at `cfl_ac_q3_at`'s entry, plus the env-gated rung |
203+| `crates/ec-av1/src/stream.rs` | gate 1 `cfl_ac_444_routes_to_its_own_1x1_luma_body_and_420_to_the_2x2_average`, gate 2 `cfl_ac_q3_at_is_reached_only_through_the_420_fallthrough_of_cfl_ac_ss`, and the helper `oracle_plane_diffs` (per-plane Y/U/V mismatch counts — `decode_all_frames_vs_oracle` names an offset but not a plane, and for a chroma defect the plane split IS the diagnosis) |
204+| `crates/ec-av1/examples/decode_probe.rs` | one census line so the sweep in §1 is reproducible from outside the crate |
205+
206+**Gate 1 — measured, two-sided, with a pixel compare.** Two pinned fixtures,
207+each asserting the arm its format MUST take is `> 0` (so the `== 0` is a
208+routing fact, not an absence of CfL), the counter it must NOT touch, and
209+`0/0/0` per-plane mismatches against the instrumented `aomdec`:
210+
211+* 4:4:4 `fixtures/444_lossy_superres_mode2_256x128.obu` — 16620 bytes, fnv
212+ `0x8cbb_36b2_5e0f_07ab`, sha256
213+ `c18496cf3b7db0feca9aa904024cec2115be80b5b94f87c848ac52f9b32ffd97`,
214+ aomenc `testsrc2=size=256x128:rate=25 -pix_fmt yuv444p --passes=1
215+ --end-usage=q --cq-level=20 --cpu-used=2 --superres-mode=2 --limit=4 --obu`,
216+ 4 frames;
217+* 4:2:0 control `fixtures/420_intrabc_rect4_witness.obu` — 890 bytes, fnv
218+ `0x57ec_3da2_a63b_403a`, sha256
219+ `d01352af5059919cdce733abdcbae8e8240ac3c2a6190fa1bd96d3c6f945b979`, 1 frame,
220+ 640x480.
221+
222+Both are already pinned by existing gates; no fixture was added and none was
223+encoded on the server fleet (there was no witness to hunt for — the claim was
224+about reachability, and reachability was the thing that turned out to be
225+false).
226+
227+**Gate 2 — the static closure, the way `lane-av1rect8x16` closed its `(4, 8)`
228+refusal.** Not a comment: a source enumeration that asserts (1) `cfl_ac_q3_at`
229+has exactly 3 call sites — 2 in `decode.rs`, 1 in `encode.rs`; (2) both
230+`decode.rs` wrappers have exactly one caller, inside `cfl_ac_ss`; (3) inside
231+`cfl_ac_ss` the 4:4:4 and 4:2:2 tests come BEFORE both wrapper calls, so the
232+format-blind average stays the fallthrough; (4) neither `encode.rs` nor
233+`encoder.rs` contains `subsampling_x: 0`, so the encoder cannot hand it a
234+4:4:4 block.
235+
236+---
237+
238+## 4. Before / after, per plane
239+
240+There is no fix, so "before" and "after" are the same tree — that is the
241+finding, and the numbers are here to be checked rather than believed:
242+
243+| fixture | format | CfL blocks | `cfl_ac_q3_at` | Y mismatches | U mismatches | V mismatches |
244+|---|---|---|---|---|---|---|
245+| `444_lossy_superres_mode2_256x128.obu` | 4:4:4 | 64 (arm 0) | **0** | 0 / 32768 | 0 / 32768 | 0 / 32768 |
246+| `420_intrabc_rect4_witness.obu` | 4:2:0 | 30 (arms 2+3: 14 + 16) | 30 | 0 / 307200 | 0 / 76800 | 0 / 76800 |
247+
248+The 4:4:4 denominator is the upscaled 256x128 plane; the 4:2:0 denominators are
249+640x480 luma and 320x240 chroma. Raw gate line, green:
250+
251+```text
252+cfl_ac_444_routes_to_its_own_1x1_luma_body_and_420_to_the_2x2_average: fixtures/444_lossy_superres_mode2_256x128.obu arm0 [64, 0, 0, 0], cfl_ac_q3_at 0, per-plane Y/U/V mismatches vs aomdec 0/0/0 of 256x128; sha256 c18496cf3b7db0feca9aa904024cec2115be80b5b94f87c848ac52f9b32ffd97
253+cfl_ac_444_routes_to_its_own_1x1_luma_body_and_420_to_the_2x2_average: fixtures/420_intrabc_rect4_witness.obu arm2 [0, 0, 14, 16], cfl_ac_q3_at 30, per-plane Y/U/V mismatches vs aomdec 0/0/0 of 640x480; sha256 d01352af5059919cdce733abdcbae8e8240ac3c2a6190fa1bd96d3c6f945b979
254+ok
255+```
256+
257+The 4:4:4 arm is byte-exact on much heavier witnesses too, re-quoted unchanged
258+on this branch:
259+
260+```text
261+a_444_lossy_superres_12bit_d9_stream_decodes_pixel_exact: 4 decode-order frame(s) (0 hidden) byte-exact vs aomdec at 12-bit (256, 128) upscaled from [(9, 228) x4] per frame, 4 upscale(s), 1956 scaled MC block(s)
262+a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries: fixtures/444_lossy_rect4_odd_130x122.obu 4 decode-order frame(s) byte-exact vs aomdec, 12 own-extent 1:4 chroma gather(s), 28 1:4 inter strip(s)
263+a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries: fixtures/444_lossy_rect4_wide_256x128.obu 4 decode-order frame(s) byte-exact vs aomdec, 24 own-extent 1:4 chroma gather(s), 76 1:4 inter strip(s)
264+a_444_lossy_superres_mode2_random_denom_stream_decodes_pixel_exact: 4 decode-order frame(s) byte-exact vs aomdec at (256, 128) upscaled from [(11, 186), (14, 146), (15, 137), (9, 228)], 2265 scaled MC block(s)
265+```
266+
267+**4:2:0 CfL gates re-quoted unchanged** (all pass on this branch, no edit
268+touches their code path):
269+
270+```text
271+a_real_libaom_cfl_stream_decodes_pixel_exact .............................. ok
272+a_real_film_key_frame_with_a_skipped_cfl_block_decodes_pixel_exact ...... ok (pixel-exact, skipped_cfl=1)
273+the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact ........ ok (1 skipped sub-8x8 CfL chroma block, frame pixel-exact)
274+```
275+
276+---
277+
278+## 5. Mutation proof — the gate is not a green that survives anything
279+
280+Three mutations, each reverted, each with the restore verified byte-identical
281+(`diff <(git diff) /tmp/av1cflac-green2.patch` → identical).
282+
283+**M1 — make the latent defect live (4:4:4 arm calls the 4:2:0 body).**
284+`decode.rs:19899-19912` replaced with
285+`cfl_ac_q3_at(px, py, bw, bh, |lx, ly| i32::from(y.data[ly * y.width + lx]))`.
286+Naive form (half extent, as the defect literally is) does not even reach an
287+assertion — it is a **hard crash**, which is the honest release framing
288+(skill `release-invariant-not-debug-assert` §2):
289+
290+```text
291+thread 'stream::tests::cfl_ac_444_routes_to_its_own_1x1_luma_body_and_420_to_the_2x2_average' panicked at crates/ec-av1/src/decode.rs:4455:16:
292+index out of bounds: the len is 16 but the index is 16
293+test result: FAILED. 0 passed; 1 failed
294+```
295+
296+So the "silent wrongness" framing in the inherited report is wrong twice over:
297+a live 4:4:4 route would **panic in the reconstruct path**, not silently
298+mis-colour. Extent-preserving form (`bw*2, bh*2` with a clamped reader, so
299+the vector length stays right) reds the routing assertion by name:
300+
301+```text
302+panicked at crates/ec-av1/src/stream.rs:47568:17:
303+assertion `left == right` failed: ... fixtures/444_lossy_superres_mode2_256x128.obu is 4:4:4 and entered the
304+format-blind cfl_ac_q3_at 64 time(s) -- its extent is bw/2, bh/2 and its footprint is a 2x2 luma average, both wrong
305+at ss (0,0) (libaom cfl.c:230 vs :257). Arm deltas [64, 0, 0, 0]. Either cfl_ac_ss lost its 4:4:4 arm or a new caller
306+reached cfl_ac_q3_at directly; both make this site LIVE
307+ left: 64
308+ right: 0
309+test result: FAILED. 0 passed; 1 failed
310+```
311+
312+**M2 — a fourth call site** (`cfl_ac_q3_at_mutation_probe` delegating to
313+`cfl_ac_q3_at`, `#[allow(dead_code)]`) reds gate 2's enumeration:
314+
315+```text
316+panicked at crates/ec-av1/src/stream.rs:47681:9:
317+assertion `left == right` failed: ... cfl_ac_q3_at's call-site set changed -- {"decode.rs": 3, "encode.rs": 1}
318+against an expected 2 in decode.rs (the cfl_ac_q3 / cfl_ac_q3_rect wrappers) and 1 in encode.rs ...
319+ left: {"decode.rs": 3, "encode.rs": 1}
320+ right: {"decode.rs": 2, "encode.rs": 1}
321+test result: FAILED. 0 passed; 1 failed
322+```
323+
324+**Restored green** (`cargo test -p ec-av1 --lib --no-run` clean, then):
325+
326+```text
327+test stream::tests::cfl_ac_444_routes_to_its_own_1x1_luma_body_and_420_to_the_2x2_average ... ok
328+test stream::tests::cfl_ac_q3_at_is_reached_only_through_the_420_fallthrough_of_cfl_ac_ss ... ok
329+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 763 filtered out
330+```
331+
332+`cargo check -p ec-av1 --all-targets` → `Finished`, 0 warnings.
333+
334+---
335+
336+## 6. Boundary note — which files, versus the other lane
337+
338+I touched **`crates/ec-av1/src/decode.rs`, `crates/ec-av1/src/stream.rs`,
339+`crates/ec-av1/examples/decode_probe.rs`, and this report.** Nothing else.
340+
341+I did **not** touch `decode_intrabc_owned_rect` (definition `decode.rs:16843`
342+on this branch, the `let (cw, ch) = (bw / 2, bh / 2);` at `16861`; on post-merge
343+main the same function is at `16823` with the `EC_HALV ibc_owned` rung at `16854`) — one `git diff -U0` hunk list proves it: my decode.rs hunks are
344+at `5981` and `19899`, `19919`, `19938`, `19941`, `19953`. That function is the
345+*other* half of the same latent class and it stays with its owning lane; the
346+difference is that one is genuinely unreachable (this report) and the other is
347+reachable-but-refused on a 4:4:4 rect chroma shape pending a `TxbSet`
348+(`lanes/av1chromahalvings.report.md` r5.2).
349+
350+**Edit-path leak, for the next lane (it cost this lane two recoveries).** The
351+`edit` tool resolved my RELATIVE path `crates/ec-av1/src/stream.rs` against the
352+session cwd — the MAIN checkout — not the caller's worktree, and put a 249-line
353+gate into main twice. Detected by `git -C <main> status --porcelain` after
354+each batch, preserved at `/tmp/av1cflac-gate-leak.patch`, restored with
355+`git checkout --`, and re-applied inside the lane with
356+`git apply --3way`. Every edit in this lane after that point used an absolute
357+`/home/user/.cache/wt/av1cflac/...` header.
358+
359+---
360+
361+## 7. Handed back
362+
363+The latent-defect row, for whoever makes 4:4:4 rect chroma reachable (the
364+`ChromaRect32x64` / `ChromaRect64x32` `TxbSet`):
365+
366+> **`cfl_ac_q3_at`** (`decode.rs:19946`) computes libaom's **4:2:0** CfL AC: a
367+> 2x2 luma average per chroma sample (`cfl_luma_subsampling_420_lbd_c`, cfl.c:230)
368+> over a `bw/2 x bh/2` extent, average-subtracted (`CFL_SUB_AVG_FN`, cfl.h:183).
369+> It has **no `fctx`/`ss`**, so at `ss (0,0)` it is wrong on **both** counts:
370+> chroma extent equals luma extent, and the footprint is 1x1 (`<< 3`, cfl.c:257)
371+> rather than 2x2. It is **unreachable at 4:4:4 today** — `cfl_ac_ss` returns
372+> 4:4:4 and 4:2:2 from their own bodies before the 4:2:0 fallthrough — and two
373+> committed gates now say so (`cfl_ac_444_routes_to_its_own_1x1_luma_body_and_420_to_the_2x2_average`,
374+> `cfl_ac_q3_at_is_reached_only_through_the_420_fallthrough_of_cfl_ac_ss`).
375+> **When a 4:4:4 rect chroma block can reach it, threading `ss` is the fix and
376+> the pixel gate is already there** — mutation M1 above is that state, and it
377+> is a panic, not a colour shift.
378+
379+Not done, deliberately:
380+
381+* **no `fctx`/`ss` threading.** At every reachable call site the current
382+ arithmetic is right; threading would be an unmeasured change to a shared
383+ helper on a path Main classified as unreachable, and this project does not
384+ take unmeasured decoder changes (same reasoning as
385+ `lanes/av1merge-wave3d.report.md:225`).
386+* **no new fixture, no server encode.** Nothing to hunt: reachability was the
387+ claim, and it was false. Both gate fixtures are already-pinned aomenc
388+ artifacts.
389+* **no 4:2:2 arm change.** `(bw >> 1, bh)` in `cfl_ac_ss` is proven inert
390+ (§1.3) and left exactly as found.