lane-av1422tailskip: s422_384x240 is byte-exact -- the writer was the 4:2:2 intra-in-inter PALETTE chroma per-unit window, not the reserved inter SKIP arm
Browse files at this commitfa0bdda0856e2c657719bafd77c09b93d72da981Parent: 09027b45 changed files +433 -0
- crates/ec-av1/examples/decode_probe.rs +4 -0
- crates/ec-av1/fixtures/422_palette_intra_in_inter_384x240_17f.obu +0 -0
- crates/ec-av1/src/decode.rs +42 -0
- crates/ec-av1/src/stream.rs +94 -0
- lanes/av1422tailskip.report.md +293 -0
crates/ec-av1/examples/decode_probe.rsmodified+4 -0
| @@ -79,6 +79,10 @@ fn main() { | ||
| 79 | 79 | ); |
| 80 | 80 | let (pal_y, pal_uv) = ec_av1::stream::intra_in_inter_palette_hits(); |
| 81 | 81 | println!("intra_in_inter_palette: y={pal_y} uv={pal_uv}"); |
| 82 | + println!( | |
| 83 | + "palette_422_unit_window: {}", | |
| 84 | + ec_av1::decode::palette_422_unit_window_hits() | |
| 85 | + ); | |
| 82 | 86 | println!( |
| 83 | 87 | "rect64_corner_tu: 64x32={} 32x64={}", |
| 84 | 88 | ec_av1::stream::rect64_corner_tu_hits(0), |
crates/ec-av1/fixtures/422_palette_intra_in_inter_384x240_17f.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+42 -0
| @@ -2132,6 +2132,25 @@ pub fn chroma422_square_hits() -> usize { | ||
| 2132 | 2132 | CHROMA422_SQUARE_HITS.with(|c| c.get()) |
| 2133 | 2133 | } |
| 2134 | 2134 | |
| 2135 | +// lane-av1422tailskip: how many 4:2:2 (ss 1,0) intra-in-inter chroma TRANSFORM | |
| 2136 | +// UNITS took their own window on the block-sized chroma palette prediction -- | |
| 2137 | +// `decode_inter_block`'s `side == 64` TX_32X32 walk, where the plane block is | |
| 2138 | +// 32x64 but codes two stacked square units per plane. Zero on a 4:2:0 or 4:4:4 | |
| 2139 | +// frame (their chroma unit is the whole plane block, one window), and zero on | |
| 2140 | +// a 4:2:2 block with no palette, so a witness gate reading 0 proves the arm | |
| 2141 | +// never ran. | |
| 2142 | +thread_local! { | |
| 2143 | + static PALETTE_422_UNIT_WINDOW_HITS: std::cell::Cell<usize> = | |
| 2144 | + const { std::cell::Cell::new(0) }; | |
| 2145 | +} | |
| 2146 | + | |
| 2147 | +/// Current value of [`PALETTE_422_UNIT_WINDOW_HITS`]. | |
| 2148 | +// lane-av1422tailskip: `pub` so `examples/decode_probe.rs` can census it the | |
| 2149 | +// way it does every other capability counter. | |
| 2150 | +pub fn palette_422_unit_window_hits() -> usize { | |
| 2151 | + PALETTE_422_UNIT_WINDOW_HITS.with(|c| c.get()) | |
| 2152 | +} | |
| 2153 | + | |
| 2135 | 2154 | // lane-av1-422f: how many RECT chroma coefficient units the square-block |
| 2136 | 2155 | // path read on a 4:2:2 frame (ss 1,0) -- TX_4X8 / TX_8X16 / TX_16X32, the |
| 2137 | 2156 | // plane block's own half-width, unhalved-height shape. A 4:2:0 or 4:4:4 |
| @@ -45700,6 +45719,21 @@ fn decode_inter_block( | ||
| 45700 | 45719 | y.height, |
| 45701 | 45720 | fctx, |
| 45702 | 45721 | ); |
| 45722 | + // The 4:2:2 plane block is `(chroma_w, chroma_h)` -- | |
| 45723 | + // 32x64 -- but codes TWO stacked TX_32X32 units, so | |
| 45724 | + // each unit needs its OWN window on the block-sized | |
| 45725 | + // chroma palette prediction. Armed once above, the | |
| 45726 | + // first unit consumed the whole 2048-entry buffer and | |
| 45727 | + // the second found none pending, silently falling back | |
| 45728 | + // to the edge DC prediction (s422_384x240 decode | |
| 45729 | + // frame 1, U/V rows 170..189 cols 23..31). | |
| 45730 | + if let Some((ub, _)) = &palette_uv_bufs { | |
| 45731 | + set_palette_pred( | |
| 45732 | + palette_window(ub, chroma_w, 0, cu_row * cu_h, cu_w, cu_h), | |
| 45733 | + fctx, | |
| 45734 | + ); | |
| 45735 | + } | |
| 45736 | + hit!(PALETTE_422_UNIT_WINDOW_HITS); | |
| 45703 | 45737 | let cu_grid = read_plane( |
| 45704 | 45738 | dec, |
| 45705 | 45739 | cdfs, |
| @@ -45827,6 +45861,14 @@ fn decode_inter_block( | ||
| 45827 | 45861 | y.height, |
| 45828 | 45862 | fctx, |
| 45829 | 45863 | ); |
| 45864 | + // The V twin of the U arm's per-unit window above. | |
| 45865 | + if let Some((_, vb)) = &palette_uv_bufs { | |
| 45866 | + set_palette_pred( | |
| 45867 | + palette_window(vb, chroma_w, 0, cu_row * cu_h, cu_w, cu_h), | |
| 45868 | + fctx, | |
| 45869 | + ); | |
| 45870 | + } | |
| 45871 | + hit!(PALETTE_422_UNIT_WINDOW_HITS); | |
| 45830 | 45872 | let cu_grid = read_plane( |
| 45831 | 45873 | dec, |
| 45832 | 45874 | cdfs, |
crates/ec-av1/src/stream.rsmodified+94 -0
| @@ -2787,6 +2787,100 @@ pub(crate) mod tests { | ||
| 2787 | 2787 | } |
| 2788 | 2788 | } |
| 2789 | 2789 | |
| 2790 | + /// lane-av1422tailskip: the WITNESS cell for the 4:2:2 intra-in-inter | |
| 2791 | + /// PALETTE chroma per-unit window, and its byte pin. | |
| 2792 | + /// | |
| 2793 | + /// `422_palette_intra_in_inter_384x240_17f.obu` (19344 B, sha256 | |
| 2794 | + /// `bf1c658e9bfdc13ec1ed51e59049d2b81201941b6ef4571f8382f356ea4b815b`) is | |
| 2795 | + /// the one 4:2:2 cell of the 384x240 census sweep: 384x240, ss (1,0), | |
| 2796 | + /// 8-bit, **17 decode frames, 16 shown** (decode 1 is the hidden altref). | |
| 2797 | + /// Its decode-frame-1 block at mi(32,0) is a 64x64 INTRA block with a | |
| 2798 | + /// PALETTE -- `aomdec`'s `EC_PIB` prints `use_palette=1` there, and the | |
| 2799 | + /// oracle's own prediction rungs print nothing for the block because | |
| 2800 | + /// `av1_predict_intra_block` returns at its palette branch before them | |
| 2801 | + /// (`reconintra.c:1735`). | |
| 2802 | + /// | |
| 2803 | + /// At 4:2:2 that block's chroma plane block is 32x64, but | |
| 2804 | + /// `av1_get_max_uv_txsize` adjusts `max_tx_size_rect_lookup[BLOCK_32X64]` | |
| 2805 | + /// down to TX_32X32, so it codes TWO STACKED SQUARE units per plane. | |
| 2806 | + /// `decode_inter_block`'s `side == 64` walk armed the ONE block-sized | |
| 2807 | + /// 2048-entry chroma palette prediction before the loop: the first unit | |
| 2808 | + /// consumed all of it and the second found none pending, so it silently | |
| 2809 | + /// fell back to the edge DC prediction -- a flat 90/240 box where the | |
| 2810 | + /// oracle carries its palette (U/V rows 170..189, cols 23..31, 180 wrong | |
| 2811 | + /// samples per plane at the pre-filter stage). Each unit now takes its own | |
| 2812 | + /// `palette_window` of that buffer (`decode.rs`) -- the same helper the | |
| 2813 | + /// split-transform chroma paths already used. | |
| 2814 | + /// | |
| 2815 | + /// **The committed assertion follows the family's standing rule** (same | |
| 2816 | + /// shape as | |
| 2817 | + /// [`the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name`]): | |
| 2818 | + /// the byte pin plus this decoder's disposition of those bytes. While | |
| 2819 | + /// `decode_stream` still refuses 4:2:2 at the sequence header | |
| 2820 | + /// (`decode_frame`, `subsampling_x != subsampling_y`) that is the refusal | |
| 2821 | + /// BY NAME, and the gate additionally asserts the arm's counter reads 0 -- | |
| 2822 | + /// the pin alone must never be able to fake a green. When the header lift | |
| 2823 | + /// lands the same test becomes the full gate: 17 decode-order frames | |
| 2824 | + /// byte-exact against aomdec with `palette_422_unit_window_hits()` fired, | |
| 2825 | + /// which is what it asserts then. Both branches are loud. | |
| 2826 | + #[test] | |
| 2827 | + fn the_pinned_422_palette_intra_in_inter_cell_window_is_byte_exact() { | |
| 2828 | + const NAME: &str = "the_pinned_422_palette_intra_in_inter_cell_window_is_byte_exact"; | |
| 2829 | + const FILE: &str = "422_palette_intra_in_inter_384x240_17f.obu"; | |
| 2830 | + const BYTES: usize = 19344; | |
| 2831 | + const FP: u64 = 0x923ccabfcb933e90; | |
| 2832 | + const REFUSAL: &str = "a chroma format of 4:2:2"; | |
| 2833 | + let _gate_lock = lock_gate_counters(); | |
| 2834 | + let data = std::fs::read(crate_pin(FILE)).unwrap_or_else(|e| { | |
| 2835 | + panic!("{NAME}: the committed pin {FILE} is missing ({e}) -- a failure, not a skip") | |
| 2836 | + }); | |
| 2837 | + assert_eq!(data.len(), BYTES, "{NAME}: {FILE} size drifted"); | |
| 2838 | + assert_eq!(fnv1a64(&data), FP, "{NAME}: {FILE} bytes drifted"); | |
| 2839 | + let before = crate::decode::palette_422_unit_window_hits(); | |
| 2840 | + match decode_stream(&data) { | |
| 2841 | + Err(e) => { | |
| 2842 | + let err = e.to_string(); | |
| 2843 | + assert!( | |
| 2844 | + err.contains(REFUSAL), | |
| 2845 | + "{NAME}: {FILE} neither refused by name nor decoded to the 17 \ | |
| 2846 | + decode-order frames this gate claims -- if 4:2:2 has been lifted the \ | |
| 2847 | + ERROR arm is stale, got: {err}" | |
| 2848 | + ); | |
| 2849 | + assert_eq!( | |
| 2850 | + crate::decode::palette_422_unit_window_hits(), | |
| 2851 | + before, | |
| 2852 | + "{NAME}: a refusal cannot reach the palette arm, so its counter moved \ | |
| 2853 | + from {before} -- this is not the refusal this gate models" | |
| 2854 | + ); | |
| 2855 | + eprintln!( | |
| 2856 | + "{NAME}: {FILE} refuses 4:2:2 at the sequence header (the standing \ | |
| 2857 | + family rule), so the per-unit palette window could not be exercised \ | |
| 2858 | + here; the exactness and fired-counter claims are measured on a local \ | |
| 2859 | + patch-run-restore build -- see lanes/av1422tailskip.report.md" | |
| 2860 | + ); | |
| 2861 | + } | |
| 2862 | + Ok(_) => { | |
| 2863 | + let windows = crate::decode::palette_422_unit_window_hits() - before; | |
| 2864 | + assert!( | |
| 2865 | + windows > 0, | |
| 2866 | + "{NAME}: {FILE} decoded, but no 4:2:2 intra-in-inter chroma unit took \ | |
| 2867 | + the per-unit palette window ({windows} did) -- this cell does not \ | |
| 2868 | + exercise the arm at all (class gate-blind-to-feature)" | |
| 2869 | + ); | |
| 2870 | + let (decoded, hidden) = decode_all_frames_vs_oracle(&data, FILE); | |
| 2871 | + assert_eq!( | |
| 2872 | + decoded, 17, | |
| 2873 | + "{NAME}: the oracle decoded {decoded} frames in DECODE order, not 17" | |
| 2874 | + ); | |
| 2875 | + assert_eq!(hidden, 1, "{NAME}: expected exactly the one hidden altref"); | |
| 2876 | + eprintln!( | |
| 2877 | + "{NAME}: {decoded} decode-order frame(s) byte-exact against aomdec \ | |
| 2878 | + ({hidden} hidden), {windows} chroma palette unit window(s)" | |
| 2879 | + ); | |
| 2880 | + } | |
| 2881 | + } | |
| 2882 | + } | |
| 2883 | + | |
| 2790 | 2884 | /// lane-av1-ibc128chunk: the WITNESS for the 128-root intrabc strip's |
| 2791 | 2885 | /// de-square-cut mu-chunk chroma walk, and the byte pin for it. |
| 2792 | 2886 | /// |
lanes/av1422tailskip.report.mdadded+293 -0
| @@ -0,0 +1,293 @@ | ||
| 1 | +# lane-av1422tailskip — `s422_384x240` is FIXED: the reserved arm was not the writer | |
| 2 | + | |
| 3 | +**Outcome in one line: the cell is byte-exact on all 16 displayed frames (and all | |
| 4 | +17 decode-order frames) against ffmpeg 8.1.3; the cause was NOT the group-tail | |
| 5 | +inter chroma SKIP arm at `decode.rs:43948` that three lanes reserved and this one | |
| 6 | +was chartered to fix, but the **4:2:2 intra-in-inter PALETTE chroma per-unit | |
| 7 | +window** in `decode_inter_block`'s `side == 64` TX_32X32 chroma walk — the second | |
| 8 | +chroma transform unit found no palette prediction pending and silently fell back | |
| 9 | +to the edge DC prediction.** | |
| 10 | + | |
| 11 | +Branch `lane/av1422tailskip`, worktree `/home/user/.cache/wt/av1422tailskip`, | |
| 12 | +base `main` = `0c77bad5`. The 4:2:2 sequence-header refusal | |
| 13 | +(`stream.rs:1803`, `if seq.subsampling_x != seq.subsampling_y`) is **untouched | |
| 14 | +and in place**; every 4:2:2 measurement below was taken on a local | |
| 15 | +patch-run-restore bypass and the patch was reverted before the commit. No push. | |
| 16 | + | |
| 17 | +--- | |
| 18 | + | |
| 19 | +## 0. Why the reserved arm was the wrong owner | |
| 20 | + | |
| 21 | +The chartered site, `decode.rs:43948` (`decode_inter_block`'s single-reference | |
| 22 | +`push_mc_rect(1, cpx, cpy, chroma_stride, write_chroma_w, write_chroma_h, su, | |
| 23 | +ZERO_RESIDUAL)`), **does** fire at the 64x64 mi(32,0) geometry — from decode | |
| 24 | +frame **2** onward. It never fires for decode frame 1, the first divergent frame. | |
| 25 | + | |
| 26 | +The oracle settles it. `EC_DP` (per-block rung, private build) on the pinned | |
| 27 | +cell: | |
| 28 | + | |
| 29 | +``` | |
| 30 | +line 236 pict 0 EC_DP mi_row=32 mi_col=0 bsize=12 inter=0 chroma_ref=1 skip_txfm=0 | |
| 31 | +line 2298 pict 1 EC_DP mi_row=32 mi_col=0 bsize=12 inter=0 chroma_ref=1 skip_txfm=0 | |
| 32 | +line 7074 pict 2 EC_DP mi_row=32 mi_col=0 bsize=12 inter=1 chroma_ref=1 skip_txfm=1 | |
| 33 | +line 12200 pict 3 EC_DP mi_row=32 mi_col=0 bsize=12 inter=1 chroma_ref=1 skip_txfm=1 | |
| 34 | +``` | |
| 35 | + | |
| 36 | +bsize 12 is `BLOCK_64X64` (`common_data.h`'s `block_size_wide[12] = 64`, | |
| 37 | +`block_size_high[12] = 64`). **Decode frame 1's block at mi(32,0) is an INTRA | |
| 38 | +64x64 block** (`inter=0`, `skip_txfm=0`, `chroma_ref=1`) in the oracle exactly as | |
| 39 | +in our decoder. Only pictures 2+ code it as an inter SKIP block. So the first | |
| 40 | +divergence is not an inter prediction at all, and no edit at `decode.rs:43948` | |
| 41 | +can reach it. | |
| 42 | + | |
| 43 | +`EC_PIB` (the intra prediction call identity, printed before the palette early | |
| 44 | +return) on the same block, picture 1: | |
| 45 | + | |
| 46 | +``` | |
| 47 | +EC_PIB mi_row=32 mi_col=0 plane=1 row_off=0 col_off=0 txw=32 txh=32 mode=0 | |
| 48 | + use_palette=1 filter_intra=5 bsize=12 px=0 py=0 hbd=0 | |
| 49 | +EC_PIB mi_row=32 mi_col=0 plane=1 row_off=8 col_off=0 txw=32 txh=32 mode=0 | |
| 50 | + use_palette=1 filter_intra=5 bsize=12 px=0 py=32 hbd=0 | |
| 51 | +``` | |
| 52 | + | |
| 53 | +`use_palette=1` — and that is why the oracle's prediction rungs print nothing | |
| 54 | +for this block: `av1_predict_intra_block` (`reconintra.c:1735`) returns at the | |
| 55 | +palette branch, before `EC_PREDOUT8`'s `build_directional_and_filter_...` site. | |
| 56 | +Picture 0's twin prints `use_palette=0` and does emit `EC_PREDOUT8` | |
| 57 | +(`sum=92160`, flat 90 — a DC prediction), which is what made the earlier lanes | |
| 58 | +read this as a DC intra block. | |
| 59 | + | |
| 60 | +## 1. The cause | |
| 61 | + | |
| 62 | +At 4:2:2 the 64x64 block's chroma plane block is **32x64**, but | |
| 63 | +`av1_get_max_uv_txsize` adjusts `max_tx_size_rect_lookup[BLOCK_32X64] = TX_32X64` | |
| 64 | +down to **TX_32X32**, so it codes **two stacked square units per plane**. | |
| 65 | +`decode_inter_block`'s `side == 64` walk armed the palette prediction **once, | |
| 66 | +before the loop** (`decode.rs:45640` for U, `:45776` for V), handing the whole | |
| 67 | +2048-entry block-sized buffer to the first unit. `take_palette_pred` is a | |
| 68 | +`.take()`: the second unit found nothing pending and reconstructed from the | |
| 69 | +block edge (DC) instead. Measured with `EC_DEBUG_PAL=1`: | |
| 70 | + | |
| 71 | +``` | |
| 72 | +PALSET len=2048 stale=false at crates/ec-av1/src/decode.rs:45641:21 (U, whole 32x64) | |
| 73 | +PALTAKE len=Some(2048) at crates/ec-av1/src/decode.rs:4072:16 (unit 0 takes it all) | |
| 74 | +PALTAKE len=None at crates/ec-av1/src/decode.rs:4072:16 (unit 1: nothing) | |
| 75 | +PALSET len=2048 stale=false at crates/ec-av1/src/decode.rs:45777:21 (V) | |
| 76 | +PALTAKE len=Some(2048) | |
| 77 | +PALTAKE len=None | |
| 78 | +``` | |
| 79 | + | |
| 80 | +Exactly one 4:2:2 intra-in-inter palette chroma block of that shape exists in | |
| 81 | +the cell, and its `PALSET len=2048` count over the whole decode is **2** (U and | |
| 82 | +V). The pixel consequence is precisely the measured box: unit 0 (chroma rows | |
| 83 | +128..159) matches the oracle, unit 1 (rows 160..191) is flat 90/240 wherever the | |
| 84 | +palette differs. | |
| 85 | + | |
| 86 | +## 2. The fix | |
| 87 | + | |
| 88 | +`decode.rs`, `decode_inter_block`, the `side == 64` arm's per-unit loop, both | |
| 89 | +planes: arm **this unit's window** on the block-sized buffer instead of the | |
| 90 | +whole buffer once — the helper the split-transform chroma paths already used | |
| 91 | +(`palette_window`, whose own doc names this exact failure mode). | |
| 92 | + | |
| 93 | +```rust | |
| 94 | +if let Some((ub, _)) = &palette_uv_bufs { | |
| 95 | + set_palette_pred( | |
| 96 | + palette_window(ub, chroma_w, 0, cu_row * cu_h, cu_w, cu_h), | |
| 97 | + fctx, | |
| 98 | + ); | |
| 99 | +} | |
| 100 | +hit!(PALETTE_422_UNIT_WINDOW_HITS); | |
| 101 | +``` | |
| 102 | + | |
| 103 | +Nothing else in the tree changed: the pre-loop arm stays for the `chroma_w == | |
| 104 | +chroma_h` (4:2:0 / 4:4:4) branch, whose single unit IS the whole plane block, | |
| 105 | +and for the `skip` arm, which pushes one 32x64 chroma unit. | |
| 106 | + | |
| 107 | +## 3. The cell, before and after (per plane, per frame, ffmpeg 8.1.3) | |
| 108 | + | |
| 109 | +Comparator: `ffmpeg -v error -i s422_384x240.obu -f rawvideo -pix_fmt yuv422p -` | |
| 110 | +in DISPLAY order against `decode_probe`'s `EC_PROBE_OUT`; the decode-order | |
| 111 | +table below is `EC_AV1_PREFILT_WIDE_DUMP` (mi-aligned true extents) against | |
| 112 | +aomdec's `EC_AV1_PREFILT_DUMP`, both decode order. Geometry is read from the | |
| 113 | +sequence header by ffprobe, never from a file size; 17 decode frames, 16 | |
| 114 | +displayed (`decode 1` is the hidden altref), map | |
| 115 | +`0 HID 7 3 1 2 5 4 6 11 9 8 10 13 12 14 15`. | |
| 116 | + | |
| 117 | +### 3.1 Display order vs ffmpeg — wrong samples per plane | |
| 118 | + | |
| 119 | +| display | Y | U | V | | display | Y | U | V | | |
| 120 | +|---|---|---|---|---|---|---|---|---| | |
| 121 | +| 0 | 0 | 0 | 0 | | 8 | 0 | **96** | **104** | | |
| 122 | +| 1 | 0 | 0 | 0 | | 9 | 0 | **138** | **150** | | |
| 123 | +| 2 | 0 | 0 | 0 | | 10 | 0 | **210** | **210** | | |
| 124 | +| 3 | 0 | 0 | 0 | | 11 | 0 | **250** | **258** | | |
| 125 | +| 4 | 0 | 0 | 0 | | 12 | 0 | **292** | **303** | | |
| 126 | +| 5 | 0 | 0 | 0 | | 13 | 0 | **290** | **303** | | |
| 127 | +| 6 | 0 | **4** | **12** | | 14 | 0 | **248** | **261** | | |
| 128 | +| 7 | 0 | **50** | **60** | | 15 | 0 | **202** | **210** | | |
| 129 | +| | | | | | **total** | **0** | **1780** | **1871** | | |
| 130 | + | |
| 131 | +**After the fix: 0 / 0 / 0 on every one of the 16 displayed frames** — | |
| 132 | +`cmp mine/fin4.yuv ff.yuv` reports the two files byte-identical (2 949 120 B). | |
| 133 | + | |
| 134 | +### 3.2 Decode order, pre-filter reconstruction vs aomdec | |
| 135 | + | |
| 136 | +| decode | 0 | 1 | 2 | 3–7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | | |
| 137 | +|---|---|---|---|---|---|---|---|---|---|---|---|---|---| | |
| 138 | +| before Y/U | 0/0 | 0/**180** | 0/**48** | 0 | 0/**4** | 0/**246** | 0/**136** | 0/**92** | 0/**202** | 0/**290** | 0/**290** | 0/**248** | 0/**202** | | |
| 139 | +| after Y/U | 0/0 | 0/0 | 0/0 | 0 | 0/0 | 0/0 | 0/0 | 0/0 | 0/0 | 0/0 | 0/0 | 0/0 | 0/0 | | |
| 140 | + | |
| 141 | +17/17 decode frames byte-exact per plane after the fix (V included). The first | |
| 142 | +divergence box, before: U and V rows **170..189**, cols **23..31**, 180 wrong | |
| 143 | +samples per plane — ours flat 90 (U) / 240 (V), the oracle's palette. Luma was | |
| 144 | +already exact in all 17 and stays exact. | |
| 145 | + | |
| 146 | +### 3.3 Comparator liveness (the flip control) | |
| 147 | + | |
| 148 | +One oracle sample's low byte flipped, per plane, at display frame 4, baseline | |
| 149 | +0/0/0: **+1 in exactly that plane of exactly that frame, 0 in all 47 other | |
| 150 | +plane/frame slots.** A 0/0/0 here is therefore a measurement, not a | |
| 151 | +non-comparison. (The same control is what | |
| 152 | +`scripts/cmpff.py`'s `flip()` performs, and the sweep below runs every cell | |
| 153 | +through that instrument.) | |
| 154 | + | |
| 155 | +## 4. Regression sweeps (both binaries, same machine, same oracle) | |
| 156 | + | |
| 157 | +Two independent instruments, base = `0c77bad5`'s `decode.rs`, fixed = this | |
| 158 | +branch; the only difference is the two window lines and the counter. | |
| 159 | + | |
| 160 | +1. **Committed corpus, 115 fixtures** (`crates/ec-av1/fixtures/*.obu`), display | |
| 161 | + order, per plane per frame vs ffmpeg: **0 of 115 cells changed** — 78 | |
| 162 | + byte-exact under both, and every other cell's verdict and totals identical | |
| 163 | + between base and fixed. | |
| 164 | +2. **The 4:2:0 / 4:2:2 / 4:4:4 census sweep cells** | |
| 165 | + (`~/.cache/census422b/sweep/*.obu`, 54 cells) through the repo's own | |
| 166 | + comparator (`EC_AV1_FINAL_DUMP`, decode order, `scripts/cmpff.py`'s derived | |
| 167 | + decode→display map): **48 byte-exact, 5 still diverging, 1 instrument failure | |
| 168 | + (`s422_416x250_10b` — "luma identity never covers the display side", the same | |
| 169 | + failure under both binaries) — and exactly ONE cell changed:** | |
| 170 | + | |
| 171 | + ``` | |
| 172 | + s422_384x240.obu DIVERGES [0, 1780, 1871] -> BYTE-EXACT [0, 0, 0] | |
| 173 | + ``` | |
| 174 | + | |
| 175 | + The five still-diverging census cells, identical under both binaries (another | |
| 176 | + lane's): `s422_320x246` 0/7810/5531, `s422_322x240` 0/22003/21625, | |
| 177 | + `s422_322x246` 0/3437/2222, `s422_352x242_10b` 0/4653/3777, `s422_416x242_10b` | |
| 178 | + 0/5740/4348. | |
| 179 | +3. **The committed 115 through the repo's own comparator** (`EC_AV1_FINAL_DUMP`, | |
| 180 | + decode order, `cmpff.py`) for the 56 cells that instrument finished inside its | |
| 181 | + run budget: every verdict identical between base and fixed. That run stopped | |
| 182 | + at its own 3000 s cap, not at a failure — `cmpff.py`'s decode→display | |
| 183 | + assignment search is exponential in the display-frame count and the long | |
| 184 | + `ii-flake` / `all_side` cells did not finish. Those cells are still covered | |
| 185 | + by instrument 1 above, which compared all 115 and found no change. | |
| 186 | +4. **All 169 cells (115 committed + 54 census), base vs fixed, BYTE IDENTITY** | |
| 187 | + with no oracle at all: both binaries run with `EC_AV1_FINAL_DUMP` (decode | |
| 188 | + order, hidden altref included) plus the display-order `EC_PROBE_OUT`, and | |
| 189 | + every dumped byte of every frame is compared. Two cells differ and only one | |
| 190 | + of them is real: | |
| 191 | + | |
| 192 | + * `census/s422_384x240.obu` -- **the target**, as intended. | |
| 193 | + * `corpus/440_request_is_422.obu` -- **not a change: that cell decodes | |
| 194 | + NON-DETERMINISTICALLY.** Six runs of the two binaries over it produced six | |
| 195 | + distinct md5s, three of them from the *same* binary: | |
| 196 | + | |
| 197 | + ``` | |
| 198 | + e5db1cf5… rep_base_1 147dbacf… rep_base_2 23361e34… rep_base_3 | |
| 199 | + 40d83d5b… rep_fixed_1 975a71a5… rep_fixed_2 a8acc479… rep_fixed_3 | |
| 200 | + ``` | |
| 201 | + | |
| 202 | + It is the hand-built 2014-byte 4:2:2 witness (a profile-2 4:4:0 request; | |
| 203 | + ffprobe and ffmpeg both refuse to read it, so it has no oracle), it reads | |
| 204 | + `intra_in_inter_palette: y=0 uv=0` -- so this lane's palette arm does not | |
| 205 | + even run on it -- and its differing bytes are 255<->0 swaps. That is the | |
| 206 | + unwritten-plane-sample class (`decode.rs`'s `fresh_plane` deliberately hands | |
| 207 | + out uninitialised storage, and `EC_AV1_PLANE_SENTINEL` exists to catch it). | |
| 208 | + Pre-existing, independent of this lane, named here rather than fixed: | |
| 209 | + `the_440_cell_is_not_a_codable_chroma_shape` -- the only gate pinning those | |
| 210 | + bytes -- asserts the (1,0) header and the refusal by name, never pixels, | |
| 211 | + and passes. | |
| 212 | + | |
| 213 | +Named cells from the charter: | |
| 214 | + | |
| 215 | +| cell | before | after | | |
| 216 | +|---|---|---| | |
| 217 | +| `s422_384x240` (the target) | DIVERGES 0/1780/1871 | **BYTE-EXACT 0/0/0** | | |
| 218 | +| `s422_384x242` | BYTE-EXACT | BYTE-EXACT | | |
| 219 | +| `s422_384x246` | BYTE-EXACT | BYTE-EXACT | | |
| 220 | +| `s422_320x240` | BYTE-EXACT | BYTE-EXACT | | |
| 221 | +| the frame-0 4:2:2 cells (`s422_416x242_10b`, …) | DIVERGES 0/5740/4348 | DIVERGES 0/5740/4348 (unchanged — another lane's) | | |
| 222 | + | |
| 223 | +## 5. The gate | |
| 224 | + | |
| 225 | +`stream.rs::the_pinned_422_palette_intra_in_inter_cell_window_is_byte_exact` | |
| 226 | +plus the pinned fixture `crates/ec-av1/fixtures/422_palette_intra_in_inter_384x240_17f.obu` | |
| 227 | +(19 344 B, sha256 `bf1c658e9bfdc13ec1ed51e59049d2b81201941b6ef4571f8382f356ea4b815b`, | |
| 228 | +fnv1a64 `0x923ccabfcb933e90`; the sweep artifact | |
| 229 | +`/home/user/.cache/census422b/sweep/s422_384x240.obu`, unchanged). | |
| 230 | + | |
| 231 | +The counter is `decode::palette_422_unit_window_hits()` — the number of 4:2:2 | |
| 232 | +intra-in-inter chroma transform units that took their own window. It reads 0 on | |
| 233 | +a 4:2:0 or 4:4:4 frame (their chroma unit is the whole plane block) and 0 on a | |
| 234 | +4:2:2 block with no palette, so a witness gate reading 0 proves the arm never | |
| 235 | +ran. | |
| 236 | + | |
| 237 | +**Two branches, and why.** `decode_stream` still refuses 4:2:2 at the sequence | |
| 238 | +header — the standing family rule, untouched here — so the committed tree's | |
| 239 | +run takes the refusal branch: it asserts the byte pin and that the refusal is | |
| 240 | +BY NAME, prints that the exactness claim could not be exercised, and asserts the | |
| 241 | +counter reads 0 so the pin alone can never fake a green. On the local | |
| 242 | +patch-run-restore build the same test takes its other branch and reports: | |
| 243 | + | |
| 244 | +``` | |
| 245 | +the_pinned_422_palette_intra_in_inter_cell_window_is_byte_exact: | |
| 246 | + 17 decode-order frame(s) byte-exact against aomdec (1 hidden), | |
| 247 | + 16 chroma palette unit window(s) | |
| 248 | +``` | |
| 249 | + | |
| 250 | +**Red-before-green, measured.** With the two `palette_window(...)` calls | |
| 251 | +replaced by the pre-fix `ub.clone()` / `vb.clone()` and everything else | |
| 252 | +unchanged, the same command fails: | |
| 253 | + | |
| 254 | +``` | |
| 255 | +422_palette_intra_in_inter_384x240_17f.obu: decode-order frame 1 of 17 | |
| 256 | +(16 shown, 1 hidden) differs from the oracle at byte 124631 (ours 90 vs 89), | |
| 257 | +412 bytes differ | |
| 258 | +``` | |
| 259 | + | |
| 260 | +## 6. Not claimed / open | |
| 261 | + | |
| 262 | +* **The armed-counter half of the gate is deferred to the 4:2:2 header lift.** | |
| 263 | + The arm is reachable only at ss (1,0), and `decode_stream` refuses that at the | |
| 264 | + sequence header, so a committed fired-counter assertion is impossible without | |
| 265 | + re-committing the bypass the family rule forbids. The counter, the fixture, the | |
| 266 | + pin and both branches of the gate are in place; the moment the lift lands, the | |
| 267 | + test already asserts 17 decode-order frames byte-exact **and** | |
| 268 | + `palette_422_unit_window_hits() > 0`, with no further edit to this lane. | |
| 269 | +* **The rest of the palette class was not audited arm by arm.** ~50 | |
| 270 | + `set_palette_pred` sites exist; the ones reachable on the committed corpora are | |
| 271 | + covered by the sweeps above (all 115 fixtures and all 54 census cells, byte | |
| 272 | + for byte unchanged). The untested remainder is "a block-sized palette buffer | |
| 273 | + armed once in front of a MULTI-unit walk" — the class this fix is one instance | |
| 274 | + of — and it is reachable only through shapes no committed fixture codes today. | |
| 275 | + Named here rather than claimed closed. | |
| 276 | +* **`corpus/440_request_is_422.obu` decodes nondeterministically** — six runs, | |
| 277 | + six md5s, three of them from one binary (§4.4). Unwritten plane samples reach | |
| 278 | + that hand-built 4:2:2 witness's output. Found by this lane's byte-identity | |
| 279 | + sweep, not caused by it; `EC_AV1_PLANE_SENTINEL` is the instrument that would | |
| 280 | + localise it. It has no oracle (ffprobe and ffmpeg both refuse the stream) and | |
| 281 | + no pixel gate. `deferred(the 4:2:2 lift owns every 4:2:2 pixel claim, and this | |
| 282 | + cell is reachable only through that bypass)` — named, not fixed. | |
| 283 | +* The oracle binary in `~/.cache/aom-oracle/build/aomdec` is **stale** relative | |
| 284 | + to its own source: `EC_DP` does not fire in it (the rung is at | |
| 285 | + `decodeframe.c:983`), and its `AOM_CPRED` prints block chroma extents the | |
| 286 | + current source does not print for the plane. Every structural reading in §0/§1 | |
| 287 | + was therefore taken from a private rebuild | |
| 288 | + (`~/.cache/aom-oracle-tailskip`, built from the current source), whose pixels | |
| 289 | + agree with ffmpeg 0/0/0 on every shown frame of this cell under the display | |
| 290 | + map. | |
| 291 | +* Measurements taken on a local patch-run-restore bypass (never committed, the | |
| 292 | + refusal restored in the commit's tree): the §3.2 table, the fired-counter | |
| 293 | + branch of §5, and the red-before mutation's oracle comparison. | |
| \ No newline at end of file |