From 28382aa3a2f02f2f55024a2f692ce2c55fa19a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Sep 2026 08:55:22 +0300 Subject: [PATCH] docs(kf1200): r2 report -- skipped-CfL root cause, gate, census 11/24, suite 378/0 --- lanes/COMMON-20260901.md | 6 ++ lanes/kf1200-r2.report.md | 183 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 lanes/kf1200-r2.report.md diff --git a/lanes/COMMON-20260901.md b/lanes/COMMON-20260901.md index 07c3a305..517ff4f0 100644 --- a/lanes/COMMON-20260901.md +++ b/lanes/COMMON-20260901.md @@ -100,3 +100,9 @@ If you ran it: extract your own hunks, `git checkout -- crates/`, re-apply. never two suites per lane; film extracts ≤2 s; a watchdog (`ec-memwatch` user unit, log `$HOME/.cache/ec-memwatch.log`) SIGKILLs any codec/test process above 6 GiB RSS or the largest one when MemAvailable < 3 GiB — a killed run means YOUR command exceeded the budget: bound it, do not retry as-is. + +## WORKTREE SETUP (2026-09-02, three lanes lost a round to this) +A new worktree needs the TOP-LEVEL fixtures symlink: `ln -s /home/user/Documents/Code/Rust/edith_codecs/fixtures /fixtures`. +Without it exactly one gate fails: a_real_aomenc_stream_with_film_grain_decodes_pixel_exact with Os NotFound — it is NOT a decode defect. +New files under crates/ec-av1/fixtures/ need `git add -f` (bare `fixtures` in .gitignore); verify with `git ls-files`. +Commit-msg hook rejects film titles / home paths: describe streams by codec/resolution/bit depth. diff --git a/lanes/kf1200-r2.report.md b/lanes/kf1200-r2.report.md new file mode 100644 index 00000000..e574a54d --- /dev/null +++ b/lanes/kf1200-r2.report.md @@ -0,0 +1,183 @@ +# lane-kf1200 r2 — a skipped sub-8x8 chroma block dropped its CfL alpha + +## 1. Merge + +`git merge --no-commit main` (main `85887c7`, lane-mvtwin + lane-sb128b) — clean +auto-merge, no conflicts. `crates/ec-av1/src/cdf.rs` byte-identical to main's +(`cmp <(git show main:.../cdf.rs) .../cdf.rs` → identical). r1's pair-mi chroma +edge-filter fix and its counter survive at `decode.rs:7747`. Commit `d85d7d2`. +main contains neither lane-reelckf nor lane-kf900 (`git log --oneline main | grep` +→ empty for both), so no duplicate-implementation resolution was needed and the +multi-million-byte census rows are still lane-kf900's territory. + +## 2. Defect found and fixed: `-ss 300`, 463 bytes → 0 + +Re-measured premise on this branch (1-frame truncation, hash stable twice): +U 219 / V 220 samples wrong, Y exact. `EC_AV1_PREFILT_DUMP16` ours vs aomdec's: +227 U + 227 V wrong **before the loop filter**, in a 16x16 chroma region at +chroma `(384,412)` — reconstruction, not filters. + +First bad sample chroma `(412,384)` = the 4x4 chroma block of the `BLOCK_4X4` +2x2 group at luma mi `(206,192)`. aomdec `EC_TRACE_MODE`: +`EC_IMODE_VAL mi_row=207 mi_col=193 mode=4 uv_mode=13 skip=1` — `uv_mode = 13` +is `UV_CFL_PRED`, `skip_txfm = 1`. Our `OUR_PRED x=384 y=412 side=4 mode=0 +sum=8240 row0=[515,515,515,515]` is flat: DC with **no CfL term at all** +(aomdec's own prediction sums to 8241 with a bottom-left ramp). + +Root cause: both sub-8x8 leaf decoders passed a literal `None` for the CfL +argument in their `skip_txfm` arm — + +- `crates/ec-av1/src/decode.rs:10554/10555` (the 4-leaf `BLOCK_4X4` group) +- `crates/ec-av1/src/decode.rs:10916/10917` (the 2-leaf group) + +libaom's `av1_predict_intra_block_facade` (`av1/common/reconintra.c:1719`) calls +`cfl_predict_block` whenever `mbmi->uv_mode == UV_CFL_PRED`; `skip_txfm` only +suppresses the residual, never the alpha. Both arms now compute +`cfl_ac_q3(y, gpx, gpy, 8)` and pass `alpha.zip(ac)`, exactly like the +non-skip arm two lines below and like the rect skip arms already did. + +### Class sweep + +Every chroma `reconstruct` / `reconstruct_rect` call site in `decode.rs` was +parsed and its cfl argument printed (script in the r2 scratchpad). The rect +skip arms (`6015`, `6519`, `8078`) already pass `alpha.zip(ac)`; the only other +literal `None` is `20284/20296`, which sits directly behind the refusal +"a non-DC chroma mode on an 8x8 inter-frame leaf" (`decode.rs:20212`), so +`uv_mode == DC_PRED` is guaranteed there. No other instance of the class. + +### Counter + gate + +- `decode.rs:2207` `SKIP_CFL_HITS` / `pub fn skip_cfl_hits()` — skipped sub-8x8 + chroma blocks that carried a CfL alpha. +- `crates/ec-av1/src/stream.rs` + `the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact` — pins + `crates/ec-av1/fixtures/reelb_ss300_key_frame.obu` (139 201 B, sha256 + `7e3ddf0d602f9496b2f7eb11f051fd4a045020e094d5bc02f83825e2c494ef12`, one + 3840x1608 yuv420p10le key frame), decodes it, HARD-asserts + `skip_cfl_hits > 0`, then compares Y/U/V against ffmpeg's own 10-bit decode. + `git add -f` was used (bare `fixtures` in .gitignore); `git ls-files` confirms + it is tracked. + +Why a fixture and not an aomenc recipe: lane-reelckf r1's ledger dead-end — +20 recipes (cq 40..63 × nine lavfi sources, min/max-partition sweeps, sb-size +64 and 128) never produced a **skipped** sub-8x8 CfL block (`skip_cfl` counter +0 in all). The shape fires exactly **once** in a whole 4K key frame, which is +why no synthetic source reaches it. + +No refusal lifted → `refusal_inventory.rs` / `gate_coverage.rs` unchanged. + +## 3. Remaining residuals — triaged, one class + +`-ss 600 / 2400 / 3300 / 5700` (48771 / 42343 / 39971 / 16375 bytes) are ONE +defect class, not four: in every one of them the damage is confined to the +**last 8 luma rows** of the frame. + +| -ss | Y rows wrong | U/V rows | first bad Y sample | +|----:|---|---|---| +| 600 | 1595..1607 | 796..803 | (1595, 2916) | +| 2400 | 1595..1607 | 796..803 | (1595, 2445) | +| 3300 | 1595..1607 | 796..803 | (1595, 1235) | +| 5700 | 1596..1607 | 796..803 | (1596, 3039) | + +`EC_AV1_PREFILT_DUMP16` on `-ss 600` narrows it further: pre-loop-filter the +damage is exactly rows **1600..1607**, columns **192..3839** (rows 1595..1599 +in the final picture are deblock spill across the y=1600 edge). The frame is +1608 rows = 25 full 64-px superblock rows + one 8-row remainder, so this is the +bottom **partial** superblock row, and the first three superblocks of it +(columns 0..191) are pixel-exact. + +Divergence localised to a single block. Through luma mi `(400,47)` our +prediction trace matches aomdec's block for block (mi 44: four TX_4X4 in an +8x8; mi 46: 8x8 — `EC_PRED mi_row=400 mi_col=46 txw=8 txh=8`). At the very +first block of superblock #3: + +- aomdec: `EC_PRED mi_row=400 mi_col=48 txw=16 txh=8 mode=2 p_angle=180 bsize=5 part=1 ft=1` +- ours: `OUR_PRED x=192 y=1600 bw=32 bh=16 mode=0 ad=0` (decode.rs:6511) + +i.e. we read a 32x16 `PARTITION_HORZ` where libaom reads a 16x8, and the mode +differs too — a **partition-symbol divergence at the root of a partial-height +superblock** (`has_rows == false`, only 2 of 16 mi rows present), not a +prediction bug and not caused by the preceding block. Everything after it in +that row is garbage because the row never re-syncs (it is the last row, so +nothing propagates downward). + +`-ss 4800` (2348 bytes in r1, **34 bytes** after this round's CfL fix) is a +different, much smaller shape: chroma only, +U 29 + V 5 samples in the final picture. `EC_AV1_PREFILT_DUMP16` puts it +**pre-loop-filter** too — U 25 + V 3 samples in an **8x4 chroma patch** at +rows 540..543, cols 1200..1207 (`|d| <= 6`), luma exact. That is the same +geometry as r1's defect (an 8x4 chroma block = the chroma half of a 16x8 +`PARTITION_HORZ_4` pair) at luma mi ~`(270,600)`, so it is a strong candidate +for a sibling of the pair-mi bug rather than a new class. + +## 4. Disposition + +- fix-now (done): `-ss 300` skipped-CfL, fixed + gated + swept. +- deferred: the bottom partial-superblock partition divergence (`-ss 600`, + 2400, 3300, 5700). Unblocked by: a range ladder over the partition symbols + of superblock `(mi_row=400, mi_col=48)` in `s600_f1.obu` comparing aomdec's + `r->ec.rng` at `EC_IMODE` against ours — the first three superblocks of the + same row are exact, so the ladder starts already in sync at mi 400/47. +- deferred: `-ss 4800` (34 B, down from 2348) — stage-attributed (pre-loop-filter, chroma-only, + 8x4 patch at chroma (540,1200), luma mi ~(270,600)); the per-block + `EC_IMODE_VAL`/`EC_PRED` comparison at that mi is the next step. +- accepted: `-ss 900 / 1500 / 2100 / 2700 / 3900 / 6000 / 6300 / 6600` + (multi-million bytes) are lane-kf900's entropy desyncs, not merged into main. + +## 5. 24 key-frame census (bytes differing vs ffmpeg, 1 truncated frame each) + +Recipe: `$HOME/.cache/kf1200-census-r2.log` (script `census.sh` in the r2 +scratchpad) — `ffmpeg -ss S -t 0.4 -c:v copy -f obu`, `trunc.py … 1`, each +stream sha256'd twice (identical in all 24 rows), `EC_PROBE_OUT16` vs +`ffmpeg -pix_fmt yuv420p10le`. + +| -ss | r1 (after pair-mi fix) | r2 (after skipped-CfL fix) | +|----:|-----------------------:|---------------------------:| +| 0 | 0 | 0 | +| **300** | **463** | **0** | +| 600 | 48771 | 48771 | +| 900 | 14057191 | 14057191 | +| 1200 | 0 | 0 | +| 1500 | 16649650 | 16649650 | +| 1800 | 0 | 0 | +| 2100 | 15147782 | 15148697 | +| 2400 | 42343 | 42343 | +| 2700 | 7726287 | 7726168 | +| 3000 | 0 | 0 | +| 3300 | 39971 | 39971 | +| 3600 | 0 | 0 | +| 3900 | 7554023 | 7554023 | +| 4200 | 0 | 0 | +| 4500 | 0 | 0 | +| **4800** | **2348** | **34** | +| 5100 | 0 | 0 | +| 5400 | 0 | 0 | +| 5700 | 16375 | 16375 | +| 6000 | 15449720 | 15449720 | +| 6300 | 15410864 | 15410664 | +| 6600 | 15181688 | 15180826 | +| 6900 | 0 | 0 | + +**11 of 24 key frames now decode pixel-exact** (was 10). `-ss 300` is exact; +`-ss 4800` fell 2348 → 34 bytes (its remaining 8x4 chroma patch is the residue +described in §3). Rows differing by a few hundred bytes inside the +multi-million-byte segments are the usual desync churn of lane-kf900's +territory, not a regression: none of them changed sign or magnitude class. + +## 6. Suite + +`cargo test -p ec-av1 --lib` under `systemd-run --user --unit=kf1200-suite-r2b +-p MemoryMax=10G`, `EC_AV1_REQUIRE_AOMENC=1 EC_NOMEMGUARD=1 -j3`, log +`$HOME/.cache/kf1200-suite-r2.log`: +**378 passed / 0 failed / 33 ignored**, 794.95 s. + +## EVIDENCE + +EVIDENCE: $HOME/.cache/kf1200-suite-r2.log | systemd unit kf1200-suite-r2b, EC_AV1_REQUIRE_AOMENC=1, cargo test -p ec-av1 --lib -j3 | test result: ok. 378 passed; 0 failed; 33 ignored; 794.95s +EVIDENCE: scratchpad/kf1200/{o300,r300} | 1-frame -ss 300 truncation (sha256 7e3ddf0d602f9496 twice), EC_PROBE_OUT16 vs ffmpeg -pix_fmt yuv420p10le | before fix Y 0 / U 219 / V 220 samples differ; after fix Y 0 / U 0 / V 0 +EVIDENCE: scratchpad/kf1200/{pre300.f0,apre300.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec, same stream | 227 U + 227 V wrong PRE-loop-filter in a 16x16 chroma region at (384,412) => reconstruction +EVIDENCE: scratchpad/kf1200/{o300.trace,a300.trace} | EC_PRED=1 ours, EC_TRACE_MODE=1 EC_PRED=1 aomdec | aomdec EC_IMODE_VAL mi_row=207 mi_col=193 uv_mode=13 (UV_CFL_PRED) skip=1; ours OUR_PRED x=384 y=412 side=4 mode=0 sum=8240 flat (no CfL term) +EVIDENCE: gate run `cargo test -p ec-av1 --lib the_reelb_ss300 -- --nocapture` | pinned 1-frame fixture + ffmpeg 10-bit reference | "1 skipped sub-8x8 CfL chroma blocks, frame pixel-exact", 1 passed / 0 failed +EVIDENCE: scratchpad/kf1200/{pre600.f0,apre600.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec on the -ss 600 1-frame stream | damage exactly luma rows 1600..1607, cols 192..3839 = the bottom partial (8-row) superblock row from superblock #3 on +EVIDENCE: scratchpad/kf1200/{o600.trace,a600p.trace} | EC_PRED both decoders | mi (400,44) and (400,46) match block for block; at mi (400,48) aomdec txw=16 txh=8 mode=2 bsize=5 vs ours bw=32 bh=16 mode=0 => partition divergence at the partial-SB root +EVIDENCE: $HOME/.cache/kf1200-census-r2.log | census.sh, 24 key frames, each stream hashed twice | 11/24 pixel-exact (was 10); -ss 300 463->0, -ss 4800 2348->34