forge
Explore
Log in

Don't you dare go Hollow

wip(rectx): scan_8x4/4x8 asymmetric pin test vs real libaom scan.c

Browse files at this commit

6c0af34825509490fb8de55a43ccb7e20540b941Ahmet Kaan GümüşParent: 6253922
Sweeps the pair together against literal transcriptions of libaom's
default_scan_4x8/default_scan_8x4 (av1/common/scan.c) read from
~/.cache/aom-oracle/src. A same-orientation bijection check cannot
catch a swap between the two; this pins both arrays element-for-
element against sources that differ from each other, so a swap fails
deterministically. cargo test -p ec-av1 --lib: 267 passed, 0 failed
prior to this test; refusal_inventory pins survived round 1's two
refusal removals unmodified.
crates/ec-av1/src/decode.rsmodified+36 -0
@@ -13459,6 +13459,42 @@ mod tests {
13459 // this decoder's one target, and the round-trip test below is against13459 // this decoder's one target, and the round-trip test below is against
13460 // that path with real quantised residual, not a synthetic all-DC frame.13460 // that path with real quantised residual, not a synthetic all-DC frame.
13461 13461
13462+ /// [`SCAN_8X4`]/[`SCAN_4X8`] (lane-rectx r2): a bijection check alone
13463+ /// cannot catch a transposed pair -- a swap of two orientation tables is
13464+ /// still a bijection over the same 32 positions. This pins BOTH arrays
13465+ /// at once, element-for-element, against literal transcriptions of
13466+ /// libaom's real `default_scan_4x8`/`default_scan_8x4` in
13467+ /// `av1/common/scan.c` (`~/.cache/aom-oracle/src`, read directly for
13468+ /// this test, not re-derived from the zigzag formula). The two source
13469+ /// sequences are themselves different in their own right (not equal to
13470+ /// each other), so this is asymmetric in the two axes: if the repo's
13471+ /// `SCAN_8X4`/`SCAN_4X8` were swapped with each other, one side of this
13472+ /// assert pair would fail even though each individual array would still
13473+ /// pass a same-orientation bijection test.
13474+ #[test]
13475+ fn scan_8x4_and_4x8_are_not_transposed_against_each_other() {
13476+ // libaom `default_scan_4x8` verbatim (scan.c:29-32) -- this repo
13477+ // names it `SCAN_8X4` under the established w/h axis swap (see
13478+ // `SCAN_8X4`'s own doc comment).
13479+ const LIBAOM_DEFAULT_SCAN_4X8: [u16; 32] = [
13480+ 0, 8, 1, 16, 9, 2, 24, 17, 10, 3, 25, 18, 11, 4, 26, 19, 12, 5, 27, 20, 13, 6, 28, 21,
13481+ 14, 7, 29, 22, 15, 30, 23, 31,
13482+ ];
13483+ // libaom `default_scan_8x4` verbatim (scan.c:44-47) -- this repo's
13484+ // `SCAN_4X8`.
13485+ const LIBAOM_DEFAULT_SCAN_8X4: [u16; 32] = [
13486+ 0, 1, 4, 2, 5, 8, 3, 6, 9, 12, 7, 10, 13, 16, 11, 14, 17, 20, 15, 18, 21, 24, 19, 22,
13487+ 25, 28, 23, 26, 29, 27, 30, 31,
13488+ ];
13489+ assert_ne!(
13490+ LIBAOM_DEFAULT_SCAN_4X8, LIBAOM_DEFAULT_SCAN_8X4,
13491+ "the two libaom source sequences must differ, or this pin would \
13492+ pass regardless of a swap"
13493+ );
13494+ assert_eq!(SCAN_8X4, LIBAOM_DEFAULT_SCAN_4X8, "SCAN_8X4 vs libaom default_scan_4x8");
13495+ assert_eq!(SCAN_4X8, LIBAOM_DEFAULT_SCAN_8X4, "SCAN_4X8 vs libaom default_scan_8x4");
13496+ }
13497+
13462 /// `is_uni_comp_ref` (lane-av1comp): a pair is unidirectional exactly13498 /// `is_uni_comp_ref` (lane-av1comp): a pair is unidirectional exactly
13463 /// when both references sit on the same temporal side -- the three13499 /// when both references sit on the same temporal side -- the three
13464 /// `uni_comp_ref` bitstream pairs (LAST/LAST2, LAST/LAST3, LAST/GOLDEN)13500 /// `uni_comp_ref` bitstream pairs (LAST/LAST2, LAST/LAST3, LAST/GOLDEN)