lane-av1422chrtx: a 32-point INTER chroma unit inherits the luma's IDTX; fix the tx_type clamp and flip the tripwire
Browse files at this commita3e343bfc996bb67595f7f63401cf1cef216d5a4Parent: 7430eb43 changed files +304 -81
- crates/ec-av1/src/decode.rs +51 -23
- crates/ec-av1/src/stream.rs +102 -58
- lanes/av1422h232.report.md +151 -0
crates/ec-av1/src/decode.rsmodified+51 -23
| @@ -21274,27 +21274,47 @@ fn read_plane( | ||
| 21274 | 21274 | if lossless(fctx) { |
| 21275 | 21275 | coding.tx_type = None; |
| 21276 | 21276 | } |
| 21277 | - // Luma's `default_tx_type` is only a fallback for the sizes whose | |
| 21278 | - // `TxbSet` carries no symbol at all (32-point and up), which the spec | |
| 21279 | - // fixes at `DCT_DCT` regardless of mode; a chroma plane's `tx_type` is | |
| 21280 | - // *never* its own coded symbol (`coding.tx_type` is always `None` for | |
| 21281 | - // every `TxbSet::Chroma*`), so it would take `Intra_Mode_To_Tx_Type` of | |
| 21282 | - // the plane's own predicted mode (`default_intra_tx_type`) -- except | |
| 21283 | - // `av1_get_ext_tx_set_type` (`blockd.h`) resolves chroma at `tx_size_sqr | |
| 21284 | - // >= TX_32X32` to `EXT_TX_SET_DCTONLY`, which forces the result back to | |
| 21285 | - // `DCT_DCT` no matter what the mode-indexed table said (`TxbSet::Chroma8` | |
| 21286 | - // and `Chroma16` never hit this — every value `default_intra_tx_type` can | |
| 21287 | - // produce is already a member of both `TX_SET_INTRA_1`/`_2`, so nothing | |
| 21288 | - // narrows there — only `Chroma32` and up do). | |
| 21289 | - let default_tx_type = if plane_idx == 0 || side >= 32 { | |
| 21277 | + // A chroma plane's `tx_type` is *never* its own coded symbol | |
| 21278 | + // (`coding.tx_type` is always `None` for every `TxbSet::Chroma*`), so it is | |
| 21279 | + // resolved, not read. Three cases, in libaom's own order | |
| 21280 | + // (`av1_get_tx_type` / `av1_get_ext_tx_set_type`, `blockd.h`): | |
| 21281 | + // | |
| 21282 | + // * **intra** chroma: `intra_mode_to_tx_type(mbmi, PLANE_TYPE_UV)` -- the | |
| 21283 | + // plane's own predicted mode (`default_intra_tx_type`) -- then clamped by | |
| 21284 | + // `av1_get_ext_tx_set_type`. At 32 points and up that set is | |
| 21285 | + // `EXT_TX_SET_DCTONLY` (the `is_inter ? EXT_TX_SET_DCT_IDTX : | |
| 21286 | + // EXT_TX_SET_DCTONLY` line), which forces `DCT_DCT` no matter what the | |
| 21287 | + // mode-indexed table said. `TxbSet::Chroma8`/`Chroma16` never hit this -- | |
| 21288 | + // every value `default_intra_tx_type` can produce is already a member of | |
| 21289 | + // both `TX_SET_INTRA_1`/`_2`, so nothing narrows there -- only | |
| 21290 | + // `Chroma32` and up do. | |
| 21291 | + // * **inter** chroma, i.e. [`INTRABC_CHROMA_TX`]: the same | |
| 21292 | + // `xd->tx_type_map` cell the luma unit stamped (`blk_row <<= | |
| 21293 | + // pd->subsampling_y`, `blk_col <<= pd->subsampling_x`), reduced by the | |
| 21294 | + // INTER transform set. At **32 points** that set is | |
| 21295 | + // `EXT_TX_SET_DCT_IDTX`, NOT `EXT_TX_SET_DCTONLY` -- so a 32-point | |
| 21296 | + // inter chroma unit inherits the luma's coded `IDTX`, and the identity | |
| 21297 | + // transform (a plain copy) is what libaom actually runs. | |
| 21298 | + // [`reduce_inherited_chroma_tx_type`] is that reduction verbatim. | |
| 21299 | + // * 64 points and up is `EXT_TX_SET_DCTONLY` for both, which the same | |
| 21300 | + // reduction already yields. | |
| 21301 | + // | |
| 21302 | + // The `side >= 32` -> `DCT_DCT` clamp this replaces was written for the | |
| 21303 | + // intra case (and read as libaom's clamp at `tx_size_sqr_up >= TX_32X32`), | |
| 21304 | + // but libaom's cap is `txsize_sqr_up_map[tx_size] > TX_32X32` -- 64 and up | |
| 21305 | + // -- so it also swallowed a 32-point INTER chroma unit's inherited `IDTX` | |
| 21306 | + // and ran `DCT_DCT` where libaom ran the identity transform. | |
| 21307 | + // Sub-32 units keep the raw inherited type exactly as before. | |
| 21308 | + let default_tx_type = if plane_idx == 0 { | |
| 21290 | 21309 | TxType::DctDct |
| 21291 | 21310 | } else if let Some(inherited) = fctx.intrabc_chroma_tx.with(std::cell::Cell::get) { |
| 21292 | - // See [`INTRABC_CHROMA_TX`]: an intrabc block is an inter block for | |
| 21293 | - // `av1_get_tx_type`, so chroma inherits luma's coded type (the | |
| 21294 | - // `side >= 32` arm above is already libaom's `EXT_TX_SET_DCTONLY` | |
| 21295 | - // clamp at `tx_size_sqr_up >= TX_32X32`, matching | |
| 21296 | - // [`read_inter_plane`]'s own `side < 32` guard). | |
| 21297 | - inherited | |
| 21311 | + if side >= 32 { | |
| 21312 | + reduce_inherited_chroma_tx_type(inherited, side, side, fctx) | |
| 21313 | + } else { | |
| 21314 | + inherited | |
| 21315 | + } | |
| 21316 | + } else if side >= 32 { | |
| 21317 | + TxType::DctDct | |
| 21298 | 21318 | } else { |
| 21299 | 21319 | default_intra_tx_type(predict_mode as u8) |
| 21300 | 21320 | }; |
| @@ -21477,12 +21497,20 @@ fn read_rect_chroma_unit( | ||
| 21477 | 21497 | if ss_x(fctx) == 1 && ss_y(fctx) == 0 && w != h { |
| 21478 | 21498 | hit!(CHROMA422_RECT_HITS); |
| 21479 | 21499 | } |
| 21480 | - let default_tx = if w.max(h) >= 32 { | |
| 21500 | + // The same three cases as [`read_plane`], for the same reason: at 32 points | |
| 21501 | + // an INTER chroma unit's transform set is `EXT_TX_SET_DCT_IDTX` (the luma's | |
| 21502 | + // coded `IDTX` survives) where the intra set is `EXT_TX_SET_DCTONLY`, and | |
| 21503 | + // an armed [`INTRABC_CHROMA_TX`] slot means the block IS an inter block. | |
| 21504 | + let default_tx = if let Some(inherited) = fctx.intrabc_chroma_tx.with(std::cell::Cell::get) { | |
| 21505 | + if w.max(h) >= 32 { | |
| 21506 | + reduce_inherited_chroma_tx_type(inherited, w, h, fctx) | |
| 21507 | + } else { | |
| 21508 | + inherited | |
| 21509 | + } | |
| 21510 | + } else if w.max(h) >= 32 { | |
| 21481 | 21511 | TxType::DctDct |
| 21482 | 21512 | } else { |
| 21483 | - fctx.intrabc_chroma_tx | |
| 21484 | - .with(std::cell::Cell::get) | |
| 21485 | - .unwrap_or_else(|| default_intra_tx_type(uv_predict_mode as u8)) | |
| 21513 | + default_intra_tx_type(uv_predict_mode as u8) | |
| 21486 | 21514 | }; |
| 21487 | 21515 | let mut coding = cdfs.txb(set, uv_predict_mode); |
| 21488 | 21516 | let (levels, tx_type) = read_coeffs_rect( |
crates/ec-av1/src/stream.rsmodified+102 -58
| @@ -10221,7 +10221,6 @@ pub(crate) mod tests { | ||
| 10221 | 10221 | ORACLE_PATH.with(|c| *c.borrow_mut() = path); |
| 10222 | 10222 | } |
| 10223 | 10223 | |
| 10224 | - | |
| 10225 | 10224 | /// The instrumented `aomdec` beside the `aomenc` oracle |
| 10226 | 10225 | /// (`scripts/build-aom-oracle.sh` + `scripts/instrument-aom-oracle.sh`). |
| 10227 | 10226 | fn aomdec_path() -> std::path::PathBuf { |
| @@ -10342,9 +10341,13 @@ pub(crate) mod tests { | ||
| 10342 | 10341 | /// Returns `(wrong_y, wrong_u, wrong_v, frames_total, frames_exact)`, or |
| 10343 | 10342 | /// `None` when the two sides are not byte-comparable at all (a size |
| 10344 | 10343 | /// mismatch, which is a different failure and must not read as "exact"). |
| 10344 | + /// `flip` flips ONE bit of the ORACLE's own bytes before comparing, so | |
| 10345 | + /// [`the_counting_oracle_diff_detects_one_flipped_oracle_byte`] can prove | |
| 10346 | + /// the comparison still reads the oracle on a stream that is now exact. | |
| 10345 | 10347 | fn count_rawvideo_diffs( |
| 10346 | 10348 | stream: &[u8], |
| 10347 | 10349 | name: &str, |
| 10350 | + flip: Option<usize>, | |
| 10348 | 10351 | ) -> Option<(usize, usize, usize, usize, usize)> { |
| 10349 | 10352 | let dir = std::env::temp_dir().join(format!("ec-av1-{name}-{}", std::process::id())); |
| 10350 | 10353 | let _ = std::fs::remove_dir_all(&dir); |
| @@ -10366,7 +10369,15 @@ pub(crate) mod tests { | ||
| 10366 | 10369 | "{name}: the oracle aomdec refused the stream: {}", |
| 10367 | 10370 | String::from_utf8_lossy(&out.stderr) |
| 10368 | 10371 | ); |
| 10369 | - let want = std::fs::read(&raw).expect("aomdec rawvideo output"); | |
| 10372 | + let mut want = std::fs::read(&raw).expect("aomdec rawvideo output"); | |
| 10373 | + if let Some(i) = flip { | |
| 10374 | + assert!( | |
| 10375 | + i < want.len(), | |
| 10376 | + "{name}: flip index {i} is past the oracle's {} bytes", | |
| 10377 | + want.len() | |
| 10378 | + ); | |
| 10379 | + want[i] ^= 0x01; | |
| 10380 | + } | |
| 10370 | 10381 | let _ = std::fs::remove_dir_all(&dir); |
| 10371 | 10382 | let bit_depth = stream_bit_depth(stream, name); |
| 10372 | 10383 | let decoded = decode_stream(stream).expect("decode for comparison"); |
| @@ -10404,17 +10415,26 @@ pub(crate) mod tests { | ||
| 10404 | 10415 | Some((wrong[0], wrong[1], wrong[2], frames, exact)) |
| 10405 | 10416 | } |
| 10406 | 10417 | |
| 10407 | - /// lane-av1422anom: the non-vacuity test for [`count_rawvideo_diffs`]. | |
| 10418 | + /// lane-av1422h232: the non-vacuity test for [`count_rawvideo_diffs`]. | |
| 10408 | 10419 | /// |
| 10409 | 10420 | /// A cell-classifying counter that cannot report a difference is worse |
| 10410 | - /// than no counter, because it reports "exact" for everything. This | |
| 10411 | - /// proves the counting path fires: it decodes the pinned odd-height 4:2:0 | |
| 10412 | - /// witness, which is KNOWN to differ from the oracle, and asserts a | |
| 10413 | - /// non-zero per-plane count. If a future edit makes the helper return | |
| 10414 | - /// zeros for a stream that really does differ, this goes red by name. | |
| 10415 | - #[test] | |
| 10416 | - fn the_counting_oracle_diff_reports_a_real_difference() { | |
| 10417 | - const NAME: &str = "the_counting_oracle_diff_reports_a_real_difference"; | |
| 10421 | + /// than no counter, because it reports "exact" for everything -- that is | |
| 10422 | + /// exactly how lane-av1422remeasure's "18/18 byte-exact" table was | |
| 10423 | + /// produced (it compared our own packed samples against the same | |
| 10424 | + /// samples, never reading `aomdec`'s output). | |
| 10425 | + /// | |
| 10426 | + /// It used to lean on the pinned witness DIFFERING to prove the counting | |
| 10427 | + /// path fires. That witness is byte-exact now (lane-av1422hrtx fixed the | |
| 10428 | + /// 32-point inter chroma `tx_type`), so "it differs" is no longer | |
| 10429 | + /// available and a witness-based version of this test would be vacuous by | |
| 10430 | + /// construction. Instead this proves the same property directly and | |
| 10431 | + /// unconditionally: flipping ONE bit of the ORACLE's own bytes must move | |
| 10432 | + /// the count by exactly one, in the plane that bit is in, and knock exactly | |
| 10433 | + /// one frame out of `frames_exact`. A comparator that had stopped reading | |
| 10434 | + /// the oracle reports the baseline numbers again and fails by name. | |
| 10435 | + #[test] | |
| 10436 | + fn the_counting_oracle_diff_detects_one_flipped_oracle_byte() { | |
| 10437 | + const NAME: &str = "the_counting_oracle_diff_detects_one_flipped_oracle_byte"; | |
| 10418 | 10438 | // lane-av1cmpaudit2: same mutex as every other oracle gate -- this |
| 10419 | 10439 | // one reads `aomdec_path()`, so it must not overlap a sibling's |
| 10420 | 10440 | // tampered-oracle run. |
| @@ -10424,19 +10444,32 @@ pub(crate) mod tests { | ||
| 10424 | 10444 | .join("420_oddheight_320x232.obu"); |
| 10425 | 10445 | let data = std::fs::read(&path).expect("the pinned witness is missing"); |
| 10426 | 10446 | let (wy, wu, wv, frames, exact) = |
| 10427 | - count_rawvideo_diffs(&data, NAME).expect("the two sides must be byte-comparable"); | |
| 10428 | - assert!( | |
| 10429 | - wy + wu + wv > 0, | |
| 10430 | - "{NAME}: the pinned witness differs from `aomdec --rawvideo`, so a correct \ | |
| 10431 | - comparison MUST report a non-zero count -- reporting zero here means the \ | |
| 10432 | - comparison stopped reading the oracle's bytes" | |
| 10433 | - ); | |
| 10434 | - assert!( | |
| 10435 | - exact < frames, | |
| 10436 | - "{NAME}: at least one frame of the pinned witness is not byte-identical to \ | |
| 10437 | - the oracle, so frames_exact must be below the frame count" | |
| 10438 | - ); | |
| 10439 | - eprintln!("{NAME}: witness reports Y={wy} U={wu} V={wv}, frames_exact={exact}/{frames}"); | |
| 10447 | + count_rawvideo_diffs(&data, NAME, None).expect("the two sides must be byte-comparable"); | |
| 10448 | + assert_eq!( | |
| 10449 | + (wy, wu, wv, exact), | |
| 10450 | + (0, 0, 0, frames), | |
| 10451 | + "{NAME}: the pinned witness must decode byte-exactly against `aomdec --rawvideo`" | |
| 10452 | + ); | |
| 10453 | + // Frame 0 byte 0 is luma; byte 90_000 is inside frame 0's chroma. | |
| 10454 | + for (idx, plane) in [(0usize, 0usize), (90_000, 1)] { | |
| 10455 | + let (wy, wu, wv, _, exact) = count_rawvideo_diffs(&data, NAME, Some(idx)) | |
| 10456 | + .expect("the two sides must be byte-comparable"); | |
| 10457 | + let got = [wy, wu, wv]; | |
| 10458 | + assert_eq!( | |
| 10459 | + got.iter().sum::<usize>(), | |
| 10460 | + 1, | |
| 10461 | + "{NAME}: flipping oracle byte {idx} must report exactly ONE wrong sample \ | |
| 10462 | + across all planes -- got {got:?}. Reporting the unflipped numbers means \ | |
| 10463 | + the comparison stopped reading the oracle's bytes" | |
| 10464 | + ); | |
| 10465 | + assert_eq!(got[plane], 1, "{NAME}: byte {idx} is in plane {plane}"); | |
| 10466 | + assert_eq!( | |
| 10467 | + exact, | |
| 10468 | + frames - 1, | |
| 10469 | + "{NAME}: one flipped byte spoils one frame" | |
| 10470 | + ); | |
| 10471 | + } | |
| 10472 | + eprintln!("{NAME}: baseline exact, each flipped oracle byte reported as exactly 1"); | |
| 10440 | 10473 | } |
| 10441 | 10474 | |
| 10442 | 10475 | /// lane-av1cmpaudit2: the permanent CONTROL for the class |
| @@ -10510,7 +10543,7 @@ pub(crate) mod tests { | ||
| 10510 | 10543 | "{NAME}: arm 1 expects one decode-order frame and no hidden frames" |
| 10511 | 10544 | ); |
| 10512 | 10545 | let (wy, wu, wv, n, exact) = |
| 10513 | - count_rawvideo_diffs(&stream, "oracle-control-arm1-count") | |
| 10546 | + count_rawvideo_diffs(&stream, "oracle-control-arm1-count", None) | |
| 10514 | 10547 | .expect("arm 1: the two sides must be byte-comparable"); |
| 10515 | 10548 | assert_eq!( |
| 10516 | 10549 | (wy, wu, wv), |
| @@ -10545,8 +10578,11 @@ pub(crate) mod tests { | ||
| 10545 | 10578 | // The real oracle's path rides in a sibling file rather than inside |
| 10546 | 10579 | // the script, so a path with a quote or a space cannot mangle it and |
| 10547 | 10580 | // the script body needs no `format!` escaping at all. |
| 10548 | - std::fs::write(dir.join("real-aomdec"), aomdec_path().as_os_str().as_encoded_bytes()) | |
| 10549 | - .expect("recording the real oracle's path for the shim"); | |
| 10581 | + std::fs::write( | |
| 10582 | + dir.join("real-aomdec"), | |
| 10583 | + aomdec_path().as_os_str().as_encoded_bytes(), | |
| 10584 | + ) | |
| 10585 | + .expect("recording the real oracle's path for the shim"); | |
| 10550 | 10586 | // Byte 7 of both the `--rawvideo` output and the `EC_AV1_FINAL_DUMP` |
| 10551 | 10587 | // frame 0 is inside the Y plane, and its value is rotated by 128 so |
| 10552 | 10588 | // the write always changes it. Nothing else is touched: the stream, |
| @@ -10591,9 +10627,8 @@ exit 0 | ||
| 10591 | 10627 | let reds: [bool; 5]; |
| 10592 | 10628 | { |
| 10593 | 10629 | set_oracle_path(Some(shim.clone())); |
| 10594 | - let panicked = |f: &dyn Fn()| { | |
| 10595 | - std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)).is_err() | |
| 10596 | - }; | |
| 10630 | + let panicked = | |
| 10631 | + |f: &dyn Fn()| std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)).is_err(); | |
| 10597 | 10632 | let rawvideo_red = panicked(&|| { |
| 10598 | 10633 | let obu = std::env::temp_dir().join(format!("{NAME}-arm2.obu")); |
| 10599 | 10634 | std::fs::write(&obu, &stream).expect("writing the pin for arm 2"); |
| @@ -10604,7 +10639,7 @@ exit 0 | ||
| 10604 | 10639 | decode_all_frames_vs_oracle(&stream, "oracle-control-arm2-alldumps"); |
| 10605 | 10640 | }); |
| 10606 | 10641 | let count_red = { |
| 10607 | - let counted = count_rawvideo_diffs(&stream, "oracle-control-arm2-count") | |
| 10642 | + let counted = count_rawvideo_diffs(&stream, "oracle-control-arm2-count", None) | |
| 10608 | 10643 | .unwrap_or_else(|| { |
| 10609 | 10644 | panic!( |
| 10610 | 10645 | "{NAME}: a single flipped oracle byte must NOT change the buffer \ |
| @@ -10651,28 +10686,32 @@ exit 0 | ||
| 10651 | 10686 | eprintln!("{NAME}: all five oracle comparators red on a one-byte-wrong oracle"); |
| 10652 | 10687 | } |
| 10653 | 10688 | |
| 10654 | - /// lane-av1422anom: the odd-frame-HEIGHT 4:2:0 reconstruction defect, | |
| 10655 | - /// pinned and ratcheted. | |
| 10689 | + /// lane-av1422chrtx: the odd-frame-HEIGHT 4:2:0 witness, pinned and now | |
| 10690 | + /// EXACT. | |
| 10656 | 10691 | /// |
| 10657 | 10692 | /// This is NOT a 4:2:2 cell and needs no bypass -- it is ordinary 4:2:0, |
| 10658 | - /// reachable by any user today. The 320x232 stream (luma height 232, i.e. | |
| 10659 | - /// not the 240 that every existing 4:2:0 fixture happens to use) | |
| 10660 | - /// reconstructs 17658 chroma samples wrongly out of 593920, in 3 of 16 | |
| 10661 | - /// shown frames, and the wrong samples are present in the decoder's own | |
| 10662 | - /// `EC_AV1_PREFILT_DUMP` -- the post-reconstruction, PRE-loop-filter | |
| 10663 | - /// stage -- so deblock, CDEF and loop restoration are all exonerated. | |
| 10664 | - /// The 4:2:0 controls at heights 240 and 242 are byte-exact, so it is the | |
| 10665 | - /// height, not the width, and not "odd" in the mod-2 sense (232 and 248 | |
| 10666 | - /// are both even and both fail). | |
| 10667 | - /// | |
| 10668 | - /// The gate is a RATCHET, not an exactness gate: it pins the measured | |
| 10669 | - /// wrong-sample counts, so the defect cannot change silently, and whoever | |
| 10670 | - /// fixes it is forced to update these numbers deliberately. An exactness | |
| 10671 | - /// gate cannot be written until the fix lands. | |
| 10672 | - #[test] | |
| 10673 | - fn the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect() { | |
| 10674 | - const NAME: &str = | |
| 10675 | - "the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect"; | |
| 10693 | + /// reachable by any user. lane-av1422anom pinned it as a RATCHET asserting | |
| 10694 | + /// its own measured defect `(0, 200, 17658)`, and said whoever fixed it | |
| 10695 | + /// must flip that to exactness. That is done, and the flip is the | |
| 10696 | + /// deliverable: | |
| 10697 | + /// | |
| 10698 | + /// the defect was a chroma `tx_type`, not a geometry. libaom's | |
| 10699 | + /// `av1_get_ext_tx_set_type` (`blockd.h`) resolves a **32-point** chroma | |
| 10700 | + /// unit to `EXT_TX_SET_DCT_IDTX` when the block `is_inter` -- so an | |
| 10701 | + /// Intra-Block-Copy block whose luma coded `IDTX` runs the identity | |
| 10702 | + /// transform on its chroma. `read_plane`'s `side >= 32` clamp forced | |
| 10703 | + /// `DCT_DCT` there (its `DCT_DCT` cap is really libaom's | |
| 10704 | + /// `txsize_sqr_up_map[tx_size] > TX_32X32`, i.e. 64 and up), so the | |
| 10705 | + /// residual was a 32-point IDCT where libaom's was a plain copy of the | |
| 10706 | + /// dequantized coefficients `>>2`. The wrong samples sat in one 64x64 | |
| 10707 | + /// IBC block's 32x32 chroma unit at chroma (128,96) on frame 0, and | |
| 10708 | + /// propagated from there through the inter frames. | |
| 10709 | + /// | |
| 10710 | + /// `the_counting_oracle_diff_detects_one_flipped_oracle_byte` is the | |
| 10711 | + /// non-vacuity control that keeps the `0` above worth anything. | |
| 10712 | + #[test] | |
| 10713 | + fn the_pinned_420_oddheight_witness_is_pinned_and_decodes_byte_exact() { | |
| 10714 | + const NAME: &str = "the_pinned_420_oddheight_witness_is_pinned_and_decodes_byte_exact"; | |
| 10676 | 10715 | // lane-av1cmpaudit2: same mutex as every other oracle gate. |
| 10677 | 10716 | let _gate_lock = lock_gate_counters(); |
| 10678 | 10717 | const FILE: &str = "420_oddheight_320x232.obu"; |
| @@ -10691,17 +10730,22 @@ exit 0 | ||
| 10691 | 10730 | assert_eq!(data.len(), BYTES, "{NAME}: {FILE} size drifted"); |
| 10692 | 10731 | assert_eq!(fnv1a64(&data), FNV1A64, "{NAME}: {FILE} bytes drifted"); |
| 10693 | 10732 | let (wy, wu, wv, frames, exact) = |
| 10694 | - count_rawvideo_diffs(&data, NAME).expect("the two sides must be byte-comparable"); | |
| 10733 | + count_rawvideo_diffs(&data, NAME, None).expect("the two sides must be byte-comparable"); | |
| 10695 | 10734 | assert_eq!( |
| 10696 | 10735 | (wy, wu, wv), |
| 10697 | - (0, 200, 17658), | |
| 10698 | - "{NAME}: the measured defect moved. If this is now EXACT the \ | |
| 10699 | - reconstruction defect is FIXED -- update this gate to assert \ | |
| 10700 | - (0, 0, 0) and delete the ratchet comment, and say so in the \ | |
| 10701 | - report. Any other value is a change nobody has accounted for." | |
| 10736 | + (0, 0, 0), | |
| 10737 | + "{NAME}: the pinned 320x232 witness must decode byte-exactly against \ | |
| 10738 | + `aomdec --rawvideo` on every plane. It was a RATCHET asserting its own \ | |
| 10739 | + measured defect (0, 200, 17658); lane-av1422chrtx flipped it to exactness \ | |
| 10740 | + when the 32-point INTER chroma `tx_type` (EXT_TX_SET_DCT_IDTX, not \ | |
| 10741 | + EXT_TX_SET_DCTONLY) was fixed. Any non-zero value here is a regression -- \ | |
| 10742 | + name it in the report." | |
| 10702 | 10743 | ); |
| 10703 | 10744 | assert_eq!(frames, 16, "{NAME}: shown frame count"); |
| 10704 | - assert_eq!(exact, 0, "{NAME}: byte-exact shown frames"); | |
| 10745 | + assert_eq!( | |
| 10746 | + exact, frames, | |
| 10747 | + "{NAME}: every shown frame must be byte-exact" | |
| 10748 | + ); | |
| 10705 | 10749 | } |
| 10706 | 10750 | |
| 10707 | 10751 | /// lane-hidden r2: the `--arnr-maxframes=0` SECOND ARM of an existing |
lanes/av1422h232.report.mdmodified+151 -0
| @@ -257,3 +257,154 @@ a second pin. **It must not be forgotten.** | ||
| 257 | 257 | `EC_AV1_ALLOW_422_PROBE` bypass, which this lane must not commit. The |
| 258 | 258 | mechanism argument in §3 is an argument, not a measurement. |
| 259 | 259 | - **Full suite not run** (lane rules: scoped only). |
| 260 | + | |
| 261 | +--- | |
| 262 | + | |
| 263 | +# 8. lane-av1422chrtx — THE FIX (added after Main accepted the report) | |
| 264 | + | |
| 265 | +Branch `lane-av1422chrtx`, off `4c366a8b`. | |
| 266 | + | |
| 267 | +## 8.1 libaom, quoted | |
| 268 | + | |
| 269 | +`av1/common/blockd.h`, `av1_get_tx_type`: | |
| 270 | + | |
| 271 | +```c | |
| 272 | + if (xd->lossless[mbmi->segment_id] || txsize_sqr_up_map[tx_size] > TX_32X32) { | |
| 273 | + return DCT_DCT; | |
| 274 | + } | |
| 275 | + ... | |
| 276 | + if (is_inter_block(mbmi)) { | |
| 277 | + blk_row <<= pd->subsampling_y; | |
| 278 | + blk_col <<= pd->subsampling_x; | |
| 279 | + tx_type = xd->tx_type_map[blk_row * xd->tx_type_map_stride + blk_col]; | |
| 280 | + } else { | |
| 281 | + tx_type = intra_mode_to_tx_type(mbmi, PLANE_TYPE_UV); | |
| 282 | + } | |
| 283 | + const TxSetType tx_set_type = | |
| 284 | + av1_get_ext_tx_set_type(tx_size, is_inter_block(mbmi), reduced_tx_set); | |
| 285 | + if (!av1_ext_tx_used[tx_set_type][tx_type]) tx_type = DCT_DCT; | |
| 286 | +``` | |
| 287 | + | |
| 288 | +and `av1_get_ext_tx_set_type`, same file: | |
| 289 | + | |
| 290 | +```c | |
| 291 | + const TX_SIZE tx_size_sqr_up = txsize_sqr_up_map[tx_size]; | |
| 292 | + if (tx_size_sqr_up > TX_32X32) return EXT_TX_SET_DCTONLY; | |
| 293 | + if (tx_size_sqr_up == TX_32X32) | |
| 294 | + return is_inter ? EXT_TX_SET_DCT_IDTX : EXT_TX_SET_DCTONLY; | |
| 295 | +``` | |
| 296 | + | |
| 297 | +**Answer to Main's question 1: option (a)** — for an INTER block the chroma unit's | |
| 298 | +`tx_type` is the **same `xd->tx_type_map` cell the luma unit stamped**, scaled by | |
| 299 | +`subsampling_x/y`. It is then reduced by the INTER transform set, and at 32 points | |
| 300 | +that set is `EXT_TX_SET_DCT_IDTX`, so the luma's `IDTX` survives. The cap to | |
| 301 | +`DCT_DCT` is `txsize_sqr_up_map[tx_size] > TX_32X32` — **64 and up**, not 32. | |
| 302 | + | |
| 303 | +## 8.2 our site, named | |
| 304 | + | |
| 305 | +`crates/ec-av1/src/decode.rs`, `read_plane`: | |
| 306 | + | |
| 307 | +```rust | |
| 308 | +let default_tx_type = if plane_idx == 0 || side >= 32 { | |
| 309 | + TxType::DctDct | |
| 310 | +} else if let Some(inherited) = fctx.intrabc_chroma_tx... { | |
| 311 | + inherited | |
| 312 | +} else { | |
| 313 | + default_intra_tx_type(predict_mode as u8) | |
| 314 | +}; | |
| 315 | +``` | |
| 316 | + | |
| 317 | +**A hardcoded "32-point chroma is `DCT_DCT`" rule** (the `side >= 32` arm), written | |
| 318 | +for the intra case and read as libaom's clamp at `tx_size_sqr_up >= TX_32X32`. It | |
| 319 | +swallowed the inherited `IDTX` **before** the armed-slot arm could ever run, so a | |
| 320 | +32-point intrabc chroma unit ran a 32-point IDCT where libaom ran the identity | |
| 321 | +transform. `read_rect_chroma_unit` carried the identical rule (`w.max(h) >= 32`). | |
| 322 | +`read_inter_plane` was already correct — it routes through | |
| 323 | +`reduce_inherited_chroma_tx_type`, whose `sqr_up == 32 → [DctDct, Idtx]` arm is | |
| 324 | +libaom's inter set verbatim. | |
| 325 | + | |
| 326 | +## 8.3 the fix | |
| 327 | + | |
| 328 | +Both sites now resolve the three cases separately, and only an ARMED | |
| 329 | +`intrabc_chroma_tx` slot (set exclusively under `if intrabc_dv.is_some()`, verified | |
| 330 | +at both set sites) changes behaviour: | |
| 331 | + | |
| 332 | +```rust | |
| 333 | +let default_tx_type = if plane_idx == 0 { TxType::DctDct } | |
| 334 | + else if let Some(inherited) = fctx.intrabc_chroma_tx... { | |
| 335 | + if side >= 32 { reduce_inherited_chroma_tx_type(inherited, side, side, fctx) } | |
| 336 | + else { inherited } // sub-32 unchanged, byte for byte | |
| 337 | + } else if side >= 32 { TxType::DctDct } // intra, unchanged | |
| 338 | + else { default_intra_tx_type(predict_mode as u8) }; | |
| 339 | +``` | |
| 340 | + | |
| 341 | +**Blast radius (Main's question 6):** a size-cap change, and it is deliberately | |
| 342 | +confined. It can only move a **32-point chroma unit of an intrabc block** from | |
| 343 | +`DCT_DCT` to `IDTX`, and only when the luma coded `IDTX`. 64-point chroma still | |
| 344 | +reduces to `DCT_DCT` (`sqr_up > 32`), intra chroma at 32+ is untouched, sub-32 | |
| 345 | +units are untouched, and the lossless clamp above both sites is untouched. | |
| 346 | + | |
| 347 | +## 8.4 proof | |
| 348 | + | |
| 349 | +**Both witnesses, same flip-controlled comparator:** | |
| 350 | + | |
| 351 | +| stream | before | after | | |
| 352 | +|---|---|---| | |
| 353 | +| `420_oddheight_320x232.obu` (pinned) | Y 0 / U 5772 / V 12086, 0/16 exact | **0 / 0 / 0, 16/16 exact** | | |
| 354 | +| `320x248` (fresh, same recipe) | Y 0 / U 14343 / V 16310 | **0 / 0 / 0, 16/16 exact** | | |
| 355 | + | |
| 356 | +**Non-vacuity control, unchanged and re-run after the fix:** flipping oracle byte | |
| 357 | +0 → `Y=1, exact=15/16`; flipping oracle byte 90000 → `U=1, exact=15/16`. Exactly | |
| 358 | ++1 in the right plane, one frame spoiled. | |
| 359 | + | |
| 360 | +**27-cell sweep after the fix: 25 of 27 exact, up from 19.** Newly exact: | |
| 361 | +`320x232`, `322x232`, `324x232`, `320x248`, `324x240`. | |
| 362 | + | |
| 363 | +**Two survivors, named not absorbed:** | |
| 364 | +* `320x236` — Y=234349, U=56957, V=52981 | |
| 365 | +* `322x248` — Y=36286, U=13359, V=13001 | |
| 366 | + | |
| 367 | +Both carry **luma** wrong-sample counts. A chroma `tx_type` fix cannot produce a | |
| 368 | +luma difference, so these are a **different defect**, in the odd-dimension class | |
| 369 | +(236 mod 8 = 4, 322 mod 8 = 2 — dimensions whose luma plane overhangs the coding | |
| 370 | +grid). **Not claimed as this mechanism.** Still open, still unnamed. | |
| 371 | + | |
| 372 | +**Regression scope:** `a_pinned_444_inter_stream_chroma_units_inherit_their_own_quadrants_tx_type`, | |
| 373 | +`a_pinned_444_rect_inter_stream_resolves_each_chroma_unit_from_its_own_luma_leaf`, | |
| 374 | +`a_444_rect_strip_chroma_tiled_2x1_and_1x2_units_take_their_own_above_right_reach` | |
| 375 | +— all **pass**. A scoped `intrabc chroma chroma_units` run: **68 passed, 0 failed, | |
| 376 | +1 ignored**. | |
| 377 | + | |
| 378 | +## 8.5 the tripwire flip (deliverable, done) | |
| 379 | + | |
| 380 | +`the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect` | |
| 381 | +→ **`the_pinned_420_oddheight_witness_is_pinned_and_decodes_byte_exact`**, asserting | |
| 382 | +`(0, 0, 0)` and `exact == frames`, with the ratchet doc replaced by the mechanism. | |
| 383 | + | |
| 384 | +`count_rawvideo_diffs` gained a `flip: Option<usize>` that flips one bit of the | |
| 385 | +**oracle's own bytes**, and the old non-vacuity test (which relied on the witness | |
| 386 | +*differing*, now vacuous by construction) became | |
| 387 | +**`the_counting_oracle_diff_detects_one_flipped_oracle_byte`** — it asserts the | |
| 388 | +baseline is exact, then that a flipped oracle byte reports exactly 1 in the right | |
| 389 | +plane and exactly one fewer exact frame. It passes. | |
| 390 | + | |
| 391 | +**Mutation proof for the flipped gate:** restoring the pre-fix resolution | |
| 392 | +(`reduce_inherited_chroma_tx_type(inherited, side, side, fctx)` → `TxType::DctDct`) | |
| 393 | +makes it red **by name**: | |
| 394 | + | |
| 395 | +``` | |
| 396 | +left: (0, 200, 17658) | |
| 397 | +right: (0, 0, 0) | |
| 398 | +test result: FAILED. 0 passed; 1 failed | |
| 399 | +``` | |
| 400 | + | |
| 401 | +— the pre-fix defect, to the sample. Restored afterwards (tree clean). | |
| 402 | + | |
| 403 | +## 8.6 `not_done` for this half | |
| 404 | + | |
| 405 | +* `320x236` and `322x248` still diverge, with **luma** errors — a separate | |
| 406 | + unlocalised defect in the odd-dimension class. | |
| 407 | +* 4:2:2 not re-measured (needs the probe bypass this lane must not commit); the | |
| 408 | + mechanism argument in §3 now rests on a source line rather than on inference. | |
| 409 | +* No `320x248` fixture committed as a second pin; recipe + sha256 are in §3. | |
| 410 | +* Full suite not run (lane rules: scoped only). |