edith_codecs
Clone
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
Lane vp9444: VP9 profiles 1/3 (4:4:4 / 4:2:2 / 4:4:0) and 12-bit
Branch lane-vp9-444, base main f0727a87. Crate scope: crates/ec-vp9
(+ tables constants). Worktree
/home/user/Documents/Code/Rust/edith_codecs-vp9444, private
CARGO_TARGET_DIR=$HOME/.cache/cargo-target-vp9444.
Deliverable: the last two named refusals — the profile gate (profile != 0 && profile != 2) and the subsampling gate (subsampling_x != 1 || subsampling_y != 1) — are removed, plus the 12-bit refusal. Every VP9 profile (0-3), every
coded subsampling (4:2:0 / 4:2:2 / 4:4:0 / 4:4:4) and 8/10/12-bit decode
byte-identically to a libvpx 1.15.0 oracle.
Baseline (milestone 0)
$ CARGO_TARGET_DIR=$HOME/.cache/cargo-target-vp9444 cargo test -p ec-vp9
(pre-fix) 26 test binaries, 0 failed, 0 ignored
Pre-existing warnings (unchanged, present at base, exactly 5): modes.rs
unused partition_probs / x_mis / y_mis + read_partition never used,
tables/mod.rs TM_PRED never used.
Fail-pre-fix witnesses (milestone 1)
Both refusals fire on the first frame of every new fixture. Captured on a
throwaway base worktree at f0727a87 (git worktree add ... f0727a87, a
scratch_prewitness test decoding frame 0 and printing the error):
$ PREW_IVF=fixtures/bitstreams/vp9-profile1-444.ivf ... cargo test -p ec-vp9 --test scratch_prewitness
PREW ... REFUSED: unsupported: vp9 profile 1 (this lane decodes profiles 0 and 2 only (profiles 1 and 3 are 4:4:4))
$ PREW_IVF=fixtures/bitstreams/vp9-profile3-444-10bit.ivf ...
PREW ... REFUSED: unsupported: vp9 profile 3 (this lane decodes profiles 0 and 2 only (profiles 1 and 3 are 4:4:4))
$ PREW_IVF=crates/ec-vp9/tests/data/vp9-profile1-422.ivf ...
PREW ... REFUSED: unsupported: vp9 profile 1 (this lane decodes profiles 0 and 2 only (profiles 1 and 3 are 4:4:4))
$ PREW_IVF=crates/ec-vp9/tests/data/vp9-profile3-440-10bit.ivf ...
PREW ... REFUSED: unsupported: vp9 profile 3 (this lane decodes profiles 0 and 2 only (profiles 1 and 3 are 4:4:4))
$ PREW_IVF=crates/ec-vp9/tests/data/vp9-profile2-420-12bit.ivf ...
PREW ... REFUSED: unsupported: vp9 bit depth 12 (this lane decodes 8- and 10-bit only (12-bit is not ported))
The subsampling gate is UNREACHABLE behind the profile gate for every real
stream (only profiles 1/3 may code non-4:2:0, and they were refused first), so
the pre-fix witness for 4:2:2 / 4:4:0 is the profile refusal above. The
vp9 subsampling string itself is covered by the same delete.
The two tests that pinned these refusals
(keyframe_exact::profile1_444_is_named_unsupported,
hbd_exact::profile1_still_refused_by_name) are deleted, replaced by the
byte-exactness witnesses below.
Root cause / design
The crate already stored planes as u16 with a single decode walk and
clip_pixel_bd, and the HBD/inter lanes had already parameterized MC, the
intra predictor and the transform by (ss_x, ss_y) in the places the oracle
needed them. The remaining hardcoding was a single idiom repeated in ~20
sites: let s = usize::from(plane != 0) — every plane-geometry shift, the
n4 block counts, the chroma transform size, the crop extents, the chroma
sub-block MV averaging and the loop-filter plane dispatch assumed 4:2:0.
The port threads the frame's real subsampling_x/subsampling_y through, per
libvpx 1.15:
Planesgainsss_x/ss_y; chroma isaw >> ss_xbyah >> ss_y(the aligned extent is a 64-multiple so the shift is exact) anddims()/crop use(w + ss_x) >> ss_x(uv_crop_width).plane_ss(hdr, plane)replacesusize::from(plane != 0); every>> s/<< s/(5 + s)splits into itsss_x/ss_yaxis.pd->n4_w/h=(bw << 1) >> ss_x(set_plane_n4).get_uv_tx_sizebecomes the realuv_txsize_lookup[sb_type][tx_size][ss_x] [ss_y](newUV_TXSIZE_LOOKUP, 208 entries, extracted verbatim fromvp9_common_data.c);ss_sizekeeps itsss_size_lookup[bsize][ss_x][ss_y]form and now also backs libvpx'sBLOCK_INVALIDcorrupt-frame check forbsize >= 8x8under any subsampling.average_split_mvs(mc.rs) selects byss_idx: luma/4:4:4 own sub-block MV, 4:4:0 the q2 vertical pair, 4:2:2 the q2 horizontal pair, 4:2:0 the q4 average over four.- Entropy contexts: the above arrays are now
2 * mi_cols_aligned_to_sbfor EVERY plane (libvpx sizes them so:2 * mi_cols_aligned_to_sb * MAX_MB_PLANE), because a 4:4:4 chroma block indexes the same span as luma. - Loop filter (
filter_frame) dispatches exactly likevp9_loop_filter_frame(vp9_loopfilter.c:1430): luma and 4:4:4 chroma throughfilter_block_plane_ss00(4:4:4 chroma reuses the LUMA masks AND luma filter levels —lfm->lfl_y), 4:2:0 chroma through the existingss11pass, and 4:2:2 / 4:4:0 through a newfilter_non420_planeport ofvp9_filter_block_plane_non420(masks +get_filter_levelbuilt inline per superblock band). - 12-bit: the only depth-dependent syntax element is the CAT6 token; 12-bit
needs the FULL
vp9_cat6_prob_high12with 18 bits (vp9_detokenize.c:137), not the 16-bit+ 2view 10-bit uses. NewCAT6_PROB_HIGH12[18]; thedecode_coefsbranch is now8 => 14 bits / 10 => 16 / 12 => 18.
Oracle dumper
New $HOME/.cache/vp9pix/drv_pixss.c (built against the HBD libvpx 1.15.0 at
$HOME/.cache/vp9hbd/lbuild): dumps EVERY shown frame's cropped planes as
little-endian u16 (8-bit zero-extended) for any vpx_image subsampling and bit
depth (chroma ceil(dim / 2^shift)). Cross-validated against ffmpeg rawvideo,
cmp-identical, on one stream per layout before use:
| layout | pix_fmt | oracle vs ffmpeg |
|---|---|---|
| 4:4:4 8-bit | yuv444p | IDENTICAL |
| 4:4:4 10-bit | yuv444p10le | IDENTICAL |
| 4:4:4 12-bit | yuv444p12le | IDENTICAL |
| 4:2:2 8-bit | yuv422p | IDENTICAL |
| 4:2:2 10-bit | yuv422p10le | IDENTICAL |
| 4:4:0 8-bit | yuv440p | IDENTICAL |
| 4:4:0 10-bit | yuv440p10le | IDENTICAL |
| 4:2:0 12-bit | yuv420p12le | IDENTICAL |
Byte-exactness (milestone 3)
$HOME/.cache/vp9pix/sweepss.sh <worktree> <stream>: libvpx-oracle dump vs our
scratch_pixdump10 dump (both u16 LE), cmp (no parser). Our side dumps only
SHOWN frames; the oracle dumps only shown frames too, so a hidden frame would
show as a size mismatch, not a silent pass.
New shapes (frame-aligned byte counts quoted):
| stream | shape | bytes | oracle vs ours |
|---|---|---|---|
| vp9-profile1-444.ivf (corpus, 60f) | 4:4:4 8-bit | 27,648,000 | IDENTICAL |
| vp9-profile3-444-10bit.ivf (corpus, 60f) | 4:4:4 10-bit | 27,648,000 | IDENTICAL |
| tests/data vp9-profile1-444.ivf (30f) | 4:4:4 8-bit | 13,824,000 | IDENTICAL |
| tests/data vp9-profile3-444-10bit.ivf | 4:4:4 10-bit | 13,824,000 | IDENTICAL |
| tests/data vp9-profile3-444-12bit.ivf | 4:4:4 12-bit | 13,824,000 | IDENTICAL |
| tests/data vp9-profile1-422.ivf | 4:2:2 8-bit | 9,216,000 | IDENTICAL |
| tests/data vp9-profile3-422-10bit.ivf | 4:2:2 10-bit | 9,216,000 | IDENTICAL |
| tests/data vp9-profile1-440.ivf | 4:4:0 8-bit | 9,216,000 | IDENTICAL |
| tests/data vp9-profile3-440-10bit.ivf | 4:4:0 10-bit | 9,216,000 | IDENTICAL |
| tests/data vp9-profile2-420-12bit.ivf | 4:2:0 12-bit | 6,912,000 | IDENTICAL |
Non-vacuity for the loop-filter port: with EC_VP9_SKIP_LF=1 (ours) and
SKIPLF=1 (oracle) the 4:2:2 / 4:4:0 streams were IDENTICAL on the first
non420 cut, which localized the first divergence to the new
filter_non420_plane; after the fix the full-filter dumps match. (The bug was
the horizontal filter_selectively_horiz gating: a 16-tap block edge swallows
the internal 4x4 edge, the 8-/4-tap branches emit it separately, and an
internal-only bit takes the else branch.)
Full regression corpus (milestone 4) — all IDENTICAL
| stream | frames-class | bytes | result |
|---|---|---|---|
| fixtures/bitstreams/vp9-1080p-23.976-8bit.ivf | 48 | 298,598,400 | IDENTICAL |
| fixtures/bitstreams/vp9-1080p-60-8bit.ivf | 120 | 746,496,000 | IDENTICAL |
| fixtures/bitstreams/vp9-2160p-23.976-8bit.ivf | 48 | 1,194,393,600 | IDENTICAL |
| fixtures/bitstreams/vp9-superframe-altref.ivf | 60 | 13,824,000 | IDENTICAL |
| fixtures/bitstreams/vp9-tiles-1280.ivf | 30 | 82,944,000 | IDENTICAL |
| fixtures/bitstreams/vp9-1080p-23.976-10bit.ivf | 48 | 298,598,400 | IDENTICAL |
| fixtures/bitstreams/vp9-1080p-60-10bit.ivf | 120 | 746,496,000 | IDENTICAL |
| ~/.cache/vp9pix/inter.ivf | 12 | 18,662,400 | IDENTICAL |
| ~/.cache/vp9pix/inter1.ivf | 12 | 18,662,400 | IDENTICAL |
| target/vp9-witness/odd-321x241.ivf | 12 | 2,791,752 | IDENTICAL |
| tests/data/intraonly.ivf | 10 | 2,304,000 | IDENTICAL |
| tests/data/scaledref.ivf | ? | 8,985,600 | IDENTICAL |
| tests/data/scaledref_odd.ivf | ? | 8,981,602 | IDENTICAL |
Tests added (milestone 5)
New crates/ec-vp9/tests/subsampling_exact.rs (10 cases): the eight committed
fixtures above, each compared as a flat u16 stream against ffmpeg rawvideo for
the matching pix_fmt, plus two media-gated cases over the canonical corpus
4:4:4 streams (vp9-profile1-444.ivf, vp9-profile3-444-10bit.ivf) that SKIP
by name when the fixture tree is absent.
Fixtures + generators (reproducible)
Committed under crates/ec-vp9/tests/data/. Every generator is
ffmpeg -f lavfi -i testsrc2=size=320x240:rate=30:duration=1 -pix_fmt <PF> -c:v libvpx-vp9 -profile:v <P> -b:v 500k -frames:v 30 -speed 8 <out>;
re-running each reproduces the committed bytes exactly (verified with cmp
on two of them; ffmpeg 8.1.2 / libvpx 1.15.0).
| file | PF | P | sha256 |
|---|---|---|---|
| vp9-profile1-444.ivf | yuv444p | 1 | 2358c5c0e19aebe3e90e2e1071365fb45a0aa6d15e285fb9c1c93337377149d8 |
| vp9-profile3-444-10bit.ivf | yuv444p10le | 3 | b9e3347f13881811238f74d23c4a17dd57f1c6dbb8c978087cf3615a62b78d70 |
| vp9-profile3-444-12bit.ivf | yuv444p12le | 3 | b91b7541ff8daa3b7655efde327e026524a61c64b81e1ec73fc35714b8bbd692 |
| vp9-profile1-422.ivf | yuv422p | 1 | b5381b5e123572563c1594fec7cace77f6b8cb185cea628e1323b08481e7d891 |
| vp9-profile3-422-10bit.ivf | yuv422p10le | 3 | 609dac28238a7c49158ef165b0d25687005cddc90ed10807916d1d3f40fd4d36 |
| vp9-profile1-440.ivf | yuv440p | 1 | 605a52469b68baf4daaa1dd728bd76313907f8ea078e3637d2c139dc44d96012 |
| vp9-profile3-440-10bit.ivf | yuv440p10le | 3 | a91ec788cf0569988e47d629c9aab6a384cbedd33402cce1a416877f079438c5 |
| vp9-profile2-420-12bit.ivf | yuv420p12le | 2 | 5c4e25ea07edc708d0559092cf775a41b6d828aaeb882e889e416cfc1eabc3bd |
(The corpus 4:4:4 streams vp9-profile1-444.ivf / vp9-profile3-444-10bit.ivf
in fixtures/bitstreams/ remain media-gated and unchanged.)
Gates
$ CARGO_TARGET_DIR=$HOME/.cache/cargo-target-vp9444 cargo test -p ec-vp9
26 test binaries, 0 failed, 0 ignored
$ ... cargo check -p ec-vp9
warning: `ec-vp9` (lib) generated 5 warnings (exactly the 5 pre-existing)
Scoped rustfmt applied to the changed leaf files only (decode.rs, loopfilter.rs,
mc.rs, tokens.rs, tables/mod.rs + gen_tables.rs via recursion, and the touched
test files); git status shows no sibling file touched.
Deferred / dispositions
- Accepted: a 4:2:0 12-bit stream (profile 2) is proven; a 12-bit 4:2:2 /
4:4:0 / 4:4:4 stream (profile 3) was also generated and proven IDENTICAL
(see
$HOME/.cache/vp9pix/sweepss.shon the /tmp 60-frame set) but only the 4:2:0 12-bit and 4:4:4 12-bit are committed as regression fixtures; the remaining 12-bit layouts live in the sweep evidence only. - Accepted (residual risk, pre-existing): the Rust clamps the MV unconditionally; libvpx only in the is_scaled branch (no-op for encoder output).
git log
$ git log --oneline f0727a87..lane-vp9-444
vp9444: decode profiles 1/3 (4:4:4/4:2:2/4:4:0) and 12-bit
MERGE-SIDE FOLLOW-UPS (2026-09-19)
Merged into main as a real --no-ff merge (divergence disjoint: main advanced
only in crates/ec-av1/ + lanes/ since base f0727a87).
-
Merge commit
740ed6af, parents57b29edb9d9bbe873d7f5e92f043056f2a78c778(main) +a1388daed03b47e8c5381da42f48f44570eb935a(lane).git ls-remote origin main==740ed6af40341f75be72dc993637e248b63a1c83. -
CREATE-list audit: 19 paths, exactly the lane's
git diff --name-status f0727a87...lane-vp9-444set — 7 src (decode/lib/loopfilter/mc/tables:: gen_tables/mod/tokens), 8 committed.ivffixtures, 2 modified test files (hbd_exact.rs,keyframe_exact.rs), 1 added test (subsampling_exact.rs), andlanes/vp9444.report.md. No duplicate/junk file, no*rs.rsartifact. -
Fixture provenance: all 8 committed fixtures
sha256match the report's table verbatim (checked post-merge). -
Merged-tree suite (
CARGO_TARGET_DIR=$HOME/.cache/cargo-target-vp9444merge):cargo test -p ec-vp9→ 25 test targets + Doc-tests, 48 passed, 0 failed, 0 ignored;subsampling_exact10/10; every media gate non-skipped.cargo check -p ec-vp9→ exactly the 5 pre-existing warnings (TM_PRED, read_partition, partition_probs, x_mis, y_mis) — warning parity held. -
Merged-tree corpus re-sweep (mandatory: this lane touched the shared plane/kernel representation). Our dumps regenerated from the MERGED build (
scratch_pixdump10, u16 LE) vs$HOME/.cache/vp9pix/drv_pixssoracle,cmp— all IDENTICAL:stream shown frames bytes result fixtures/bitstreams/vp9-1080p-60-8bit.ivf 120 746,496,000 IDENTICAL fixtures/bitstreams/vp9-1080p-60-10bit.ivf 120 746,496,000 IDENTICAL tests/data/vp9-profile1-444.ivf 30 13,824,000 IDENTICAL tests/data/vp9-profile3-444-10bit.ivf 30 13,824,000 IDENTICAL tests/data/scaledref_odd.ivf 10 8,981,602 IDENTICAL target/vp9-witness/odd-321x241.ivf 12 2,791,752 IDENTICAL (1080p per-frame size 3,110,400 samples ×2 = 6,220,800 B; 746,496,000 / 6,220,800 = 120 frames confirmed.
scaledref_oddis a resolution-changing scaled-ref stream, so its byte count is not a single-frame multiple.) -
Cleanup: lane worktree
edith_codecs-vp9444removed (branchlane-vp9-444kept);$HOME/.cache/cargo-target-vp9444{,merge}deleted. -
Kept (instruments for the next lane): all
crates/ec-vp9/tests/scratch_*.rsprobes and theEC_VP9_*trace/dump hooks, unchanged. -
Still open: none for this lane. The sibling
lane-av1-monoownscrates/ec-av1/and is untouched by this merge.