forge
Explore
Log in

Don't you dare go Hollow

lane-av1444d10: a byte-exact gate for the 352x242 10-bit 4:4:4 palette-chroma cell

Browse files at this commit

35a444e578c005f88dd49f65ced4abe5c0f72d01Ahmet Kaan GümüşParent: 7f2ca30
Pins the census cell s444_352x242_10b as a committed fixture and gates it
byte-exact against aomdec over all 17 decode-order frames. 4:4:4 is a format
this decoder claims to support, so an accepted-and-wrong cell cannot stay
probe-only.

The geometry, named: what 352x242 has and its five same-depth controls do not
is a block whose CHROMA is taller than the 32-pixel unit cap at ss (0,0), so
decode_block_rect's tiled chroma walk splits it (nh = 2). The sensitive axis is
chroma UNIT COUNT, not frame width or height -- which is why the census could
report "geometry-sensitive" without the mechanism.

Non-vacuity: pinned length + FNV-1a64; 16 shown frames at 352x242 with
full-resolution chroma; and CHROMA_PALETTE_WINDOW_HITS read as a delta with a
measured floor of 4, incremented only on the two fixed lines, so the gate cannot
pass without them running.

Mutation proof: with the two palette_window calls replaced by the whole-buffer
hand-off (counter untouched) the gate reds BY NAME -- "decode-order frame 0 of
17 (16 shown, 1 hidden) differs from the oracle at byte 328192 (ours 209 vs
216)" -- byte 328192 being decode frame 0 plane U row 224 col 64, the census's
own first bad sample. Restored: green.
crates/ec-av1/fixtures/444_lossy_palette_chroma_352x242_10b.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+25 -0
@@ -2719,6 +2719,29 @@ pub(crate) fn palette_split_tx_hits() -> usize {
2719 PALETTE_SPLIT_TX_HITS.with(|c| c.get())2719 PALETTE_SPLIT_TX_HITS.with(|c| c.get())
2720 }2720 }
2721 2721
2722+thread_local! {
2723+ /// lane-av1444d10: chroma PREDICTION units on the 32-capped tiled chroma
2724+ /// walk (`decode_block_rect`'s `uw/uh = min(chroma, 32)` units) that were
2725+ /// handed a WINDOWED slice of their block's palette buffer -- i.e. the
2726+ /// units that are NOT the block's top-left corner. Counts units, not
2727+ /// blocks, and only units whose block actually has a UV palette, so a
2728+ /// stream without a tiled palette chroma block leaves it at zero.
2729+ static CHROMA_PALETTE_WINDOW_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2730+}
2731+
2732+/// Current value of [`CHROMA_PALETTE_WINDOW_HITS`].
2733+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2734+pub(crate) fn chroma_palette_window_hits() -> usize {
2735+ CHROMA_PALETTE_WINDOW_HITS.with(|c| c.get())
2736+}
2737+
2738+/// Zeroes [`CHROMA_PALETTE_WINDOW_HITS`] so a gate can read it as a DELTA
2739+/// (it is process-wide, like every counter here).
2740+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2741+pub(crate) fn reset_chroma_palette_window_hits() {
2742+ CHROMA_PALETTE_WINDOW_HITS.with(|c| c.set(0));
2743+}
2744+
2722 thread_local! {2745 thread_local! {
2723 /// lane-pal8 r1: square 8x8 LEAVES ([`decode_leaf8`]) that actually use a2746 /// lane-pal8 r1: square 8x8 LEAVES ([`decode_leaf8`]) that actually use a
2724 /// palette (Y or UV) -- the shape every 8-bit `--tune-content=screen`2747 /// palette (Y or UV) -- the shape every 8-bit `--tune-content=screen`
@@ -20087,6 +20110,7 @@ fn decode_block_rect64(
20087 palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh),20110 palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh),
20088 fctx,20111 fctx,
20089 );20112 );
20113+ hit!(CHROMA_PALETTE_WINDOW_HITS);
20090 }20114 }
20091 read_plane(20115 read_plane(
20092 dec,20116 dec,
@@ -20145,6 +20169,7 @@ fn decode_block_rect64(
20145 palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh),20169 palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh),
20146 fctx,20170 fctx,
20147 );20171 );
20172+ hit!(CHROMA_PALETTE_WINDOW_HITS);
20148 }20173 }
20149 push_intra_rect(20174 push_intra_rect(
20150 plane_idx,20175 plane_idx,
crates/ec-av1/src/stream.rsmodified+110 -0
@@ -50712,6 +50712,116 @@ exit 0
50712 }50712 }
50713 }50713 }
50714 50714
50715+ /// lane-av1444d10: the 10-bit 4:4:4 352x242 cell the 4:2:2 census
50716+ /// (`lanes/av1422census.report.md` §4 class D) found diverging on chroma
50717+ /// only -- 0 / 1166 / 1413 over 17 of 17 decode frames, first bad sample
50718+ /// at decode frame 0 plane U row 224 col 64 -- and the fix for it, a byte
50719+ /// exact gate. 4:4:4 is a format this decoder claims to support, so the
50720+ /// cell is not probe-only evidence.
50721+ ///
50722+ /// **Why this cell and not its five same-depth controls.** `s444_*_10b`
50723+ /// at 320x242, 320x250, 352x250, 416x242 and 416x250, same encoder recipe,
50724+ /// same 10-bit depth, were all byte-exact before the fix and still are; only
50725+ /// 352x242 diverged. What 352x242 has is the first block of the cell whose
50726+ /// chroma is TALLER than the 32-pixel unit cap at ss (0,0): a 32x64 luma
50727+ /// strip keeps its 32x64 chroma, and `decode_block_rect`'s tiled chroma
50728+ /// walk splits it into `nh = 2` units of 32x32. Every other cell's chroma
50729+ /// blocks are <= 32 on both axes, so `nw * nh == 1` and the whole-block
50730+ /// buffer IS the unit's window -- the bug is invisible there. That is why
50731+ /// the census could report "geometry-sensitive" without the mechanism:
50732+ /// the sensitive axis is chroma UNIT COUNT, not frame width or height.
50733+ ///
50734+ /// **The defect.** Both tiled arms handed the unit the WHOLE block's
50735+ /// palette prediction buffer, and `PlaneBuf::reconstruct` reads its first
50736+ /// `side * side` entries, so unit (0,1) at pixel (64, 224) reconstructed
50737+ /// the block's row-192 palette values (flat 209) where libaom writes
50738+ /// row 224's (216). The neighbouring 32x32 `PAETH_PRED` block at
50739+ /// (96, 224), whose left edge sample IS that pixel, then propagated 19
50740+ /// more wrong columns along its own top row -- which is why the census saw
50741+ /// 53 wrong columns rather than 32.
50742+ ///
50743+ /// **Red before the fix, by this gate's own name:** with the two
50744+ /// `palette_window` calls reverted the first wrong sample is decode frame
50745+ /// 0 plane U row 224 col 64 (ours 209, oracle 216) and the totals are
50746+ /// 0 / 1166 / 1413 over 17 decode frames.
50747+ ///
50748+ /// **Non-vacuity, four ways.** (1) The pinned bytes: length 24875 and
50749+ /// FNV-1a64 `0x7fda_dbb4_3bbf_9af3`, sha256
50750+ /// `84df2f37cc7982f9a572443d85dfcc13bf366a64f3fb567391dcd5acd58a0ad2`.
50751+ /// (2) 17 decode-order frames at 352x242 with FULL-RESOLUTION chroma, so
50752+ /// a decoder that kept the 4:2:0 extent cannot pass the compare.
50753+ /// (3) `decode::chroma_palette_window_hits()` read as a delta must be at
50754+ /// least 1: the fixed lines are the only thing that increments it, so a
50755+ /// gate that passes without them running would be
50756+ /// gate-blind-to-feature. (4) The oracle comparator this gate leans on has
50757+ /// its own per-plane one-byte-flip liveness control in the crate
50758+ /// (`every_oracle_comparator_reds_on_a_one_byte_wrong_oracle`).
50759+ #[test]
50760+ fn a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit() {
50761+ const NAME: &str = "a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit";
50762+ const FIXTURE: &str = "fixtures/444_lossy_palette_chroma_352x242_10b.obu";
50763+ const LEN: usize = 24875;
50764+ const FNV: u64 = 0x7fda_dbb4_3bbf_9af3;
50765+ const W: usize = 352;
50766+ const H: usize = 242;
50767+ // 16 SHOWN frames (`--limit=16`); the oracle compare below is the one
50768+ // that walks all 17 DECODE-order pictures (16 shown + 1 hidden altref).
50769+ const FRAMES: usize = 16;
50770+ // measured 4 on this stream (two tiled palette chroma blocks x U and V)
50771+ const MIN_WINDOWED_UNITS: usize = 4;
50772+ let _guard = lock_gate_counters();
50773+ let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(FIXTURE);
50774+ let stream = std::fs::read(&obu).unwrap_or_else(|e| {
50775+ panic!(
50776+ "{NAME}: pinned fixture {} is missing ({e}) -- the gate cannot run, \
50777+ which is a failure, not a skip",
50778+ obu.display()
50779+ )
50780+ });
50781+ assert_eq!(stream.len(), LEN, "{NAME}: {FIXTURE} length moved");
50782+ assert_eq!(fnv1a64(&stream), FNV, "{NAME}: {FIXTURE} bytes moved");
50783+
50784+ // Process-wide with no reset: read as a DELTA, or a full-suite run
50785+ // leaves residue that would make the reachability assert vacuous.
50786+ crate::decode::reset_chroma_palette_window_hits();
50787+ let frames = decode_stream(&stream)
50788+ .unwrap_or_else(|e| panic!("{NAME}: {FIXTURE} no longer decodes cleanly: {e}"));
50789+ let windowed = crate::decode::chroma_palette_window_hits();
50790+ assert!(
50791+ windowed >= MIN_WINDOWED_UNITS,
50792+ "{NAME}: {FIXTURE} ran {windowed} windowed palette chroma unit(s), \
50793+ expected at least {MIN_WINDOWED_UNITS} -- the tiled chroma walk did \
50794+ not reach a palette block, so the fixed lines never ran and this \
50795+ gate is blind to the defect (class gate-blind-to-feature)"
50796+ );
50797+ assert_eq!(
50798+ frames.len(),
50799+ FRAMES,
50800+ "{NAME}: {FIXTURE} decode-order frame count"
50801+ );
50802+ for (i, f) in frames.iter().enumerate() {
50803+ assert_eq!(
50804+ (f.width, f.height),
50805+ (W, H),
50806+ "{NAME}: {FIXTURE} frame {i} dimensions"
50807+ );
50808+ assert_eq!(
50809+ f.u.len(),
50810+ W * H,
50811+ "{NAME}: {FIXTURE} frame {i} chroma plane is {} samples; at 4:4:4 \
50812+ it must be full resolution ({W}x{H})",
50813+ f.u.len()
50814+ );
50815+ }
50816+ if aomdec_available(NAME) {
50817+ let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, NAME);
50818+ eprintln!(
50819+ "{NAME}: {FIXTURE} {decoded} decode-order frame(s) ({hidden} hidden) \
50820+ byte-exact vs aomdec, {windowed} windowed palette chroma unit(s)"
50821+ );
50822+ }
50823+ }
50824+
50715 /// lane-av1cfl: the 4:4:4 CfL AC body is a DIFFERENT function from the50825 /// lane-av1cfl: the 4:4:4 CfL AC body is a DIFFERENT function from the
50716 /// 4:2:0 one, and this gate is the proof that the format-blind50826 /// 4:2:0 one, and this gate is the proof that the format-blind
50717 /// `cfl_ac_q3_at` (`bw / 2, bh / 2`, a 2x2 luma average per chroma50827 /// `cfl_ac_q3_at` (`bw / 2, bh / 2`, a 2x2 luma average per chroma