forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to lanes/vp9kf.report.mdClear filter

2026-09-17

vp9kf: report -- the third odd-extent cross-product cell is coveredAhmet Kaan Gümüş · ae29de7
vp9kf: report -- the third odd-extent cross-product cell is covered

`/tmp/odd_hw_tr.ivf` (1913x1210, `-tile-rows 1`) decodes 3 of 3 frames
byte-exact, closing the last unexercised shape: odd width x odd height x
tile rows. All three odd-extent x tile-grid cells now have a byte-exact
witness.

Encoder note recorded with the fixture: libvpx-vp9 declines `-tile-rows`
whenever `-tile-columns` is non-zero in the same command (1366x768,
1366x1200, 1366x1210, 1913x1210 and 1918x1200 with `-tile-columns 1
-tile-rows 1` all come out cols 1 rows 0), and it declines tile rows
outright on short frames (320x242). The tile-row witness therefore needs
`-tile-columns 0` at a tall resolution; layout confirmed with
scratch_tiledbg before the sweep.
vp9kf: tile-ROW streams decode byte-exact -- MI-aligned extents, frame-scoped contextsAhmet Kaan Gümüş · 332f251
vp9kf: tile-ROW streams decode byte-exact -- MI-aligned extents, frame-scoped contexts

Tile-row streams (log2_tile_rows > 0) now decode byte-exact: tr.ivf and
tr2.ivf 3 of 3 frames, previously 0 of 3. Seven fixes, each ported from
libvpx with its line:

1. tx probabilities come from the frame's FrameContext tables
   (get_tx_probs, vp9_pred_common.h:173), not the TX_* const defaults.
2. the tx-size context carries libvpx's "if (!has_above) above_ctx =
   left_ctx" fallback (vp9_pred_common.h:156-170).
3. above availability is gated on the FRAME (mi_row != 0, set_mi_row_col
   vp9_onyxc_int.h:430), not on the tile-row start; tile_row_start is gone
   from the decode chain.
4. ectx/mi are frame-scoped: allocated once per frame, above cleared once,
   left per SB row (vp9_decodeframe.c:2079-2083 / :2260-2261).
5. the above entropy/partition arrays are sized mi_cols_aligned_to_sb,
   closing a pre-existing OOB panic at widths not a multiple of 8
   (decode.rs:767 on a 1366-wide frame; the baseline panicked too).
6. intra edge extension is a branch-for-branch port of
   vp9_reconintra.c:300-394: the extend-vs-direct decision comes from
   mb_to_bottom_edge/mb_to_right_edge, the extension length from the
   MI-ALIGNED buffer extent (vp9_alloc_frame_buffer sets y_width =
   (width+7)&~7 -- yv12config.c:173-174,250-251), and the arithmetic is
   isize, closing an "attempt to subtract with overflow" at intra.rs:72 on
   320x242.
7. the chroma loop filter takes no plane-width bound: all five uv_w column
   clamps are gone, matching vp9_filter_block_plane_ss11's unclamped
   MI_BLOCK_SIZE>>1 groups (vp9_loopfilter.c:1394, :313-399) which write
   into the padded plane. At 1366 wide the last chroma group overhangs the
   visible plane by 4, so every clamped edge was dropped: luma stayed
   byte-exact while chroma was off by one (U 4/5/6, V 37/33/16).

Matrix (scratch_realsweep, 3 frames each): h242, h1082, h1082tr, h1082trc,
tr, tr2, t1080, t1080-single, single1080, w1366, w1366tc and the 320x240
tile0 sweep are all byte-exact. Still unexercised: odd width x odd height x
tile ROWS -- the encoder declines -tile-rows at those heights.

Verified by an independent reviewer with revert-alone discrimination: a
visible-length extent fails h242/h1082, a 64-aligned extent fails the 1080p
fixtures, the MI-aligned extent passes all; restoring the uv_w clamps
reproduces the chroma-only residue exactly. cargo test -p ec-vp9 is green
and cargo check prints the 5 baseline warnings.

2026-09-16

vp9kf: real content decodes byte-exact -- per-SB-row left contexts, MI-row chroma extentsAhmet Kaan Gümüş · bd4fadc
vp9kf: real content decodes byte-exact -- per-SB-row left contexts, MI-row chroma extents

Two boundary bugs, both found by driving real content through the decoder
(a real 320x240 clip and a real 1920x1080 clip, all-intra VP9 transcodes):

1. decode.rs: the left entropy and partition contexts were zeroed only on the
   tile's FIRST superblock row (`if sb_row == row_lo`). libvpx zeroes them at
   the start of EVERY SB row - vp9_decodeframe.c:2256-2258 (plain decode_tiles;
   row-mt twin :2114-2115, per-tile-row twins :1825-1826 / :1898-1899). Our
   luma left index wraps at mi_row 16, so the first block of SB row 2 read a
   stale slot: ctx 1 instead of 0. First divergent bool of a real 320x240 frame
   was #74792, block mi_row 16 mi_col 0, coef_probs[TX_4X4][Y][band 0][ctx]:
   oracle prob 195 (ctx 0) vs ours 84 (ctx 1) - everything before it agreed
   bit-for-bit.
2. loopfilter.rs: the chroma ss11 row-group extents were gated on the visible
   chroma height; libvpx iterates MI rows (`r += 4`, vp9_loopfilter.c:1400;
   horizontal `r += 2`, :1431), so a group whose first MI row is inside the
   frame is filtered even when its 8 chroma rows overhang the visible height.
   1080p lost chroma rows 536-539 (last SB row, mi_rows 135); the level read
   also goes through a bounds-safe `level_at` now.

Evidence (all reproduced independently by a reviewer in hermetic scratch
copies): real 320x240 0/3 -> 3/3 byte-exact; 1080p single-tile 0/3 -> 3/3;
1080p with 4 tile columns refused -> 3/3 (both this and the BE tile-prefix fix
meet here); keyframe_exact 4/4 and the whole crate green; 5 lib warnings
unchanged. Reverting either hunk alone regresses the matching sweep.

Also: lanes/realdesync.report.md (the diagnosis: first divergent decision,
ranked causes, the tile-row class caveat) and a report section recording that
the tile-ROW path (log2_tile_rows > 0) is NOT correct yet - three pre-existing
defects isolated there, listed in lanes/vp9kf.report.md.
vp9kf: report -- multi-tile is closed at 4b6a68b9Ahmet Kaan Gümüş · 7bd2aba
vp9kf: report -- multi-tile is closed at 4b6a68b9

The report's "third finding, not fixed" and the "next lane charter seed" item 2
both described the multi-tile refusal as an open walk/offset question. They now
record the closed finding: the per-tile size prefix is big-endian
(mem_get_be32, vp9_decodeframe.c:1674/1688/1690), the offset and the
get_tile_offset geometry were already right, an 8-tile 2560x1440 stream now
walks exactly, a 4-tile stream decodes 2/2 byte-exact, the single-tile path is
untouched, and the residual real-content divergence is tile-independent. The
desync item stays open for the diagnosis lane.
vp9kf: filter the luma internal-4x4 H edge on the frame's last MI rowAhmet Kaan Gümüş · a050448
vp9kf: filter the luma internal-4x4 H edge on the frame's last MI row

Reviewer finding (independent panel seat, PASS on the other five claims). The
port gated the luma int4 H edge on `sbr + row != mi_rows - 1`, labelled "UV
edge" - but skip_border_4x4_r lives only in the 4:2:0-chroma path
(vp9_filter_block_plane_ss11, vp9_loopfilter.c:1382) and in non420 under ss_y.
vp9_filter_block_plane_ss00 passes int_4x4_y & 0xff for every MI row
(:1286-1311) and vp9_adjust_mask keeps the last row's bits (:798-805), so real
content loses one filter tap set in the bottom 8 rows whenever the bottom MI
row holds a 4x4-tx cell. Neither fixture does (last int4 anchors at y=200/204
vs last MI row 232-239), so no existing gate could see it.

Witness, fails pre-fix: loopfilter::tests::
luma_int4_h_edge_is_filtered_on_the_last_mi_row - a 64x64 grid of BLOCK_4X4
cells at level 8, plane stepped by 4 at row 60 (sharper steps fail
filter_mask's gradient test and move nothing), asserting rows 60-61 changed.
With the guard restored it panics "was not filtered"; without it, green.
lib 9/9, keyframe_exact 4/4, ec-vp9-syntax 13+3, warnings unchanged (5).
vp9kf: real-content sweep -- SB-padded plane buffers, honest Picture strides, and the desync it foundAhmet Kaan Gümüş · 3678cfd
vp9kf: real-content sweep -- SB-padded plane buffers, honest Picture strides, and the desync it found

Adds crates/ec-vp9/tests/scratch_realsweep.rs (all-intra VP9 transcode of a real
video, ours vs ffmpeg, per-frame diff counts) and scratch_tiledbg.rs. The
library holds no VP9 content of its own, so this is the first time the keyframe
path has seen real imagery - and it is NOT byte-exact: a real 320x240 frame is
exact for rows 0-127 and wrong from row 128 down (19477/15337 diffs), i.e. the
entropy decoder diverges at a block in SB row 2. "Byte-exact" was
fixture-exact.

Two real defects fixed (fixture suite re-verified green, 17 binaries):

1. Plane buffers were 8-aligned; libvpx decodes an edge block at full size and
   lets the overhang land in the frame border (decodeframe.c:1216). A 32x32
   block at mi_row 132 of a 1080-row frame wrote 8 rows past the buffer and
   panicked at intra.rs:380. Buffers are now SB-aligned, and filter_frame gets
   the MI-aligned visible extent (the padded size OOB'd the level grid).
2. Picture::stride/uv_stride reported the aligned aw while the crop packs rows;
   a consumer trusting stride misread any non-64-aligned width. Now width/2.

Reported, not fixed: multi-tile frames (ffmpeg's default at 1080p) refuse with
'Corrupt: truncated tile data' - either the tile walk or the tile-data offset
is wrong for >1 tile, and 'corrupt' is the wrong claim until that is known.
lanes/vp9kf.report.md carries the table, the next-lane charter seed, and a note
that the fixture recipes were never recorded.
vp9kf: fix the stale tile-bounds pin in ec-vp9-syntax; record the merge follow-upsAhmet Kaan Gümüş · 0f31b1d
vp9kf: fix the stale tile-bounds pin in ec-vp9-syntax; record the merge follow-ups

The lane's gates were crate-scoped (cargo test -p ec-vp9), so the merge into
main is what surfaced a stale in-lib test: tile_bounds_match_the_spec_formulas
still pinned the pre-lane model - (0,3)/(0,4)/(0,1) for 30/60/1 superblocks.
libvpx's get_max_log2_tile_cols returns max_log2 - 1 (vp9_tile_common.c:45-49),
so the values are (0,2)/(0,3)/(0,0), and a single-superblock frame reads NO
increment bit (setup_tile_info's `while (max_ones-- && vpx_rb_read_bit(rb))`
with max_ones == 0). The code was right; the test was old.

Gates on main: ec-vp9 14 binaries green; ec-vp9-syntax 13/13 + 3/3;
cargo check --workspace --all-targets clean; ec-hw lib 12/12.

Also records in lanes/vp9kf.report.md: the merged/branch/removed-worktree state,
the fixtures/vp9 copy main needed (fixtures/ is gitignored), the next-lane
candidates, and the trace-hook/scratch-harness cleanup still open.
vp9kf: keyframes byte-exact vs ffmpeg -- iadst16 stage 4, mask-driven loop filterAhmet Kaan Gümüş · 03cbf64
vp9kf: keyframes byte-exact vs ffmpeg -- iadst16 stage 4, mask-driven loop filter

keyframes_match_ffmpeg PASSES: FRAME=1 pre-LF Y 1310 diffs -> post-LF Y/U/V 0
(FRAME=0: Y pre 746 -> post 0). Byte dumps are the evidence channel.

1. iadst16 stage 4 + output permutation, ported from inv_txfm.c:520-554:
   negated sum for pairs (2,3)/(14,15), (-x_i + x_j) for the second slot of
   (6,7)/(10,11), output[13] = -x13. Reverting this alone fails frame 1 at
   Y(120,68) 209 vs 210.
2. The loop filter is now driven by vp9_setup_mask's masks for luma AND
   chroma: build_masks/build_y_mask (blocks <16x16: only the first 8x8
   touches the UV masks), then vp9_adjust_mask (TX_32->TX_16, 4-tap border
   promotion, rows/columns edge masks, rows==1 and rows==5 UV demotions,
   mask_uv_int for internal edges). All eight mask tables re-read against
   vp9_loopfilter.c:39-205 constant by constant.
3. Luma's V and H passes no longer interleave per mask bit (chroma already
   knew this); that was the last 19 Y diffs after the mask port.

Dead code: LfGrids.tx4 (write-only, drops a per-frame mi grid),
tables::uv_txsize_lookup and tables::BLOCK_INVALID (only user was the old
chroma tx-grid walk). Warning count back to HEAD's 5.

Suites: lib 8/8, keyframe_exact 4/4, dump_probe + 8 scratch harnesses PASS.
scratch_synth still fails on the tmpfs-gone /tmp/synth-kf-frame.bin
(pre-existing, fixture-dependent).

2026-09-14

vp9kf: chroma 64x64 border 4-tap is 8-tap (adjust_mask)Ahmet Kaan Gümüş · e2fa4f0
vp9kf: chroma 64x64 border 4-tap is 8-tap (adjust_mask)

left_border_uv 0x1111 / above_border_uv 0x000f. U 16→7, V 20→11, Y still
byte-exact. keyframes_match_ffmpeg still FAIL at U(31,11). Not pushed.
vp9kf: d153 row, idct32 stage 8, flat2 q0, chroma tx-grid — Y byte-exactAhmet Kaan Gümüş · 82ca712
vp9kf: d153 row, idct32 stage 8, flat2 q0, chroma tx-grid — Y byte-exact

generic d153 no longer skips row 1; idct32 runs vpx stage 8; flat_mask5
compares q4..q7 to q0 (not p0). Pre-LF Y matches libvpx; post-LF Y matches
ffmpeg. Chroma still 16 U + 20 V off (HANDOFF #6). Not pushed.
vp9-kf: loopfilter per-MI masks, 4-line kernel walk, flat_mask5 semanticsAhmet Kaan Gümüş · 9769de2
vp9-kf: loopfilter per-MI masks, 4-line kernel walk, flat_mask5 semantics

- luma edge masks per-MI (internal MI boundaries of wide blocks filter;
  left/above_64x64_txform_mask rules), luma edge set now matches the
  instrumented-libvpx trace 3044/3044 anchors
- lpf_edge walks the 4 pixel-lines of each chunk (was filtering only
  every 4th row/col)
- flat2 follows flat_mask5's shifted params: q7 vs q0, no |q0-p0| clause
- probes: EC_VP9_SKIP_LF, LFTRACE (ours + patched oracle), scratch_lfdump
  Y-plane dumps; HANDOFF #5 in lanes/vp9kf.report.md

keyframes_match_ffmpeg still FAIL: first diff (76,2) 47 vs 48; pre-LF
decode divergence from (88,24) tracked as the next dominant bug.
vp9kf: entropy round 2 — trees, kf partition probs, 8x8 partition symbol, tile-info boundsAhmet Kaan Gümüş · c445467
vp9kf: entropy round 2 — trees, kf partition probs, 8x8 partition symbol, tile-info bounds

- INTRA_MODE_TREE leaf order fixed to libvpx vp9_intra_mode_tree; the invented
  spec-doc chain UV_MODE_TREE deleted (v1.15 decodes uv with the same tree,
  decodemv.c:232). SEGMENT_TREE corrected to vp9_seg_common.c:58 balanced form.
- Keyframes now code partitions with vp9_kf_partition_probs (added; spec 7.2),
  not the inter defaults. FrameContext::new(key_frame).
- The 8x8-level partition symbol is read (decodeframe.c:1188 runs before the
  !hbs branch); sub-8x8 shapes occupy the full 8x8 mi area (luma 2x2 4x4 TUs,
  chroma 4x4 once per 8x8). bsize_of_n4 mapping fixed (2->16x16, 1->8x8).
  Duplicate kf_uv_probs removed from modes.rs (kept in tables).
- ec-vp9-syntax DEVIATION (flagged for merge review): tile_cols_log2_bounds
  returned max-1, skipping the terminating tile-cols increment bit; bounds are
  now inclusive and rows mirrors vp9_get_tile_n_bits. Test re-pinned to
  libvpx/spec values (1920 -> (0,3), 3840 -> (0,4), 1 -> (0,1)).
- keyframes_match_ffmpeg still FAILING (ours 120 vs 72 at pixel (0,0); was 133).
  inter_is_named_unsupported PASSES as a named Error. Debug traces (TILE/B/C/RC,
  EC_VP9_FORCE_TAIL) and scratch_* harnesses kept for the next round; see
  lanes/vp9kf.report.md HANDOFF #2.