edith_codecs
Clone
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
lane-ab128 — the four AB shapes at the 128 superblock root
PARTITION_HORZ_A (two 64x64 on top, one 128x64 below), _HORZ_B (one
128x64 on top, two 64x64 below), _VERT_A (two 64x64 left, one 64x128
right), _VERT_B (one 64x128 left, two 64x64 right) are written, witnessed
sample-exact through decode_stream AND ffmpeg on all four shapes, and
measured on both gates. They ship OFF (EC_AV1_B128AB=1 turns them on):
every gate row is flat or 0.1 worse. The lane's value is the measurement and
the machinery, not a shipped default.
1. What was built
crate::encode::ab128_pieces(symbol, (mi_row, mi_col))— the three pieces of a shape, position and footprint, in libaom'sdecode_partitionorder and decode.rs'sb128_aborder (decode.rs ~35269): HORZ_A = TL, TR, bottom half; HORZ_B = top half, BL, BR; VERT_A = TL, BL, right half; VERT_B = left half, TR, BR. One table, read by the search, by the writer and by the winner's grid publication, so the three cannot drift (class table and reader move together).search_root_128_ab— the three pieces priced through the samesearch_skip_64the NONE and HORZ/VERT arms use, each at its own footprint, each published into the mi grid (record_mi_rect) before the next is searched and the whole 32x32-mi window restored withMiGrid::snapshot_rect/restore_rectbefore returning (class encoder-grid-drift-invisible-to-pixel-gate). The cost carries the root's ownpartition_bits_sym(128, symbol).Quadrant::Ab128(symbol, pieces)on the root's top-left 32x32 entry, the fifteen othersCovered— exactly asRect128does.- The writer needed no new block function: a 64x64 AB piece is one inter
block coded at side 64 with
write_w == write_h == 64, and a half is the 128x64/64x128write_inter_block_128_rectalready codes. All three go throughwrite_inter_block_128_rectat their own(w, h). EC_AV1_B128AB(default off),force_b128_ab(test knob, 0 or the partition symbol 4..=7), per-shape search and writer counters, and theEC_AV1_B128_CENSUSline extended withAB roots a/b/c/d.
2. Charter premises checked against the code
- "decide whether the 64 pieces of an AB shape run the full 64-root search
or the skip-64 search, and justify by measurement; the full search is what
libaom does" — refuted by the syntax, so nothing to measure. decode.rs'
sb128_abcodes each 64x64 piece as ONEdecode_inter_blockatside = SBwith no partition symbol of its own (square64_inter!), which is libaom's own AB shape: an AB piece is a whole block, never a further-partitionable root. A "full 64-root search" candidate could not be written at all. The pieces aresearch_skip_64at (64, 64), skip-only, for the same reasonsearch_root_128_rect's halves are: the 128 residual arm they would share is parked behindEC_AV1_B128RES. - "Extend
cdef_unit_ownerfor the two-unit shape and the four-waypick_filtersgrouping" — not needed, and NOT done (rung 1: it would be dead code).write_cdef_idxwrites a literal only for a NON-SKIP block; every AB piece and every HORZ/VERT half is skip, so such a root puts nocdef_idxin the stream at all and CDEF filters none of its (all-skip) units.cdef_unit_ownercollapses units only forWhole128, which is the one 128-wide shape that can carry a residual (EC_AV1_B128RES). The same reasoning coversRect128, which lane-b128hv also left out of the map — swept and confirmed inert, not a sibling defect. The day a piece carries a residual,cdef_unit_ownermust learnRect128andAb128in the SAME diff; that is named as the constraint below. write_delta_qneeded no change: it already gates on the block's own position within the (128-wide) superblock, and no AB piece is the whole superblock, sois_whole_sb = false— whatwrite_inter_block_128_rectpasses — is right for all three.intrabc_dv_predis intra-frame only and this is the inter writer.- The charter's witness fixtures ("4K bars + film B 12-frame fixtures used by
a_128_root_horz_and_vert_halves_decode_exact_through_both_decoders") are stale: that test encodes ONE synthetictestsrc21280x768 12-frame clip. The AB witness mirrors it exactly.
3. Witness
encode::tests::a_128_root_ab_shapes_decode_exact_through_both_decoders
(--ignored), five passes over the same clip — each shape forced at every
root, then unforced:
HORZ_A: search won [660, 0, 0, 0] writer coded [1320, 0, 0, 0]
HORZ_B: search won [0, 660, 0, 0] writer coded [0, 1320, 0, 0]
VERT_A: search won [0, 0, 660, 0] writer coded [0, 0, 1320, 0]
VERT_B: search won [0, 0, 0, 660] writer coded [0, 0, 0, 660*2]
unforced: search won [0, 0, 1, 1] writer coded [0, 0, 2, 2]
Every pass sample-exact against the encoder's own reconstruction through
decode_stream and through ffmpeg, first run, no bisect needed. RED before
this lane by construction: write_sb128_root could name only NONE / HORZ /
VERT / SPLIT.
4. Census on real content (EC_AV1_B128_CENSUS=1, long-GOP films)
171 inter frames: a typical frame is 7 whole 128 roots, 0-1 HORZ + 0-1 VERT, AB roots 0/0/0/1, out of ~1050-1900 coded blocks. 44 of 171 frames took no
AB root at all; the modal non-zero frame takes exactly one. The shapes are
real but rare — which is the whole BD result below.
5. Gates (arm = default-on build, control = EC_AV1_B128AB=0; lower is better)
12-frame bd_rate_screen_native (~/.cache/ab128/12arm.log, 12ctl.log):
| row | arm vs libaom | ctl vs libaom | arm vs rav1e | ctl vs rav1e |
|---|---|---|---|---|
| bars 1080p | -3.4% | -3.4% | -19.0% | -19.0% |
| bars 2160p | +8.4% | +8.4% | -14.0% | -14.0% |
| film A | +18.1% | +18.0% | -6.2% | -6.3% |
| film B | +23.1% | +23.0% | -3.3% | -3.5% |
| screen | +14.4% | +14.4% | -33.2% | -33.2% |
Long-GOP bd_rate_film_long_gop — the deciding gate (lgarm.log,
lgctl.log):
| row | arm vs libaom | ctl vs libaom | arm vs rav1e | ctl vs rav1e |
|---|---|---|---|---|
| film A | +22.0% | +21.9% | -8.5% | -8.6% |
| film B | +75.8% | +75.8% | +0.8% | +0.8% |
Wall (both arms run concurrently, so the contention is shared): long-GOP 706.6 + 520.0 = 1226.6 s arm against 665.0 + 463.5 = 1128.5 s control, +8.7% — inside the +15% ceiling, but bought for nothing.
Keep rule: FAILED. It asks for both film rows down on both columns, or one >= 0.5 down with the other flat. Film A is 0.1 WORSE on both columns, film B is unchanged to the decimal. The candidate costs a partition symbol on every root it wins and buys back less than it spends. Shipped off.
Known under-pricing shared with lane-b128hv (unchanged by this lane): a
non-origin AB piece codes no delta_q group, but the piece AT the superblock
origin does, and nothing here prices it — lane-rectdq is adding the
delta_q_bits pricer. The mispricing is under a bit per root and is the same
for the rect arm, so it cannot explain a 0.1 BD miss on its own.
6. Suite, pins, checks
- Pins:
encode::tests::the_encoders_own_streams_are_byte_identical_to_their_pinsgreen at default and atEC_AV1_SPEED=6, unmoved (pins2.log) — the arm is off by default, so the default encoder is byte-identical to main's. --ignored --exact encoder::tests::every_speed_preset_decodes_sample_exact_through_both_decoders: ok.--ignoredHORZ/VERT witness (lane-b128hv's): ok, unaffected by the counter split (a 64x64 piece no longer counts as a "64x128 half").- Suite in three lanes, all green:
-- --skip stream::345 passed / 0 failed / 40 ignored;-- stream:: --skip 10bit202 / 0 / 15;-- 10bit42 / 0 / 1. timeout 900 cargo check --workspace --all-targets -j4: 0 errors, 0 ec-av1 warnings (the 22 warnings in the log are pre-existing ec-opus / ec-vorbis ones).
7. Disposition
deferred: a non-skip AB piece— the 64x64 pieces could carry the 64 root's own residual (b64_residual), which is where libaom's AB shapes earn their keep; the skip-only pieces here can only ever move the partition price. Unblocked by nothing but a lane: the residual writer at 64 exists (Whole64), it is the piece'ssearch_skip_64(.., residual = true)call and thewrite_inter_block_128_rectrefusal that would have to move — together withcdef_unit_ownerlearningRect128andAb128in the SAME diff, since a non-skip piece writes acdef_idxliteral that covers two units for a half.accepted: the delta_q under-pricing— shared with lane-b128hv, under a bit per root, lane-rectdq owns the pricer.