forge
Explore
Log in

Don't you dare go Hollow

Lane-lr r7 charter

Browse files at this commit

e33c385375a351563c5df0f586eb3f062e6e8e3bAhmet Kaan GümüşParent: c4474e0
  • docs
    • lane-lr r7 charter
    • commit r6's SGR pin harness out of the reapable scratchpad
Show full message
docs(av1): lane-lr r7 charter; commit r6's SGR pin harness out of the reapable scratchpad
lanes/lr-r7.charter.mdadded+55 -0
@@ -0,0 +1,55 @@
1+# lane-lr r7 — one tap
2+
3+At e5ad671 (+ this charter). Read the r6 section of `lanes/lr.report.md`.
4+
5+## Where you stand — the search is down to one number
6+r6 linked libaom's real `av1_apply_selfguided_restoration_c` out of
7+`~/.cache/aom-oracle/build/libaom.a` and called it directly on OUR OWN
8+`lr_sample`-substituted bytes. It reproduced 194. That decisively rules out
9+`lr_sample` and the stripe boundary — r5's suspicion — and it rules out the
10+fast (`r0`) arm, whose `flt0` is bit-exact against real libaom.
11+
12+What is left: the dense (`r1`) arm. Eight of its nine A/B taps at the failing
13+pixel match a from-scratch box-sum of the real bytes; the combined `flt1` is
14+**3110 where libaom gets 3109**. One tap, or a rounding mode.
15+
16+r6's harness is now committed at `scripts/lr-sgr-pin-harness.c` — it lived in
17+the scratchpad, which this box reaps (class `oracle-in-reaped-dir`). Use and
18+extend it.
19+
20+## Do not
21+- Re-suspect `lr_sample` or the stripe boundary. Proven correct.
22+- Re-suspect the fast arm. Proven bit-exact.
23+- Hand-trace further. Three rounds have now shown our arithmetic is
24+ self-consistent with our own output; only libaom's own intermediate values
25+ can break the tie.
26+
27+## Do
28+r6 named the two ways to get per-tap ground truth, and preferred the first:
29+1. `calculate_intermediate_result` and `boxsum1` are `static` in libaom's
30+ `restoration.c`, so they cannot be called from the harness as-is. Patch them
31+ non-static in the oracle copy and rebuild (~5 min) — the same pattern
32+ `scripts/instrument-aom-oracle.sh` already uses for the trace rungs, so add
33+ it there as an env-gated rung rather than an ad-hoc edit, and it stays
34+ reusable.
35+2. Or bisect single input pixels through the existing harness until the tap
36+ that diverges identifies itself.
37+
38+Then fix it, get the gate green, COMMIT immediately.
39+
40+## Then
41+Wiener and self-guided are otherwise feature-complete with the refusal already
42+dropped, so once green this lane is ready to merge. Before it does: confirm
43+`gate_coverage.rs`'s `NEVER_EXERCISED` no longer needs `enable-restoration`
44+(main's copy — down to `enable-intrabc` alone as of this batch), and consider
45+`git merge main` here first and resolving it yourself; main is at 93d9510 and
46+has landed multi-tile decode, CDEF index reads, chroma modes, a `bit_depth != 8`
47+refusal and three reworded partition refusals since this branch forked. Report
48+every refusal string you add, rename or remove, verbatim.
49+
50+Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-lr`; foreground
51+`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms. Sibling
52+worktrees have live agents — never build in or edit them. Never push, never
53+merge into `main`. 75-turn cap, does not reset: COMMIT AT EVERY GREEN STEP, and
54+commit any harness or instrument you build — a scratchpad is not storage.
55+Update `lanes/lr.report.md` with an r7 section, VERDICT first.
scripts/lr-sgr-pin-harness.cadded+48 -0
@@ -0,0 +1,48 @@
1+#include <stdio.h>
2+#include <stdint.h>
3+#include <stdlib.h>
4+
5+extern int av1_apply_selfguided_restoration_c(
6+ const uint8_t *dat8, int width, int height, int stride, int eps,
7+ const int *xqd, uint8_t *dst8, int dst_stride, int32_t *tmpbuf,
8+ int bit_depth, int highbd);
9+extern int av1_selfguided_restoration_c(const uint8_t *dgd8, int width,
10+ int height, int dgd_stride,
11+ int32_t *flt0, int32_t *flt1,
12+ int flt_stride, int sgr_params_idx,
13+ int bit_depth, int highbd);
14+
15+int main(void) {
16+ const int bw = 102, bh = 10;
17+ // real libaom splits stripe_width into RESTORATION_PROC_UNIT_SIZE=64
18+ // chunks (sgrproj_filter_stripe's `for j += procunit_width` loop) --
19+ // av1_apply_selfguided_restoration_c's internal fixed-size arrays are
20+ // sized for that max, so replicate the chunking (target col=6 is in
21+ // the first 64-wide chunk).
22+ const int w = 64, h = 4;
23+ uint8_t *buf = malloc(bw * bh);
24+ FILE *f = fopen("/tmp/lr_full.bin", "rb");
25+ if (!f) { perror("open"); return 1; }
26+ if (fread(buf, 1, bw * bh, f) != (size_t)(bw * bh)) { fprintf(stderr, "short read\n"); return 1; }
27+ fclose(f);
28+
29+ const uint8_t *dgd8 = buf + 3 * bw + 3; // logical (0,0)
30+ int xqd[2] = { -16, -32 };
31+ uint8_t dst[w * h];
32+ // flt1 = tmpbuf + RESTORATION_UNITPELS_MAX (~152100); undersizing this
33+ // segfaults inside av1_apply_selfguided_restoration_c.
34+ static int32_t tmpbuf[2 * 400 * 400];
35+
36+ int ret = av1_apply_selfguided_restoration_c(dgd8, w, h, bw, /*eps=*/6, xqd,
37+ dst, w, tmpbuf, 8, 0);
38+ printf("ret=%d\n", ret);
39+ // target pixel: row i=1, col j=6
40+ printf("out[1][6] = %d\n", dst[1 * w + 6]);
41+ printf("dgd[1][6] = %d\n", dgd8[1 * bw + 6]);
42+
43+ static int32_t flt0[400 * 400], flt1[400 * 400];
44+ int r2 = av1_selfguided_restoration_c(dgd8, w, h, bw, flt0, flt1, w, 6, 8, 0);
45+ printf("selfguided ret=%d flt0[1][6]=%d flt1[1][6]=%d\n", r2, flt0[1 * w + 6],
46+ flt1[1 * w + 6]);
47+ return 0;
48+}