ec-av1: correct the ref_chroma_shape doc's 4:2:0 claims
Browse files at this commitce4a89886625ee388d7ef75780e44f0ac9d9c359Parent: 9b029872 changed files +43 -14
crates/ec-av1/src/decode.rsmodified+24 -8
| @@ -30419,14 +30419,30 @@ fn whole_plane(data: &[u16], width: usize, height: usize) -> PlaneBuf<'_> { | ||
| 30419 | 30419 | /// **Ambiguity, measured rather than argued away:** the inference reads a |
| 30420 | 30420 | /// format off a length, so it is only as good as the lengths being |
| 30421 | 30421 | /// distinct. Brute-forced against the producer's own `round_ss` crops over |
| 30422 | -/// every `w, h` in `1..=128`, the three counts are distinct and routed | |
| 30423 | -/// correctly for **every `w >= 2 && h >= 2`**, and every misread is | |
| 30424 | -/// confined to `w == 1` or `h == 1` (a 1-row chroma plane reads as 4:2:2, | |
| 30425 | -/// a 1-column one as 4:4:4 -- the counts genuinely coincide there, so no | |
| 30426 | -/// length test can separate them). No stream this decoder accepts reaches | |
| 30427 | -/// either; the pinned fixture's chroma is 128x144. The 4:2:0 arm is | |
| 30428 | -/// deliberately left at the old `(w / 2, h / 2)`: over the same sweep, | |
| 30429 | -/// **zero** 4:2:0 shapes differ from what the old two-way test produced. | |
| 30422 | +/// every `w, h` in `1..=128`, the 4:4:4 and 4:2:2 counts are distinct from | |
| 30423 | +/// each other and from the 4:2:0 count, and both route correctly for | |
| 30424 | +/// **every `w >= 2 && h >= 2`**. No stream this decoder accepts reaches a | |
| 30425 | +/// 1-pixel chroma plane; the pinned fixture's chroma is 128x144. | |
| 30426 | +/// | |
| 30427 | +/// **Open gap, 4:2:0 at odd dimensions (pre-existing).** The 4:2:0 arm is | |
| 30428 | +/// left at the old `(width / 2, height / 2)` floor, which is byte-identical | |
| 30429 | +/// to what the two-way test this replaces produced -- that was the point, | |
| 30430 | +/// since no 4:2:0 stream changed shape. It is nevertheless the wrong shape | |
| 30431 | +/// for an odd-dimension 4:2:0 reference: the producer stored | |
| 30432 | +/// `round_ss(w, 1) x round_ss(h, 1)`, so the floor arm under-declares. | |
| 30433 | +/// Measured over the `1..=128` square: the floor under-declares in | |
| 30434 | +/// 12160 of the 16256 pairs with `w >= 2` (12288 of all 16384, the extra | |
| 30435 | +/// 128 being the `w == 1` column, where the arm declares a 0-wide plane). | |
| 30436 | +/// It is a *shape* error, not a misroute: a 4:2:0 count at `w == 1` and | |
| 30437 | +/// `h >= 2` collides with neither the 4:4:4 nor the 4:2:2 count, so the | |
| 30438 | +/// length test does put it in the right arm -- the floor fallback simply | |
| 30439 | +/// cannot express `(1, round_ss(h, 1))`. It is left alone because it | |
| 30440 | +/// predates this lane, is identical to the parent, and no in-tree coverage | |
| 30441 | +/// exercises an odd-dimension 4:2:0 reference. A ceil fallback | |
| 30442 | +/// (`(round_ss(w, 1), round_ss(h, 1))`) would close it, at the cost of | |
| 30443 | +/// departing from the parent on every odd-dimension 4:2:0 shape with | |
| 30444 | +/// nothing in the tree to justify the change; that call belongs to a lane | |
| 30445 | +/// that can bring odd-dimension 4:2:0 fixtures with it. | |
| 30430 | 30446 | fn ref_chroma_shape(len: usize, width: usize, height: usize) -> (usize, usize) { |
| 30431 | 30447 | let half_w = round_ss(width, 1); |
| 30432 | 30448 | if len == width * height { |
lanes/av1422stripwrite.report.mdmodified+19 -6
| @@ -142,12 +142,25 @@ REVERTED). | ||
| 142 | 142 | verbatim — the only thing between them is the inserted 4:2:2 test, which |
| 143 | 143 | can only fire on a count a 4:2:0 or 4:4:4 plane does not have. |
| 144 | 144 | *Brute-forced:* against the producer's own `round_ss` crops |
| 145 | - (`decode.rs:25806`) over every `w, h` in `1..=128`, all three formats | |
| 146 | - route correctly for **every `w >= 2 && h >= 2`**, every misread is | |
| 147 | - confined to `w == 1` or `h == 1` (where the counts genuinely coincide, | |
| 148 | - so no length test can separate them — not reachable by a decodable | |
| 149 | - frame), and **zero** 4:2:0 shapes differ from what the old two-way test | |
| 150 | - produced. | |
| 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 byte-identical to the parent, but it is the wrong shape | |
| 152 | + for 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. Over the | |
| 154 | + `1..=128` square that is 12160 of the 16256 pairs with `w >= 2` (12288 of | |
| 155 | + all 16384; the extra 128 are the `w == 1` column, where the arm declares | |
| 156 | + a 0-wide plane), and it differs from the parent's floor at `h == 1` for | |
| 157 | + the 127 pairs with `w >= 2` — there only by *correcting* the parent, | |
| 158 | + which claimed zero rows. At `w == 1` and `h >= 2` the 4:2:0 count | |
| 159 | + collides with neither other count, so the length test puts it in the | |
| 160 | + right arm; the floor fallback simply cannot express | |
| 161 | + `(1, round_ss(h, 1))`. A ceil fallback would close the whole gap, at | |
| 162 | + the cost of departing from the parent on every odd-dimension 4:2:0 | |
| 163 | + shape with no in-tree coverage to justify it. Recorded, not taken. | |
| 151 | 164 | *Gated:* `cargo test -p ec-av1 --lib -- lossless decodes_sample_exact |
| 152 | 165 | 444 reference_chroma` in its own target dir |
| 153 | 166 | `~/.cache/cargo-target-av1422stripwrite-gate` — see below for what that |