forge
Explore
Log in

Don't you dare go Hollow

A 4-sample-wide prediction block reads the REGULAR narrow subpel kernel under EIGHTTAP_SHARP too (spec 7.11.3.4 filterIdx, av1_interp_4tap[MULTITAP_SHARP] == av1_sub_pel_filters_4) -- we used the 8-tap sharp kernel there, which only ever bit the 4x4 chroma of an 8x8 leaf

Browse files at this commit

06a5eacdf8e571b589b0d5676ad1e12aa5bfe40dAhmet Kaan GümüşParent: d1963fa
  • fix
    • a 4-sample-wide prediction block reads the REGULAR narrow subpel kernel under EIGHTTAP_SHARP too (spec 7.11.3.4 filterIdx, av1_interp_4tap[MULTITAP_SHARP] == av1_sub_pel_filters_4) -- we used the 8-tap sharp kernel there, which only ever bit the 4x4 chroma of an 8x8 leaf
    • both 8x8-leaf motion gates go pixel-exact 24/24 frames at 8- and 10-bit, suite 271/2 -> 273/0
Show full message
fix(av1): a 4-sample-wide prediction block reads the REGULAR narrow subpel kernel under EIGHTTAP_SHARP too (spec 7.11.3.4 filterIdx, av1_interp_4tap[MULTITAP_SHARP] == av1_sub_pel_filters_4) -- we used the 8-tap sharp kernel there, which only ever bit the 4x4 chroma of an 8x8 leaf; both 8x8-leaf motion gates go pixel-exact 24/24 frames at 8- and 10-bit, suite 271/2 -> 273/0
crates/ec-av1/src/mc.rsmodified+35 -3
@@ -119,8 +119,11 @@ const SUBPEL_FILTERS_SMOOTH_4: [[i32; 8]; 16] = [
119 [0, 0, 2, 34, 62, 30, 0, 0],119 [0, 0, 2, 34, 62, 30, 0, 0],
120 ];120 ];
121 121
122-/// `Subpel_Filters[EIGHTTAP_SHARP]` (`av1_sub_pel_filters_8sharp`) -- unlike122+/// `Subpel_Filters[EIGHTTAP_SHARP]` (`av1_sub_pel_filters_8sharp`). A block
123-/// REGULAR/SMOOTH, spec 7.11.3.4 never swaps this for a narrow-block table.123+/// whose dimension is 4 or less does NOT read this table: spec 7.11.3.4's
124+/// `filterIdx` sends both EIGHTTAP and EIGHTTAP_SHARP to filter index 4, and
125+/// libaom agrees -- `av1_interp_4tap[MULTITAP_SHARP]` is `av1_sub_pel_filters_4`,
126+/// the REGULAR narrow kernel (`filter.h:243`), not a sharp one (lane-gmaffine r5).
124 const SUBPEL_FILTERS_SHARP: [[i32; 8]; 16] = [127 const SUBPEL_FILTERS_SHARP: [[i32; 8]; 16] = [
125 [0, 0, 0, 128, 0, 0, 0, 0],128 [0, 0, 0, 128, 0, 0, 0, 0],
126 [-2, 2, -6, 126, 8, -2, 2, 0],129 [-2, 2, -6, 126, 8, -2, 2, 0],
@@ -181,7 +184,7 @@ impl InterpFilterKind {
181 match self {184 match self {
182 InterpFilterKind::Regular => (&SUBPEL_FILTERS, &SUBPEL_FILTERS_4),185 InterpFilterKind::Regular => (&SUBPEL_FILTERS, &SUBPEL_FILTERS_4),
183 InterpFilterKind::Smooth => (&SUBPEL_FILTERS_SMOOTH, &SUBPEL_FILTERS_SMOOTH_4),186 InterpFilterKind::Smooth => (&SUBPEL_FILTERS_SMOOTH, &SUBPEL_FILTERS_SMOOTH_4),
184- InterpFilterKind::Sharp => (&SUBPEL_FILTERS_SHARP, &SUBPEL_FILTERS_SHARP),187+ InterpFilterKind::Sharp => (&SUBPEL_FILTERS_SHARP, &SUBPEL_FILTERS_4),
185 InterpFilterKind::Bilinear => (&SUBPEL_FILTERS_BILINEAR, &SUBPEL_FILTERS_BILINEAR),188 InterpFilterKind::Bilinear => (&SUBPEL_FILTERS_BILINEAR, &SUBPEL_FILTERS_BILINEAR),
186 }189 }
187 }190 }
@@ -854,6 +857,35 @@ mod tests {
854 }857 }
855 858
856 #[test]859 #[test]
860+ /// lane-gmaffine r5 root cause: a block 4 or fewer samples wide reads
861+ /// `Subpel_Filters[4]` -- the REGULAR narrow kernel -- for BOTH
862+ /// `EIGHTTAP` and `EIGHTTAP_SHARP` (spec 7.11.3.4's `filterIdx`, libaom
863+ /// `av1_interp_4tap[MULTITAP_SHARP] == av1_sub_pel_filters_4`,
864+ /// `filter.h:243`). We used the 8-tap sharp kernel there, which is
865+ /// invisible above 4 samples and so only ever bit the 4x4 chroma of an
866+ /// 8x8 (or smaller) luma leaf.
867+ #[test]
868+ fn a_narrow_block_reads_the_regular_four_tap_kernel_under_every_sharpness() {
869+ use crate::mc::{SUBPEL_FILTERS_4, SUBPEL_FILTERS_BILINEAR, SUBPEL_FILTERS_SMOOTH_4};
870+ for kind in [
871+ InterpFilterKind::Regular,
872+ InterpFilterKind::Smooth,
873+ InterpFilterKind::Sharp,
874+ InterpFilterKind::Bilinear,
875+ ] {
876+ let (wide, narrow) = kind.tables();
877+ let want: &[[i32; 8]; 16] = match kind {
878+ InterpFilterKind::Regular | InterpFilterKind::Sharp => &SUBPEL_FILTERS_4,
879+ InterpFilterKind::Smooth => &SUBPEL_FILTERS_SMOOTH_4,
880+ InterpFilterKind::Bilinear => &SUBPEL_FILTERS_BILINEAR,
881+ };
882+ assert_eq!(narrow, want, "{kind:?}: wrong narrow-block kernel");
883+ if kind == InterpFilterKind::Sharp {
884+ assert_ne!(wide, narrow, "sharp's wide kernel is not its narrow one");
885+ }
886+ }
887+ }
888+
857 fn integer_mv_is_identity() {889 fn integer_mv_is_identity() {
858 let width = 12;890 let width = 12;
859 let height = 12;891 let height = 12;
lanes/gmaffine-r5.report.mdadded+82 -0
@@ -0,0 +1,82 @@
1+# lane-gmaffine r5 — the 8x8-leaf chroma residue was the NARROW-BLOCK SHARP interp filter
2+
3+Commit on `lane-gmaffine`, on top of r4 (`f5e1851`). Suite (before the new unit test,
4+after the fix): `EC_AV1_REQUIRE_AOMENC=1 cargo test --release -p ec-av1 --lib -j3` →
5+**273 passed, 0 failed, 24 ignored** (r4: 271/2/24 — the two 8x8 motion gates are the
6+delta, both now green at 8-bit AND 10-bit).
7+
8+## Root cause (one line, one table entry)
9+`mc.rs:187` `InterpFilterKind::Sharp => (&SUBPEL_FILTERS_SHARP, &SUBPEL_FILTERS_SHARP)`.
10+Spec 7.11.3.4's `filterIdx`: a prediction block 4 or fewer samples wide/high reads
11+`Subpel_Filters[4]` — the REGULAR narrow kernel — for BOTH `EIGHTTAP` and
12+`EIGHTTAP_SHARP`; libaom agrees literally (`filter.h:239-245`,
13+`av1_interp_4tap[MULTITAP_SHARP] == av1_sub_pel_filters_4`). We used the 8-tap sharp
14+kernel on the narrow axis, and the old doc comment above `SUBPEL_FILTERS_SHARP` asserted
15+as fact that "spec 7.11.3.4 never swaps this for a narrow-block table" — false.
16+Invisible above 4 samples, so it could only ever bite the 4x4 chroma of an 8x8 (or
17+smaller) luma leaf: exactly the blocks r4 left red. Fixed to
18+`(&SUBPEL_FILTERS_SHARP, &SUBPEL_FILTERS_4)`; all three MC paths
19+(`predict_with_filters`, `predict_scaled`, `predict_compound_intermediate`) resolve
20+their kernels through `InterpFilterKind::tables()`, so this one entry is the whole
21+sweep — grep of `SUBPEL_FILTERS_SHARP|SUBPEL_FILTERS_4|SUBPEL_FILTERS_SMOOTH_4` finds
22+no other consumer.
23+
24+## The two charter experiments, both answered NEGATIVE before the real cause
25+Experiment 1 (chroma inverse forced to `DCT_DCT`): pixel error went from 3 chroma
26+blocks to 25 in frame 1 (u/v byte diffs 40/45 → 270/259, whole-clip 3585 → 27819) —
27+the inherited 1D types are right and used right.
28+Then the decisive instrument: `~/.cache/gmaffine-r5/inv.c`, a C harness linking the
29+oracle's `libaom.a` and calling `av1_inv_txfm2d_add_4x4_c` directly (needs
30+`av1_rtcd()`/`aom_dsp_rtcd()` first, else the txfm func pointers are NULL and it
31+segfaults). Every distinct 4x4 dequantized grid our decoder produced on the gate
32+stream — 1476 blocks, 16 distinct tx types incl. 246 `H_ADST` / 248 `H_DCT` /
33+59 `IDTX` — reproduces libaom's residual BIT-EXACT. The 4x4 inverse basis, the
34+identity scaling, the 1D-class scan and the nz ctx are therefore all exonerated;
35+so is Experiment 2 (the `ext_tx_used` clamp: this stream is `reduced_tx_set == 0`,
36+so the chroma 4x4 inter set is `EXT_TX_SET_ALL16`, which contains `H_ADST` — the
37+clamp is inert here; `side >= 32` stand-in left as-is, see residue).
38+With the transform exonerated the residual is right, so the error had to be the
39+chroma PREDICTION — one 4-sample-wide MC block.
40+
41+EVIDENCE: `/home/user/.cache/gmaffine-r5/{gm1_cq32.obu,ours.yuv,ref.yuv,f2.yuv,diff.py}`
42+| `gen.sh 32 1` reproduced the gate's own 8-bit cq32 stream twice, sha256
43+`22d09738baab612910c83106cb4fefe860ed20de1b2a01b36c5d3c717d5b18bc` both times (r4's
44+hash); `EC_PROBE_DUMP=… decode_probe gm1_cq32.obu` vs `ffmpeg -i … -pix_fmt yuv420p`
45+| before: 3585 differing bytes over 24 frames (luma 0, U/V only, first block chroma
46+(8,12) frame 1); after the one-entry fix: **0 differing bytes, all 24 frames, all 3
47+planes**.
48+
49+EVIDENCE: `/home/user/.cache/gmaffine-r5-suite.log` | `EC_AV1_REQUIRE_AOMENC=1
50+cargo test --release -p ec-av1 --lib -j3` | `test result: ok. 273 passed; 0 failed;
51+24 ignored` in 545s.
52+
53+EVIDENCE: same log + `cargo test … -- 8x8_leaf` | both lane gates run at 8-bit and
54+10-bit | `a_real_globalmv_8x8_leaf_stream_decodes_pixel_exact ... ok`,
55+`a_real_warped_causal_8x8_leaf_stream_decodes_pixel_exact ... ok`,
56+sibling `a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact ... ok`
57+(its 10-bit twin stays `#[ignore]`d from lane-inter8 r2, untouched by this round).
58+
59+## Refusals
60+The GLOBALMV / WARPED_CAUSAL 8x8-leaf refusals r1 removed are now PROVEN by two green
61+real-aomenc gates that hard-assert `globalmv_hits_8` / `warp_hits_8` at both depths —
62+the r4 deviation (not restoring them) resolves in favour of the lift. No further
63+`refusal_inventory.rs` / `gate_coverage.rs` edit was needed this round; both tests are
64+green (`refusal_inventory::tests::*` 5 passed).
65+
66+## Runnable check left
67+`mc.rs::tests::a_narrow_block_reads_the_regular_four_tap_kernel_under_every_sharpness`
68+pins the narrow kernel of all four `InterpFilterKind`s against spec 7.11.3.4.
69+Run: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-gmaffine EC_NOMEMGUARD=1 cargo test
70+--release -p ec-av1 --lib -- mc::tests` → 8 passed, 0 failed.
71+
72+## Residue
73+- `read_plane`'s `side >= 32` stand-in for `av1_get_ext_tx_set_type`'s
74+ `av1_ext_tx_used` membership — accepted for now: it is exact for every set this
75+ decoder currently reaches (`reduced_tx_set == 0` inter/intra at ≤16 is ALL16/INTRA_1,
76+ both of which contain every type the CDF can emit), and no gate can distinguish it
77+ until a `reduced_tx_set == 1` inter stream is gated. deferred(a `--reduced-tx-type-set=1`
78+ aomenc gate) — not a defect this round could measure.
79+- Instrumentation from this round was removed before commit (the `EC_EXP1`/`EC_EXP_DUMP`
80+ hooks in `decode.rs` and `EC_TX_DUMP` in `transform.rs`); the C oracle harness lives
81+ outside the repo at `~/.cache/gmaffine-r5/inv.c` and is worth keeping — it is the
82+ only instrument that can settle "is our inverse transform the defect?" in one run.