Commits
2026-10-23
Restore edith_codecs after local data loss (2026-10-23)Ahmet Kaan Gümüş · b7434a2
Restore edith_codecs after local data loss (2026-10-23) On 2026-10-23 an automated agent ran `rm -rf $HOME` and deleted the local repository with all of its history. This commit restores the working tree from the newest surviving copy, the host-c server lane mirror. That mirror matches local main as of the testcut Phase 2 reports, including the tool cache, the nextest fast profile and changed-crates.sh. The history before this commit was not recovered.
2026-10-01
ec-av1: route every test-pin write through dumpio::LoudDumpAhmet Kaan Gümüş · f3fd848
ec-av1: route every test-pin write through dumpio::LoudDump
The self-pin sites in stream.rs wrote with `let _ = std::fs::write(..)`
and then named the path in the panic that followed ("stream pinned at
{}"), so an ENOSPC/EFBIG left a TRUNCATED stream at exactly the path the
reader was told to replay -- the same silent-truncation class as the
dump path, one hop later. dumpio gains pin() (fatal) and pin_reporting()
(same failure line, returned not panicked); msac's symtrace dump folds its
hand-rolled check into the same writer.ec-av1: every dump site fails loudly on a short writeAhmet Kaan Gümüş · 286530d
ec-av1: every dump site fails loudly on a short write All 11 dump write sites in the crate wrote through `let _ = f.write_all(..)`. A full filesystem, a quota or an RLIMIT_FSIZE therefore left a SHORT file on disk and nothing said so -- the artefact behind two full days of chasing a "decoder nondeterminism" that reproduced bit-for-bit as a truncated frame (lanes/unwritten-dep.report.md: frames 0..4 complete plus 13320192 bytes of frame 5), and behind an empty dump read as instability. New `dumpio::LoudDump`: the caller declares the byte count from the geometry it already has (per-axis extents, u16-vs-u8 sample width), `finish()` checks it against the file's own length on disk, and any shortfall -- or a failure to create the file at all -- aborts with ec-av1 dump FAILED [EC_AV1_FINAL_DUMP] <path>: wrote <on-disk> of <owed> bytes: <reason> Two sites cannot know a total length (EC_AV1_DUMP_TABLES and the ECDUMP symbol stream are append-mode, whole-run files); they say "of an unknown number of bytes" rather than declaring a number they would have to invent. The written count is the file's MEASURED length, not what write_all confirmed: under RLIMIT_FSIZE the kernel stores up to the cap and only then returns EFBIG, so a naive acknowledged count reported "wrote 0" over a 30 720-byte file. Gates: a real decode under a real RLIMIT_FSIZE now FAILS with the line above (child process, SIGXFSZ ignored, asserted against the fragment's real length), plus /dev/full, uncreatable-path, under-declared-length and append-unknown arms. The success path is byte-identical: the hg fixture sweep reproduces a26438168c / 8d7a43bc5f, 3/3 each, 18524160 B per frame. 0ee1edf403 is still NOT reproduced (plain 3/3, sentinel 3/3, concurrent reuse, 7 RLIMIT caps, 204 prefix shapes: all plain value or no match). It stays open -- a SIGKILLed process emits no line at all, so that shape is not ruled out. What is now closed is the silent-truncation class: every truncating cap aborts loudly instead of leaving an artefact.
2026-09-29
av1: the per-unit bit-interval ladder, and the second 4:4:4 intra-BC witness at full exactnessAhmet Kaan Gümüş · a4597ea
av1: the per-unit bit-interval ladder, and the second 4:4:4 intra-BC witness at full exactness The 4:4:4 intra-BC chroma fork at mi (20,40) is NOT an entropy fork, and the count asymmetry that named it does not exist. Re-measured on 444_intrabc_rect4_witness.obu with a per-unit BIT-INTERVAL ladder against the oracle's EC_ECDUMP_IN/_OUT/_END: 512 real txb_skip reads against the oracle's 513, not the ~1069 fewer an earlier round reported (that figure counted the 1883 zero-bit reads the rung fires for, and filtered one side only). Every one of the 2365 in-stream units agrees on entry, post-txb_skip AND end-of-unit position at a MEASURED constant offset of +14 bits; all_zero agrees on all 2395. The 30 tail mismatches are end-of-buffer padding, not a fork. There is no first divergent symbol, because there is no divergence in the coefficient ladder. What the ladder ruled out is the finding. With entropy excluded and the filters exonerated (oracle PREFILT == oracle FINAL on all three planes), the fork was a wrong-PLACE write: our PREDICTION at the first divergent sample was byte-identical to the oracle's (sum 26258 both, same first row), so the defect had to be a later different write -- and the MC/inter write path had no rung to say so. Hence EC_MCWR (the write's origin and shape) and EC_MCPUSH (the push site, #[track_caller]), which named decode_intrabc_owned_rect's skip arm committing a 32x16 chroma window at (px/2, py/2) = (160,80) and leaving its own 64x32 footprint at (320,160) unwritten. Two difference components, 8 cells sharp and 1182 over the whole quadrant: one wrong-place write, not two defects. That fix is ALREADY ON MAIN, in a more general form than this lane first wrote it: 5324a685 (lane-av1chromarect) made the extent and origins ss-derived for this whole function, skip arm included, after solving the missing-TxbSet blocker that had forced this lane to scope its fix to the skip arm; 2c0fd2b9 (lane-av1chromadc) windowed the skipped-block chroma override per unit. Main's version is kept, for a substantive reason: scoping to the skip arm would have left a known-wrong shape in the arm that actually reads coefficients. This branch is rebuilt from 79b2a73f and carries only the instrument, the gate and the report; the pre-rebase commit e0a7b744 is on backup-av1ibcfork for the record. With both landed the witness is byte-exact on all three planes, including the "(416,192) residual tail" this lane had called a separate open defect -- it was a consequence of the same wrong-place write, not an independent one. Gate a_444_intrabc_rect4_witness_is_byte_exact_after_the_skip_arm_footprint: a SECOND witness, not a repeat of chromarect's r512.obu gate, because the two shapes fail differently -- r512's 128-root strips fail as a sizing error inside the coefficient walk, while this witness's 64x32 skip block read no coefficient at all, so its only symptom was pixels. Four arms: 4:4:4 header asserted, the 4:2:0 twin byte-exact (where >> ss_x IS / 2, so it is the measurement), IBC_OWNED_RECT_CHROMA_FOOTPRINT_444_HITS >= 1, and FULL byte-exactness on all three planes. Mutating the function back to the halving reds it at (x=160, y=80) -- the same sample this lane measured by hand before the gate existed. Also: SymbolDecoder::symr_mi(), because a per-unit rung needs a mi and set_symr_mi only wrote it.
2026-09-28
lane-av1422warp r33: reviewer rework -- OBMC snap, hot-path env, two docs, one wrong numberAhmet Kaan Gümüş · 4e1fb23
lane-av1422warp r33: reviewer rework -- OBMC snap, hot-path env, two docs, one wrong number
Reviewer FAIL addressed, all five findings.
P2 (a4532a41) OBMC PAIR-MERGE SNAP. The snap was clamped on the wrong
value. libaom (obmc.h:44-46) snaps the pair index `& ~1` UNCONDITIONALLY
and reads at `snap + 1`; only the REPORTED offset
(`above_mi_col - mi_col`) is negative, and it feeds
`av1_setup_build_prediction_by_above_pred` while the READ feeds
`above_filter.get(mi_col + src4)` and the MiInfo itself. Clamping the
snapped index to `mi_col`/`mi_row` silenced the underflow and in exchange
read the neighbour one column RIGHT of libaom's, then stepped past
`mi_col + 1` entirely. Both sites now keep the snap and clamp only the
offset. The tuple is `usize`, so libaom's -1 is carried as 0; that is
noted in the code rather than glossed.
New gate the_obmc_pair_merge_snap_reads_libaoms_neighbour_not_one_to_the_
right pins the snapped READ against a synthetic grid with distinguishable
neighbours at the pair's even half, odd half, and the column to the right.
Mutation-proven both ways. It is necessary because NO STREAM IN THE CORPUS
exercises this branch: a1.obu's 1338 traced OBMC neighbours are identical
before and after the fix, since its 4-wide pair never starts on an odd
edge.
P2 HOT-PATH ENV LOOKUP. `SymbolDecoder::symbol` called
`std::env::var_os("EC_SYMR")` on every symbol read of every stream,
production formats included. Now `envflags::env_flag!("EC_SYMR")`, one
LazyLock per call site (the ecdump_armed precedent at msac.rs:1059).
Proved byte-identical: same build, both forms, identical 246735-line
EC_SYMR traces.
P3 MI_SIZE DOC. The doc claimed "MI_SIZE (aom_scale.h)" and 8. libaom's
MI_SIZE is 4 (av1/common/enums.h:39-40) and lives in enums.h. Renamed
MI_SIZE_8PX; both its doc and read_lr's are restated in 8-pixel terms,
with why the value is double libaom's (its denom is a pixel count, so
numerator and denominator already sit on opposite scales) and the paired
trace named as the authority. The rename is so nobody corrects it to 4.
P3 TOP-HALF CENSUS WAS AN UPPER BOUND, AND 248 WAS WRONG.
top_half_warp_hits incremented on "either slot's model > TRANSLATION"
alone, omitting `is_globalmv && side >= 8`, so it counted blocks that are
not global-mv blocks. It now increments on `is_global_mv0 || is_global_mv1`
-- libaom's own `is_global_mv_block` -- with the census moved below their
definition. CORRECTED UPPER-HALF FIGURE: 3 warp, 3 compound. Not 248.
Frame-global figures unchanged (compound_warp 25, compound_warp_8 18,
rotzoom_gm_warp 84, lr_wiener 22, lr_sgrproj 10). The gate doc and the
lift section are corrected; 248 was never a count of anything real.
P3 ACCESSOR DOCS. Both claimed a committed reader that does not exist and
cannot: with the header refusal standing no committed test decodes a 4:2:2
stream. Both now say so.
NO CHANGE to the 4:2:2 refusal, which stays unconditional. NO committed
bypass. Stream still 246735/246735 paired and 16/16 pixel-exact.lane-av1422warp: instrument -- EC_SYMR cdf tag is ONE-SHOT; tag the inter readsAhmet Kaan Gümüş · 372f8f5
lane-av1422warp: instrument -- EC_SYMR cdf tag is ONE-SHOT; tag the inter reads No behaviour change; identity re-proved (4:2:0 control byte-identical to aomdec --rawvideo, 4:4:4 witness byte-identical to the pre-lane build, both pinned 422 witnesses pixel-exact). Main's suspicion was right and is fixed: the cdf tag was STICKY -- set at a read site and carried by every later read -- which is exactly how an 8-SYMBOL read came to be labelled `interintra`, a 2-SYMBOL table. `SymbolDecoder::symbol` now CONSUMES the tag, so an empty `cdf=` means "no table set for this read", never the previous read's table. That also retracts round 28's "the two missing reads are interintra", which rested on the sticky label. Remaining inter-path reads tagged so the window is readable: y_mode, uv_mode, motion_mode, skip_mode, comp_group_idx, compound_idx, interintra. Verified sparse on a1.obu: comp_group_idx 947, interintra 945, uv_mode 895, motion_mode 736, compound_idx 726, y_mode 293, rest empty. Oracle side snapshotted separately (one-shot plus its own tags).
lane-av1422warp: fix the EC_SYMR cdf slot -- it was printing the phaseAhmet Kaan Gümüş · a384eeb
lane-av1422warp: fix the EC_SYMR cdf slot -- it was printing the phase
Instrument bug, found by the round-28 check that flagged it. The format
is `ph={} cdf={} ...` but the second argument was `SYMR_PHASE` again, not
`SYMR_CDF` -- an off-by-one from inserting the phase argument in round 27
and the cdf one in round 28. So every read reported the PHASE in the cdf
field, which is exactly the `inter8` round 28 saw where no code path ever
sets that value, and why this lane could not label its own half of the
window.
With it fixed the tag is live and verified against three distinct tables
on a1.obu: interintra 72533, compound_idx 33655, comp_group_idx 13744.
No behaviour change -- the print only. Identity re-proved: 4:2:0 control
byte-identical to aomdec --rawvideo, 4:4:4 witness byte-identical to the
pre-lane build, both pinned 422 witnesses pixel-exact.lane-av1422warp: instrument -- EC_SYMR carries the CDF table nameAhmet Kaan Gümüş · e9a6ad8
lane-av1422warp: instrument -- EC_SYMR carries the CDF table name No behaviour change: set_symr_cdf only feeds the env-gated print. Identity re-proved after the edit: 4:2:0 control a420.obu byte-identical to aomdec --rawvideo, 4:4:4 444_sb128rect_lr_witness.obu byte-identical to the pre-lane build, both pinned 422 witnesses pixel-exact. `cdf0` alone cannot identify a table -- two rows can share a first entry -- which is what stopped round 27 from naming the two missing reads. EC_SYMR now prints `cdf=`, set at the read sites for the tables in this window: interintra, comp_group_idx, compound_idx (both sides; the oracle's tags are snapshotted separately). With the oracle side tagged, read 107517 at mi(30,62) carries `cdf=interintra` and the two reads this decoder omits sit either side of it. That is NOT yet an attribution: the matching gate on our side (`enable_interintra_compound && !skip_mode`) is TRUE on every one of its 451 firings, so this decoder is not skipping the interintra read there, and the cdf tag on our side has not been verified against a known read. Recorded in the report as an open question rather than closed.
lane-av1422warp: instrument -- EC_SYMR carries a phase, and a CORRECTED inter miAhmet Kaan Gümüş · c39e6f5
lane-av1422warp: instrument -- EC_SYMR carries a phase, and a CORRECTED inter mi No behaviour change: `set_symr_phase` and the extra `set_symr_mi` only feed the env-gated print. Identity re-proved after the edit: 4:2:0 control a420.obu byte-identical to aomdec --rawvideo, 4:4:4 444_sb128rect_lr_witness.obu byte-identical to the pre-lane build, both pinned 422 witnesses pixel-exact. Two changes, both prompted by round 26's failed coverage check. 1. PHASE on every read. The coefficient rungs stop well before the frame-3 divergence on BOTH sides, so the per-read stream is the only instrument that reaches it, and a read with no phase is unattributable. `EC_SYMR` now prints `ph=`: "inter" over the inter mode-info path, "inter8" over the sub-8x8 arm, "" elsewhere. 2. THE INTER mi LABEL WAS WRONG, and fixing it changes the answer. Round 27 first published the mi from `decode_inter_block`'s entry `at`, which labels a DIFFERENT block -- it reported mi(28,52) for reads this decoder makes for mi(30,62). The `EC_MODE_VAL8` rung, printed by the function that actually reads the mode, reports mi(30,62). The phase/mi are now also published from `decode_inter_block8` at the block's own `leaf_mi`, which is what makes the inter mi trustworthy -- round 22's misattribution was exactly this class of error, and it is now closed at the source rather than worked around. With the label correct, reads 107514-107516 pair at mi(30,62) on both sides and the divergence is clean: the oracle reads two n=2 inter-mode symbols (107517, 107518) that this decoder does not, and its n=8 at 107519 is identical to our n=8 at 107517 -- a two-symbol shift, same block.
lane-av1422warp: instrument -- EC_SYMR names its own block (mi on every read)Ahmet Kaan Gümüş · 5e7ae32
lane-av1422warp: instrument -- EC_SYMR names its own block (mi on every read) No behaviour change: the three `set_symr_mi` calls and the new thread-local only feed an env-gated print. Identity re-proved after the edit: 4:2:0 control a420.obu byte-identical to aomdec --rawvideo, 4:4:4 444_sb128rect_lr_witness.obu byte-identical to the pre-lane build, pinned 422_allskip_2f.obu and 422_sb128_3f.obu still pixel-exact. A symbol read carries no mi, so the per-read stream could only be located by correlating it against a SEPARATE trace. That correlation is what mis-attributed reads in rounds 22 and 23: the divergence was pinned on a 4x4 leaf at mi(24,57) that the EC_SYMR stream shows is nowhere near it. With mi on every read the same divergence names its OWN block, and the answer changes: it is the 32x32 intra block at **mi(64,56)** -- the frame's bottom-right corner at 4:2:2 -- whose mode-info reads pair exactly (skip/cdef/dq/mode=3/angle_y=-2/uv_mode=8/angle_uv=-1) and whose COEFFICIENT reads diverge. The oracle side is the same edit, already snapshotted in the oracle tree as 35d97e5, so both sides carry mi and the streams are directly comparable read for read. `mi` is a LABEL for attribution and is deliberately NOT part of the divergence criterion: the oracle publishes it one read later than we do, so requiring equality on it would report a spurious divergence at read 5.
lane-av1422warp: gate the 32x16 strip reader's 4:2:2 chroma dc-sign voteAhmet Kaan Gümüş · b86686a
lane-av1422warp: gate the 32x16 strip reader's 4:2:2 chroma dc-sign vote decode_block_rect built its chroma vote with `around_rect` and no 4:2:2 rerouting -- the sibling decode_leaf_rect, which lane's round-6 fix gated, was not. At ss (1,0) that strip's chroma is a square (side/2, side) block whose above cells spread over `side` LUMA mi columns, so the per-mi rect gather double-counts every chroma column's whole-unit dc sign. Found with the EC_SYMR sequence diff (see the report): of 46260 symbol reads on a1_f0.obu, reads 0..45259 pair EXACTLY on value, range, CDF row (32768 - ours == oracle), alphabet, symbol and post-read range, and read 45260 is the first divergence -- the chroma-U 4x4 transform of the 32x16 strip at mi(68,16), whose DC sign this decoder reads from dc_sign_ctx 1 where libaom reads row 0. Same position, same symbol, same bits, different row: the signature the ladder cannot see. After the fix all 46260 reads match at state level (the only residual difference is the `bit` field over the last 17 reads, which is the reference's own buffer-end tell convention). Frame 0 is PIXEL-EXACT against aomdec for the first time on this stream; the 16-frame measure goes 0/16 -> 3/16 frames exact and 1619115 -> 1332125 differing samples. Identity, all four unchanged: the 4:2:0 control a420.obu byte-identical to aomdec --rawvideo; 444_sb128rect_lr_witness.obu byte-identical to the pre-lane build; pinned 422_allskip_2f.obu and 422_sb128_3f.obu still pixel-exact against aomdec. The gate is ss (1,0), so 4:2:0 and 4:4:4 never reach the sampler. Also restores EC_SYMR in SymbolDecoder::symbol (msac.rs), which an earlier `git checkout` in this lane had wiped along with the oracle's copy; the format follows skill ec-av1-consumption-gap-symr Step 3.
2026-09-24
2026-09-19
ec-av1: non-420 named refusal, disable_cdf_update wiring, rect-intrabc var-tx + sub-8 txfm-context fixesAhmet Kaan Gümüş · 8b37c57
ec-av1: non-420 named refusal, disable_cdf_update wiring, rect-intrabc var-tx + sub-8 txfm-context fixes Five defects, each with a gate and/or a first-divergence move (report S9): - non-4:2:0 chroma (4:4:4/4:2:2) is now REFUSED BY NAME at the sequence header instead of decoding silently wrong pixels; gate a_non_420_subsampled_sequence_header_is_refused_by_name (profile 1 + 2 headers, profile-0 control still decodes) and a real aomenc yuv444p stream refuses where it used to decode garbage. - disable_cdf_update (spec 5.9.2) is now consumed: per-reader msac::SymbolDecoder::adapt + FrameCtx cell + one line in decode_frame. Gates: a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact (byte-exact vs ffmpeg; pre-fix the same stream differs at byte 6) and the msac unit gate a_reader_told_not_to_adapt_matches_a_non_adapting_writer. - transform.rs:1134 panic root-caused and FIXED: txbset_for_inter (a duplicate whose 4 fell through to Luma64) is deleted; all inter-table sites use inter_txbset_for, which has the 4x4 arms libaom's EXT_TX_SET_ALL16/_DTT4_IDTX ask for. allintra0 no longer panics; it stops at the existing named mixed-leaf var-tx refusal. - rect intrabc leaves (4x8/8x4) read the INTER var-tx tree under TxMode::Select (block_signals_txsize is bsize > BLOCK_4X4) and reconstruct per 4x4 TU when it splits; sub-8x8 leaves publish the TXFM context bands (set_txfm_ctxs for every block); the stale intrabc_dv slot no longer leaks into the next 8x8+ block. - inventory re-pin: the dead sub-8x8-intrabc refusal entry retired, the Golomb entry re-pinned to its measured symptom-reachability. warped is NOT byte-exact yet: first divergence moved (38,60) -> (46,66), the key-frame tx-depth context read off the deblock grid where libaom reads the TXFM bands (next step in report S9.7). allintra/warped now stop 16 mi rows later at the 1:4 rect-strip intrabc refusal (lane 3's).
2026-09-08
2026-09-07
feat(av1): a decode-side syntax census, and the film B vs rav1e table it producedAhmet Kaan Gümüş · 373b6a2
feat(av1): a decode-side syntax census, and the film B vs rav1e table it produced The BD gate says our stream is bigger; it never says which syntax it is bigger in. This adds a per-CDF-table bit accountant to the symbol decoder (EC_AV1_BITCENSUS=1, one relaxed load per symbol when off) plus block, tx, mv, mode and frame-header funnels, and an examples/syntax_census.rs that prints one table per stream -- so our stream and rav1e's are measured by the same reader. lanes/census-filmB.md holds the answer for film B at matched PSNR: the whole gap is in the inter frames (our key frame is the smaller and the worse one), 75% of it in the leaves, and the three mechanisms are the flat pyramid q ladder, the missing 64x64 blocks and transforms, and a 52.5% vs 84.8% skip share.
2026-09-06
perf(av1): price a symbol string off its final interval, not one log2 per symbolAhmet Kaan Gümüş · fb3fa69
perf(av1): price a symbol string off its final interval, not one log2 per symbol The bit account the RD search prices with cost `__log2_fma` 8.2% of the encoder's profile, one call per symbol written or priced. A symbol costs `log2(r) - log2(rng)` for the two widths it narrows between, and the next symbol's `r` is this one's `rng` shifted up by the renormalisation, so a whole string's cost telescopes to `bits_base + shifts - log2(rng)`: one `log2` per price asked for. Same reading as libaom's `od_ec_enc_tell_frac`. A pricing coder also keeps `low`, `cnt` and the precarry buffer whose only consumer is `finish`, which a search never calls; `SymbolEncoder::pricer` drops that bookkeeping and keeps the interval width the account reads. Byte-exact: all twelve ladder points of the three gate clips keep their length and FNV-1a hash. 1080p ladder -4.76% instructions:u (116.49G -> 110.95G, ABAB x2), of which the pricer accounts for -0.92%.
perf(av1): coefficient reading walks a non-zero list and flat neighbour tapsAhmet Kaan Gümüş · de3e402
perf(av1): coefficient reading walks a non-zero list and flat neighbour taps The sign pass re-walked `scan[..eob]`, redid the `pos >> sh` / `& mask` decomposition and loaded each level back out of the padded frame only to skip the zeros. The base pass already knows both, so it now records `(scan_idx << 4) | level` per non-zero coefficient and the sign pass walks that list in reverse -- same coefficients, same order, same trace output. The five base-context neighbour taps and the three base-range ones are a function of the tx class alone, which is fixed for a whole transform unit: `flat_taps` resolves them once per unit as flat offsets into the padded level frame, so the per-coefficient path loses the class match and the `(dr, dc)` -> `dr * stride + dc` arithmetic. Both readers (square and rect) share the new `base_mag`/`br_mag`; `br_ctx`/`br_ctx_rect` stay as the `(row, col)` form the new test pins the flat one against, over every class, every square size and the whole `(row, col)` domain. `SymbolDecoder::literal` was a real call per raw bit across a codegen-unit boundary (this crate builds without LTO) -- the sign pass and the Golomb tail read one bit at a time; it is `#[inline]` now. instructions:u at EC_AV1_THREADS=1: 4K segment -1.01%, 1080p segment -1.42%.
2026-09-05
perf(av1): the arithmetic reader takes its two-symbol shape straightAhmet Kaan Gümüş · 864a703
perf(av1): the arithmetic reader takes its two-symbol shape straight Most symbols the tile reader reads are two-symbol: every flag, and every bit of a literal, which coded its bit through the general alphabet walk against a fixed equiprobable CDF. That walk set up a loop, tested two candidates and multiplied out the `EC_MIN_PROB` floor to read one boundary. `symbol_fixed` now computes that single boundary directly for a two-symbol alphabet and `literal` reads its bits through the same path, where the range multiply is a shift. The general walk keeps its loop but stops one candidate early: the last boundary is always `CDF_TOP`, whose interval end is zero, so the last candidate needs no test and its arithmetic is the fall-through. The `EC_MIN_PROB` floor counts down instead of being multiplied per candidate. The renormalisation tail all three paths share is one inlined helper. Byte-exact: the four gate streams hash identically at 1, 4 and (16,4,2) threads. A new lockstep test decodes 20k mixed symbols and literals twice -- once through the fast paths, once through the spec-literal 8.2.6 walk kept in the test -- and compares the symbol, the adapted CDF and the coder's (range, value) after every read. instructions:u at one thread: 1080p 131.684 -> 131.442 G (-0.18%), 4K 405.018 -> 404.483 G (-0.13%). Cycles were not usable as a verdict this session (box load ~15-35, base repeated to +-14% on cycles while instructions repeated to 0.0002%).
perf(av1): coefficient reading -- buffered msac bit window, static scan tables, no per-block level allocationAhmet Kaan Gümüş · 8841aa8
perf(av1): coefficient reading -- buffered msac bit window, static scan tables, no per-block level allocation The frame thread's coefficient path paid four avoidable costs per transform block, all bit-exact to remove: * every symbol's renormalisation assembled five bytes out of the payload and shifted twice; `SymbolDecoder` now keeps a 64-bit window refilled once per eight bytes (`bulk_bit_reads_match_the_per_bit_form` still pins `f(n)` against the per-bit form, through the new `seek_bits`); * `symbol_fixed`/`symbol`/`f`/`update_cdf` were out-of-line across codegen units, and the CDF walk indexed a slice the bounds checker could not see the end of -- inlined, and the walk iterates instead; * `default_scan` allocated a `Vec` and regenerated the whole anti-diagonal walk on every block: one table per side (4/8/16/32), built once; * `read_coeffs` divided by the transform side per coefficient (always a power of two) and allocated its level buffer per block. instructions:u on the 4K segment at one thread: 570.76 G -> 559.11 G (-2.0%). All 12 gate hashes unchanged at 1/4/16 threads; lib suite 500 passed, 27 ignored.
2026-09-04
perf(av1): refill the arithmetic decoder a field at a time, not a bit at a timeAhmet Kaan Gümüş · bea686b
perf(av1): refill the arithmetic decoder a field at a time, not a bit at a time `SymbolDecoder::symbol_fixed` was 6.8% self time after the transform work, and most of what it does per symbol beyond the alphabet walk is `f(n)` -- the renormalisation refill, which looped once per bit, fetching, masking and shifting a byte each time. Five bytes cover any 32-bit field at any bit offset, so the whole field is now one assemble-and-shift; a byte past the end of the payload still reads as zero, exactly as the per-bit `unwrap_or(0)` did. The alphabet walk also hoists `range >> 8`, which cannot move until the symbol is chosen. `bulk_bit_reads_match_the_per_bit_form` checks the new `f` against the loop it replaced at every start offset over a 40-byte payload, every width from 0 to 32, and 16 bits past the end. Byte-exact: `EC_PROBE_OUT16` dumps hash-identical to the lane's baseline binary on 1080p 10-bit, 2160p HDR and the 8-bit palette fixture. Interleaved medians against the previous commit: 1080p 12.35 s -> 12.07 s, 4K 64.44 s -> 63.94 s.
2026-08-28
wip(av1): msac symbol_fixed hand-verified correct; real desync is a switchable_interp read aomdec never performs for this block. Round 6, capped at budget.Ahmet Kaan Gümüş · 21c8320
wip(av1): msac symbol_fixed hand-verified correct; real desync is a switchable_interp read aomdec never performs for this block. Round 6, capped at budget. COMPILES. No behaviour change: new EC_AV1_EOBPT_CDF-gated `debug_state()`/eprintln! diagnostics only (msac.rs's new `pub(crate) fn debug_state`, decode.rs's three new state prints in `read_coeffs` and `read_eob`), same pattern as every prior round's instrumentation. R6'S OWN PLAN'S STEP 1/2 (msac.rs correctness) IS NOW CLOSED, NEGATIVE: hand-derived `symbol_fixed` (msac.rs:301-329) against libaom's actual `od_ec_decode_cdf_q15` source (`/tmp/libaom-src/aom_dsp/entdec.c:204`, read fresh this round, not from memory) term-by-term for nsyms=11 specifically -- `N = nsyms - 1`, loop increments `ret` before indexing `icdf[++ret]`, `v = ((r>>8)*(icdf[ret]>>EC_PROB_SHIFT))>>(7-EC_PROB_SHIFT) + EC_MIN_PROB*(N-ret)`, loop continues `while (c < v)`. This is algebraically IDENTICAL to our `cur = (((range>>8)*(f>>EC_PROB_SHIFT)) >>(7-EC_PROB_SHIFT)) + EC_MIN_PROB*(nsyms-1-symbol)`, loop `while value < cur`. nsyms=11 is not special-cased anywhere in either implementation. r5's suspicion (1) is FALSIFIED -- do not re-open without new evidence. DECISIVE NEW EVIDENCE (this round's actual find): added a `debug_state()` accessor to `SymbolDecoder` and printed `(range, value)` before/after the `all_zero` (txb_skip) read, after the `tx_type` read, and entering `eob_pt` -- then added the SAME state to aomdec's `decodetxb.c` (`EC_AV1_EOBPT_STATE_IN`, plus `rng_before` on the existing `EC_PLANE` trace). Result: **the coder state ALREADY diverges before the `txb_skip` read even starts** -- ours enters at `range=46855`, aomdec enters at `rng_before=50720`. So r5's "CDF + symbol byte-identical at tx_type/eob_pt" was real but downstream of an earlier, silent divergence; walking back from there: Between `EC_MV` (motion vector, matches exactly: `mv=(-2,-8)` both sides) and `EC_TXBCTX`/`EC_PLANE` (first plane's coeff decode), the ONLY symbol read possible on this path is the switchable interpolation filter (`resolve_interp_filter`, decode.rs:3726 / libaom's `read_mb_interp_filter`, decodemv.c:1122). Ours takes the *real-symbol* branch (`interp_fixed == None`, i.e. the frame header says `interpolation_filter == Switchable`) and decodes `filter=[3, 3]` (BILINEAR both directions) -- a real, adapting 3-symbol CDF read. aomdec's own trace for this exact block (`mi_row=0 mi_col=0`, frame=14, ref=1, mode=NEWMV=16) shows `interp=(0,0)` (REGULAR both directions) with **no `IFILTER_DBG` line at all** -- confirmed by instrumenting `av1_is_interp_needed()`'s own three sub-conditions directly (`IFILTER_NEEDED ... skip_mode=0 motion_mode=0 mode=16 needed=1`): the function returns TRUE (the read is not skipped by the gate), yet `read_mb_interp_filter`'s OWN symbol-read branch never fires for this block, which by its source (decodemv.c:1134, `if (interp_filter != SWITCHABLE)`) is only possible if **libaom's own per-frame `features->interp_filter` is a FIXED value for frame 14, not `SWITCHABLE`** -- i.e. aomdec's `interpolation_filter` header field for THIS frame differs from what our decoder computed. CONCLUSION / R7 HANDOFF, IN ORDER: 1. This is very likely NOT an msac bug at all (closed, see above). The live suspect is `read_interpolation_filter()` (`ec-av1-syntax/src/frame.rs:1165`) or, more likely given the header bit-parsing there matches spec 5.9.10 exactly on inspection, a **frame-header/frame-index MISMATCH**: this pin's "decode-order frame 1" may not be resolving to the same underlying temporal-unit frame aomdec calls its own "frame=14" -- ties back to f952bb4's already-flagged "hidden frame" suspicion from round 3, never fully closed. Confirm by dumping `header.interpolation_filter` (and ideally `show_frame`/`frame_type`/`order_hint`) for EVERY frame header our decoder parses in this stream, aligned against aomdec's own `cm->current_frame.frame_number` sequence (add an `EC_AV1_FRAME_NUMBER`-style eprintln! to `av1_read_coeffs_txb` or the frame-header decode point on aomdec's side, matching the counters already in place) -- find the first frame where the two disagree on `interpolation_filter`, and from there whether it's a genuine off-by-one in which OBU/frame our pin harness treats as "decode-order frame 1", or a real per-frame header field ours reads as `Switchable` when it should not. 2. If frame alignment IS correct and headers genuinely disagree on this field for the SAME frame: re-derive `read_interpolation_filter` against spec 5.9.10 word-for-word once more (looks correct on this round's read, but re-check the surrounding `allow_high_precision_mv` /`force_integer_mv` order just above it, frame.rs:963-968 -- an earlier misread bit could shift every subsequent header field by one bit position without desyncing the *tile* data at all, which is exactly the shape of "everything downstream of one header field looks locally consistent but globally wrong"). 3. Once the true cause is found and fixed, re-run the pin (`EC_AV1_PIN_N=24`) for exactness, THEN full `cargo test -p ec-av1 --release` (not just `--lib`) per existing done-criteria -- a header-parsing fix is even more likely than an msac fix to touch every stream. 4. If the pin goes exact: run the three flaking gates 15x each (`compound_references`, `reference_select`, `deblocking`) and report pass counts honestly. Instrumentation added this round, env-gated (no behaviour change when unset): `SymbolDecoder::debug_state()` (msac.rs, `pub(crate)`, mirrors the existing `debug_bitpos()`), three new `EC_AV1_EOBPT_CDF`-gated state prints in decode.rs (`EC_AV1_STATE_BEFORE_TXBSKIP`, `EC_AV1_STATE_AFTER_TXBSKIP`, `EC_AV1_STATE_AFTER_TXTYPE`). External, not committed to this repo: `/tmp/libaom-src`'s `av1/decoder/decodetxb.c` (`EC_AV1_EOBPT_STATE_IN`, `rng_before` on `EC_PLANE`) and `av1/decoder/decodemv.c` (`IFILTER_NEEDED`, gated on the pre-existing `EC_IFILTER_DBG`) -- rebuilt into `/tmp/libaom-src/build/decoder-debug/aomdec`; this source tree is outside the repo and NOT reproducible from a fresh checkout, note for whoever runs r7 without the same `/tmp` state. class: sibling of [[stale-premise-lanes]] -- r4 and r5 both suspected mechanisms one level too deep (a table's forwarding, then a coder primitive) because both were proven correct in isolation without first walking the state itself backward to its true entry point; the actual divergence sits one whole syntax element earlier (a per-block symbol read that should not have fired at all), in territory ([[hidden frame]] frame-index resolution) an even earlier round (f952bb4) already named and left open.
wip(av1): r6 -- sweep clean, class sweep clean, CURRENT_OP scaffolding removedAhmet Kaan Gümüş · a3b0b8a
wip(av1): r6 -- sweep clean, class sweep clean, CURRENT_OP scaffolding removed Sweep: both wide gates (reference_select, compound_references) 10/10 green, all pixel-exact, no defect found. Old pins re-verified: av1blend- r1-mismatch.obu 24/24 MATCH (already closed by r6/r7's ref_ctx fix, not a new result); cdfflake-stream-seed45.bin still mismatches at frame 2 (359/4096 luma, worst delta 6) -- unrelated cdf-forwarding defect, NOT closed by the mvstack fix. Charter's "comp_group_idx==0 refusal" premise did not match HEAD 8f08e06: only a comp_group_idx==1 (wedge/diffwtd) refusal exists, which is a genuinely-unsupported blend type the charter itself says must stay masked. No comp_group_idx==0/compound_idx refusal exists anywhere in decode.rs -- that path is already live and unmasked, and the sweep confirms it is currently defect-free. Nothing to unmask. Class sweep (neighbour votes all its fields): every remaining site (single_ref/comp_ref/comp_bwdref/uni_comp_ref ctx family, reference_mode_ctx, comp_reference_type_ctx, get_comp_group_idx_context, get_comp_index_context, switchable_interp_ctx, the either-ref filter_ctx checks) already threads both compound slots correctly -- verified against mvstack.rs/decode.rs source, no new bug found. Cleanup (partial, budget-bound): removed msac.rs's EC_RNG trace block and the CURRENT_OP thread_local plus all 102 call sites in decode.rs that set it. tile.rs's separate, older EC_RNG trace (lane-av1truesize, still load-bearing for the encoder side) is untouched -- out of this lane's scope. Still owed: EC_AV1_SREF_DUMP/EC_AV1_COMPIDX_DUMP/ EC_AV1_COMPOUND_DEBUG/BITPOS_BLK_START blocks, r17_dump/ R17_DUMP_FRAME_IDX (EC_AV1_PREFILT/POSTFILT_DUMP), and scratch_* #[ignore] tests beyond the two pin-repro tools -- next round. cargo test -p ec-av1 --lib: 214 passed/0 failed/19 ignored (individual runs); one flaked FAILED in a full-suite run reproduced green in isolation -- pre-existing aomenc-RD-nondeterminism flake class, not a regression from this change.
fix(av1): single-ref mvstack scan votes a compound neighbour's second slotAhmet Kaan Gümüş · 2b9615f
fix(av1): single-ref mvstack scan votes a compound neighbour's second slot Named read #538 (EC_RNG global trace): L5039, the new_mv symbol in decode_inter_block16's single-ref path, fed a new_mv_ctx computed from find_mv_stack_with_sign_bias. Its row/col/corner scans and the single-ref extension pass (process_single_ref_mv_candidate) matched a neighbour on info.ref_frame alone, silently dropping the vote whenever a compound-coded neighbour's match sat in its second slot (ref_frame1/mv1) -- the third instance of the neighbour-votes-all-its- fields class. Frame 10 (decode order) has reference_select=true, so a compound neighbour is live next to the diverging single-ref query. Added single_ref_match() (mirrors libaom's add_ref_mv_candidate `for ref in 0..1+is_compound`), used by scan_row/scan_col/scan_corner/ scan_top_right; extended process_single_ref_mv_candidate to donate both of a compound candidate's slots instead of just the first. Proof: av1idx-refsel-pin.obu (20 frames) now 60/60 plane-MATCH against ffmpeg (0 mismatches), 3x. Full ec-av1 --lib suite 214/0/19 green. Also: added a CURRENT_OP thread-local (msac.rs) plus a per-call-site tag before every dec.symbol()/symbol_fixed() read in decode.rs (r5 scratch instrumentation, EC_RNG=1 trace now prints op=L<line>), and a reference_select/primary_ref_frame field on the EC_AV1_SREF_DUMP print (stream.rs) used to confirm frame 10's header state.
2026-08-27
fix(av1): V_DCT/H_DCT coefficient scan order + TX4 leaf8 scan table mixupAhmet Kaan Gümüş · 700543b
fix(av1): V_DCT/H_DCT coefficient scan order + TX4 leaf8 scan table mixup Two real desync causes past r3's tx-class context-derivation fix: 1. read_coeffs always read coefficients in the default zigzag scan regardless of tx_type. libaom's V_DCT/H_DCT classes use Mrow_Scan/ Mcol_Scan instead (scan.c av1_scan_orders index 10/11) -- decoded here as class_scan_table: V_DCT's class-scan is our grid's own natural row-major order (0..N), H_DCT's is that walk transposed. base_ctx/br_ctx's row/col-offset formulas (r3's fix) were already correct; only the scan order feeding position/row/col into them was wrong. 2. decode_leaf8's TX4 split loop (an 8x8 leaf's tx_depth=1 case) read its four 4x4 luma transform units with `scans.0` -- the leaf's own *8x8* scan table (64 entries) -- instead of `scans.1` (the 4x4 table), so `pos` values up to 63 got written into a 16-cell grid. Pre-existing bug, only reachable/visible once (1) stopped eating the stream earlier. 5-scale probe (examples/probe_tx4.rs, /tmp/tx4work/s*.obu) moved past every prior refusal point to new, later ones (scale 1.5 now refuses on "a directional chroma mode (round 2)" instead of an angle_delta/partition desync) -- real progress, not yet clean; next round needs the same trace-correlation to chase the remaining divergence(s). Suite green 172/172.
feat(av1): read the mv_hp/class0_hp bits real hp streams carryAhmet Kaan Gümüş · e192a62
feat(av1): read the mv_hp/class0_hp bits real hp streams carry The dropped-as-dead half-pel MV CDFs (our own writer never sets allow_high_precision_mv) were silently unread on foreign streams whose headers set the flag -- every later symbol shifted one bit, the same silently-unread-symbol shape as use_filter_intra. Tables restored, reads gated on the frame header's flag, plumbed through the inter tile path. On the pinned forwarding stream frame 3's desync drops from 2618 wrong luma pixels (worst 35) to 541 (all within 1, chroma exact) -- entropy now aligned, a luma-only reconstruction residue remains.
Merge branch 'lane-av1-rect': mod-32==8 key frames — the 8x8-leaf straddle pathAhmet Kaan Gümüş · e05f550
Merge branch 'lane-av1-rect': mod-32==8 key frames — the 8x8-leaf straddle path Fifteen rounds: side-8 CDF layer (TX_8X8/TX_4X4, partition_w8), Reach and scan tables for 8x8 leaves, mi-precise partition/mode contexts, the CFL alphabet, reduced_tx_set declared in the key-frame header, and the leaf mode-neighbour write moved out of the per-leaf loop. 640x360-class key frames now encode and round-trip through ffmpeg bit-exact; the 8x8-leaf split competes on RD cost; 40x40-class both-axes sizes still refuse.
fix(av1): declare reduced_tx_set in the key-frame header; rng in tracesAhmet Kaan Gümüş · a9fbebe
fix(av1): declare reduced_tx_set in the key-frame header; rng in traces The writer coded 8x8-leaf tx types against TX_SET_INTRA_2 tables while the header's reduced_tx_set:false told decoders to read TX_SET_INTRA_1 — a 7-vs-5-symbol alphabet skew that shifts the arithmetic coder's range with no symbol value ever differing. All existing sizes still round-trip bit-exact (16x16 resolves to the same 5-symbol set under both headers). Straddle test stays ignored: a further divergence remains past leaf(0,8).
feat(av1): begin a software key-frame decoder (round 1)Ahmet Kaan Gümüş · e6eadb9
feat(av1): begin a software key-frame decoder (round 1) Promotes msac's test-only SymbolDecoder to a real, non-test decoder (the inverse of SymbolEncoder, already spec-derived and roundtrip tested), and adds crates/ec-av1/src/decode.rs: a from-spec reader that mirrors tile.rs's sb_coeff_key_frame_tile symbol order (partition tree through 64x64/32x32/16x16, coefficient base/base-range/EOB/Golomb/sign syntax, CDF adaptation) without importing from tile.rs, which a sibling lane is editing concurrently. Round 1 scope: key frames only, DC_PRED blocks only, unskipped, and frames a whole number of 64x64 superblocks -- everything else refuses with a named error rather than miscoding. Within that scope, real encoder output (encode_key_frame_with_modes forced to DC_PRED, two sizes, real quantised AC/DC residual) decodes byte-exact against the encoder's own reconstruction. Encoded gains three pub(crate) fields (tile, mi_cols, mi_rows, base_q_idx) so a decoder test can reach the raw tile payload without re-deriving it from the OBU stream. Deferred to round 2: non-DC_PRED intra modes (needs the directional edge-reach plumbing), inter frames, skipped blocks, and the partial-superblock/gathered-CDF true-edge path.
2026-08-26
Merge branch 'lane-av1-size': pad-to-32 with cropped reconstructionsAhmet Kaan Gümüş · 77b8ab9
Merge branch 'lane-av1-size': pad-to-32 with cropped reconstructions The merge exposed a latent mvstack defect the two lanes could only trip together: real inter residuals (lane-av1-desync) on padded content (lane-av1-size) hit a block whose ref_mv context libaom derives from a diagonal corner probe our reduction never ran. Folded into this merge: - port libaom's scan_blk_mbmi(-1,-1) corner probe; ref_mv_ctx now splits (nearest_match, ref_match_count) exactly as mvref_common.c does - fix the REF_CAT_LEVEL DRL boost comparison (was trivially true); weights are boosted in place before the corner probe can add an unboosted entry - SymbolEncoder::tell(), the od_ec_enc_tell mirror the hunt relied on Gate: cargo test -p ec-av1 --release = 116 passed, 5 ignored.
feat(av1): inter tile writer sb_coeff_inter_frame_tileAhmet Kaan Gümüş · 302d3c4
feat(av1): inter tile writer sb_coeff_inter_frame_tile Flat 32x32-block-grid writer for inter frames: skip -> is_inter (ctx from above/left skip+inter tracking) -> intra path (Y_MODE by size group, not KF_Y_MODE) or inter path (single_ref chain, find_mv_stack, read_inter_mode NEWMV/NEARESTMV, DRL idx 0 only, mv_joint + per component symbols) -> existing coefficient path. Widens SymbolDecoder::symbol to pub(crate) for cross-module roundtrip tests. One-line encode.rs fix required for BlockCoeffs' two new fields (skip, inter) via ..BlockCoeffs::default() at its one non-spread construction site. Corner-cuts (documented in tile.rs): whole-superblock frames only, DRL always index 0, allow_high_precision_mv=0 assumed (validated, not silently rounded), InterMode limited to NearestMv/NewMv.
2026-08-25
feat(av1): the mode search prices its coefficients through the writer's CDFsAhmet Kaan Gümüş · 870ed18
feat(av1): the mode search prices its coefficients through the writer's CDFs The mode search costed the mode symbol exactly and the levels with a magnitude estimate. Now the levels go through write_coeffs on a throwaway encoder, so a trial is ranked by the bits the tile writer will really spend on it: end-of-block position, base levels, base range, signs and the Golomb tail, under the block's own contexts. The bit account prices the interval narrowing each symbol performs rather than its table entry, because the coder's eight-bit range multiply and its EC_MIN_PROB floor put the table entry 8% off the bytes actually written. Worth -1.19% BD-rate on a 1080p film frame and -0.20% on a screen capture against the estimate; LAMBDA_SCALE stays 0.1, re-swept.
feat(av1): the Golomb tail carries levels the base range cannot reachAhmet Kaan Gümüş · 0eba770
feat(av1): the Golomb tail carries levels the base range cannot reach The base and base-range syntax reach level fourteen between them, and until now the writer refused anything above it. The spec carries the rest as a Golomb tail — the remainder plus one, as its bit length in unary followed by its own bits — written after the coefficient's sign rather than beside its level, which is where `write_golomb` now puts it. The refusal moves up to the largest level the spec's twenty-bit reader can read back. Two gates. The spec's own `read_golomb`, written from the pseudocode, must hand back the level that was asked for over the whole range, which fails the moment the tail is a bit long, a bit short, or written against the wrong base. And ffmpeg must decode a run of DC levels either side of the threshold into a run of steadily brighter blocks, with the negatives of the same levels steadily darker, which fails if the tail lands in the wrong place in the syntax.
feat(av1): symbol coder for tile payloadsAhmet Kaan Gümüş · a580965
feat(av1): symbol coder for tile payloads AV1 specifies only the decoding process for its multi-symbol arithmetic coder, so the writer is derived as the inverse of section 8.2: it narrows the same interval decode_symbol tracks and flushes the shortest prefix that pins the interval down whatever bytes follow. CDF adaptation follows section 8.3.2, and CDFs are stored in the specification's own orientation (cumulative, 1 << 15 total, counter in the last entry) so the code reads against the spec text rather than against a decoder's internal complement. Covers the adaptive multi-symbol write, the fixed-CDF write, and L(n) literals; the flush handles carry propagation through the precarry buffer. Gated by a decoder written separately from the section 8.2 pseudocode: alphabets of 2..=16 symbols roundtrip over 4000 adaptive symbols each, 2000 mixed-width literals roundtrip, a 3000-item interleaving of both roundtrips, and a 1-in-256 stream is asserted to cost under a quarter bit per symbol so a backwards interval narrowing cannot pass. This is the primitive every AV1 tile payload is written through; the OBU writers so far cover only the headers around it.