forge
Explore
Log in

Don't you dare go Hollow

Lane-hbd r7 report -- CDEF pri-tap coeff_shift root cause, gate closed

Browse files at this commit

f646bbd322e3ad65fd636a9a67834b8c3e6c3946Ahmet Kaan GümüşParent: d8be076
  • docs
    • lane-hbd r7 report -- CDEF pri-tap coeff_shift root cause, gate closed
Show full message
docs(av1): lane-hbd r7 report -- CDEF pri-tap coeff_shift root cause, gate closed
lanes/hbd-r7.report.mdadded+86 -0
@@ -0,0 +1,86 @@
1+# lane-hbd round 7 report
2+
3+## Step 1: gate on d6bd69a (CDEF fix, unmeasured going in)
4+
5+`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib a_real_aomenc_10bit_stream_decodes_pixel_exact -- --nocapture`
6+(fixed the `-j4` flag placement -- it belongs before `--`, not after, as a
7+libtest arg; `cargo test -j4 -p ec-av1 --lib ... -- --nocapture`)
8+
9+Diff count: **1 of 4096 luma pixels off by exactly 1** (down from round 6's
10+32). Chroma (U, V) exact. `left: [..., 328, ...] right: [..., 327, ...]`,
11+extracted via the python re.search method.
12+
13+EVIDENCE: /tmp/gate_r7.log | cargo test -j4 -p ec-av1 --lib a_real_aomenc_10bit_stream_decodes_pixel_exact -- --nocapture | 1/4096 luma pixels differ by 1, chroma untested (Y assert panics first)
14+
15+## Step 2: geometry
16+
17+Added a temporary per-plane diff dump (`HBD_R7_YDIFF`/`UDIFF`/`VDIFF`, since
18+reverted) before the asserts to get all three planes' diffs without the
19+first `assert_eq!` short-circuiting. Result: `Y: [(x=1, y=34, ours=328,
20+theirs=327)]`, `U: []`, `V: []` -- a single luma pixel, near the left frame
21+edge (x=1), row 34 (inside CDEF 8x8 block row 4, i.e. rows 32-39), not on
22+an LR-unit or CDEF-block corner.
23+
24+EVIDENCE: /tmp/gate_r7c.log (dump run) | cargo test -j4 -p ec-av1 --lib a_real_aomenc_10bit_stream_decodes_pixel_exact -- --nocapture | HBD_R7_YDIFF [(1, 34, 328, 327)], U/V empty
25+
26+## Step 3: root cause -- checked against `~/.cache/aom-oracle/src/av1/common/cdef_block.c` and `cdef.h`
27+
28+Ruled out, all verified line-for-line against libaom source (not rebuilt,
29+read only):
30+- `cdef.h:61` `constrain()` -- matches `cdef_constrain` exactly.
31+- `cdef_block.c:57-110` `cdef_find_dir_c` -- matches `cdef_find_dir` exactly
32+ (partial-sum accumulation, div_table, cost formula, `>>128` centring).
33+- `cdef_block.c:250-256` frame-boundary `CDEF_VERY_LARGE` fill -- matches
34+ our `ny<0||nx<0||...>=true_w/h` boundary check; this 64x64 fixture is
35+ exactly one superblock so every frame edge coincides with the SB edge,
36+ same as libaom's `frame_boundary[LEFT/RIGHT/TOP/BOTTOM]` gating.
37+- `cdef_block.c:135` `Cdef_Directions` table -- byte-for-byte identical to
38+ our `CDEF_DIRECTIONS`.
39+- `cdef_block.c:190` output rounding `(8 + sum - (sum<0)) >> 4` -- identical
40+ to ours.
41+- `cdef_block.c:289-292` `adjust_strength` -- identical; and `cdef_block.c:388`
42+ confirms it's luma-only (`pli ? pri_strength : adjust_strength(...)`,
43+ matching our chroma path skipping it).
44+- `cdef_block.c:352-360` direction reuse for 4:2:0 chroma (`xdec==ydec`, no
45+ `conv422`/`conv440` remap) -- matches our shared `dir`/`uv_dir` reuse.
46+
47+**Root cause found**: `cdef_block.c:147`
48+`pri_taps = cdef_pri_taps[(pri_strength >> coeff_shift) & 1]` -- libaom
49+right-shifts `pri_strength` by `coeff_shift` *before* reading the tap-set
50+parity bit, because `pri_strength` (and its `adjust_strength` derivative)
51+was pre-shifted `<< coeff_shift` for the bit-depth scale up in
52+`av1_cdef_filter_fb`. Our `cdef_filter_block` read `pri_strength & 1`
53+directly. For 8-bit (`coeff_shift == 0`) this is a no-op and every existing
54+8-bit gate stayed exact by construction. For 10-bit (`coeff_shift == 2`),
55+`pri_strength` is always a multiple of 4, so `pri_strength & 1` was always
56+0 -- CDEF silently always used primary tap set `{4,2}` instead of `{3,3}`
57+whenever the true (unshifted) strength level was odd. This only produces a
58+visible pixel difference where the wrong tap set actually changes the
59+clamped/rounded output, which explains the very sparse (1/4096) residue.
60+
61+Fix: threaded `coeff_shift` into `cdef_filter_block` and changed the index
62+to `(pri_strength >> coeff_shift) & 1`, matching libaom exactly. Both call
63+sites (luma, chroma) updated. Commit `7e007da`.
64+
65+## Step 1 re-run after the fix
66+
67+`cargo test -j4 -p ec-av1 --lib a_real_aomenc_10bit_stream_decodes_pixel_exact -- --nocapture`
68+-> **0 diffs, all three planes** (`HBD_R7_YDIFF []`, `UDIFF []`, `VDIFF []`),
69+`test result: ok`.
70+
71+EVIDENCE: /tmp/gate_r7c.log | cargo test -j4 -p ec-av1 --lib a_real_aomenc_10bit_stream_decodes_pixel_exact -- --nocapture | test result: ok. 1 passed; 0 failed
72+
73+Temporary diff-dump instrumentation reverted from `stream.rs` before commit
74+(the gate's own three `assert_eq!`s are the permanent check).
75+
76+## Step 3: full suite
77+
78+(filled in below once run)
79+
80+## Step 4: workspace check
81+
82+(filled in below once run)
83+
84+## Step 5: decode_probe on real films
85+
86+(filled in below once run)