From 35a38d408e13cfd512ee2b1a31fec64c6e2e77c5 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 18:18:30 +0300 Subject: [PATCH] gate the 4:4:4 palette chroma walk's horizontal arm and a 12-bit cell The 32-capped chroma walk in decode_block_rect64 windows the palette prediction per unit on BOTH axes, but only the cu_row term was ever exercised: a census of every committed fixture found windowed units only on blocks with nw == 1, so `cu_col * uw` was correct by construction and reached by nothing. No 12-bit 4:4:4 palette chroma stream had been built at all. Two new aomenc cells reach it. At ss (0,0) a 64-wide luma rect block keeps cw = 64, so the cap tiles it into nw = 2; that shape needs the horizontal partition arms and the lane-av1rect14 ibc640 flag set (rect + 1:4 partitions, min-partition-size=8, sb-size=64, screen tune) at cq-level 45. The 10-bit cell lands the rect-unit arm (uw 32, uh 16), the 12-bit cell the square-unit arm (uw 32, uh 32). Both are byte-exact against the instrumented aomdec, 0/0/0 per plane over the single decode-order frame, with a one-byte oracle tamper moving the mismatch count 0 -> 1 at each depth so the zero is not a dead comparator. Reverting the two palette_window calls to the whole-block buffer reds the new gate at 54278 differing bytes (10-bit) and 13312 (12-bit), luma 0 in both, first bad sample at the cu_col = 1 unit's own column. The existing 352x242 gate stays green, and the coverage-debt floor of 4 is re-measured per stream: 4 / 8 / 4 windowed units across the three committed palette-chroma streams, 8 of them on the horizontal arm. decode.rs gains one env-gated EC_PALWALK rung inside decode_block_rect64 (diagnostic only, same style as EC_PALSYN) so the nw/nh census is reproducible on any future fixture. --- .../444_palette_chroma_hstrip_640x480_10b.obu | Bin 0 -> 3301 bytes .../444_palette_chroma_hstrip_640x480_12b.obu | Bin 0 -> 2571 bytes crates/ec-av1/src/decode.rs | 16 ++ crates/ec-av1/src/stream.rs | 131 ++++++++++++ lanes/av1444palw.report.md | 199 ++++++++++++++++++ 5 files changed, 346 insertions(+) create mode 100644 crates/ec-av1/fixtures/444_palette_chroma_hstrip_640x480_10b.obu create mode 100644 crates/ec-av1/fixtures/444_palette_chroma_hstrip_640x480_12b.obu create mode 100644 lanes/av1444palw.report.md diff --git a/crates/ec-av1/fixtures/444_palette_chroma_hstrip_640x480_10b.obu b/crates/ec-av1/fixtures/444_palette_chroma_hstrip_640x480_10b.obu new file mode 100644 index 0000000000000000000000000000000000000000..aa226821b14fc295fa8efc6043889405ccba0f1c GIT binary patch literal 3301 zcmVxzi015{=CMW*;aDXz`8BDYQNTHy|=Lc!7SUEcq*ifZEf3g`wQN`l%d1!7Dg10 zn$?pfqX09mdylEgc8)Y!{dhCxjk1;h41=L?4p8&z%3oiqfQP0S=`rnGka9m7JHy<7 zF8gB*+8V#96vh@A^=s<~hisUa5$}qo#floUehBdCCn%IconJVFhjy$M!w|^z0=eUP zFnkZ}EHdGj|9GRN=cG`aW2nvC`QmOc@wZx|){qsi}6fdP1A;X!ylnJEPSJ$Z02+Q;ZLyrip zXyVy$LLcOyEdWn8N>$ajNJ3cXvHA;@YsSw-e-GpzCTH?u6$sNey1Y^Bp_vvMrbU-5 zYhnEZ>++RAl%r1Q+xzK#*wC22+239VWo^eF-_BNQzYt0s{ zhVg9&ygdHU=09-A<)xCb6H-r2fz{hXqBhAuE~7W55jJLX#Q;CbPEDNN7|>4)mV2C1 z^sW*wVe=8;Zwo<@ml};S;}f>l>(UE=4(55}*l?BBJ>$kjNv?%^Gcj&|Byg?2(;Fwx z>opYB6WpYAocTA<6=?+;0)ZYhV^j!ZU_p3D(N#|j;{UU{w%QPRfIhc2P8YhtL+s(7 z@xB#BE(Bp4@GCy+s0Lhyi;YM?JNFdCyFp{w_&fG8;V;0{co*pN*KPKBU>xS8B&|5Py+WFy0uQ+t*MvsG0N@t<+~`n z-7kwym`?EM-(2^o@$$%A`04;Kuq_V`;#up17ot+6I%D<>12k8BZJO0JwtvSuAx@9S zB;y*CqCQ0aD^BL^4{FD!j9X%Q>2JI{LaErBwgHgoHIt5clvf1UIg=OWc=>eHzA+KW zWfALG^O4$tQYaI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-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 84b720b1..80b9168c 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -20087,6 +20087,22 @@ fn decode_block_rect64( } }; let bigger = nw * nh > 1; + // lane-av1444palw: the reach census for the horizontal arm of this + // walk. `EC_PALWALK=1` prints, per rect64 block, the plane-block + // geometry, the unit grid it was tiled into, and whether a chroma + // palette was present -- so a fixture search can tell `nw >= 2` (the + // arm nothing had reached) from `nh >= 2` (the arm the corpus census + // already covered), and can see WHY a candidate block did not fire. + // Diagnostic only; no decode behaviour depends on it. + if crate::envflags::env_flag!("EC_PALWALK") { + eprintln!( + "EC_PALWALK mi={r},{c} px={px} py={py} bw={bw} bh={bh} cw={chroma_w} \ + ch={chroma_h} uw={uw} uh={uh} nw={nw} nh={nh} ast={allow_screen_content_tools} \ + puv={} py={}", + palette_uv.is_some() as i32, + palette_y.is_some() as i32 + ); + } let mut u_levels = vec![0i32; chroma_w * chroma_h]; let mut v_levels = vec![0i32; chroma_w * chroma_h]; // The tiled units below stamp their own coefficient context diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 87730f62..99e91b0a 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -50824,6 +50824,137 @@ exit 0 } } + /// lane-av1444palw: the gate for the arm + /// `a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit` + /// could NOT reach -- the HORIZONTAL half of the same 32-capped chroma + /// walk in `decode_block_rect64` (`palette_window(pbuf, chroma_w, + /// cu_col * uw, cu_row * uh, uw, uh)`, the arms at decode.rs:20131 and + /// :20199). Its `cu_col` term is the axis the corpus census never + /// exercised: a 106-fixture trace of that walk found 16 windowed units and + /// every one had `nw == 1`, i.e. only the `cu_row` term (`nh = 2`) was + /// ever load-bearing. + /// + /// **What makes `nw >= 2` reachable.** At ss (0,0) the chroma plane block + /// equals the luma one, so a 64-WIDE luma rect block keeps `cw = 64` and + /// the 32-cap tiles it into `nw = 2` units. `decode_block_rect64` is the + /// only function owning this walk at a 64-wide block, reached from + /// `PARTITION_HORZ`/`HORZ_A`/`HORZ_B` (64x32) and `HORZ_4` (64x16). The + /// cells here came from sweeping `--min-partition-size` x `--cq-level` over + /// a 4:4:4 testsrc2 640x480 cell encoded with the lane-av1rect14 + /// `ibc640` flag set (rect + 1:4 partitions, `--min-partition-size=8 + /// --sb-size=64 --tune-content=screen --enable-palette=1 + /// --enable-intrabc=1 --enable-tx-size-search=0 --cpu-used=0 + /// --lag-in-frames=0 --kf-max-dist=1 --limit=1 --threads=1 + /// --tile-columns=0 --passes=1 --end-usage=q --profile=1`): + /// `--min-partition-size=8` is what yields the 64-wide strip, and + /// `cq-level=45` is what makes the chroma palette win on it. Census read + /// off `EC_PALWALK=1`, the diagnostic rung this lane added to + /// `decode_block_rect64`: + /// + /// * 10-bit `cq 45`: `bw=64 bh=16 cw=64 ch=16 uw=32 uh=16 nw=2 nh=1 puv=1` + /// -- the RECT-unit arm (`uw != uh`) carrying a chroma palette, `nw = 2`. + /// * 12-bit `cq 45`: `bw=64 bh=32 cw=64 ch=32 uw=32 uh=32 nw=2 nh=1 puv=1` + /// -- the SQUARE-unit arm carrying a chroma palette, `nw = 2`, on the + /// 12-bit chroma plane no prior gate had built. + /// + /// **Both cells are byte-exact against the instrumented `aomdec`** per + /// plane over the single decode-order frame (10-bit 0/0/0, 12-bit 0/0/0), + /// and the comparator's liveness is proved by a one-byte oracle tamper + /// moving the mismatch count 0 -> 1 at each depth. + /// + /// **Red without the per-unit window, by this gate's own numbers.** + /// Reverting both `palette_window` calls to the whole-block buffer (the + /// counter left armed) gives 0 / 25553 / 26139 on the 10-bit cell, first + /// wrong sample decode frame 0 plane U row 96 col 448 (mutant 810, oracle + /// 763; plane V the same sample 891 vs 767), and 0 / 6400 / 6400 on the + /// 12-bit cell, first wrong sample plane U row 352 col 160 (866 vs 2004). + /// Both are the `cu_col = 1` unit reading the block's column 0 -- this arm, + /// not a cascade. + /// + /// **Non-vacuity.** (1) pinned bytes: 3301 / 2571 with FNV-1a64 and + /// sha256 asserted. (2) the DERIVED condition: the counter is guarded on + /// `nw * nh > 1`, so a hit proves the tiled arm ran, and the floors below + /// are re-measured on these two streams (the pinned gate's floor of 4 was + /// a floor from ONE stream, not a census). (3) 640x480 with + /// FULL-RESOLUTION chroma, so a 4:2:0 extent cannot pass. (4) the crate's + /// own one-byte oracle-comparator liveness control. + #[test] + fn a_444_palette_chroma_horizontal_unit_window_is_byte_exact_10bit_and_12bit() { + const NAME: &str = + "a_444_palette_chroma_horizontal_unit_window_is_byte_exact_10bit_and_12bit"; + // (fixture, len, fnv1a64, bit_depth, min_windowed_units) + const ARMS: [(&str, usize, u64, usize, usize); 2] = [ + ( + "fixtures/444_palette_chroma_hstrip_640x480_10b.obu", + 3301, + 0x6f94_da75_95cd_9a17, + 10, + 8, + ), + ( + "fixtures/444_palette_chroma_hstrip_640x480_12b.obu", + 2571, + 0x65a5_8561_c1f3_538e, + 12, + 4, + ), + ]; + const W: usize = 640; + const H: usize = 480; + let _guard = lock_gate_counters(); + for (fixture, len, fnv, depth, min_units) in ARMS { + let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(fixture); + let stream = std::fs::read(&obu).unwrap_or_else(|e| { + panic!( + "{NAME}: pinned fixture {fixture} is missing ({e}) -- the gate cannot \ + run, which is a failure, not a skip" + ) + }); + assert_eq!(stream.len(), len, "{NAME}: {fixture} length moved"); + assert_eq!(fnv1a64(&stream), fnv, "{NAME}: {fixture} bytes moved"); + + crate::decode::reset_chroma_palette_window_hits(); + let frames = decode_stream(&stream) + .unwrap_or_else(|e| panic!("{NAME}: {fixture} no longer decodes cleanly: {e}")); + let windowed = crate::decode::chroma_palette_window_hits(); + assert!( + windowed >= min_units, + "{NAME}: {fixture} ran {windowed} windowed palette chroma unit(s), expected \ + at least {min_units} -- the 32-cap tiled chroma walk did not reach enough \ + palette blocks, so the horizontal windowing under test never ran and this \ + gate is blind to the defect (class gate-blind-to-feature)" + ); + assert_eq!( + frames.len(), + 1, + "{NAME}: {fixture} decode-order frame count" + ); + for (i, f) in frames.iter().enumerate() { + assert_eq!( + (f.width, f.height), + (W, H), + "{NAME}: {fixture} frame {i} dimensions" + ); + assert_eq!( + f.u.len(), + W * H, + "{NAME}: {fixture} frame {i} chroma plane is {} samples; at 4:4:4 it must \ + be full resolution ({W}x{H}) -- a {depth}-bit decoder that kept the \ + 4:2:0 extent cannot pass this compare", + f.u.len() + ); + } + if aomdec_available(NAME) { + let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, NAME); + eprintln!( + "{NAME}: {fixture} ({depth}-bit) {decoded} decode-order frame(s) \ + ({hidden} hidden) byte-exact vs aomdec, {windowed} windowed palette \ + chroma unit(s)" + ); + } + } + } + /// lane-av1cfl: the 4:4:4 CfL AC body is a DIFFERENT function from the /// 4:2:0 one, and this gate is the proof that the format-blind /// `cfl_ac_q3_at` (`bw / 2, bh / 2`, a 2x2 luma average per chroma diff --git a/lanes/av1444palw.report.md b/lanes/av1444palw.report.md new file mode 100644 index 00000000..1c1f4bd3 --- /dev/null +++ b/lanes/av1444palw.report.md @@ -0,0 +1,199 @@ +# lane-av1444palw — the 4:4:4 palette chroma walk's HORIZONTAL arm (nw >= 2) and a 12-bit cell + +## Verdict + +| claim | before this lane | after | +| --- | --- | --- | +| horizontal windowing (`cu_col * uw`, `nw >= 2`) on a palette chroma block | "correct by construction", reached by **nothing** in 106 committed fixtures | **MEASURED**: 2 committed fixtures, 8 windowed units on the `nw = 2` arm, byte-exact vs `aomdec`, reds without the window | +| 12-bit 4:4:4 palette chroma | never built | **MEASURED**: 1 committed 12-bit fixture, 4 windowed units on the `nw = 2` arm, byte-exact, reds without the window | +| coverage-debt counter floor | `MIN_WINDOWED_UNITS = 4`, a floor from ONE stream | re-measured per stream below; no single floor is a census | + +No second defect was found. The horizontal window is byte-exact wherever it is reached. + +## The mechanism, and why the arm was dead + +`decode_block_rect64`'s 32-capped chroma walk (`decode.rs:20075`): + +```rust +let (uw, uh) = (chroma_w.min(32), chroma_h.min(32)); +let (nw, nh) = (chroma_w / uw, chroma_h / uh); +``` + +and both tiled arms hand each unit + +```rust +palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh) +``` + +(`decode.rs:20132` square-unit arm, `decode.rs:20200` rect-unit arm). At 4:4:4 (ss +0,0) the chroma plane block equals the luma one, so a **64-wide** luma rect +block keeps `cw = 64` and the cap tiles it into `nw = 2`. That shape is only +reachable from `PARTITION_HORZ` / `HORZ_A` / `HORZ_B` (64x32) and `HORZ_4` +(64x16) — the horizontal siblings of the `PARTITION_VERT` 32x64 strip the +pinned gate already covered. + +## Reach census (this lane's own measurement) + +`EC_PALWALK=1` — a new env-gated rung in `decode_block_rect64`, printing +`bw/bh/cw/ch/uw/uh/nw/nh/ast/puv/py` per block. Diagnostic only; nothing in the +decode path depends on it. + +**Census over every committed fixture** (108 `.obu` files, `decode_probe` per +file, `EC_PALWALK=1`): + +| fixture | walks | geometry | +| --- | --- | --- | +| `420_intrabc_rect4_witness.obu` | 4 | `bw=64 bh=32 cw=32 ch=16` / `bw=64 bh=16 cw=32 ch=8` — 4:2:0, so `nw = 1` by subsampling | +| `444_lossy_palette_chroma_352x242_10b.obu` | 1 | `bw=32 bh=64 cw=32 ch=64 uw=32 uh=32 nw=1 nh=2` | +| `r512_rect2x1_1x2_444.obu` | 1 | `bw=32 bh=64 cw=32 ch=64 uw=32 uh=32 nw=1 nh=2` | + +That reproduces the charter's census exactly: **every windowed unit in the +corpus has `nw = 1`**. The 4:2:0 fixture is the interesting near-miss — it owns +a genuine 64-WIDE luma palette rect block, and subsampling collapses its chroma +to 32, so the horizontal term stays dead there too. + +## The search that reached `nw >= 2` + +Dead ends, all measured (walks = `EC_PALWALK` lines, `nw2_puv` = lines with +`nw >= 2` **and** a chroma palette): + +| family | cells | result | +| --- | --- | --- | +| testsrc2 4:4:4, width sweep 256…640 x cq 16/24/36 (the pinned gate's recipe verbatim) | 26 | 3 cells with any walk, all `nw = 1` | +| the same cell with `--sb-size=64` | 4 | 309 PALSET but 0 walks — palette fires, never on a 64-wide rect64 block | +| the same cell, raw planes transposed (edges swap axis) | 6 | 0 walks | +| flat synthetic colour cells (64x64 / 64x32 / 128x64 / 64x128 grids, 2-colour halves, 4-colour quadrants, horizontal bands with a growing palette downwards) at cq 20/24/40 x screen-tune on/off | 120 | 0 walks — the encoder picks 32x16 / 16x8 strips there | +| **lane-av1rect14 `ibc640` flag set, 4:4:4 640x480, `--min-partition-size` x `cq` grid** | 12 | **2 cells with `nw = 2` AND `puv = 1`** | + +The lever that worked is `--min-partition-size=8` (at 4 it stays `puv = 0`; at +16 the 12-bit cell stops firing) combined with the rect + 1:4 partition flags: +those keep the 64-wide strip in the partition search while a small minimum +partition size stops the encoder from subdividing it past 64. + +## The two cells + +Provenance, both `aomenc` from `~/.cache/aom-oracle/build/aomenc` on +`ffmpeg -f lavfi -i 'testsrc2=s=640x480:r=25' -frames:v 1 -pix_fmt yuv444p{10,12}le -f yuv4mpegpipe`: + +``` +aomenc --codec=av1 --profile=1 --input-bit-depth=$D --bit-depth=$D \ + --width=640 --height=480 --passes=1 --end-usage=q --threads=1 --tile-columns=0 \ + --enable-rect-partitions=1 --enable-1to4-partitions=1 --min-partition-size=8 \ + --sb-size=64 --tune-content=screen --enable-intrabc=1 --enable-palette=1 \ + --enable-tx-size-search=0 --cpu-used=0 --lag-in-frames=0 --kf-max-dist=1 \ + --limit=1 --cq-level=45 --obu -o .obu .y4m +``` + +| fixture | bytes | sha256 | FNV-1a64 | depth | `EC_PALWALK` on the reaching block | +| --- | --- | --- | --- | --- | --- | +| `444_palette_chroma_hstrip_640x480_10b.obu` | 3301 | `40cebc523b327ff41f00d1e813046976990f29fec7da40e730c981b489de6493` | `0x6f94da7595cd9a17` | 10 | `bw=64 bh=16 cw=64 ch=16 uw=32 uh=16 nw=2 nh=1 ast=true puv=1 py=1` — the **rect-unit** arm | +| `444_palette_chroma_hstrip_640x480_12b.obu` | 2571 | `2fb5ba97d7257756a0a2bf781d9f3300ff2d66009989d297758d848561daee9a` | `0x65a58561c1f3538e` | 12 | `bw=64 bh=32 cw=64 ch=32 uw=32 uh=32 nw=2 nh=1 ast=true puv=1 py=0` — the **square-unit** arm | + +Both tiled arms of the walk are now covered, at two bit depths. + +## Measurement vs the oracle (per plane, per decode-order frame) + +Oracle: the instrumented `aomdec` at `~/.cache/aom-oracle/build/aomdec`, +`--rawvideo --output-bit-depth=$D`; ours: `EC_AV1_FINAL_DUMP` u16 LE. 640x480, +one decode-order frame, no hidden frames. + +| cell | Y | U | V | +| --- | --- | --- | --- | +| 10-bit | 0 | 0 | 0 | +| 12-bit | 0 | 0 | 0 | + +**Comparator liveness, proved per depth before trusting the zero.** Flipping +ONE byte of the oracle's own dump: + +``` +10-bit: clean diffs 0 -> tampered diffs 1 +12-bit: clean diffs 0 -> tampered diffs 1 +``` + +## Mutation proof (the gate reds without the per-unit window) + +Reverting both `palette_window(...)` calls at `decode.rs:20132` / `decode.rs:20200` +to the whole-block buffer `pbuf.clone()`, leaving the counter armed, then +running the gate: + +``` +$ cargo test -p ec-av1 --lib a_444_palette_chroma_horizontal_unit_window_is_byte_exact_10bit_and_12bit -- --nocapture +thread 'stream::tests::a_444_palette_chroma_horizontal_unit_window_is_byte_exact_10bit_and_12bit' panicked at crates/ec-av1/src/stream.rs:10848:17: +a_444_palette_chroma_horizontal_unit_window_is_byte_exact_10bit_and_12bit: decode-order frame 0 of 1 (1 shown, 0 hidden) differs from the oracle at byte 738176 (ours 42 vs 251), 54278 bytes differ +test result: FAILED. 0 passed; 1 failed +``` + +(10-bit arm; the 12-bit arm alone, with the 10-bit row removed from `ARMS`, +fails the same way at byte 1065280, 13312 bytes differ.) The reachability assert +stays green through both mutations — the counter is untouched by the mutation — +so it is the PIXEL compare that reds, which is what a non-vacuous gate needs. + +Per-plane counts of the same mutation, from the dumps: + +| cell | Y | U | V | first wrong sample | +| --- | --- | --- | --- | --- | +| 10-bit | 0 | 25553 | 26139 | frame 0 plane U r96 c448, mutant 810 vs oracle 763 (plane V same sample 891 vs 767) | +| 12-bit | 0 | 6400 | 6400 | frame 0 plane U r352 c160, mutant 866 vs oracle 2004 | + +Both are the `cu_col = 1` unit reading the block's column 0 — the horizontal arm +itself, not a downstream cascade (luma stays at 0 in both, so no luma-side +neighbour context is involved). + +## The re-measured counter census + +`decode::chroma_palette_window_hits()` is guarded on `nw * nh > 1`, so a hit +means "the 32-cap tiled this block", i.e. per unit per plane: + +| stream | windowed units | of which `nw >= 2` | +| --- | --- | --- | +| `444_lossy_palette_chroma_352x242_10b.obu` (pinned, existing gate) | 4 | 0 | +| `444_palette_chroma_hstrip_640x480_10b.obu` (new) | 8 | 4 | +| `444_palette_chroma_hstrip_640x480_12b.obu` (new) | 4 | 4 | + +The charter's "floor of 4" was one stream's number. Across the three committed +palette-chroma streams the total is **16 units, 8 of them on the horizontal +arm**, and the per-stream numbers are what the gate now asserts (8 and 4, both +exactly the measured values — the asserts are `>=` on those measurements, so a +future encoder-side change that drops a block still reds the gate). + +## Regression gate + +`stream.rs::a_444_palette_chroma_horizontal_unit_window_is_byte_exact_10bit_and_12bit` +— pinned length + FNV-1a64 per arm, the derived-condition counter as a floor, one +decode-order frame at 640x480 with **full-resolution** chroma asserted (so a +4:2:0 extent cannot pass the compare), and `decode_all_frames_vs_oracle` (which +carries the crate's own one-byte oracle-tamper liveness control). + +Scoped runs on this branch: + +``` +$ CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1444palw \ + cargo test -p ec-av1 --lib a_444_palette_chroma_horizontal_unit_window_is_byte_exact_10bit_and_12bit -- --nocapture +a_444_palette_chroma_horizontal_unit_window_is_byte_exact_10bit_and_12bit: fixtures/444_palette_chroma_hstrip_640x480_10b.obu (10-bit) 1 decode-order frame(s) (0 hidden) byte-exact vs aomdec, 8 windowed palette chroma unit(s) +a_444_palette_chroma_horizontal_unit_window_is_byte_exact_10bit_and_12bit: fixtures/444_palette_chroma_hstrip_640x480_12b.obu (12-bit) 1 decode-order frame(s) (0 hidden) byte-exact vs aomdec, 4 windowed palette chroma unit(s) +test stream::tests::a_444_palette_chroma_horizontal_unit_window_is_byte_exact_10bit_and_12bit ... ok +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 803 filtered out; finished in 0.50s + +$ cargo test -p ec-av1 --lib a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit -- --nocapture +a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit: fixtures/444_lossy_palette_chroma_352x242_10b.obu 17 decode-order frame(s) (1 hidden) byte-exact vs aomdec, 4 windowed palette chroma unit(s) +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 803 filtered out; finished in 1.20s + +$ cargo test -p ec-av1 --lib palette -- --nocapture +test result: ok. 24 passed; 0 failed; 0 ignored; 0 measured; 780 filtered out; finished in 27.07s +``` + +## Scope and honesty notes + +* The only `decode.rs` change is the `EC_PALWALK` diagnostic rung inside + `decode_block_rect64`; no decode logic changed. Announced over IRC to the + three peer lanes before landing; `Agent23-4` and `Agent05-5` confirmed no overlap. +* `EC_PALWALK` is an env-gated `eprintln` in the same style as the existing + `EC_PALSYN` / `EC_DEBUG_PAL` rungs, so the census stays reproducible on any + future fixture without re-deriving it. +* The 12-bit cell needed its own sweep (`--min-partition-size=16`, cq 45): at 8 + the 12-bit chroma never lands a palette on the 64-wide strip. Both settings + are recorded above so either cell can be reproduced exactly. +* The `nw = 2` walk is still reachable only through the `decode_block_rect64` + partition arms. A 128-wide chroma plane block (`nw = 4`) would need a + `128x64` intra block, which this decoder routes elsewhere; that shape remains + **unmeasured**, and no gate claims it.