Merge lane-av1cmpframe: count_rawvideo_diffs attributes planes PER FRAME (instrument fix)
Browse files at this commit3 changed files +398 -12
- crates/ec-av1/fixtures/420_oddheight_320x236_diverging.obu +0 -0
- crates/ec-av1/src/stream.rs +212 -12
- lanes/av1cmpframe.report.md +186 -0
crates/ec-av1/fixtures/420_oddheight_320x236_diverging.obuadded+0 -0
Binary file changed
crates/ec-av1/src/stream.rsmodified+212 -12
| @@ -10413,31 +10413,59 @@ pub(crate) mod tests { | |||
| 10413 | return None; | 10413 | return None; |
| 10414 | } | 10414 | } |
| 10415 | let bpp = if bit_depth == 8 { 1 } else { 2 }; | 10415 | let bpp = if bit_depth == 8 { 1 } else { 2 }; |
| 10416 | - // The plane split comes from the FIRST decoded picture, not from a | 10416 | + // lane-av1cmpframe: the plane split is PER FRAME and comes from each |
| 10417 | - // formula: a 4:2:0 picture's chroma is a quarter of the luma, a | 10417 | + // decoded frame's OWN plane lengths -- never from a formula, and |
| 10418 | - // 4:2:2/4:4:4 chroma is not, and a wrong split silently attributes | 10418 | + // never from the first picture. |
| 10419 | - // every wrong sample to the wrong plane. | 10419 | + // |
| 10420 | - let f0 = decoded.first().expect("a decoded picture"); | 10420 | + // The first-picture form was wrong on every multi-frame stream: it |
| 10421 | - let (w, h) = (f0.width, f0.height); | 10421 | + // compared a byte index against frame 0's thresholds forever, so |
| 10422 | - let (ys, us) = (w * h * bpp, f0.u.len() * bpp); | 10422 | + // every sample after frame 0's luma was attributed to the LAST |
| 10423 | + // plane. On `420_oddheight_320x236_diverging` (16 frames of 320x236 | ||
| 10424 | + // 4:2:0, whose frame is 113 280 bytes and whose V plane therefore | ||
| 10425 | + // holds 302 080 bytes in total) it reported `wrong_v = 330 673` -- | ||
| 10426 | + // more wrong V bytes than exist. The per-frame byte totals and the | ||
| 10427 | + // frame-exact count were sound; only the per-plane attribution was | ||
| 10428 | + // not, and a wrong attribution is the one thing a per-plane report | ||
| 10429 | + // is read for. | ||
| 10430 | + // | ||
| 10431 | + // `pack_rawvideo` already lays the bytes out per frame from the same | ||
| 10432 | + // plane lengths, so this table is exactly the layout it produced. | ||
| 10433 | + let mut spans: Vec<[usize; 4]> = Vec::with_capacity(decoded.len()); | ||
| 10434 | + let mut off = 0usize; | ||
| 10435 | + for f in &decoded { | ||
| 10436 | + let (y, u, v) = (f.y.len() * bpp, f.u.len() * bpp, f.v.len() * bpp); | ||
| 10437 | + spans.push([off, off + y, off + y + u, off + y + u + v]); | ||
| 10438 | + off += y + u + v; | ||
| 10439 | + } | ||
| 10440 | + assert_eq!( | ||
| 10441 | + off, | ||
| 10442 | + ours.len(), | ||
| 10443 | + "{name}: the per-frame plane table covers {off} bytes but the packed output is {}", | ||
| 10444 | + ours.len() | ||
| 10445 | + ); | ||
| 10423 | let mut wrong = [0usize; 3]; | 10446 | let mut wrong = [0usize; 3]; |
| 10447 | + let mut frame = 0usize; | ||
| 10424 | for (i, (&a, &b)) in ours.iter().zip(&want).enumerate() { | 10448 | for (i, (&a, &b)) in ours.iter().zip(&want).enumerate() { |
| 10449 | + while frame + 1 < spans.len() && i >= spans[frame][3] { | ||
| 10450 | + frame += 1; | ||
| 10451 | + } | ||
| 10425 | if a == b { | 10452 | if a == b { |
| 10426 | continue; | 10453 | continue; |
| 10427 | } | 10454 | } |
| 10428 | - let pi = if i < ys { | 10455 | + let s = spans[frame]; |
| 10456 | + let pi = if i < s[1] { | ||
| 10429 | 0 | 10457 | 0 |
| 10430 | - } else if i < ys + us { | 10458 | + } else if i < s[2] { |
| 10431 | 1 | 10459 | 1 |
| 10432 | } else { | 10460 | } else { |
| 10433 | 2 | 10461 | 2 |
| 10434 | }; | 10462 | }; |
| 10435 | wrong[pi] += 1; | 10463 | wrong[pi] += 1; |
| 10436 | } | 10464 | } |
| 10437 | - let per = ys + 2 * us; | ||
| 10438 | let frames = decoded.len(); | 10465 | let frames = decoded.len(); |
| 10439 | - let exact = (0..frames) | 10466 | + let exact = spans |
| 10440 | - .filter(|k| ours[k * per..(k + 1) * per] == want[k * per..(k + 1) * per]) | 10467 | + .iter() |
| 10468 | + .filter(|s| ours[s[0]..s[3]] == want[s[0]..s[3]]) | ||
| 10441 | .count(); | 10469 | .count(); |
| 10442 | Some((wrong[0], wrong[1], wrong[2], frames, exact)) | 10470 | Some((wrong[0], wrong[1], wrong[2], frames, exact)) |
| 10443 | } | 10471 | } |
| @@ -10499,6 +10527,177 @@ pub(crate) mod tests { | |||
| 10499 | eprintln!("{NAME}: baseline exact, each flipped oracle byte reported as exactly 1"); | 10527 | eprintln!("{NAME}: baseline exact, each flipped oracle byte reported as exactly 1"); |
| 10500 | } | 10528 | } |
| 10501 | 10529 | ||
| 10530 | + /// lane-av1cmpframe: the control for the class | ||
| 10531 | + /// `comparator-that-attributes-the-wrong-plane`. | ||
| 10532 | + /// | ||
| 10533 | + /// [`count_rawvideo_diffs`] used to derive its plane split from the FIRST | ||
| 10534 | + /// decoded picture and compare every byte index against those frame-0 | ||
| 10535 | + /// thresholds. On a multi-frame stream that attributes every sample after | ||
| 10536 | + /// frame 0's luma to the LAST plane: on the pinned 320x236 stream below | ||
| 10537 | + /// (16 frames of 320x236 4:2:0, 113 280 bytes per frame, so plane V holds | ||
| 10538 | + /// 302 080 bytes in total) it reported `wrong_v = 330 673` -- more wrong V | ||
| 10539 | + /// bytes than exist. The per-frame totals and the frame-exact count were | ||
| 10540 | + /// sound, so the defect was invisible to every gate that only asserted | ||
| 10541 | + /// zeros; it corrupted exactly the numbers a per-plane report exists to | ||
| 10542 | + /// give. | ||
| 10543 | + /// | ||
| 10544 | + /// Three arms, each of which the old attribution FAILS: | ||
| 10545 | + /// | ||
| 10546 | + /// 1. **Arithmetic.** Each plane's count must be at most that plane's own | ||
| 10547 | + /// byte capacity summed over frames, and the three must sum to the | ||
| 10548 | + /// independently computed total. The old code reported 330 673 wrong V | ||
| 10549 | + /// bytes in a 302 080-byte plane. | ||
| 10550 | + /// 2. **A later frame's U.** Flipping one byte inside frame 5's U plane | ||
| 10551 | + /// must move U by exactly one and leave Y and V at their baseline. | ||
| 10552 | + /// The old code has no frame-5 U at all -- byte 600 000 is past every | ||
| 10553 | + /// frame-0 threshold, so it landed in V. | ||
| 10554 | + /// 3. **Frame attribution.** `frames_exact` must equal the number of | ||
| 10555 | + /// frames this test counts itself, per frame, from the decoded | ||
| 10556 | + /// pictures' own plane lengths. | ||
| 10557 | + /// | ||
| 10558 | + /// The pin is asserted only for IDENTITY (bytes + fnv1a64) and for | ||
| 10559 | + /// comparability. Whether the stream currently diverges is deliberately | ||
| 10560 | + /// NOT asserted: this is a control for the INSTRUMENT, and it must keep | ||
| 10561 | + /// biting after the odd-height entropy fork is fixed. | ||
| 10562 | + #[test] | ||
| 10563 | + fn the_counting_oracle_diff_attributes_planes_per_frame() { | ||
| 10564 | + const NAME: &str = "the_counting_oracle_diff_attributes_planes_per_frame"; | ||
| 10565 | + let _gate_lock = lock_gate_counters(); | ||
| 10566 | + const FILE: &str = "420_oddheight_320x236_diverging.obu"; | ||
| 10567 | + const BYTES: usize = 16562; | ||
| 10568 | + // sha256 84e4d1ab56620af1c5b78e1aa3d2d67496a492f2e127198c82dd1d68b01c6200. | ||
| 10569 | + // The tree pins fixture identity by fnv1a64; a `const SHA256` | ||
| 10570 | + // compared against itself would be the tautology this lane exists to | ||
| 10571 | + // kill, so it is not written. | ||
| 10572 | + const FNV1A64: u64 = 521889434652397870; | ||
| 10573 | + let data = crate_pin(FILE); | ||
| 10574 | + let data = std::fs::read(&data) | ||
| 10575 | + .unwrap_or_else(|e| panic!("{NAME}: the committed pin {FILE} is missing ({e})")); | ||
| 10576 | + assert_eq!(data.len(), BYTES, "{NAME}: {FILE} size drifted"); | ||
| 10577 | + assert_eq!(fnv1a64(&data), FNV1A64, "{NAME}: {FILE} bytes drifted"); | ||
| 10578 | + let bit_depth = stream_bit_depth(&data, NAME); | ||
| 10579 | + let bpp = if bit_depth == 8 { 1 } else { 2 }; | ||
| 10580 | + | ||
| 10581 | + // ---- this test's own reading of the oracle, from scratch --------- | ||
| 10582 | + let dir = std::env::temp_dir().join(format!("ec-av1-{NAME}-{}", std::process::id())); | ||
| 10583 | + let _ = std::fs::remove_dir_all(&dir); | ||
| 10584 | + std::fs::create_dir_all(&dir).expect("scratch dir"); | ||
| 10585 | + let obu = dir.join("in.obu"); | ||
| 10586 | + std::fs::write(&obu, &data).expect("writing the stream"); | ||
| 10587 | + let raw = dir.join("aomdec.raw"); | ||
| 10588 | + let out = Command::new(aomdec_path()) | ||
| 10589 | + .args(["--codec=av1", "--rawvideo", "-o"]) | ||
| 10590 | + .arg(&raw) | ||
| 10591 | + .arg(&obu) | ||
| 10592 | + .stdin(Stdio::null()) | ||
| 10593 | + .stdout(Stdio::piped()) | ||
| 10594 | + .stderr(Stdio::piped()) | ||
| 10595 | + .output() | ||
| 10596 | + .expect("aomdec failed to run"); | ||
| 10597 | + assert!( | ||
| 10598 | + out.status.success(), | ||
| 10599 | + "{NAME}: the oracle aomdec refused the stream: {}", | ||
| 10600 | + String::from_utf8_lossy(&out.stderr) | ||
| 10601 | + ); | ||
| 10602 | + let want = std::fs::read(&raw).expect("aomdec rawvideo output"); | ||
| 10603 | + let _ = std::fs::remove_dir_all(&dir); | ||
| 10604 | + let decoded = decode_stream(&data).expect("the pinned stream decodes"); | ||
| 10605 | + let ours = pack_rawvideo(&decoded, bit_depth, NAME); | ||
| 10606 | + assert_eq!(ours.len(), want.len(), "{NAME}: the two sides differ in size"); | ||
| 10607 | + | ||
| 10608 | + // The per-frame plane table, built from each decoded picture's OWN | ||
| 10609 | + // plane lengths -- the same source `pack_rawvideo` lays the bytes out | ||
| 10610 | + // from, and never a formula. | ||
| 10611 | + let mut spans: Vec<[usize; 4]> = Vec::with_capacity(decoded.len()); | ||
| 10612 | + let mut capacity = [0usize; 3]; | ||
| 10613 | + let mut off = 0usize; | ||
| 10614 | + for f in &decoded { | ||
| 10615 | + let (y, u, v) = (f.y.len() * bpp, f.u.len() * bpp, f.v.len() * bpp); | ||
| 10616 | + spans.push([off, off + y, off + y + u, off + y + u + v]); | ||
| 10617 | + capacity[0] += y; | ||
| 10618 | + capacity[1] += u; | ||
| 10619 | + capacity[2] += v; | ||
| 10620 | + off += y + u + v; | ||
| 10621 | + } | ||
| 10622 | + assert_eq!(off, ours.len(), "{NAME}: the plane table covers the buffer"); | ||
| 10623 | + | ||
| 10624 | + // The truth, counted here with no help from the helper under test. | ||
| 10625 | + let mut truth = [0usize; 3]; | ||
| 10626 | + let mut truth_exact = 0usize; | ||
| 10627 | + for s in &spans { | ||
| 10628 | + let mut frame_exact = true; | ||
| 10629 | + for (p, a, b) in [(0usize, s[0], s[1]), (1, s[1], s[2]), (2, s[2], s[3])] { | ||
| 10630 | + let n = ours[a..b] | ||
| 10631 | + .iter() | ||
| 10632 | + .zip(&want[a..b]) | ||
| 10633 | + .filter(|(x, y)| x != y) | ||
| 10634 | + .count(); | ||
| 10635 | + truth[p] += n; | ||
| 10636 | + frame_exact &= n == 0; | ||
| 10637 | + } | ||
| 10638 | + truth_exact += usize::from(frame_exact); | ||
| 10639 | + } | ||
| 10640 | + | ||
| 10641 | + let (wy, wu, wv, frames, exact) = | ||
| 10642 | + count_rawvideo_diffs(&data, NAME, None).expect("the two sides must be byte-comparable"); | ||
| 10643 | + eprintln!( | ||
| 10644 | + "{NAME}: pinned {FILE} as wrongY={wy} wrongU={wu} wrongV={wv} over {frames} frames, \ | ||
| 10645 | + {exact} exact; this test's own count {truth:?} with {truth_exact} exact frames; \ | ||
| 10646 | + plane capacities {capacity:?}" | ||
| 10647 | + ); | ||
| 10648 | + assert_eq!(frames, decoded.len(), "{NAME}: frame count"); | ||
| 10649 | + assert_eq!( | ||
| 10650 | + [wy, wu, wv], | ||
| 10651 | + truth, | ||
| 10652 | + "{NAME}: the helper's per-plane split must equal an independent per-frame count" | ||
| 10653 | + ); | ||
| 10654 | + assert_eq!(exact, truth_exact, "{NAME}: frames_exact"); | ||
| 10655 | + for p in 0..3 { | ||
| 10656 | + assert!( | ||
| 10657 | + truth[p] <= capacity[p], | ||
| 10658 | + "{NAME}: plane {p} counts {} wrong bytes but holds only {}", | ||
| 10659 | + truth[p], | ||
| 10660 | + capacity[p] | ||
| 10661 | + ); | ||
| 10662 | + } | ||
| 10663 | + | ||
| 10664 | + // ---- arm 2: a byte inside a LATER frame's U plane. -------------- | ||
| 10665 | + // Frame 5's U plane's first byte. The old first-picture attribution | ||
| 10666 | + // has no frame-5 U at all: that byte is past every frame-0 threshold, | ||
| 10667 | + // so it landed in V. | ||
| 10668 | + let u5 = spans[5][1]; | ||
| 10669 | + let (fy, fu, fv, fframes, fexact) = count_rawvideo_diffs(&data, NAME, Some(u5)) | ||
| 10670 | + .expect("the two sides must be byte-comparable"); | ||
| 10671 | + let flipped = [fy, fu, fv]; | ||
| 10672 | + assert_eq!(fframes, frames, "{NAME}: frame count under the flip"); | ||
| 10673 | + assert_eq!( | ||
| 10674 | + flipped.iter().sum::<usize>(), | ||
| 10675 | + truth.iter().sum::<usize>() + 1, | ||
| 10676 | + "{NAME}: flipping one byte inside frame 5's U plane must add exactly one wrong \ | ||
| 10677 | + byte -- got {flipped:?} against this test's own count {truth:?}" | ||
| 10678 | + ); | ||
| 10679 | + assert_eq!( | ||
| 10680 | + flipped[1], | ||
| 10681 | + truth[1] + 1, | ||
| 10682 | + "{NAME}: byte {u5} is inside frame 5's U plane" | ||
| 10683 | + ); | ||
| 10684 | + assert_eq!(flipped[0], truth[0], "{NAME}: byte {u5} is not in luma"); | ||
| 10685 | + assert_eq!( | ||
| 10686 | + flipped[2], truth[2], | ||
| 10687 | + "{NAME}: byte {u5} must NOT be attributed to V -- the first-picture attribution \ | ||
| 10688 | + puts every byte past frame 0's luma in V" | ||
| 10689 | + ); | ||
| 10690 | + let want_exact = if truth_exact < frames { | ||
| 10691 | + truth_exact | ||
| 10692 | + } else { | ||
| 10693 | + frames - 1 | ||
| 10694 | + }; | ||
| 10695 | + assert_eq!( | ||
| 10696 | + fexact, want_exact, | ||
| 10697 | + "{NAME}: one flipped byte inside frame 5 leaves frames_exact at {want_exact}" | ||
| 10698 | + ); | ||
| 10699 | + } | ||
| 10700 | + | ||
| 10502 | /// lane-av1cmpaudit2: the permanent CONTROL for the class | 10701 | /// lane-av1cmpaudit2: the permanent CONTROL for the class |
| 10503 | /// `comparator-that-never-reads-the-oracle`. | 10702 | /// `comparator-that-never-reads-the-oracle`. |
| 10504 | /// | 10703 | /// |
| @@ -51611,4 +51810,5 @@ exit 0 | |||
| 51611 | } | 51810 | } |
| 51612 | let _ = std::fs::remove_dir_all(&dir); | 51811 | let _ = std::fs::remove_dir_all(&dir); |
| 51613 | } | 51812 | } |
| 51813 | + | ||
| 51614 | } | 51814 | } |
lanes/av1cmpframe.report.mdadded+186 -0
| @@ -0,0 +1,186 @@ | |||
| 1 | +# lane-av1cmpframe — `count_rawvideo_diffs` attributed planes by the FIRST picture | ||
| 2 | + | ||
| 3 | +Base `6c3d079c` (merge of `lane-av1gapremeasure`), branch `lane-av1cmpframe`. | ||
| 4 | +**This is an INSTRUMENT fix.** No decoder behaviour is touched: the diff is one | ||
| 5 | +test-module helper plus one new gate and one committed fixture. | ||
| 6 | + | ||
| 7 | +## 1. The defect | ||
| 8 | + | ||
| 9 | +`count_rawvideo_diffs` (`crates/ec-av1/src/stream.rs:10374`) packed our decoded | ||
| 10 | +pictures frame by frame — `pack_rawvideo` walks `decoded` and lays out each | ||
| 11 | +frame's own `y`/`u`/`v` lengths — and then attributed every differing byte with | ||
| 12 | +**frame 0's thresholds, forever**: | ||
| 13 | + | ||
| 14 | +```rust | ||
| 15 | +let f0 = decoded.first().expect("a decoded picture"); | ||
| 16 | +let (ys, us) = (w * h * bpp, f0.u.len() * bpp); | ||
| 17 | +let pi = if i < ys { 0 } else if i < ys + us { 1 } else { 2 }; | ||
| 18 | +``` | ||
| 19 | + | ||
| 20 | +On a multi-frame stream that is wrong for every byte after frame 0's luma: all of | ||
| 21 | +it lands in plane V. The totals and `frames_exact` stayed sound (they were | ||
| 22 | +computed from `per` = one frame's size applied uniformly, which is right for the | ||
| 23 | +uniform-size streams in the corpus), so **every gate that only asserted zeros | ||
| 24 | +could not see it** — and the per-plane split is the only reason a per-plane | ||
| 25 | +report exists. | ||
| 26 | + | ||
| 27 | +The symptom that exposed it: on the pinned 320x236 stream it reported | ||
| 28 | +`wrongV = 330 673` when plane V holds **302 080** bytes across the 16 frames. A | ||
| 29 | +count larger than its own plane is not a plausible measurement. | ||
| 30 | + | ||
| 31 | +## 2. The fix | ||
| 32 | + | ||
| 33 | +The plane table is now built **per frame from each decoded picture's own plane | ||
| 34 | +lengths** — the same source `pack_rawvideo` lays the bytes out from, and not a | ||
| 35 | +formula, not `width * height`, not the first picture: | ||
| 36 | + | ||
| 37 | +```rust | ||
| 38 | +let mut spans: Vec<[usize; 4]> = Vec::with_capacity(decoded.len()); | ||
| 39 | +let mut off = 0usize; | ||
| 40 | +for f in &decoded { | ||
| 41 | + let (y, u, v) = (f.y.len() * bpp, f.u.len() * bpp, f.v.len() * bpp); | ||
| 42 | + spans.push([off, off + y, off + y + u, off + y + u + v]); | ||
| 43 | + off += y + u + v; | ||
| 44 | +} | ||
| 45 | +assert_eq!(off, ours.len(), ...); | ||
| 46 | +``` | ||
| 47 | + | ||
| 48 | +then a monotone cursor walks `spans` as the byte index advances, and | ||
| 49 | +`frames_exact` compares each frame's own span instead of a fixed stride. A | ||
| 50 | +stream whose frames differ in size is now attributed correctly as well — the old | ||
| 51 | +code could not express that case at all. The signature is unchanged, so no caller | ||
| 52 | +changed. | ||
| 53 | + | ||
| 54 | +## 3. The control, and the mutation that proves it bites | ||
| 55 | + | ||
| 56 | +New gate `the_counting_oracle_diff_attributes_planes_per_frame` on a new | ||
| 57 | +committed pin `420_oddheight_320x236_diverging.obu` (16562 B, sha256 | ||
| 58 | +`84e4d1ab56620af1c5b78e1aa3d2d67496a492f2e127198c82dd1d68b01c6200`, fnv1a64 | ||
| 59 | +`521889434652397870`; the recipe and the one-flag bisect that reaches it are in | ||
| 60 | +`lanes/av1gapremeasure.report.md` §5). | ||
| 61 | + | ||
| 62 | +It counts the truth **itself** — running `aomdec --rawvideo` again, packing our | ||
| 63 | +pictures, and walking its own per-frame plane table — and then asserts the | ||
| 64 | +helper agrees with it, on three axes: | ||
| 65 | + | ||
| 66 | +1. **per-plane split** equals the independent per-frame count, and | ||
| 67 | +2. `frames_exact` equals the independently counted exact frames, and | ||
| 68 | +3. **a byte inside frame 5's U plane** (`spans[5][1]`, i.e. a byte ~5 frames in) | ||
| 69 | + moves **U** by exactly one and leaves Y and V at their baseline values. This | ||
| 70 | + is the arm the old code cannot pass: that byte is past every frame-0 | ||
| 71 | + threshold, so the old attribution put it in V. | ||
| 72 | + | ||
| 73 | +Measured on the fixed tree: | ||
| 74 | + | ||
| 75 | +``` | ||
| 76 | +pinned 420_oddheight_320x236_diverging.obu as wrongY=234349 wrongU=56957 | ||
| 77 | +wrongV=52981 over 16 frames, 0 exact; this test's own count | ||
| 78 | +[234349, 56957, 52981] with 0 exact frames; plane capacities | ||
| 79 | +[1208320, 302080, 302080] | ||
| 80 | +``` | ||
| 81 | + | ||
| 82 | +**Mutation (the fix reverted to the first-picture form, one hunk):** | ||
| 83 | + | ||
| 84 | +``` | ||
| 85 | +left: [11198, 2416, 330673] | ||
| 86 | +right: [234349, 56957, 52981] | ||
| 87 | +``` | ||
| 88 | + | ||
| 89 | +with the named message `the helper's per-plane split must equal an independent | ||
| 90 | +per-frame count`. The old numbers are reproduced digit for digit, including the | ||
| 91 | +impossible `V > capacity`. | ||
| 92 | + | ||
| 93 | +The gate deliberately does **not** assert that the stream diverges: it is a | ||
| 94 | +control for the instrument and must keep biting after the odd-height entropy fork | ||
| 95 | +is fixed. The flip arm's expected `frames_exact` is written to accept either | ||
| 96 | +case (`truth_exact` when the frame is already wrong, `frames - 1` when it was | ||
| 97 | +exact). | ||
| 98 | + | ||
| 99 | +## 4. Caller sweep — who else attributes planes, and are they frame-aware | ||
| 100 | + | ||
| 101 | +| site | how it splits planes | verdict | | ||
| 102 | +|---|---|---| | ||
| 103 | +| `count_rawvideo_diffs` (`stream.rs:10374`) | was frame 0's `width*height` / `u.len()`, applied to every byte | **FIXED here** | | ||
| 104 | +| `oracle_plane_diffs` (`stream.rs:49951`) | reads ONE `EC_AV1_FINAL_DUMP` file per decode-order frame and splits that frame with the caller's `plane_samples` | already frame-aware | | ||
| 105 | +| the 10-bit film arm of `every_ffmpeg_comparator_reds_on_a_one_sample_wrong_ffmpeg` (`count10`, `stream.rs:11008`) | `for (a, b) in our_10bit.iter().zip(theirs)` then per-plane over each pair's own `y`/`u`/`v` | already frame-aware | | ||
| 106 | +| the 8-bit arm of the same control (`count8`, `stream.rs:10975`) | `our_8bit[0]` / `theirs[0]` — **frame 0 only** | not a mis-attribution: the arm's subject is one 320x240 frame and it is documented as such | | ||
| 107 | +| `assert_rawvideo_matches` / `decode_all_frames_vs_oracle` | byte-equality per decode-order frame, no plane attribution at all | not applicable | | ||
| 108 | +| the `320x240` offset arithmetic in the ffmpeg shim control (`stream.rs:10805`) | asserts its own geometry (`ys == 76800`, `cs == 19200`) for a single even-sized frame | correct by assertion | | ||
| 109 | + | ||
| 110 | +So `count_rawvideo_diffs` was the only site with the defect. | ||
| 111 | + | ||
| 112 | +## 5. Re-measured numbers for the two open cells (now attributed) | ||
| 113 | + | ||
| 114 | +With the fixed comparator, live `aomdec --rawvideo`, and a `flip` byte-0 control | ||
| 115 | +on each cell: | ||
| 116 | + | ||
| 117 | +| cell | bytes | wrong Y | wrong U | wrong V | frames exact | flip-0 control | | ||
| 118 | +|---|---|---|---|---|---|---| | ||
| 119 | +| `320x236` (the committed pin, sha256 `84e4d1ab…`) | 16562 | **234349** | **56957** | **52981** | 0/16 | Y 234349 → 234350 | | ||
| 120 | +| `322x248` (sha256 `9e8c9c6c…`) | 16131 | **36286** | **13359** | **13001** | 0/16 | Y 36286 → 36287 | | ||
| 121 | +| `320x232` (the committed pin, sha256 `6832c3cd…`) | 15773 | 0 | 0 | 0 | 16/16 | Y 0 → 1, exact 16 → 15 | | ||
| 122 | +| `320x248` (sha256 `e4a4f71d…`) | 16440 | 0 | 0 | 0 | 16/16 | Y 0 → 1 | | ||
| 123 | +| `324x236` (sha256 `11687cc7…`) | 16683 | 0 | 0 | 0 | 16/16 | Y 0 → 1 | | ||
| 124 | + | ||
| 125 | +**These are the debt's own numbers, reproduced by the crate's own instrument.** | ||
| 126 | +The debt line reads "`320x236` (Y 234349, U 56957, V 52981) and `322x248` (Y | ||
| 127 | +36286, U 13359, V 13001)" — the fixed helper now emits exactly those figures. | ||
| 128 | +The earlier lane that recorded them used a different, frame-aware comparator; | ||
| 129 | +the helper was the broken one, and the debt was right. | ||
| 130 | + | ||
| 131 | +## 6. Earlier reports whose headline number was a mis-attributed split | ||
| 132 | + | ||
| 133 | +- **`lanes/av1422anom.report.md:90` and `:176`** — the `Y_420_320x232` row, | ||
| 134 | + "`0 | 200 | 17658`", and its total "17858". Produced by this helper on a | ||
| 135 | + 16-frame stream, so the U and V columns are not that cell's U and V: only | ||
| 136 | + frame 0's chroma could reach U, and frames 1–15's chroma was all counted as V. | ||
| 137 | + **What it should now read:** the totals (17858 differing bytes, 0/16 frames | ||
| 138 | + exact) stand; the per-plane split does not, and no corrected split is | ||
| 139 | + recoverable because the cell is byte-exact on main today. The conclusion the | ||
| 140 | + row supports — a real 320x232 chroma divergence, since fixed by | ||
| 141 | + lane-av1422chrtx — is unaffected, because the divergence was non-zero either | ||
| 142 | + way. | ||
| 143 | +- **`lanes/av1422h232.report.md:31-35`** — the red-before table | ||
| 144 | + (`420_oddheight_320x232.obu` "0 | 5772 | 12086", and the same from an | ||
| 145 | + independent re-encode). Same defect, same conclusion: the totals and 0/16 are | ||
| 146 | + sound, the U/V split is not. | ||
| 147 | +- **`lanes/av1cmpaudit2.report.md:71`** — quotes "17658 wrong chroma of 593920" | ||
| 148 | + from the same measurement to argue `count_rawvideo_diffs` is a LIVE comparator. | ||
| 149 | + The liveness argument survives (the count is non-zero and comes from the | ||
| 150 | + oracle's real bytes); the "of 593920" denominator does not describe a plane. | ||
| 151 | + | ||
| 152 | +No other report quotes a non-zero per-plane split from this helper. Every | ||
| 153 | +zero-valued result in the corpus is unchanged by the fix, because a zero is a | ||
| 154 | +zero under any attribution. | ||
| 155 | + | ||
| 156 | +## 7. What was run | ||
| 157 | + | ||
| 158 | +Scoped, on this branch, with `EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMDEC=1 | ||
| 159 | +EC_AV1_REQUIRE_AOMENC=1 EC_AV1_REQUIRE_FFMPEG=1`: | ||
| 160 | + | ||
| 161 | +- `the_counting_oracle_diff_attributes_planes_per_frame` — new, green. | ||
| 162 | +- `the_counting_oracle_diff_detects_one_flipped_oracle_byte` — the pre-existing | ||
| 163 | + non-vacuity control, green. | ||
| 164 | +- `the_pinned_420_oddheight_witness_is_pinned_and_decodes_byte_exact` — the | ||
| 165 | + pre-existing caller that asserts `(0, 0, 0, exact == frames)`, green. | ||
| 166 | +- `every_oracle_comparator_reds_on_a_one_byte_wrong_oracle` — the control for | ||
| 167 | + the whole comparator family, green. | ||
| 168 | +- the mutation of §3, red with the named message. | ||
| 169 | + | ||
| 170 | +Full-suite validation is the orchestrator's; the diff is one helper, one gate, | ||
| 171 | +one fixture. | ||
| 172 | + | ||
| 173 | +## 8. `not_done` | ||
| 174 | + | ||
| 175 | +- The odd-height entropy fork itself (`320x236`, `322x248`) is **not** touched: | ||
| 176 | + no decoder behaviour changed here, and the fix is an instrument fix. | ||
| 177 | +- No second pin was added for `322x248`; its numbers in §5 come from a live | ||
| 178 | + encode with the recipe in `lanes/av1gapremeasure.report.md` §5. Committing a | ||
| 179 | + fixture nothing gates would be dead weight; if the fork's owning lane wants a | ||
| 180 | + witness, it should commit the pin together with the ratchet gate it needs. | ||
| 181 | +- The mis-attributed U/V splits in the three reports of §6 are **not** | ||
| 182 | + retro-corrected in those files. The debt is Main's to update and this lane was | ||
| 183 | + told not to touch it; the corrected figures for the still-diverging cells are | ||
| 184 | + in §5 for whoever writes the debt text. | ||
| 185 | +- `count8` in the ffmpeg control still scores frame 0 only. That is the arm's | ||
| 186 | + declared scope, not a defect, so it was left alone. | ||