Merge 1f4b8afb (422stripwrite) — suite green: 422stripwrite GREEN 625/0
Browse files at this commit3 changed files +362 -34
- crates/ec-av1/src/decode.rs +118 -33
- crates/ec-av1/src/encode.rs +4 -1
- lanes/av1422stripwrite.report.md +240 -0
crates/ec-av1/src/decode.rsmodified+118 -33
| @@ -30992,42 +30992,17 @@ impl<'p> RefPix<'p> { | |||
| 30992 | ( | 30992 | ( |
| 30993 | whole_plane(&g.y, g.width, g.height), | 30993 | whole_plane(&g.y, g.width, g.height), |
| 30994 | { | 30994 | { |
| 30995 | - // Reference pictures carry no subsampling field -- the | 30995 | + // No subsampling field on a stored reference: the |
| 30996 | - // plane's own shape is inferred from its length: | 30996 | + // chroma format comes off its own sample count -- |
| 30997 | - // luma-sized is 4:4:4, `halfw x height` is 4:2:2 | 30997 | + // 4:4:4 `w * h`, 4:2:2 `round_ss(w, 1) * h`, 4:2:0 |
| 30998 | - // (ss_x 1, ss_y 0 -- the chroma plane is HALF-width | 30998 | + // `round_ss(w, 1) * round_ss(h, 1)`. The helper's own |
| 30999 | - // and FULL-height), `halfw x halfh` is 4:2:0. The | 30999 | + // doc carries the measurement behind those three arms |
| 31000 | - // three lengths are pairwise distinct for every | 31000 | + // and the pre-existing odd-dimension 4:2:0 gap. |
| 31001 | - // w, h >= 1, so the guess is exact. The old | 31001 | + let (cw, ch) = ref_chroma_shape(g.u.len(), g.width, g.height); |
| 31002 | - // two-way guess read every 4:2:2 reference as | ||
| 31003 | - // quarter-height: a 128x128 frame's chroma resolved | ||
| 31004 | - // 64x64, the bottom mu-chunk row's prediction | ||
| 31005 | - // sampled a clamped row-63 edge and the frame's | ||
| 31006 | - // own pixels were right (the crop is ss-aware) -- | ||
| 31007 | - // only INTER prediction off the slot was wrong | ||
| 31008 | - // (lane-av1-422bigblock: the sb128 witness's | ||
| 31009 | - // frame-2 chroma, rows 64..127). | ||
| 31010 | - let halfw = (g.width + 1) / 2; | ||
| 31011 | - let halfh = (g.height + 1) / 2; | ||
| 31012 | - let (cw, ch) = if g.u.len() == g.width * g.height { | ||
| 31013 | - (g.width, g.height) | ||
| 31014 | - } else if g.u.len() == halfw * g.height { | ||
| 31015 | - (halfw, g.height) | ||
| 31016 | - } else { | ||
| 31017 | - (halfw, halfh) | ||
| 31018 | - }; | ||
| 31019 | whole_plane(&g.u, cw, ch) | 31002 | whole_plane(&g.u, cw, ch) |
| 31020 | }, | 31003 | }, |
| 31021 | { | 31004 | { |
| 31022 | - let halfw = (g.width + 1) / 2; | 31005 | + let (cw, ch) = ref_chroma_shape(g.v.len(), g.width, g.height); |
| 31023 | - let halfh = (g.height + 1) / 2; | ||
| 31024 | - let (cw, ch) = if g.v.len() == g.width * g.height { | ||
| 31025 | - (g.width, g.height) | ||
| 31026 | - } else if g.v.len() == halfw * g.height { | ||
| 31027 | - (halfw, g.height) | ||
| 31028 | - } else { | ||
| 31029 | - (halfw, halfh) | ||
| 31030 | - }; | ||
| 31031 | whole_plane(&g.v, cw, ch) | 31006 | whole_plane(&g.v, cw, ch) |
| 31032 | }, | 31007 | }, |
| 31033 | ) | 31008 | ) |
| @@ -31094,6 +31069,69 @@ fn whole_plane(data: &[u16], width: usize, height: usize) -> PlaneBuf<'_> { | |||
| 31094 | } | 31069 | } |
| 31095 | } | 31070 | } |
| 31096 | 31071 | ||
| 31072 | +/// A reference picture's own chroma plane shape, `(width, height)`, from its | ||
| 31073 | +/// luma size and its chroma sample count. A stored reference carries no | ||
| 31074 | +/// subsampling field, so the format is read back off the count -- and the | ||
| 31075 | +/// counts are the producer's own [`round_ss`] crops | ||
| 31076 | +/// (`decode.rs:25806`), so the test must use `round_ss` too and not a bare | ||
| 31077 | +/// halving: 4:4:4 stores `w * h`, 4:2:2 stores `round_ss(w, 1) * h` (half | ||
| 31078 | +/// width CEIL, full height), 4:2:0 stores `round_ss(w, 1) * round_ss(h, 1)`. | ||
| 31079 | +/// A floor test here silently misses every odd-width 4:2:2 reference and | ||
| 31080 | +/// drops it into the 4:2:0 arm -- the same defect one dimension over. | ||
| 31081 | +/// | ||
| 31082 | +/// The two-way test this replaces ("luma-sized, else a quarter") folded 4:2:2 | ||
| 31083 | +/// into the 4:2:0 shape entirely, so a 4:2:2 reference plane claimed | ||
| 31084 | +/// `h / 2` rows -- half the samples it actually holds. Every chroma MC | ||
| 31085 | +/// reading such a plane then had its source row clamped against | ||
| 31086 | +/// `true_height` (spec 7.11.3.4 / libaom's | ||
| 31087 | +/// `dec_calc_subpel_params_and_extend` clamps to the reference's valid | ||
| 31088 | +/// area), which folded every chroma row at or past the frame's midpoint | ||
| 31089 | +/// back onto the last valid row: on the pinned t422 fixture frame 1, the | ||
| 31090 | +/// 8x4 inter strip at luma (88, 208) MC-predicted chroma (88, 104) from | ||
| 31091 | +/// frame 0 with mv 0 and a pure copy, yet wrote (206, 204, 202, 200) x4 | ||
| 31092 | +/// rows where the reference holds (202, 204, 204, 167) / | ||
| 31093 | +/// (185, 190, 190, 165) / ... | ||
| 31094 | +/// **Ambiguity, measured rather than argued away:** the inference reads a | ||
| 31095 | +/// format off a length, so it is only as good as the lengths being | ||
| 31096 | +/// distinct. Brute-forced against the producer's own `round_ss` crops over | ||
| 31097 | +/// every `w, h` in `1..=128`, the 4:4:4 and 4:2:2 counts are distinct from | ||
| 31098 | +/// each other and from the 4:2:0 count, and both route correctly for | ||
| 31099 | +/// **every `w >= 2 && h >= 2`**. No stream this decoder accepts reaches a | ||
| 31100 | +/// 1-pixel chroma plane; the pinned fixture's chroma is 128x144. | ||
| 31101 | +/// | ||
| 31102 | +/// **Open gap, 4:2:0 at odd dimensions (pre-existing).** The 4:2:0 arm is | ||
| 31103 | +/// left at the old `(width / 2, height / 2)` floor, which is what the | ||
| 31104 | +/// two-way test this replaces produced -- that was the point, since no | ||
| 31105 | +/// 4:2:0 stream changed shape. It is nevertheless the wrong shape for an | ||
| 31106 | +/// odd-dimension 4:2:0 reference: the producer stored | ||
| 31107 | +/// `round_ss(w, 1) x round_ss(h, 1)`, so the floor arm under-declares. | ||
| 31108 | +/// Measured over the `1..=128` square, running each 4:2:0 count through | ||
| 31109 | +/// this very function: 12160 of the 16384 pairs come back smaller than the | ||
| 31110 | +/// plane actually holds, 12033 of those with `w >= 2` and 127 in the | ||
| 31111 | +/// `w == 1` column (at `w == 1, h == 1` the 4:4:4 arm catches the count | ||
| 31112 | +/// and `(1, 1)` is exact). Under-declaration at `h == 1` is **zero** over | ||
| 31113 | +/// the whole square: there the 4:2:0 count equals the 4:2:2 count, routes | ||
| 31114 | +/// into the 4:2:2 arm, and lands on the correct | ||
| 31115 | +/// `(round_ss(w, 1), 1)`. The `w == 1` residue is a *shape* error, not a | ||
| 31116 | +/// misroute -- the floor fallback simply cannot express | ||
| 31117 | +/// `(1, round_ss(h, 1))`. It is left alone because it predates this lane, | ||
| 31118 | +/// is identical to the parent, and no in-tree coverage exercises an | ||
| 31119 | +/// odd-dimension 4:2:0 reference. A ceil fallback | ||
| 31120 | +/// (`(round_ss(w, 1), round_ss(h, 1))`) would close it, at the cost of | ||
| 31121 | +/// departing from the parent on every odd-dimension 4:2:0 shape with | ||
| 31122 | +/// nothing in the tree to justify the change; that call belongs to a lane | ||
| 31123 | +/// that can bring odd-dimension 4:2:0 fixtures with it. | ||
| 31124 | +fn ref_chroma_shape(len: usize, width: usize, height: usize) -> (usize, usize) { | ||
| 31125 | + let half_w = round_ss(width, 1); | ||
| 31126 | + if len == width * height { | ||
| 31127 | + (width, height) | ||
| 31128 | + } else if len == half_w * height { | ||
| 31129 | + (half_w, height) | ||
| 31130 | + } else { | ||
| 31131 | + (width / 2, height / 2) | ||
| 31132 | + } | ||
| 31133 | +} | ||
| 31134 | + | ||
| 31097 | /// Resolves a reference's own planes -- the `ref_frame -> picture` lookup | 31135 | /// Resolves a reference's own planes -- the `ref_frame -> picture` lookup |
| 31098 | /// [`decode_inter_block`]'s single-ref path does, factored out so the | 31136 | /// [`decode_inter_block`]'s single-ref path does, factored out so the |
| 31099 | /// compound path can call it twice (lane-av1comp), and the point where | 31137 | /// compound path can call it twice (lane-av1comp), and the point where |
| @@ -45726,6 +45764,53 @@ mod tests { | |||
| 45726 | RefPix::ready(refs) | 45764 | RefPix::ready(refs) |
| 45727 | } | 45765 | } |
| 45728 | 45766 | ||
| 45767 | + /// lane-av1422stripwrite: the reference chroma shape is read back off the | ||
| 45768 | + /// stored plane's own sample count, so the counts the PRODUCER writes | ||
| 45769 | + /// (`round_ss` crops, `decode.rs:25806`) must route back to the shape | ||
| 45770 | + /// they came from. A floor half-width here passes every even-width case | ||
| 45771 | + /// -- the pinned fixture's 256-wide frame included -- and silently drops | ||
| 45772 | + /// every odd-width 4:2:2 reference into the 4:2:0 arm, which is the | ||
| 45773 | + /// exact defect this lane fixed, one dimension over. So the table below | ||
| 45774 | + /// is driven off `round_ss`, not off hand-written numbers, and sweeps | ||
| 45775 | + /// odd and even widths. | ||
| 45776 | + #[test] | ||
| 45777 | + fn a_reference_chroma_sample_count_routes_back_to_its_own_format() { | ||
| 45778 | + for w in [2usize, 3, 4, 5, 8, 9, 16, 17, 64, 65, 128, 129] { | ||
| 45779 | + for h in [2usize, 3, 4, 5, 8, 9, 64, 65, 144, 145] { | ||
| 45780 | + let cases = [ | ||
| 45781 | + ("4:4:4", round_ss(w, 0) * round_ss(h, 0), (w, h)), | ||
| 45782 | + ("4:2:2", round_ss(w, 1) * round_ss(h, 0), (round_ss(w, 1), h)), | ||
| 45783 | + ( | ||
| 45784 | + "4:2:0", | ||
| 45785 | + round_ss(w, 1) * round_ss(h, 1), | ||
| 45786 | + (w / 2, h / 2), | ||
| 45787 | + ), | ||
| 45788 | + ]; | ||
| 45789 | + for (name, len, want) in cases { | ||
| 45790 | + assert_eq!( | ||
| 45791 | + ref_chroma_shape(len, w, h), | ||
| 45792 | + want, | ||
| 45793 | + "{name} reference of {w}x{h} (chroma {len} samples) \ | ||
| 45794 | + must route back to its own shape" | ||
| 45795 | + ); | ||
| 45796 | + } | ||
| 45797 | + } | ||
| 45798 | + } | ||
| 45799 | + } | ||
| 45800 | + | ||
| 45801 | + /// lane-av1422stripwrite: the whole point of the 4:2:2 arm is that it | ||
| 45802 | + /// claims the frame's FULL chroma height -- that is what stops every | ||
| 45803 | + /// chroma MC sourcing a row at or past the midpoint from being clamped | ||
| 45804 | + /// against `true_height`. Pinned on the t422 shape. | ||
| 45805 | + #[test] | ||
| 45806 | + fn a_422_reference_claims_the_full_chroma_height() { | ||
| 45807 | + // 256x144 luma at ss (1, 0): chroma is 128 wide and 144 rows tall. | ||
| 45808 | + let (cw, ch) = ref_chroma_shape(round_ss(256, 1) * 144, 256, 144); | ||
| 45809 | + assert_eq!((cw, ch), (128, 144)); | ||
| 45810 | + // The bug's own signature: 72 rows claimed for 144 rows held. | ||
| 45811 | + assert!(ch > 144 / 2, "a 4:2:2 reference must not claim half its rows"); | ||
| 45812 | + } | ||
| 45813 | + | ||
| 45729 | /// [`last_only`] plus `GOLDEN_FRAME` (index 4 of the name-keyed array) | 45814 | /// [`last_only`] plus `GOLDEN_FRAME` (index 4 of the name-keyed array) |
| 45730 | /// and `ALTREF_FRAME` (index 7, the frame two back, which the encoder | 45815 | /// and `ALTREF_FRAME` (index 7, the frame two back, which the encoder |
| 45731 | /// keeps in the slot the current frame refreshes): what a frame this | 45816 | /// keeps in the slot the current frame refreshes): what a frame this |
crates/ec-av1/src/encode.rsmodified+4 -1
| @@ -1548,7 +1548,10 @@ pub struct Picture { | |||
| 1548 | pub height: usize, | 1548 | pub height: usize, |
| 1549 | /// The luma plane, `width * height` samples in raster order. | 1549 | /// The luma plane, `width * height` samples in raster order. |
| 1550 | pub y: Vec<u16>, | 1550 | pub y: Vec<u16>, |
| 1551 | - /// The U plane, at half the width and half the height. | 1551 | + /// The U plane: half the width, and the frame's own chroma height -- a |
| 1552 | + /// quarter of the luma samples at 4:2:0, half at 4:2:2, all of them at | ||
| 1553 | + /// 4:4:4. A consumer that only knows the luma size reads the chroma | ||
| 1554 | + /// format off this sample count (see `decode::ref_chroma_shape`). | ||
| 1552 | pub u: Vec<u16>, | 1555 | pub u: Vec<u16>, |
| 1553 | /// The V plane, the same shape as U. | 1556 | /// The V plane, the same shape as U. |
| 1554 | pub v: Vec<u16>, | 1557 | pub v: Vec<u16>, |
lanes/av1422stripwrite.report.mdadded+240 -0
| @@ -0,0 +1,240 @@ | |||
| 1 | +# lane-av1-422stripwrite — the 4:2:2 residual was NOT the rect-strip | ||
| 2 | +# chroma write/anchor: a reference picture's chroma plane claimed | ||
| 3 | +# `h / 2` rows, so every chroma MC sourced at or past the frame's | ||
| 4 | +# midpoint was clamped; the pinned 16-frame t422 stream now decodes | ||
| 5 | +# byte-exact (first cut FAILed on review for a floor half-width where | ||
| 6 | +# the producer ceils — corrected, ladder re-run, still 48/48 + 16/16) | ||
| 7 | + | ||
| 8 | +## Outcome | ||
| 9 | + | ||
| 10 | +The parent lane's named site is **fixed, and it was not where the parent | ||
| 11 | +pointed**. Frame-1 prefilt chroma no longer first-diffs at U/V (88, 104): | ||
| 12 | +after the fix **all 16 frames of the pinned t422 stream are byte-exact on | ||
| 13 | +every plane at prefilt, post-deblock AND post-CDEF, and the final | ||
| 14 | +(post-loop-restoration) output is byte-identical to the oracle for all 16 | ||
| 15 | +frames** — 0 diffs, measured. The 4:2:2 header refusal stays. | ||
| 16 | + | ||
| 17 | +## Localization: the write and the anchor were both already right | ||
| 18 | + | ||
| 19 | +The parent read the site as "our written rows 88..91 are not the oracle's | ||
| 20 | +MC output" and suspected the strip write/anchor. Measured, in order: | ||
| 21 | + | ||
| 22 | +1. **The block is not what the parent said.** The oracle's own dispatch | ||
| 23 | + trace (`SUB48D`, added to `build_inter_predictors` in | ||
| 24 | + `reconinter_template.inc`) puts the site on **two `BLOCK_8X4` blocks at | ||
| 25 | + luma (88, 208) and (88, 216)** — `bsize=2`, `mi=(208,88)` / `mi=(216,88)`, | ||
| 26 | + one per mi column, i.e. the top strips of the 8x8 groups at mi (11,26) | ||
| 27 | + and (11,27), each coded its own chroma `TX_4x4` at chroma (88,104) and | ||
| 28 | + (88,108) (`is_chroma_reference` at ss (1,0): `mi_size_wide[BLOCK_8X4] == 2` | ||
| 29 | + in libaom's 4x4-mi units, so the column clause `!(bw & 1)` is true and | ||
| 30 | + BOTH are chroma references — `av1_common_int.h:1454`). The parent's | ||
| 31 | + "mi(22,52)" is this decoder's own 4x4-mi coordinate for the same block | ||
| 32 | + (`const MI: usize = 4`, `decode.rs:6052`), not libaom's 8x8 mi, and its | ||
| 33 | + "chroma cols 104..111, rows 88..95" spans TWO mi columns and two 8x8 | ||
| 34 | + groups. There is no strip-2 chroma MC because the strips below | ||
| 35 | + (luma rows 92..95) are INTRA, not because the pair merged. | ||
| 36 | +2. **The oracle's prediction is a pure reference copy** (`AOMIN48`/ | ||
| 37 | + `AOMOUT48`, both inert without the env var): `row=88 col=104 bw=4 bh=4 | ||
| 38 | + sx=0 sy=0 srcoff=17000 stride=192` → source = frame 0's final U at | ||
| 39 | + (88, 104) exactly, output `r0 = 202 204 204 167` = the source bytes. | ||
| 40 | + The oracle's final chroma there is the same value, so the strip is a | ||
| 41 | + zero-residual copy. | ||
| 42 | +3. **Our MC inputs were identical and correct.** A temporary rung in | ||
| 43 | + `decode_inter_sub8_rect2`'s 4:2:2 per-piece arm dumped the raw | ||
| 44 | + reference samples at the unit before the MC: | ||
| 45 | + `unit=(104,88) stride=128 tw=128 th=72 xq4=1664 yq4=1408 | ||
| 46 | + raw=[202, 204, 204, 167, 185, 190, 190, 165, 158, 164, 163, 148, | ||
| 47 | + 145, 150, 148, 138]` — byte-identical to the oracle's `src0`. So the | ||
| 48 | + reference *contents*, the position, the mv, the filters and the scale | ||
| 49 | + were all right, and the 4x4 write rect `(unit_x, unit_y, 4, 4)` was | ||
| 50 | + right. What was wrong was that the MC turned those correct inputs into | ||
| 51 | + `206 204 202 200` x4 rows. | ||
| 52 | +4. **The MC output was the tell.** `th=72` on a 144-tall frame. The | ||
| 53 | + reference plane the MC read declared **72 chroma rows** while holding | ||
| 54 | + 144. Rows at/past 72 are out of the plane's valid area, so | ||
| 55 | + `predict_with_filters` clamped them — the four output rows came from a | ||
| 56 | + clamped row, which is why they were identical to each other and why | ||
| 57 | + they matched nothing in the reference. | ||
| 58 | + | ||
| 59 | +## Root cause, class `ref-chroma-shape-420-folds-422` | ||
| 60 | + | ||
| 61 | +`RefPix::planes` (`decode.rs:30311`) builds each reference's chroma | ||
| 62 | +`PlaneBuf` from a **two-way** shape test: | ||
| 63 | + | ||
| 64 | +```rust | ||
| 65 | +let full = g.u.len() == g.width * g.height; | ||
| 66 | +let (cw, ch) = if full { (g.width, g.height) } else { (g.width / 2, g.height / 2) }; | ||
| 67 | +``` | ||
| 68 | + | ||
| 69 | +A stored reference carries no subsampling field, so the code inferred it | ||
| 70 | +from the sample count — but the inference only knew 4:4:4 (luma-sized) and | ||
| 71 | +4:2:0 (a quarter). A 4:2:2 reference is **half-width, full-height**: | ||
| 72 | +`round_ss(w, 1) * h`, which matches neither, so it fell into the 4:2:0 | ||
| 73 | +branch and claimed `h / 2` rows. The stored data was never wrong (the frame | ||
| 74 | +is stored through `round_ss(fw, ss_x) x round_ss(fh, ss_y)`, | ||
| 75 | +`decode.rs:25806`, which is 4:2:2-correct) — only the *declared* shape was, | ||
| 76 | +and `whole_plane` copies it into `width`/`height`/`true_*`, which is what | ||
| 77 | +every chroma MC and every edge clamp reads. | ||
| 78 | + | ||
| 79 | +Consequence: at 4:2:2, **every** inter chroma prediction whose source row | ||
| 80 | +was at or past the frame's vertical midpoint read clamped garbage, on every | ||
| 81 | +subsampling-independent path (square blocks, rect strips, sub-8 pieces, | ||
| 82 | +compound, OBMC). On the pinned fixture the same rung sweep found four | ||
| 83 | +`mv = 0` per-piece units wrong, all with `unit_y >= 72`: (104,88), | ||
| 84 | +(108,88) [the named site] and (80,120), (80,124) — the parent's residual | ||
| 85 | +count was one symptom, not the site. | ||
| 86 | + | ||
| 87 | +## Fix | ||
| 88 | + | ||
| 89 | +One helper, both call sites (`decode.rs`): | ||
| 90 | + | ||
| 91 | +```rust | ||
| 92 | +fn ref_chroma_shape(len: usize, width: usize, height: usize) -> (usize, usize) { | ||
| 93 | + let half_w = round_ss(width, 1); | ||
| 94 | + if len == width * height { (width, height) } // 4:4:4 | ||
| 95 | + else if len == half_w * height { (half_w, height) } // 4:2:2 | ||
| 96 | + else { (width / 2, height / 2) } // 4:2:0 | ||
| 97 | +} | ||
| 98 | +``` | ||
| 99 | + | ||
| 100 | +The half width comes from `round_ss`, **not** a bare `width / 2`, because | ||
| 101 | +that is what the producer used: a frame is stored through | ||
| 102 | +`round_ss(fw, ss_x) x round_ss(fh, ss_y)` (`decode.rs:25806`) and | ||
| 103 | +`round_ss(dim, 1) == (dim + 1) >> 1` is a **ceil**. A floor test here | ||
| 104 | +(this lane's first cut, corrected on review) silently misses every | ||
| 105 | +odd-width 4:2:2 reference and drops it into the 4:2:0 arm — the same | ||
| 106 | +defect one dimension over. The 4:2:0 arm is left at the old | ||
| 107 | +`(width / 2, height / 2)` on purpose, so 4:2:0 keeps the exact shape it | ||
| 108 | +always had. | ||
| 109 | + | ||
| 110 | +`Picture`'s `u`/`v` doc comment (`encode.rs`) was corrected to state the | ||
| 111 | +real contract (half width, the frame's own chroma height) — the inference | ||
| 112 | +above depends on it. | ||
| 113 | + | ||
| 114 | +**Untouched:** the current frame's chroma planes were already | ||
| 115 | +`(width >> ss_x) x (height >> ss_y)` (`decode.rs:27313`, `41692`); the | ||
| 116 | +`4:2:0` group-tail chroma SKIP arm (its owning lane); `stream.rs`'s 4:2:2 | ||
| 117 | +header refusal (byte-identical, unconditional — the local | ||
| 118 | +`EC_AV1_ALLOW_422_PROBE` bypass was applied for the probe runs and | ||
| 119 | +REVERTED). | ||
| 120 | + | ||
| 121 | +## Verification | ||
| 122 | + | ||
| 123 | +- **Before/after on the named fixture** (`/tmp/i422/t422_2f.obu`, sha256 | ||
| 124 | + `d166ebf3c1bde8c32152cd9d077a317b4c7205b6538f0a7481e09fb6333ffdf4`; | ||
| 125 | + decode_probe + `EC_AV1_{PREFILT,POSTDEBLOCK,POSTCDEF}_DUMP` vs the | ||
| 126 | + oracle's): frame 0 exact before and after; frame 1 before: Y 0, U 2231 | ||
| 127 | + (first (88,104) ours 206 / oracle 202), V 2197 (first (88,104) ours 212 / | ||
| 128 | + oracle 231) — byte-identical to the parent lane's reported counts, so | ||
| 129 | + the reproduction is sound; frame 1 after: **0 / 0 / 0**. | ||
| 130 | +- **16-frame ladder** (`/tmp/i422/t422_16f.obu`, sha256 | ||
| 131 | + `dda96300d2d36ba9dc958febb033e2334a2caee137bcb286c0276f259e57d5b6`): | ||
| 132 | + **0 diffs on every plane of every frame 0..15 at prefilt, post-deblock | ||
| 133 | + and post-CDEF** (48 stage-frame-plane groups), and the final | ||
| 134 | + post-loop-restoration dump is **byte-identical (73728 B) for all 16 | ||
| 135 | + frames**. Re-measured after the probe-bypass revert/re-apply round trip: | ||
| 136 | + 48 groups, 0 diffs, 16/16 final. The oracle ladder was regenerated with | ||
| 137 | + the current build and is byte-identical to the parent lane's on every | ||
| 138 | + frame where both exist. | ||
| 139 | +- **4:2:0/4:4:4 identity, measured three ways.** | ||
| 140 | + *By construction:* the inference's 4:4:4 arm is the old first test | ||
| 141 | + unchanged, and the 4:2:0 arm is the old fallback `(w / 2, h / 2)` | ||
| 142 | + verbatim — the only thing between them is the inserted 4:2:2 test, which | ||
| 143 | + can only fire on a count a 4:2:0 or 4:4:4 plane does not have. | ||
| 144 | + *Brute-forced:* against the producer's own `round_ss` crops | ||
| 145 | + (`decode.rs:25806`) over every `w, h` in `1..=128`, the 4:4:4 and 4:2:2 | ||
| 146 | + counts are distinct from each other and from the 4:2:0 count and both | ||
| 147 | + route correctly for **every `w >= 2 && h >= 2`**; nothing a decodable | ||
| 148 | + frame produces falls outside that (the pinned fixture's chroma is | ||
| 149 | + 128x144). | ||
| 150 | + *4:2:0 at odd dimensions — an open, pre-existing gap, not a clean bill.* | ||
| 151 | + The floor arm is what the parent produced, but it is the wrong shape for | ||
| 152 | + an odd-dimension 4:2:0 reference: the producer stored | ||
| 153 | + `round_ss(w, 1) x round_ss(h, 1)`, so the floor under-declares. Running | ||
| 154 | + every 4:2:0 count over the `1..=128` square through the shipping helper: | ||
| 155 | + **12160 of the 16384 pairs** come back smaller than the plane holds — | ||
| 156 | + **12033** of them with `w >= 2` and **127** in the `w == 1` column (at | ||
| 157 | + `1x1` the 4:4:4 arm catches the count and `(1, 1)` is exact). | ||
| 158 | + Under-declaration at `h == 1` is **zero**: there the 4:2:0 count equals | ||
| 159 | + the 4:2:2 count, routes into the 4:2:2 arm and lands on the correct | ||
| 160 | + `(round_ss(w, 1), 1)`, which is also the one place the new arm departs | ||
| 161 | + from the parent's floor — for the 127 pairs with `w >= 2`, and there | ||
| 162 | + only by *correcting* the parent, which claimed zero rows. The `w == 1, | ||
| 163 | + h >= 2` residue is a shape error, not a misroute: the floor fallback | ||
| 164 | + simply cannot express `(1, round_ss(h, 1))`. A ceil fallback would close | ||
| 165 | + the whole gap, at the cost of departing from the parent on every | ||
| 166 | + odd-dimension 4:2:0 shape with no in-tree coverage to justify it. | ||
| 167 | + Recorded, not taken. | ||
| 168 | + *Gated:* `cargo test -p ec-av1 --lib -- lossless decodes_sample_exact | ||
| 169 | + 444 reference_chroma` in its own target dir | ||
| 170 | + `~/.cache/cargo-target-av1422stripwrite-gate` — see below for what that | ||
| 171 | + run is and is not evidence of. | ||
| 172 | +- **Oracle instrumentation (measurement, not decode).** The oracle's | ||
| 173 | + `EC_AV1_POSTCDEF_DUMP` rung sat inside `if (!optimized_loop_restoration)`, | ||
| 174 | + so a frame with no CDEF and no superres produced **no** post-CDEF dump — | ||
| 175 | + frame 15 got none, which is why the parent lane's "f15 postcdef Y=5059" | ||
| 176 | + had no oracle counterpart to compare against (the file it names, | ||
| 177 | + `/tmp/i422/av1422mi24/postcdef.f15`, is 81920 B — this decoder's own | ||
| 178 | + padded dump, not an oracle dump). The rung is now a shared | ||
| 179 | + `ec_dump_postcdef()` called from both branches; the oracle confirms | ||
| 180 | + frame 15's post-CDEF equals its post-deblock (no CDEF on that frame), | ||
| 181 | + and our frame 15 post-CDEF is byte-identical to it. | ||
| 182 | +- **A gate run that was thrown away, and why.** An earlier identity-gate | ||
| 183 | + run on this branch was launched against the ceil form and then | ||
| 184 | + **invalidated by my own concurrent edits**: while it was in flight I added | ||
| 185 | + the two routing tests below and deliberately mutated `half_w` back to the | ||
| 186 | + floor form to prove the test non-vacuous. Its result was never delivered, | ||
| 187 | + and whatever it compiled was not the shipping source (`decode.rs` | ||
| 188 | + md5 `999348d786ca0a8e930010ee46184d87` is the tree the accepted run | ||
| 189 | + covers). It is recorded here as **no evidence** rather than quietly | ||
| 190 | + dropped, and the accepted run is a clean re-run in a dedicated target | ||
| 191 | + dir with nothing else of mine touching cargo. Not a target-dir lock: the | ||
| 192 | + other suites on the host each use their own | ||
| 193 | + `$HOME/.cache/av1-local-suite/target-*` dir. | ||
| 194 | +- `cargo check -p ec-av1 --all-targets` (target dir | ||
| 195 | + `~/.cache/cargo-target-av1422stripwrite`): **0 warnings, 0 errors**. | ||
| 196 | +- **Regression tests, and proof they are not vacuous.** Two unit tests in | ||
| 197 | + `decode.rs`'s test module, the only 4:2:2-reachable gate while the header | ||
| 198 | + refusal stands (no stream can reach the code path otherwise): | ||
| 199 | + `a_reference_chroma_sample_count_routes_back_to_its_own_format` drives | ||
| 200 | + all three formats off the producer's own `round_ss` crops over odd AND | ||
| 201 | + even widths (2,3,4,5,8,9,16,17,64,65,128,129) and heights | ||
| 202 | + (2,3,4,5,8,9,64,65,144,145), and | ||
| 203 | + `a_422_reference_claims_the_full_chroma_height` pins the t422 shape | ||
| 204 | + (256x144 -> chroma 128x144, explicitly not the 72 rows the bug claimed). | ||
| 205 | + **Mutation proof:** with `half_w` reverted to `width / 2` — the exact | ||
| 206 | + floor form this lane's first cut shipped and the review caught — the first | ||
| 207 | + test FAILS with `4:2:2 reference of 3x2 (chroma 4 samples) must route | ||
| 208 | + back to its own shape`, and passes again on the restored ceil form. So | ||
| 209 | + the test pins the defect, not the implementation. | ||
| 210 | +- `git status` names `decode.rs`, `encode.rs` (doc comment) and this | ||
| 211 | + report. Every temporary rung (`EC_SW422` in the 4:2:2 per-piece arm and | ||
| 212 | + in `build_c`; `SUB48`/`SUB48D`/`SUB48P` in the oracle's | ||
| 213 | + `reconinter_template.inc`) was removed before the commit. | ||
| 214 | + | ||
| 215 | +## State | ||
| 216 | + | ||
| 217 | +- Commit on `lane-av1-422stripwrite` (no push): the `ref_chroma_shape` | ||
| 218 | + helper + its two call sites in `crates/ec-av1/src/decode.rs`, its two | ||
| 219 | + routing regression tests, the `Picture` chroma-shape doc correction in | ||
| 220 | + `crates/ec-av1/src/encode.rs`, and this report. The first cut was FAILed | ||
| 221 | + on review for using a floor half-width where the producer ceils; the | ||
| 222 | + corrected helper, the ladder re-run (48/48 + 16/16 again) and the | ||
| 223 | + identity re-proof are all in this commit. | ||
| 224 | +- **Merge note.** The sibling lane's `RefPix` three-way inference | ||
| 225 | + (`39f45c31`, lane-av1-422bigblock) edits the same two call sites. Both | ||
| 226 | + now agree on the arithmetic — the half width is `round_ss(w, 1)`, i.e. | ||
| 227 | + ceil, because that is what `decode.rs:25806` stores — so the union is a | ||
| 228 | + union, not a floor-vs-ceil fight. If that lane threads an explicit | ||
| 229 | + subsampling instead of inferring one from the length, prefer it and drop | ||
| 230 | + this helper; the 48/48 result is a property of the *shape* being right, | ||
| 231 | + not of how it is derived, so it survives either way. Re-run the 16-frame | ||
| 232 | + ladder after resolving. | ||
| 233 | +- **No residual to hand on.** The 4:2:2 stream is pixel-exact end to end | ||
| 234 | + on this fixture, so the 16-frame ladder is no longer a frontier. What | ||
| 235 | + remains for 4:2:2 is coverage, not correctness: the 4:2:2 header | ||
| 236 | + refusal is still unconditional, and every claim here rests on one | ||
| 237 | + 256x144 fixture (`aomenc` 4:2:2, `--limit` cut) whose inter content is | ||
| 238 | + skip-heavy. A second 4:2:2 fixture with real residuals, compound and | ||
| 239 | + warped motion above the vertical midpoint is what would justify lifting | ||
| 240 | + the refusal — not more work on this stream. | ||