edith_codecs
Clone
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
lane-kf900 r1 HANDOFF — mid-frame entropy desync on the 4K 10-bit AV1 key frames
Tip: 81b16cc on lane-kf900 (worktree /home/user/Documents/Code/Rust/edith_codecs-kf900,
base 18bf7dc = main tip at start, no rebase needed).
ROOT CAUSE (fixed)
crates/ec-av1/src/decode.rs, decode_leaf8 tail — was:
neighbours.fill_lf_grid(leaf_mi, 2, 8, 0); // literal block side
now neighbours.fill_lf_grid(leaf_mi, 2, resolved as u8, 0);
libaom calls set_txfm_ctxs(mbmi->tx_size, bw, bh, skip_txfm && is_inter_block(mbmi), xd)
(decodemv.c). For an INTRA block that skip term is always 0, so a skipped 8x8 intra
leaf whose tx_depth symbol resolved to TX_4X4 still publishes 4 to the next block's
get_tx_size_context (pred_common.h:342). Our tail wrote 8 for every 8x8 leaf,
including the skipped-and-split ones (decode_leaf8's non-skip resolved == 4 branch had
its own early return with the correct 4 — only the skip path fell through to the literal).
Consequence: the 8x16 strip below such a leaf computed tx_size_context_rect = 2 where
libaom computes 1, and read tx_size_cat1 row 2 instead of row 1 — same 3-symbol
alphabet, wrong CDF row (class wrong-alphabet-same-value). The msac range diverged
mid-frame, no refusal, everything after it garbage.
Evidence chain (all reproducible from /home/user/.cache/kf900/)
s900_1.obu(1 frame, sha256a273ae99328388be14a1ff8fa1c5a6d391a9948159eaef120e1b50e02015eb83, hashed twice from two independentffmpeg -ss 900 -t 2 -c:v copy -f obuextracts).- Pre-fix first bad luma sample: row 186 col 1803, delta 2, max |d| 929, 5405035 luma
samples differing. Pre-filter (
EC_AV1_PREFILT_DUMP16ours vs aomdec) first difference row 192 col 512 → recon, not loop filter. - Cross-decoder block ladder (new
EC_IMODErung, mirrors aomdecdecodemv.c:818): identical for 3543 blocks, first divergence entering mi (60,124). - Symbol ladder (
EC_TRACE_MODE_STEP, both sides) inside mi (60,122) — aBLOCK_8X16(aomdecbsize=4): identical throughfilter_intra_mode val=0 rng=33750, then aomdectx_depth val=0 ctx=1 cat=1 rng=53206, oursctx=2. - New
EC_TXCTXrung:mi_row=60 mi_col=122 w=8 h=16 above_px=8 left_px=16 ctx=2;above_pxshould be 4. NewEC_LFGRIDrung:mi_row=58 mi_col=122 w_mi=2 h_mi=2 tx_px=8written by the leaf above, which hadskip=1andtx_depth val=1(TX_4X4).
RESULT — 24 key frames, 1-frame truncation each, ours (EC_PROBE_OUT16) vs ffmpeg -pix_fmt yuv420p10le
bytes_before = census4 pre-fix all-plane byte diff; bytes_after = same, post-fix;
luma_after = differing luma samples post-fix. Every segment decodes OK (no refusal)
at 1 frame. Script: /home/user/.cache/kf900/census.sh, raw: /home/user/.cache/kf900/census.tsv.
| -ss | bytes_before | bytes_after | luma_after |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 300 | 463 | 463 | 0 |
| 600 | 48771 | 0 | 0 |
| 900 | 14057195 | 51272 | 0 |
| 1200 | 14 | 14 | 0 |
| 1500 | 16649701 | 108644 | 0 |
| 1800 | 248 | 248 | 0 |
| 2100 | 15147518 | 2383 | 0 |
| 2400 | 42343 | 0 | 0 |
| 2700 | 7726287 | 1243 | 0 |
| 3000 | 0 | 0 | 0 |
| 3300 | 44500 | 4529 | 0 |
| 3600 | 1 | 1 | 0 |
| 3900 | 7554020 | 8 | 0 |
| 4200 | 0 | 0 | 0 |
| 4500 | 0 | 0 | 0 |
| 4800 | 2348 | 2348 | 0 |
| 5100 | 0 | 0 | 0 |
| 5400 | 0 | 0 | 0 |
| 5700 | 0 | 0 | 0 |
| 6000 | 15450360 | 10207 | 0 |
| 6300 | 15410936 | 146881 | 0 |
| 6600 | 15181681 | 67588 | 0 |
| 6900 | 0 | 0 | 0 |
24/24 luma-exact. All remaining diffs are chroma-only.
OPEN RESIDUE
- Chroma-only defect (deferred — needs its own lane). On
s900_1.obuafter the fix: Y 0, U 266 samples (max |d| 23), V 47927 (max |d| 2). First at chroma (102,688) = luma (204,1376) = mi (51,344). It is pre-filter (pf/ours2.f0vspf/aom.f0: Y 0, U 228, V 47800 first at chroma row 102 col 689) → chroma reconstruction, not a loop filter. Luma being exact proves the entropy stream is exact, so this is a prediction/inverse-transform bug on one chroma path. Unblocked by: anEC_TRACE_COEFFplane-1/2 ladder at mi (51,344) — the entropy side is now a fixed reference. - The two new gate arms FAIL on their counter assert (
stream.rs, aftera_real_aomenc_multi_tile_intra_stream_...):a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_pixel_exactand its_10bit_twin. Both decode 6/6 attempts pixel-exact, butskip_split_tx_hits() == 0— the sharedgradients_sourceat 256x128 never makes aomenc pick a skipped 8x8 intra leaf that also splits its transform (skip wants the residual quantised away, TX_4X4 wants detail; the film has both at 4K). They are committed FAILING on purpose: an assert that never fires is thetool-disabled-in-every-gateclass, andskip_split_tx_hitswaspubwith zero callers anywhere before this round.
EXACT NEXT STEP
Sweep for a recipe, then keep or replace the assert:
$HOME/.cache/cargo-target-kf900/release/examples/decode_probe <stream.obu> now prints
skip_split_tx: N — sweep aomenc without rebuilding the test binary.
On the film's own frame it prints 15, so the counter is correct.
Suggested axes (none tried yet): 4K-ish frame sizes (the film's leaves are 8x8 inside 64x64
SBs at 3840 wide), --cpu-used=0, cq-level 40..58, and a source with fine detail plus
flat regions (mandelbrot, testsrc2 + noise=all_seed=N:alls=20), 8- and 10-bit arms.
If no recipe reaches it after a measured sweep (record every attempt), the charter's
fallback applies: commit crates/ec-av1/fixtures/reelb_kf900.obu (the 484640-byte
/home/user/.cache/kf900/s900_1.obu, sha256 above) plus a test that decodes it and
compares against a stored sha256 of the ffmpeg output (do not commit the yuv), and
assert skip_split_tx_hits() >= 15.
Suite: armed detached as user unit kf900-suite-r1, log $HOME/.cache/kf900-suite-r1.log.
Check with grep -E "^test result|FAILED" $HOME/.cache/kf900-suite-r1.log. Expect the two
new gate arms to be the failures until the recipe lands.
NOT DONE (charter items)
- deferred: block-position printing on refusal in
decode_probe(frame index, mi_row, mi_col, bsize) — not started, ran out of turns; unblocked by ~10 minutes ondecode.rs'sunsupported()call sites. - deferred:
refusal_inventory.rs/gate_coverage.rsupdates — this round lifted no refusal, so neither file needed a change; re-check once the gate recipe lands.