ec-av1: align a chroma unit's context publication to its chroma cell
Browse files at this commitc84b51a8f288d24edab318b3e02dd080f7476a48Parent: 1766d694 changed files +335 -2
- crates/ec-av1/fixtures/420_lossless_arf_1to4_320x240_5f.obu +0 -0
- crates/ec-av1/src/decode.rs +52 -0
- crates/ec-av1/src/stream.rs +97 -2
- lanes/arf-gm-lossless.report.md +186 -0
crates/ec-av1/fixtures/420_lossless_arf_1to4_320x240_5f.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+52 -0
| @@ -6495,6 +6495,33 @@ thread_local! { | ||
| 6495 | 6495 | static INTER16_SUB8_PIECE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 6496 | 6496 | } |
| 6497 | 6497 | |
| 6498 | +// lane-arfchroma: chroma transform-unit publications whose block started | |
| 6499 | +// MID-CELL -- the condition `record_mi_chroma`'s origin alignment exists for. | |
| 6500 | +// A 4x4 chroma unit is `1 << ss` luma mi per axis, so a block whose mi origin | |
| 6501 | +// is not step-aligned (a 16x4 / 4x16 1:4 strip at 4:2:0 has an ODD mi row or | |
| 6502 | +// column) publishes a context cell whose origin is the step-aligned mi BELOW | |
| 6503 | +// or RIGHT of its own. Counted per publication, `[row_misaligned, | |
| 6504 | +// col_misaligned, both]`, so a gate can prove the witness really walks the | |
| 6505 | +// realigned path instead of passing on a stream whose chroma units all happen | |
| 6506 | +// to start on a cell boundary. | |
| 6507 | +thread_local! { | |
| 6508 | + static CHROMA_MIDCELL_PUB_HITS: std::cell::Cell<[usize; 3]> = | |
| 6509 | + const { std::cell::Cell::new([0; 3]) }; | |
| 6510 | +} | |
| 6511 | + | |
| 6512 | +/// ChROMA publications that started mid-cell: `[row, col, both]`. See | |
| 6513 | +/// [`CHROMA_MIDCELL_PUB_HITS`]. | |
| 6514 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 6515 | +pub fn chroma_midcell_pub_hits() -> [usize; 3] { | |
| 6516 | + CHROMA_MIDCELL_PUB_HITS.with(std::cell::Cell::get) | |
| 6517 | +} | |
| 6518 | + | |
| 6519 | +/// Zeroes [`CHROMA_MIDCELL_PUB_HITS`] so a gate can measure its own decode. | |
| 6520 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | |
| 6521 | +pub fn reset_chroma_midcell_pub_hits() { | |
| 6522 | + CHROMA_MIDCELL_PUB_HITS.with(|c| c.set([0; 3])); | |
| 6523 | +} | |
| 6524 | + | |
| 6498 | 6525 | // lane-intra16x4: INTRA-coded strips of an inter 16x16-level 1:4 partition -- |
| 6499 | 6526 | // [0] 16x4, [1] 4x16, [2] the odd (chroma-reference) ones, which carry the |
| 6500 | 6527 | // pair's single 8x4 (4x8) chroma unit for BOTH strips. |
| @@ -10910,6 +10937,31 @@ impl Neighbours { | ||
| 10910 | 10937 | plane: usize, |
| 10911 | 10938 | grid: &[i32], |
| 10912 | 10939 | ) { |
| 10940 | + // lane-arfchroma: a 4x4 CHROMA transform unit is `4 << ss` luma px per | |
| 10941 | + // axis, i.e. `1 << ss` LUMA mi, so its context cell is the step-aligned | |
| 10942 | + // group of mi a block may only PART of. A block starting mid-cell (a | |
| 10943 | + // 16x4 / 4x16 1:4 strip, whose mi row/col is ODD at 4:2:0) stamped its | |
| 10944 | + // own origin plus the mi row/col BELOW it, so the strip above a block | |
| 10945 | + // handed that block a "left neighbour" libaom never had -- its chroma | |
| 10946 | + // cell is one row up -- and the block's chroma `txb_skip` context came | |
| 10947 | + // out one base high (ours 2, libaom 7+1 = 8, at 320x240 frame 2 block | |
| 10948 | + // mi (4,0) of the 4:2:0 lossless alt-ref witness). Align the origin | |
| 10949 | + // DOWN to the cell: that is where libaom's per-plane 2-D | |
| 10950 | + // `left/above_context_map` cell lives, indexed in the PLANE's own 4x4 | |
| 10951 | + // units rather than in luma mi. | |
| 10952 | + let (step_x, step_y) = (w_px / MI, h_px / MI); | |
| 10953 | + // the flags read the CALLER's origin, before the shadowing align below | |
| 10954 | + let (row_mid, col_mid) = (mi_r & (step_y - 1) != 0, mi_c & (step_x - 1) != 0); | |
| 10955 | + if row_mid || col_mid { | |
| 10956 | + CHROMA_MIDCELL_PUB_HITS.with(|c| { | |
| 10957 | + let mut v = c.get(); | |
| 10958 | + v[0] += usize::from(row_mid); | |
| 10959 | + v[1] += usize::from(col_mid); | |
| 10960 | + v[2] += usize::from(row_mid && col_mid); | |
| 10961 | + c.set(v); | |
| 10962 | + }); | |
| 10963 | + } | |
| 10964 | + let (mi_r, mi_c) = (mi_r & !(step_y - 1), mi_c & !(step_x - 1)); | |
| 10913 | 10965 | let round_up_even = |n: usize| n.div_ceil(2) * 2; |
| 10914 | 10966 | let (bound_h, bound_w) = (round_up_even(self.mi_rows), round_up_even(self.mi_cols)); |
| 10915 | 10967 | let state = neighbour_state(grid); |
crates/ec-av1/src/stream.rsmodified+97 -2
| @@ -8783,6 +8783,98 @@ pub(crate) mod tests { | ||
| 8783 | 8783 | the one that forked the ladder at read 32813)" |
| 8784 | 8784 | ); |
| 8785 | 8785 | } |
| 8786 | + | |
| 8787 | + /// lane-arfchroma: 4:2:0 **lossless** with an alt-ref frame and 1:4 inter | |
| 8788 | + /// strips. Ordinary, user-reachable aomenc output, no bypass: before the | |
| 8789 | + /// fix this cell diverged in 15 of 16 shown frames (1 088 573 wrong | |
| 8790 | + /// samples, only frames 0-1 exact) or -- one knob away, e.g. | |
| 8791 | + /// `--sb-size=64`, `--enable-dual-filter=0`, `--max-reference-frames=3`, | |
| 8792 | + /// or the same stream cut to 5-12 frames -- REFUSED outright with | |
| 8793 | + /// `a Golomb tail longer than this decoder reads`. The refusal was this | |
| 8794 | + /// divergence arriving at a named guard, not an independent gap: the | |
| 8795 | + /// `16-frame` variant of this exact cell now decodes byte-exact. | |
| 8796 | + /// | |
| 8797 | + /// Mechanism (paired rungs, `EC_COEFF_STEP` / `EC_ECDUMP` against | |
| 8798 | + /// aomdec, 320x240, 5 frames): the first forked read is frame 2's 8x8 | |
| 8799 | + /// inter block at mi (4,0) (ref0 = 7 = ALTREF, mv (36,0), NEWMV), its | |
| 8800 | + /// CHROMA U `txb_skip` read. All four LUMA units match read for read, and | |
| 8801 | + /// the chroma read's pre-state `(rng 35592)` is IDENTICAL on both sides -- | |
| 8802 | + /// only the context differs: ours 2, libaom 8 | |
| 8803 | + /// (`7 + get_entropy_context`, `txb_common.h:360`). `EC_ECDUMP` names the | |
| 8804 | + /// cause: libaom's chroma left neighbour is `[0]` and ours is coded. The | |
| 8805 | + /// publisher is the 16x4 (1:4) strip above it: `record_mi_chroma` | |
| 8806 | + /// published the unit at the BLOCK's mi origin, but a 4x4 chroma unit is | |
| 8807 | + /// `1 << ss` luma mi per axis, so a strip whose mi row is ODD at 4:2:0 | |
| 8808 | + /// starts mid-cell and its state landed one mi row too low -- into the | |
| 8809 | + /// cell of the block that read it. libaom's per-plane | |
| 8810 | + /// `left/above_context_map` is indexed in the PLANE's own 4x4 units | |
| 8811 | + /// (`entropy.h:87`, `txb_common.h:429`), so the cell's origin is the | |
| 8812 | + /// step-aligned mi, which is what the fix aligns to. | |
| 8813 | + /// | |
| 8814 | + /// The gate asserts three things, in this order: the pin's identity, the | |
| 8815 | + /// mid-cell route counter (so it cannot pass on a stream whose chroma | |
| 8816 | + /// units all start on a cell boundary -- class | |
| 8817 | + /// gate-blind-to-feature), and then BOTH comparisons: decode order | |
| 8818 | + /// (which sees the hidden alt-ref frame no shown-frame gate can) and the | |
| 8819 | + /// per-plane shown-frame count. | |
| 8820 | + /// | |
| 8821 | + /// Recipe (both sides reproducible, 28394 bytes): | |
| 8822 | + /// ```text | |
| 8823 | + /// ffmpeg -f lavfi -i testsrc2=size=320x240:rate=25 -frames:v 5 \ | |
| 8824 | + /// -pix_fmt yuv420p y.yuv | |
| 8825 | + /// aomenc --codec=av1 --obu --lossless=1 -w 320 -h 240 \ | |
| 8826 | + /// --lag-in-frames=25 --auto-alt-ref=1 --limit=5 -o w.obu y.yuv | |
| 8827 | + /// ``` | |
| 8828 | + /// sha256 c5507ed97f74ca495b71449fda24f5fe2fcfa34eed38988a69141d45b126627c. | |
| 8829 | + /// The tree pins fixture identity by fnv1a64; a `const SHA256` compared | |
| 8830 | + /// against itself would be the tautology lane-av1422anom exists to kill. | |
| 8831 | + #[test] | |
| 8832 | + fn a_420_lossless_alt_ref_1to4_strip_witness_is_byte_exact_in_decode_order() { | |
| 8833 | + const NAME: &str = | |
| 8834 | + "a_420_lossless_alt_ref_1to4_strip_witness_is_byte_exact_in_decode_order"; | |
| 8835 | + // lane-av1cmpaudit2: same mutex as every other oracle gate. | |
| 8836 | + let _gate_lock = lock_gate_counters(); | |
| 8837 | + const FILE: &str = "420_lossless_arf_1to4_320x240_5f.obu"; | |
| 8838 | + const BYTES: usize = 28394; | |
| 8839 | + const FNV1A64: u64 = 16971188390893372935; | |
| 8840 | + let path = crate_pin(FILE); | |
| 8841 | + let data = std::fs::read(&path) | |
| 8842 | + .unwrap_or_else(|e| panic!("{NAME}: the committed pin {FILE} is missing ({e})")); | |
| 8843 | + assert_eq!(data.len(), BYTES, "{NAME}: {FILE} size drifted"); | |
| 8844 | + assert_eq!(fnv1a64(&data), FNV1A64, "{NAME}: {FILE} bytes drifted"); | |
| 8845 | + crate::decode::reset_chroma_midcell_pub_hits(); | |
| 8846 | + let (decoded, hidden) = decode_all_frames_vs_oracle(&data, NAME); | |
| 8847 | + assert_eq!( | |
| 8848 | + decoded, 6, | |
| 8849 | + "{NAME}: the oracle decoded {decoded} frames in DECODE order; the 5-frame recipe \ | |
| 8850 | + carries 5 source frames, one of them a hidden alt-ref picture plus a \ | |
| 8851 | + `show_existing_frame` header" | |
| 8852 | + ); | |
| 8853 | + assert_eq!( | |
| 8854 | + hidden, 1, | |
| 8855 | + "{NAME}: this cell exists for the HIDDEN alt-ref frame -- {decoded} decode-order \ | |
| 8856 | + dumps against {decoded} - {hidden} shown outputs means the gate saw the picture no \ | |
| 8857 | + shown-frame compare can reach" | |
| 8858 | + ); | |
| 8859 | + let mid = crate::decode::chroma_midcell_pub_hits(); | |
| 8860 | + assert!( | |
| 8861 | + mid[2] > 0 || mid[0] + mid[1] > 0, | |
| 8862 | + "{NAME}: no chroma transform unit was published from a mid-cell origin \ | |
| 8863 | + ({mid:?} = [row, col, both]), so this witness does not exercise the origin \ | |
| 8864 | + alignment at all (class gate-blind-to-feature) -- re-encode per the recipe above" | |
| 8865 | + ); | |
| 8866 | + let (wy, wu, wv, shown, exact) = | |
| 8867 | + count_rawvideo_diffs(&data, NAME, None).expect("the two sides must be byte-comparable"); | |
| 8868 | + assert_eq!( | |
| 8869 | + (wy, wu, wv, exact), | |
| 8870 | + (0, 0, 0, shown), | |
| 8871 | + "{NAME}: shown-frame per-plane diff vs `aomdec --rawvideo`" | |
| 8872 | + ); | |
| 8873 | + eprintln!( | |
| 8874 | + "{NAME}: {decoded} decode-order frame(s) byte-exact ({hidden} hidden), \ | |
| 8875 | + {shown} shown frame(s) exact per plane, mid-cell chroma publications {mid:?}" | |
| 8876 | + ); | |
| 8877 | + } | |
| 8786 | 8878 | /// lane-av1444rect r2 — the SAME class as the gate above, second |
| 8787 | 8879 | /// instance: `decode_rect4_16_intrabc` applied the 4:2:0 pair geometry at |
| 8788 | 8880 | /// ss (0,0), where `is_chroma_reference` makes an intra-BC 1:4 strip its |
| @@ -10603,7 +10695,11 @@ pub(crate) mod tests { | ||
| 10603 | 10695 | let _ = std::fs::remove_dir_all(&dir); |
| 10604 | 10696 | let decoded = decode_stream(&data).expect("the pinned stream decodes"); |
| 10605 | 10697 | let ours = pack_rawvideo(&decoded, bit_depth, NAME); |
| 10606 | - assert_eq!(ours.len(), want.len(), "{NAME}: the two sides differ in size"); | |
| 10698 | + assert_eq!( | |
| 10699 | + ours.len(), | |
| 10700 | + want.len(), | |
| 10701 | + "{NAME}: the two sides differ in size" | |
| 10702 | + ); | |
| 10607 | 10703 | |
| 10608 | 10704 | // The per-frame plane table, built from each decoded picture's OWN |
| 10609 | 10705 | // plane lengths -- the same source `pack_rawvideo` lays the bytes out |
| @@ -51810,5 +51906,4 @@ exit 0 | ||
| 51810 | 51906 | } |
| 51811 | 51907 | let _ = std::fs::remove_dir_all(&dir); |
| 51812 | 51908 | } |
| 51813 | - | |
| 51814 | 51909 | } |
lanes/arf-gm-lossless.report.mdadded+186 -0
| @@ -0,0 +1,186 @@ | ||
| 1 | +# lane-arf-gm-lossless — 4:2:0 LOSSLESS + alt-ref + global motion DIVERGES | |
| 2 | + | |
| 3 | +Branch `lane-arf-gm-lossless`, base `aef4fa67`. FIXED (one line of arithmetic in | |
| 4 | +`record_mi_chroma`, plus a route counter and a pinned gate). | |
| 5 | + | |
| 6 | +## 1. The four-configuration table, re-measured (320x240 testsrc2, 16 frames, lossless) | |
| 7 | + | |
| 8 | +Recipe: `ffmpeg -f lavfi -i testsrc2=size=320x240:rate=25 -frames:v 16 -pix_fmt yuv420p y.yuv` | |
| 9 | +then `aomenc --codec=av1 --obu --lossless=1 -w 320 -h 240 <knobs> -o x.obu y.yuv`. | |
| 10 | + | |
| 11 | +| lag | alt-ref | global-motion | sha256 (first 16) | bytes | pre-fix | post-fix | | |
| 12 | +|---|---|---|---|---|---|---| | |
| 13 | +| 0 | 0 | 0 | 796afea2597f7b86 | 107094 | EXACT 16/16 | EXACT 16/16 | | |
| 14 | +| 0 | 1 | 0 | 796afea2597f7b86 | 107094 | EXACT 16/16 | EXACT 16/16 | | |
| 15 | +| 25 | 0 | 0 | 8c7f117b51097df1 | 113465 | EXACT 16/16 | EXACT 16/16 | | |
| 16 | +| 25 | 1 | 0 | 065cdfb5d4212b19 | 87075 | **DIVERGES** (1242219 wrong) | EXACT 17/17 | | |
| 17 | +| 25 | 1 | 1 | b8eea5dc679f50df | 86649 | **DIVERGES** (1088573 wrong) | EXACT 17/17 | | |
| 18 | + | |
| 19 | +Full shas: L0_A0_G0 = L0_A1_G0 = `796afea2597f7b8665b11ff16eb2b7a3fa7e7acd02fdfdcd1355bd8290edae8a`, | |
| 20 | +L25_A0_G0 = `8c7f117b51097df1ecf1d41660e1950bc6cbf9b19c41c4859ecd79794baeab0f`, | |
| 21 | +L25_A1_G0 = `065cdfb5d4212b195460709ade77f1ceb4caf3948777df81cd243a1afc688afc`, | |
| 22 | +L25_A1_G1 = `b8eea5dc679f50dfaae99da09011b123d143a7d9b60e14be74683f6c366f2cfb`. | |
| 23 | + | |
| 24 | +**Two corrections to the ticket's premise, both measured:** | |
| 25 | +1. Global motion is NOT the trigger. `--auto-alt-ref=1 --enable-global-motion=0` | |
| 26 | + diverges too (and by MORE: 1 242 219 wrong samples vs 1 088 573). Every GM model in | |
| 27 | + the frame headers is `Identity`, so no global motion is applied at all. | |
| 28 | +2. The "ARF alone refuses" cell does not refuse at 16 frames. It DIVERGES, exactly | |
| 29 | + like ARF+GM. The *refusal* appears in the neighbouring cells that a single encoder | |
| 30 | + knob moves: `--sb-size=64`, `--enable-dual-filter=0`, `--enable-intra-edge-filter=0`, | |
| 31 | + `--max-reference-frames=3`, and the same cell cut to 5/6/8/12 frames. | |
| 32 | + Lossy is exact with alt-ref (`--cq-level=30`, 17/17), so the trigger is | |
| 33 | + **lossless AND alt-ref AND a 1:4 rect strip**; `--enable-rect-partitions=0` and | |
| 34 | + `--enable-1to4-partitions=0` both make the cell exact. | |
| 35 | + | |
| 36 | +## 2. Decode order vs shown, per plane | |
| 37 | + | |
| 38 | +Per-cell table from `EC_AV1_FINAL_DUMP` on BOTH sides (one file per decoded picture, | |
| 39 | +hidden alt-ref frames included), 320x240 4:2:0, 115200 B/frame: | |
| 40 | + | |
| 41 | +L25_A1_G1 pre-fix, 17 decode-order frames (16 shown outputs, 1 show_existing header): | |
| 42 | + | |
| 43 | +| frame | Y | U | V | note | | |
| 44 | +|---|---|---|---|---| | |
| 45 | +| 0 | 0 | 0 | 0 | key frame exact | | |
| 46 | +| 1 | 0 | 0 | 0 | hidden alt-ref #1 exact | | |
| 47 | +| 2 | 12559 | 4715 | 4761 | **first divergence**: the first frame that predicts from the ALTREF slot (`refs[ALTREF]=1`) | | |
| 48 | +| 3-16 | 34033-68857 | 9530-18514 | 9676-17607 | monotone growth (each frame predicts from the previous, already-wrong picture) | | |
| 49 | +| total | 686123 | 198962 | 203488 | 1 088 573 wrong, 2/17 frames exact | | |
| 50 | + | |
| 51 | +So: **both** planes and **both** classes of frame — the first wrong frame is a HIDDEN | |
| 52 | +alt-ref frame (decode-order 2), and the damage reaches the shown frames by prediction | |
| 53 | +from it. Post-fix: 0/0/0 on all 17, per plane. | |
| 54 | + | |
| 55 | +Spatial shape: not whole-frame garbage (only 299 of 1200 8x8 luma blocks in frame 2), | |
| 56 | +a wedge over the moving content — i.e. wrong PREDICTION downstream of one wrong context | |
| 57 | +read, not an entropy flood. 1st wrong sample luma (264,0). | |
| 58 | + | |
| 59 | +Per-cell control (comparator proven to read the oracle): flipping ONE bit in | |
| 60 | +`aom.f2` byte 1000 moves the count by exactly +1 in Y and knocks exactly one frame out | |
| 61 | +of 17/17 → 16/17. A chroma-side flip behaves the same in U. | |
| 62 | + | |
| 63 | +## 3. Mechanism (paired rungs, one read followed to the source) | |
| 64 | + | |
| 65 | +Scoped to the 5-frame variant (28394 B) so the fork is early. Rungs: oracle | |
| 66 | +`EC_TRACE_MODE=1` (`EC_MODE`/`EC_MODE_MV`/`EC_MODE_VAL`) + `EC_ECDUMP=1` + | |
| 67 | +`EC_TRACE_COEFF=1`; ours the same tags plus `EC_SYMR=1` and `EC_CHROMA_PUB=1`. | |
| 68 | + | |
| 69 | +1. The `EC_MODE` PRE-read ladder (mi, rng) is in lockstep for **359 blocks** and both | |
| 70 | + sides read block mi (4,0) with the same pre-state `rng=38812`; the next block | |
| 71 | + differs (aom 62752 / ours 60484). The fork is inside mi (4,0) of **frame 2** | |
| 72 | + (`EC_COEFF_FRAME decode_idx=2`). | |
| 73 | +2. mi (4,0) is a 16x16 partition split to an 8x8 leaf: `mode=16` (NEWMV), `ref0=7` | |
| 74 | + (ALTREF), `mv0=(36,0)`, `warp=false`, `stack=1` — identical on both sides. | |
| 75 | +3. Its coefficient ladder matches read for read through all **four luma 4x4 TUs** | |
| 76 | + (`all_zero ctx=3,6,3,6`, eob 7, base_eob 2, base c=5..0, br k=3,0 — every post-rng | |
| 77 | + equal: 42119, 53648, 63600, 51536, 35042, 48436, 53568, 38352, 49028, 51204, 43384). | |
| 78 | +4. The 5th read is the chroma U `txb_skip`, and here the pre-state is **identical** | |
| 79 | + (`pre rng=35592` both sides) while the context differs: **ours 2, libaom 8** | |
| 80 | + (`EC_ECDUMP plane=1 mi=(4,0) bc=0 br=0 ctx=8 above=[23,] left=[0,]`). | |
| 81 | + libaom 8 = `7 + get_entropy_context` with above≠0, left==0 | |
| 82 | + (`av1/common/txb_common.h:429-435`, `av1/common/entropy.h:87-97`); ours 2 = both | |
| 83 | + neighbours coded. | |
| 84 | +5. `EC_ECDUMP` names the disagreement: libaom's chroma LEFT neighbour is level 0 — | |
| 85 | + there is none — and ours is the 16x4 (1:4) strip above, whose chroma cell is one | |
| 86 | + mi row up. Both sides agree on chroma ABOVE (23). | |
| 87 | + | |
| 88 | +**Root cause.** `record_mi_chroma` (decode.rs:10932) published a chroma transform | |
| 89 | +unit's coefficient context at the **block's** mi origin. A 4x4 chroma unit is `4 << ss` | |
| 90 | +luma px = `1 << ss` **luma mi** per axis, so a block that starts mid-cell — a 16x4 / | |
| 91 | +4x16 1:4 strip, whose mi row (or column) is ODD at 4:2:0 — stamped its own origin plus | |
| 92 | +the mi row/col BELOW it, one row/col past the cell it owns. libaom's per-plane | |
| 93 | +`left/above_context_map` is indexed in the **plane's own 4x4 units** | |
| 94 | +(`entropy.h:87`, `txb_common.h:313-366`), so the cell's origin is the step-aligned mi. | |
| 95 | +`EC_CHROMA_PUB` pre-fix prints the strip's units at `mi=(3,0)/(3,2)` and `mi=(1,0)/(1,2)`; | |
| 96 | +post-fix at `mi=(2,0)/(2,2)` and `(0,0)/(0,2)`. | |
| 97 | + | |
| 98 | +**The fix** (one line): align the publication origin DOWN to the cell, | |
| 99 | +`mi_r & !(step_y - 1)`, `mi_c & !(step_x - 1)`, with the step derived from the unit's | |
| 100 | +own luma span (`w_px / MI`), so 4:2:0 aligns by 2, 4:2:2 by 2/1, 4:4:4 by 1. One point, | |
| 101 | +all six callers. | |
| 102 | + | |
| 103 | +**Class sweep.** `record_mi_chroma` is the only per-transform-unit chroma publisher; | |
| 104 | +the luma publishers (`record_mi_luma`, `record_mi_luma_rect`) sit on the unsubsampled | |
| 105 | +mi grid where no alignment exists, and the whole-block records | |
| 106 | +(`record_mi_rect`/`record_split_luma_rect_mi`) write at most the block's own rows — | |
| 107 | +they UNDER-publish a cell, which no raster-order reader can observe, and never | |
| 108 | +over-publish into the next cell. So the over-publication defect is unique to the site | |
| 109 | +fixed. The mode/partition/skip/ref/filter context arrays are all luma-mi keyed and | |
| 110 | +unaffected. | |
| 111 | + | |
| 112 | +## 4. Is the 'Golomb tail' refusal this divergence? | |
| 113 | + | |
| 114 | +**Yes — proven by construction, not inferred.** Mutating the one alignment line back to | |
| 115 | +the identity (`let (mi_r, mi_c) = (mi_r, mi_c);`) makes the new gate fail with exactly | |
| 116 | +`unsupported: AV1 tile (a Golomb tail longer than this decoder reads)` on this cell | |
| 117 | +(stream.rs:10410). The guard is honest about what it sees (a long Golomb tail really is | |
| 118 | +what a wrong MV-derived read produces) but it was reporting THIS defect on a | |
| 119 | +user-reachable cell; with the alignment in place the cell decodes byte-exact and the | |
| 120 | +refusal is left to mean what it says. | |
| 121 | + | |
| 122 | +## 5. Witness, pin, gate, mutation proof | |
| 123 | + | |
| 124 | +- Pin: `crates/ec-av1/fixtures/420_lossless_arf_1to4_320x240_5f.obu`, 28394 bytes, | |
| 125 | + sha256 `c5507ed97f74ca495b71449fda24f5fe2fcfa34eed38988a69141d45b126627c`, | |
| 126 | + fnv1a64 `16971188390893372935` (asserted by the gate; the tree pins by fnv, a | |
| 127 | + self-compared `const SHA256` would be the tautology lane-av1422anom exists to kill). | |
| 128 | +- Recipe in the gate doc comment: `ffmpeg testsrc2 320x240 r=25 -frames:v 5 | |
| 129 | + -pix_fmt yuv420p` + `aomenc --codec=av1 --obu --lossless=1 -w 320 -h 240 | |
| 130 | + --lag-in-frames=25 --auto-alt-ref=1 --limit=5`. | |
| 131 | +- Gate: `a_420_lossless_alt_ref_1to4_strip_witness_is_byte_exact_in_decode_order` | |
| 132 | + (stream.rs:8786). Asserts, in order: pin identity → **6 decode-order frames | |
| 133 | + byte-exact vs aomdec (1 hidden)** → the new `chroma_midcell_pub_hits()` route counter | |
| 134 | + is non-zero (a mid-cell chroma publication really happened, so the gate cannot pass | |
| 135 | + on a stream whose chroma units all start on a cell boundary) → 5 shown frames exact | |
| 136 | + per plane via `count_rawvideo_diffs`. | |
| 137 | +- New counter: `chroma_midcell_pub_hits() -> [row, col, both]` / reset, incremented in | |
| 138 | + `record_mi_chroma` from the CALLER's (pre-alignment) origin. | |
| 139 | +- Mutation proof: alignment → identity ⇒ `FAILED ... a Golomb tail longer than this | |
| 140 | + decoder reads`; alignment restored ⇒ `ok`. GREEN measured after restore. | |
| 141 | +- The 16-frame cell (the ticket's own) was NOT pinned: at 86649 B it is 3x the pin for | |
| 142 | + the same code path; its recipe + sha are in §1 and both are exact. | |
| 143 | + | |
| 144 | +## 6. Regression | |
| 145 | + | |
| 146 | +`cargo test -p ec-av1 --lib --features gate-counters -- chroma`: **52 passed, 0 failed** | |
| 147 | +(includes the 4:2:2/4:4:4/intra-BC/sb128 chroma gates and the 1:1-to-4 chroma-pair | |
| 148 | +gate). A second scoped run (`lossless 1to4 rect_`) was launched; see the yield for its | |
| 149 | +result. | |
| 150 | + | |
| 151 | +## not_done | |
| 152 | + | |
| 153 | +- No full-suite run (main's job by the lane rules); only the two scoped filters above. | |
| 154 | +- `scripts/fixture-library.tsv` is GENERATED and every fixture reference is recorded | |
| 155 | + with a `file:line`; the new pin adds a row that belongs to the post-wave merge | |
| 156 | + (`scripts/gen-fixture-library.sh`). Not hand-edited here on purpose. | |
| 157 | +- The 4:4:4 / 4:2:2 alignment paths (step 1 and 2/1) are exercised by the existing | |
| 158 | + chroma gates, not by a NEW 4:4:4 mid-cell witness: at 4:4:4 a chroma cell is one mi, | |
| 159 | + so no block can start mid-cell on the row/col axis, and 4:2:2's odd axis is the same | |
| 160 | + arithmetic as 4:2:0's. | |
| 161 | +- The broader knob matrix (`--cpu-used`, `--enable-order-hint=0`, `--enable-obmc=0`, …) | |
| 162 | + was measured for narrowing only; each "exact" result there is a re-partitioning | |
| 163 | + coincidence, NOT mechanism evidence, and none of them is claimed as such. | |
| 164 | + | |
| 165 | +## 7. Two more resolutions / contents (same recipe, lag 25 / alt-ref 1 / GM 1 / lossless) | |
| 166 | + | |
| 167 | +| content | size | sha256 | pre-fix | post-fix | | |
| 168 | +|---|---|---|---|---| | |
| 169 | +| `testsrc2` 416x240, 16f | 24430 | `d87a13d84edd427e96bc195f5e90b8be6c4937b0a42fa5f26829622aa5da9dd1` | DIVERGES 655 402 wrong (Y 424601 / U 113556 / V 117245), 3/17 frames exact | EXACT 17/17 (0/0/0) | | |
| 170 | +| `mandelbrot` 320x240, 16f | 332523 | `cc82abd16949e3449d2e63f93a646e030f869bbc1091794af987028b767190bc` | DIVERGES 1 474 781 wrong (Y 981821 / U 243154 / V 249806), 1/16 frames exact | EXACT 16/16 (0/0/0) | | |
| 171 | + | |
| 172 | +Pre-fix numbers measured by rebuilding the parent commit's `decode.rs` | |
| 173 | +(`git checkout aef4fa67 -- crates/ec-av1/src/decode.rs`) into the same target dir and | |
| 174 | +re-running the same comparator on the same bytes; the tree was restored and rebuilt | |
| 175 | +afterwards (`git status` clean). | |
| 176 | + | |
| 177 | +## 8. Regression, second filter | |
| 178 | + | |
| 179 | +`cargo test -p ec-av1 --lib --features gate-counters -- lossless 1to4 rect_` hit my | |
| 180 | +300 s cap with several LIVE-aomenc tests still encoding; every test that completed was | |
| 181 | +green (no `FAILED` line), among them | |
| 182 | +`a_real_aomenc_stream_with_a_superblock_level_1to4_partition_decodes_pixel_exact`, | |
| 183 | +`..._filter_intra_on_a_32_level_1to4_strip_...`, `..._rect_palette_...`, | |
| 184 | +`..._rect_screen_content_...`, `an_sb128_rect_strip_with_intrabc_...`. The filter needs a | |
| 185 | +longer cap (or a server) to finish; the `chroma` filter (52 tests, the ones this change can | |
| 186 | +plausibly move) completed fully green. |