Commits
Commits on
dfeffbcebd64426ceeebbf03214c8d6fe57282d6Filtered to crates/ec-av1/src/mvstack.rsClear filter2026-09-20
ec-av1: rect intrabc r4 -- publish every block's footprint into the intrabc mv gridAhmet Kaan Gümüş · e9e3a48
ec-av1: rect intrabc r4 -- publish every block's footprint into the intrabc mv grid The DV predictor of a later intrabc block is libaom's INTRA_FRAME MV stack, built by scans that walk `xd->mi[]` -- an entry for EVERY coded block -- and step by `mi_size_wide/height[candidate->bsize]`. This decoder's grid held only the intrabc blocks, so a non-intrabc neighbour read as `None`, the scan advanced that cell by one instead of by its real width, and at mi(84,104) of the 512x384 testsrc2 cq45 arm the row scan's extended offset -3 over-reached from libaom's last probe (81,106) to (81,108). The extra -512 vote (weight 16) flipped the sorted stack, so `nearestmv` became -512 where libaom's is -520: one whole-pel-wrong skip=1 copy, 528 wrong luma samples. `MiGrid` gains a block-COVERAGE map (`cover_rect`) filled for every coded block from `Neighbours::fill_lf_grid_rect`, and `get` synthesizes a non-inter, zero-MV entry from it, which `single_ref_match` never matches but the scan still steps by. An unfilled cover reads as uncovered, so the tile writer's own grid and every synthetic test grid keep their old behaviour exactly. Stream B is byte-exact; stream A stays byte-exact. New gate `a_coded_rect_intrabc_block_reconstructs_in_both_orientations` (HORZ coded, VERT coded -- the regression stream -- and TX_MODE_SELECT), with a new coded-orientation instrument; it fails pre-fix at the VERT arm.
2026-09-09
2026-09-08
fix(av1): keep the mi cell at 16 bytes -- the pricer's skip band rides beside itAhmet Kaan Gümüş · c73918f
fix(av1): keep the mi cell at 16 bytes -- the pricer's skip band rides beside it mi_info_cell_stays_compact and mi_info_stays_small_enough_for_a_4k_grid went red: a bool in MiInfo took the cell from 16 to 18 bytes, and that struct is what every mv-stack scan walks. The flag moves to a Vec<bool> beside the cells, filled only by the encoder's record_mi and read only by the stack's above_skip/left_skip. Streams are byte-identical (both pins unchanged).
fix(av1): the RD pricer's skip and is_inter symbols were priced at CDF context 0Ahmet Kaan Gümüş · b527fb1
fix(av1): the RD pricer's skip and is_inter symbols were priced at CDF context 0 The tile writer contexts skip off its above/left neighbours' own skip flags and is_inter off their intra/inter state; the pricer read row 0 for both, so the skip-versus-residual margin every inter candidate is chosen on came off the wrong CDF row. MvStack now carries the two cells the writer reads (its above/left NeighbourRef plus each side's skip, published by record_mi), and the two new shared pricers read the writer's own contexts. MiInfo gains skip: the encoder search and the tile writer publish the real flag; the decoder's grid publishes false, nothing on that side reads it.
feat(av1): price the reference symbols at the writer's own neighbour contextsAhmet Kaan Gümüş · 9a0a562
feat(av1): price the reference symbols at the writer's own neighbour contexts Arm 2 of the pricer fix: the search charged every single_ref symbol out of context row 0, where a backward reference reads as almost free (p1=1 costs 0.23 bits against LAST's 2.74). MvStack now carries the two cells write_single_ref derives its contexts from, so the pricer runs the same single_ref_p1..p6 context functions the writer does.
2026-09-07
fix(av1): temporal MV candidates ignored force_integer_mvAhmet Kaan Gümüş · 0c17efc
fix(av1): temporal MV candidates ignored force_integer_mv `lower_mv_precision` implemented only its `is_integer == false` half, on a comment claiming no reachable stream sets `force_integer_mv` because `allow_screen_content_tools` is refused at the stream level. Neither half of that claim holds: libaom turns screen-content tools on for dark, smooth FILM (`av1_set_screen_content_options` counts near-flat 16x16 blocks) and then sets `force_integer_mv` on the frames its hash test calls static, and this decoder parses such streams without refusing anything. The consequence was invisible to the parse: every temporal MV candidate came out at eighth-pel where libaom rounds it to full pel, so the mv stack held values libaom never produced. The stack still had the right shape for a while, so the frame decoded "successfully" into a whole-frame prediction mismatch, and the entropy desync that followed surfaced as the unrelated refusal "a Golomb tail longer than this decoder reads" (class `refusal-names-a-correlate`). First divergence, measured against the instrumented libaom oracle: film-B gate clip, `-cpu-used 6 -crf 35 -g 12`, decode-order frame 3 (order_hint 1, the one inter frame with `force_integer_mv == 1`), block mi(0,0), the NEWMV predictor -- identical `EC_TPL` field cells and identical range in both decoders, aomdec's stack `(16,0)w16 (16,-8)w12 (8,-40)w4` against ours `(14,-4)w16 (12,-2)w8 (12,-38)w4 (16,-4)w4`. Class: `branch-dropped-as-unreachable` -- a spec branch deleted on an unreachability note that a capability change (screen-content streams no longer refused) silently invalidated. All four libaom film-B ladder points at 48 frames now decode sample-exact against ffmpeg/libdav1d except crf 5, which desyncs on the KEY frame at mi(184,344) (base_q 9) -- a separate, still-open defect.
2026-09-06
wip(av1): compound syntax writers, snapshot at the agent cap (may not compile)Ahmet Kaan Gümüş · b22678dBrowse files
feat(av1): a two-level frame pyramid in the encoder facadeAhmet Kaan Gümüş · d496905
feat(av1): a two-level frame pyramid in the encoder facade Hidden ALTREF coded ahead of its display position and re-output by a show_existing_frame header, per-level quantizer offsets, a per-level rate loop and packet dts/level. The flat one-in-one-out path is untouched.
feat(av1): the writer mirrors the decoder's single_ref context functionsAhmet Kaan Gümüş · f5cb29a
feat(av1): the writer mirrors the decoder's single_ref context functions InterInfo carries its own ref_frame and the writer codes the whole single_ref_p1..p6 tree through write_single_ref, each symbol at the context decode.rs read_single_ref uses (single_ref_p1_ctx/p2/p3/p4/p5/p6 on the immediate above/left neighbours' references, -1 for an intra or unavailable one) -- the writer's Neighbours now tracks above_ref/left_ref the way the decoder's does. The mv stack and the MI grid take the block's own reference too. Byte-exact against the previous streams: the BD gate reports the same bytes at all twelve points (133.7/162.3/83.8 vs libaom, 84.7/113.1/18.0 vs rav1e), which is what proves the mirrored contexts equal the collapsed all-LAST ones they replace. mvstack::single_ref_ctx is now test-only.
2026-09-05
perf(av1): route every gate counter through hit!/hit_do! behind a default-on gate-counters featureAhmet Kaan Gümüş · 04187f1Browse files
perf(av1): inline the temporal-MV probe and shrink the tpl cell, -0.4% parse instructionsAhmet Kaan Gümüş · ac23155
perf(av1): inline the temporal-MV probe and shrink the tpl cell, -0.4% parse instructions
The mv-stack builders' temporal-MV sample was a closure LLVM would not
inline into either builder (both far past its size threshold), so it was
emitted as a real function -- find_mv_stack_with_sign_bias::{closure#1}
and find_mv_stack_compound::{closure#1}, together 3.5% of the parse
thread -- and every one of the up-to-19 probes per inter block paid a
call plus the argument shuffle. Making it an #[inline(always)] free
function with the EC_TRACE_TPL dump split off #[cold] removes both
symbols (-0.26% instructions).
motion_field_projection re-derived two of libaom's three pos_valid terms
for every one of a 4K field's 129600 cells per direction although
neither depends on the cell; they are now one early return and one
per-ref table, and the cell walk reads contiguous row slices instead of
a bounds-checked accessor (-0.13%).
The projected tpl cell dropped its Option tag: the projection only ever
stores a strictly positive ref_frame_offset, so 0 already is libaom's
own 'never projected' marker, and the tag cost 8 bytes per cell (20 vs
12) over a field that is 2.6 MB at 4K.
Byte-exact: 12/12 gate hashes at 1, 4 and 16 threads.test(av1): the clamp gate's candidate is far outside the frame but inside the spec's MV widthAhmet Kaan Gümüş · 3ec98b7
test(av1): the clamp gate's candidate is far outside the frame but inside the spec's MV width lane-migrid: the fixture stored 100000 in a motion vector, which the spec (and libaom's own int16_t `MV`) cannot represent; 30000 is still far past this 16x16-px frame's clamp window, so the expected clamped value is unchanged.
perf(av1): the mi grid's cell is 16 bytes -- MiInfo motion vectors ride as i16Ahmet Kaan Gümüş · 3c15699
perf(av1): the mi grid's cell is 16 bytes -- MiInfo motion vectors ride as i16 `MiInfo` is written per 4x4 cell for every coded block and read by every MV stack scan, so the cell's size is that scan's memory traffic. Both motion vectors now ride as `i16` pairs, which is libaom's own `MV` (`int16_t row, col`) and the spec's MV range, taking the cell (and `Option<MiInfo>`, whose niche still lives in `is_inter`) from 24 bytes to 16 and the grid's index arithmetic from a multiply to a shift. `mv32`/`mv16` widen/narrow at the handful of producer/consumer sites; `mv16` debug-asserts the range. `MiGrid::get`/`get_frame` return the cell by value now (16 bytes, one move) instead of by reference. Measured on the 4K segment, interleaved ABAB: instructions:u -0.03% at 1 thread and -0.09% at (16,4,2), task-clock:u lower in 3/3 threaded pairs (-1.6%/-9.4%/-3.2%, box loaded, so the sign is the claim, not the size). All 12 gate hashes unchanged at 1/4/16 threads.
perf(av1): 24-byte mi grid cellAhmet Kaan Gümüş · 5ba1d08
perf(av1): 24-byte mi grid cell `MiInfo` is one cell per 4x4 unit of the frame and `find_mv_stack` walks it for every inter block, so the cell's size is that scan's memory traffic. The second reference slot carried two `Option` tag words (`ref_frame1`, `mv1`); slot 1 only ever holds a real reference, so `NO_REF1` (-1) tags it absent and `mv1` becomes a plain pair -- 32 -> 24 bytes, `is_inter` still giving `Option<MiInfo>` a niche so the grid cell costs no extra word. An interintra neighbour (slot 1 = INTRA_FRAME, no second MV) was excluded by its `mv1` being `None` and is now excluded by `ref_frame1 > 0`, the same condition libaom's own ref-diff scan uses. Byte-exact: all 12 gate hashes (4 streams x 1/4/16 threads) unchanged. instructions:u on the 4K segment 410.629 -> 410.478 G at 1 thread, 419.746 -> 419.481 G at (16,4,2); task-clock at (16,4,2) 42.41 -> 41.81 s against the lane base.
perf(av1): heap-free MV stack and row-fill mi publicationAhmet Kaan Gümüş · fc982db
perf(av1): heap-free MV stack and row-fill mi publication The MV stack was two heap allocations per inter block (`entries` plus `drl_ctx`); both lists are bounded by a spec constant, so they move into a fixed-capacity inline `SmallVec` that derefs to the same slice API. Mode-info publication stamped its block footprint cell by cell through `MiGrid::set`; rows are contiguous, so `MiGrid::fill_rect` fills each row with one `slice::fill` of the `Copy` cell instead. Byte-exact: all four gate streams hash unchanged at 1 thread. instructions:u on the 4K segment 412.376 -> 410.629 G at 1 thread, 421.419 -> 419.746 G at (16,4,2).
perf(av1): hoist the temporal-MV probe out of the per-sample loop, thread-local the mvstack gate countersAhmet Kaan Gümüş · e08e4e4
perf(av1): hoist the temporal-MV probe out of the per-sample loop, thread-local the mvstack gate counters `add_tpl_ref_mv` re-derived the parity, the field bounds and the row base on every one of the (up to 19) 8x8 probes a query block makes. Those are per-BLOCK quantities: `row8 = mi_row + blk_row + (mi_row even)` means the cell index is `(mi_row + 1 - (mi_row & 1) + blk_row) >> 1`, and an arithmetic shift keeps the spec's `row8 < 0` rejection exact. `TplProbe` holds the two bases plus the cell slice, so a probe is an add, a shift and a bounds check; the compound stack reads the cell ONCE and projects it to both sides instead of walking the field twice. `EC_TRACE_TPL`'s per-sample dump is unchanged: the flag is read once per block and the traced path still goes through `add_tpl_ref_mv` itself. The four mvstack firing counters (`TMV_HITS` per inter block, `STACK_FULL_DROPS` per candidate insertion, `COMP_GM_FILL_HITS`, `TILE_REACH_CLIPS`) were process-global atomics: one shared cache line bumped by 16 frame threads on the parse critical path. They are now thread-local `Cell`s, the form every other gate counter in the crate already uses; the gates that read them decode on their own thread. -0.21% instructions on the 4K segment at 1 thread (443.29 vs 444.24 G); the counter step is flat there and inside the box's noise at 16 threads. Byte-exact: all 12 gate hashes unchanged at 1/4/16 threads.
test(av1): pin Option<MiInfo> at 32 bytes or lessAhmet Kaan Gümüş · 4bb9310
test(av1): pin Option<MiInfo> at 32 bytes or less The 4K mi grid is ~518k cells refilled per frame and walked by every mv-stack scan, so a widened field here is a measurable throughput regression rather than a free change.
perf(av1): mi-grid writers fill whole rows and MiInfo carries u8 block sidesAhmet Kaan Gümüş · 77576dd
perf(av1): mi-grid writers fill whole rows and MiInfo carries u8 block sides The mode-info bookkeeping the parse thread runs per coded block wrote its grids one 4x4 cell at a time, each write a bounds check: `fill_lf_grid_rect` (6 grids), `fill_skip_grid_rect` (4), `record_uv_mode_mi`, `record_mi_rect` and `record_inter_rect_mi`. A mi rect's cells are contiguous inside one grid row, so each of those rows is one `fill_span` -- same cells, same values, including the out-of-range drop the per-cell `get_mut`/`break` did. `record_mi_rect`'s per-cell `array::from_fn` predicate is monotone in the plane bound (`bound[1] == bound[2] >= bound[0]`), so the left/above neighbour state is three contiguous runs, not a branch per cell. `MiInfo::size`/`size_h` are 4x4-cell counts that never exceed 32; as `u8` they take `Option<MiInfo>` from 48 to 28 bytes, shrinking both the per-frame grid fill and the mv-stack scans' cache footprint. Byte-exact: all 12 gate hashes unchanged. instructions:u on the 4K segment 570.74 G -> 565.02 G (-1.00%).
perf(av1): remove four per-block allocation sites from the parse pathAhmet Kaan Gümüş · d4c852e
perf(av1): remove four per-block allocation sites from the parse path
lane-alloc. A tracking global allocator (new `alloc_probe` example: size
histogram plus a sampled backtrace per 512 allocations, with line numbers)
ranked the decoder's allocation sites on the 4K segment -- 83.6 M
allocations over 272 frames. Four of the top sites are removed here:
* `find_samples` built a `String` per warp block (`format!("{mi_row},
{mi_col}")` plus the env snapshot's own `String` clone) to compare against
an unset debug flag; the OBMC blend did the same for `EC_MCB`. Both now
sit behind the per-call-site `env_flag!` load.
* `Edges::build` allocated four vectors per intra prediction (collect,
grow, then a second buffer to prepend the corner); it builds each edge
once, corner first. `directional`'s two working buffers were a copy of
those same vectors, so it takes the `Edges` by value instead.
* `obmc_neighbour_pred` allocated its prediction buffer per neighbour per
plane; the caller now keeps one buffer per plane for the whole block.
* The MV stacks and the OBMC neighbour lists are capped (8 entries /
`max_neighbors`), so they reserve once rather than growing and memcpying
up to four times.
seg4k at one thread: 601.657 -> 599.329 G instructions:u (-0.39%, perf stat
-r 3). Reverting only the reserve step measured 600.014 G, so it stays
despite raising the raw allocation COUNT (an empty stack now allocates):
the saved reallocation memcpys outweigh the extra tcache hits.
Byte-exact: sha6t hashes equal the reference for all four streams at
threads 1, 4 and 16 (the last with FILTER_THREADS=4 RECON_THREADS=2).2026-09-04
chore(av1): clear the ec-av1 compiler warnings (300 -> 0 on the release lib)Ahmet Kaan Gümüş · 16efbd9
chore(av1): clear the ec-av1 compiler warnings (300 -> 0 on the release lib) No arithmetic, control flow or public signature changes; the four perf6 decode hashes are byte-identical. - gate-counter accessors and other test-only items carry `#[allow(dead_code)]` with the reason on the line (they are read from the `#[cfg(test)]` gates, which the plain lib build cannot see); - `///` blocks sitting on `thread_local!`/macro invocations become `//` (rustc never attached them to anything); - `cdf.rs` tables and the `InterpFilterKind` variants get a one-line doc; - unused locals/params prefixed `_` where the value is genuinely unused; dead initializers dropped where the compiler proves every read is preceded by an assignment; - `decode_key_frame_tile` import is now `#[cfg(test)]` (its only user). Left standing on purpose, as findings rather than hidden warnings: `stream.rs` census counters `other` and `rect_residual_refusals` are incremented and never read back by their gates.
refactor(av1): the 38 per-frame decode-state thread_locals become one FrameCtxAhmet Kaan Gümüş · b9a9498
refactor(av1): the 38 per-frame decode-state thread_locals become one FrameCtx Every per-frame/per-stream decode state in ec-av1 lived in a thread_local! static, so a decode was a function of the calling THREAD's history rather than of the bitstream, and a worker thread saw empty state -- the blocker for frame-parallel decoding. All 38 (SB128, BIT_DEPTH, SUPERRES, CDEF_*, DELTA_Q_*/DELTA_LF_*, CURRENT_Q_IDX, QUANT_DELTAS, the 9 SEG* maps, TX_SELECT_INTER, REDUCED_TX_SET_INTER, ENABLE_FILTER_INTRA_INTER, PALETTE_PRED, INTRABC_*, LUMA_TX_TYPE, INTRA_IN_INTER_MODE, INTER_STRIP_CHROMA, INTER_LAST_MC, ENABLE_EDGE_FILTER, LAST_FRAME_WIDE_MARGIN, REACH_SB_PX, GRAIN_BIT_DEPTH) are now fields of decode::FrameCtx, owned by decode_stream_with and threaded as `fctx: &FrameCtx` down the decode call graph (~1200 call sites). The fields keep the Cell/RefCell interior mutability the statics had, so every read/write site is byte-identical and this is a pure ownership move; Cell/RefCell also make FrameCtx !Sync on purpose -- one context per decoding thread, never shared. The scratch pools, gate hit counters and trace switches stay thread_local by design.
2026-09-02
fix(av1): the mv-stack frame-edge clamp window is signed -- a block overhanging the bottom/right edge was never clampedAhmet Kaan Gümüş · 3bd2894
fix(av1): the mv-stack frame-edge clamp window is signed -- a block overhanging the bottom/right edge was never clamped libaom's `mb_to_right_edge` / `mb_to_bottom_edge` (`set_mi_row_col`, av1_common_int.h) are signed: a block that overhangs the frame's right or bottom edge keeps its full `bw4`/`bh4`, so `mi_cols - bw4 - mi_col` and `mi_rows - bh4 - mi_row` go NEGATIVE and `clamp_mv_ref` (mvref_common.h) narrows the predictor window by exactly that much. Our port computed both terms with `usize::saturating_sub`, which clipped them to 0 and left the window up to two block sizes too wide, so an edge block's stack entry was never clamped. On a 10-bit 3840x1608 stream (`mi_rows == 402`) every bottom-row 64x64 block overhangs by 14 mi units: the 64x64 NEWMV block at mi(400,368) of decode frame 88 took `mv0=(224,568)` where libaom takes `(32,568)` -- the entropy stream is identical (same range at EC_MODE and EC_MODE_MV), only the reconstructed value differed -- and its MC then read the reference's replicated last row instead of real rows 1604..1606. That frame was the only non-exact one in the 100-frame 4K head prefix (221 bytes); it is now exact. New counter `mvstack::mv_clamp_edge_overhang_hits` (also printed by decode_probe) counts stack entries the negative-edge window actually moves. crates/ec-av1/fixtures/reelb_head_mvclamp_witness.obu (72158 bytes, sha256 451a9b138995e636f22308847a123b5c8621d4908cd93772cf5bbf2b37df39d7, truncated twice to identical hashes) is the smallest prefix of that head firing it (N=79 -> 0, N=80 -> 5); new gate `a_10bit_film_frames_with_frame_edge_mv_clamping_decode_pixel_exact` decodes its 52 shown frames pixel-exact against ffmpeg on every plane and hard-asserts the counter. `clamp_mv_ref_window_is_signed_at_the_frame_bottom_edge` pins the ladder's exact numbers.
fix(av1): the warp-sample top-right probe needs libaom's rect shape refinements, not just the longer sideAhmet Kaan Gümüş · 00aa449
fix(av1): the warp-sample top-right probe needs libaom's rect shape refinements, not just the longer side r9 changed `av1_findSamples`' top-right probe to libaom's `AOMMAX(xd->width, xd->height)` (mvref_common.c:1235) but left our `has_top_right` port without the two shape refinements libaom applies right after the mask loop (`av1_common_int.h:1419-1428`): is_last_vertical_rect = !((mi_col + width) & (height - 1)) [width < height] is_first_horizontal_rect = !(mi_row & (width - 1)) [width > height] Both are derivable from mi_row/mi_col/bw4/bh4 alone -- no partition context -- and they only bite when bw4 != bh4, i.e. exactly the blocks whose probe size r9 changed. Probing at the longer side WITHOUT them is half a port: it fixed the 64x128 block (bs=32 > 16, early-out, no top-right sample, 2-symbol obmc alphabet) and broke a 32-wide tall leaf in an earlier superblock, moving the first divergence of the 10-bit 1920x792 264-frame cut EARLIER (decode frame 49, mi(24,376) -> its successor mi(24,380) read a different rng). With the refinements ported, on that cut: * mode ladder vs the instrumented reference decoder over ALL 264 frames: 915 equal runs, 914 inserts (our per-sub-block prints the reference does not emit), ZERO replace/delete -- every EC_MODE (mi_row, mi_col, rng) triple the reference emits matches ours, previously the first mismatch was frame 49. * pixel compare vs the reference decoder: 231/267 frames bit-exact, 36 frames differ by 1-3 bytes each (the known chroma-MC bottom-row clamp residue, lane-t900 r8); was 218/267 frames differing, frame 49 alone by 2.26 MB. `tr_reach_longer_side_hits()` now counts blocks where the full probe disagrees with the old square-at-width probe (9936 on that cut). corner-cut: libaom's third refinement (PARTITION_VERT_A bottom-left square) still not ported -- it needs the parent partition type; ceiling and upgrade path recorded on `mvstack::has_top_right`.
fix(av1): mv-stack row/col scans dropped libaom's sub-8px clauses, desyncing every 4-wide/4-high blockAhmet Kaan Gümüş · 9d5ecaa
fix(av1): mv-stack row/col scans dropped libaom's sub-8px clauses, desyncing every 4-wide/4-high block `scan_row`/`scan_col` (and the compound twins) applied the weight and `processed_rows`/`processed_cols` update whenever `bw4 <= n4`, but libaom `scan_row_mbmi`/`scan_col_mbmi` (mvref_common.c:172/222) gate that on `xd->width >= mi_size_wide[BLOCK_8X8]` as well, and step the |offset|>1 column back on an odd mi_col under a sub-8px block. A 4-wide 1:4 strip therefore got a raised candidate weight and a shifted outer scan: on a 128x128 cq60 aomenc stream, mi(24,15) built the stack (12,28) w648 / (-4,26) w648 / (-4,18) w8 where libaom builds (12,28) w650 / (-4,18) w648 / (-4,26) w8 / (6,332) w4, picking a different mv and desyncing 5466 luma pixels of frame 1 from (122,13). With both clauses ported the same stream is entropy-exact (125/125 aomdec EC_MODE entries match, value and range) and stops on another lane's named sub-8x8 intra refusal instead of decoding wrong pixels. The intra 16x4/4x16 gate becomes continue-and-sweep: every arm decodes, named refusals only from a measured list, every decode-order frame compared on every plane, and ONE end-of-sweep assert over the recorded failures plus a per-bit- depth firing assert. Still ignored, refusal NOT lifted -- no recipe found yet gives a pixel-exact attempt with the counter above zero.
fix(av1): the saved motion field kept only the LAST tile's columns -- av1_copy_frame_mvs read the mi grid through the per-tile reach clampAhmet Kaan Gümüş · ba5351f
fix(av1): the saved motion field kept only the LAST tile's columns -- av1_copy_frame_mvs read the mi grid through the per-tile reach clamp `build_motion_field` (this crate's `av1_copy_frame_mvs`) walks the whole frame's mi grid AFTER the tile loop has finished, when `MiGrid`'s tile window is still narrowed to the last tile. `MiGrid::get` returns `None` outside that window, so every tile but the last saved no motion vectors at all: on the pinned 192x68 2-tile-column stream the saved field held only mi_col 32..47, and the next frame's temporal (MFMV) candidates over the whole left two thirds silently vanished from the MV stack. The entropy stream still matched symbol for symbol -- a missing weight-2 temporal vote only reorders the stack -- so a NEW_NEWMV block at mi(0,24) took stack[1] = (36,0) (the compound extension's zero-fill) instead of libaom's (0,0), predicting 32 px off and leaving a 32-px-wide wrong column band. New `MiGrid::get_frame` is the unclamped frame-level read; only `build_motion_field` uses it. Rungs added with it: `EC_TPL` (per frame: use_ref_frame_mvs + filled projected cells) and `EC_TRACE_TPL`'s new `EC_TPL_SAVED` occupancy map of the saved field, which is what showed the 16-column hole. Pre-filter reconstruction of all 6 decode-order frames of the pinned stream goes 1306/3358/5027/6622 wrong luma px (frames 2..5) -> 0.
fix(av1): gate the top-right mv probe on the bs>64 half of has_top_right only, and cap inter var-tx leaves per root sizeAhmet Kaan Gümüş · 76749a1
fix(av1): gate the top-right mv probe on the bs>64 half of has_top_right only, and cap inter var-tx leaves per root size The r5 wiring applied libaom's whole has_top_right, position mask included, without its three shape refinements (is_last_vertical_rect, is_first_horizontal_rect, the PARTITION_VERT_A bottom-left square). That is right for a 128 block (bs > 64 -> no candidate, the defect r5 fixed) and wrong below it: the 64-level AB, free-partition and 1:4 stream gates lost frame 16 luma. Gate on the size half only; ceiling and upgrade path named at the helper. Also: the merged var-tx leaf ceiling is per root (32 below the 128 root, 64 at it, where the mu-chunk reader codes a TX_64X64's 32x32 coded corner), and the skipped-inter internal-edge suppression is narrowed to the 128 root, the only size whose leaves are not the block.
fix(av1): gate the mv-stack top-right probe on has_top_right; 128-root motion_mode/obmc CDF rows; TX_64X64 coded corner on the intra-in-inter pathAhmet Kaan Gümüş · b6c54c5
fix(av1): gate the mv-stack top-right probe on has_top_right; 128-root motion_mode/obmc CDF rows; TX_64X64 coded corner on the intra-in-inter path
Three root causes behind the 128x128 inter gate's frame-5 reconstruction residue,
all on a 256x256 8/10-bit stream with use_128x128_superblock:
1. mvstack.rs find_mv_stack{,_compound} called scan_top_right unconditionally.
libaom setup_ref_mv_list (mvref_common.c:497/546) gates it on has_top_right,
which is 0 for bs > 16 -- a 128x128 block's above-right cell is populated
(previous SB row) but unavailable, so we invented a candidate and desynced
the drl symbols.
2. decode.rs mapped a square block's motion_mode/obmc CDF row with
trailing_zeros - 3, sending 128 to our packed BLOCK_16X32 row. Added libaom
default_motion_mode_cdf / default_obmc_cdf rows 13/14/15 (64X128, 128X64,
128X128) and explicit match arms ahead of the square one.
3. A TX_64X64 luma unit on the intra-in-inter-frame path used the full 64x64
scan and tx_side; only the top-left 32x32 is coded (spec 5.11.40), which
panicked the inverse transform on the 10-bit arm.
All 9 decode-order frames of the 8-bit and 10-bit gate arms are now pixel-exact
(EC_AV1_PREFILT_DUMP, was 19550/14164/26667/26716 wrong bytes on f5..f8); the
mode-value ladder matches aomdec exactly. The tx-size-search arm is still red on
4 post-deblock chroma pixels -- a phantom chroma TU edge published by the
per-vartx-leaf lf-grid write, analysed in lanes/sb128c-r5.handoff.md.fix(av1): three MV-stack divergences from libaom setup_ref_mv_list, one of them a compound-vs-single twin driftAhmet Kaan Gümüş · 199abd2
fix(av1): three MV-stack divergences from libaom setup_ref_mv_list, one of them a compound-vs-single twin drift Phase-by-phase diff of both twins (find_mv_stack_with_sign_bias and find_mv_stack_compound) against libaom mvref_common.c; full 20-phase table in lanes/mvtwin-r1.report.md. 1. TWIN DRIFT (compound only): combine_compound_candidates filled a comp_list slot past both ref_id/ref_diff lists with (0, 0). libaom fills it with THAT SIDE's own gm_mv_candidates[idx] (mvref_common.c:718-719) -- the single-ref twin closed the identical gm-fallback gap on its mv_ref_list tail in r6. Wrong the moment a compound pair names a ROTZOOM/AFFINE reference and the scans leave the stack short. 2. BOTH twins: add_candidate/add_compound_candidate pushed unbounded and let a later sort+truncate pick the survivors. libaom drops the 9th distinct candidate AT INSERTION (*refmv_count < MAX_REF_MV_STACK_SIZE, mvref_common.c:100/128/388/425), keeping a different set. The dedup weight bump on a full stack is preserved. 3. BOTH twins: the row/col reach and the up/left availability gates were FRAME-relative. libaom's find_valid_row_offset/find_valid_col_offset clamp to tile->mi_row_start/mi_col_start (mvref_common.c:512-533). MiGrid::get already hid the out-of-tile cells, so the symptom was the scan weight (inc) and through it the stack order, inside every tile not starting at mi 0. Not defects, checked and recorded: the two bubble passes vs one stable sort (equivalent -- no post-boost entry can reach REF_CAT_LEVEL), the compound add_tpl_ref_mv double lookup (offset-independent, so both sides resolve together), and the has_tr grid probe (mask logic and "already decoded" coincide for square blocks, and libaom's is_last_vertical_rect refinement restores the rect case our probe already gets right). Gates: new a_real_aomenc_compound_mv_stack_gate, the first compound gate here that leaves --enable-ref-frame-mvs ON, with --auto-alt-ref=1 --lag-in-frames=25, a cq sweep and 30 seeds per arm; three arms (8-bit sb64 gm=0, 8-bit sb64 gm=1, 10-bit sb128 gm=1) decode every frame pixel-exact vs ffmpeg while hard-asserting comp_mode_hits AND tmv_hits advanced. Plus one deterministic unit test per defect. Found but NOT caused here: a 128x64 --tile-columns=1 stream mis-decodes frame 1 luma (ablation-proven pre-existing); kept as an #[ignore]d reproducer with the repro command in its doc comment.
wip(sb128): r3 state -- compound tpl extension samples ported, inter refusal liftedAhmet Kaan Gümüş · d5ca61cBrowse files
fix(av1): keep the MV stack's top-right grid probe (the has_top_right port red-lined 8 gates); docs(sb128): r2 reportAhmet Kaan Gümüş · 9852037
fix(av1): keep the MV stack's top-right grid probe (the has_top_right port red-lined 8 gates); docs(sb128): r2 report
feat(av1): 128x128 superblock root in the INTER tile loop (visit order + prologue), sb-aware has_top_right; refusal kept for a residual one-frame mismatchAhmet Kaan Gümüş · b7c0e21
feat(av1): 128x128 superblock root in the INTER tile loop (visit order + prologue), sb-aware has_top_right; refusal kept for a residual one-frame mismatch The inter tile loop now walks libaom's quadrant visit order (sb_visit_order) and reads the 128 root once per superblock (read_lr over the whole 128x128, the 8-symbol partition_w128 with its edge gather) through a new shared read_sb128_root, extracted from the key-frame loop so both paths cannot drift. libaom has_top_right is now a single sb-aware port in mvstack (the warp-sample copy in decode.rs hardcoded a 64x64 superblock and now delegates to it), and the MV stack's top-right probe is gated on it instead of a bare grid probe. 8 of the 9 decode-order frames of the new gate stream are pixel-exact against the instrumented aomdec, hidden alt-ref included; frame 6 still differs by 996 luma bytes with the entropy stream in sync, and the same content at --sb-size=64 is exact (sb128_r2_control_sb64), so the residual is sb128-specific. The product-path refusal therefore STAYS and the gate ships #[ignore]d as its reproducer -- silent wrong pixels on his films are worse.
2026-09-01
feat(av1): decode an intrabc block vector -- use_intrabc now reads a real DV instead of refusingAhmet Kaan Gümüş · fbda1c6
feat(av1): decode an intrabc block vector -- use_intrabc now reads a real DV instead of refusing The DV predictor is the ordinary MV stack queried with INTRA_FRAME (libaom av1_find_mv_refs/av1_find_ref_dv), the difference reads off a separate ndvc context at full-pel precision (MV_SUBPEL_NONE), and the block-copy prediction rides the existing PALETTE_PRED per-block prediction override with BILINEAR taps off the current frame's own pre-loop-filter planes (all loop filters are already off when allow_intrabc). tx_type switches to the inter ext-tx sets, since libaom counts an intrabc block as is_inter_block. Two real index bugs fell out: mvstack's sign_bias() and gm_mv() both indexed table[ref_frame - LAST_FRAME] unguarded, so any INTRA_FRAME query -- exactly what intrabc does -- panicked at usize::MAX. The lane's refusal is REPLACED, not lifted: every real aomenc intrabc block sits under TX_MODE_SELECT, whose inter var-tx transform tree (read_var_tx_size) this decoder has nowhere, so no stream reconstructs one end to end yet and enable-intrabc stays in gate_coverage's NEVER_EXERCISED list. Recipe + evidence in lanes/intrabc-r1.report.md.
2026-08-30
feat(av1): inter frame per-tile decode loop, MV stack bounded per tileAhmet Kaan Gümüş · aaa4b1b
feat(av1): inter frame per-tile decode loop, MV stack bounded per tile decode_inter_frame_tile_with_cdfs now takes tiles: &[&[u8]] + &TileInfo and grows the same per-tile loop decode_key_frame_tile_with_cdfs already has: fresh SymbolDecoder + CDF copy per tile, PlaneBuf::set_tile_origin threaded with real x1/y1 (right/bottom reach bound), only context_update_tile_id's own adapted table kept as the frame's own output. mvstack.rs: MiGrid gets tile_row0/col0/row1/col1 bounds (set_tile_bounds, called once per tile) so scan_row/scan_col/scan_top_right's grid.get() cannot see a cell outside the current tile -- bounds all four find_mv_stack*/find_mv_stack_compound call sites through the one grid they all read, without touching their own signatures. Lifts the "an inter frame with more than one tile" refusal (verbatim, removed from stream.rs and refusal_inventory.rs's pinned list). The >2-columns and multi-tile-with-loop-filter refusals stay -- not gate-proven safe to lift this round (deferred, see report). cargo check clean; scoped tests green: tile/frame/mvstack/stream tile tests (44), refusal_inventory (2), gate_coverage (2), including the existing mi_units_outside_the_tile_contribute_nothing tile-bound test and both real-aomenc two-tile-column gates.
fix(av1): mv-stack single-ref predictor falls back to global motion, not zeroAhmet Kaan Gümüş · 43e5d8c
fix(av1): mv-stack single-ref predictor falls back to global motion, not zero Root cause of lane-gm r4/r5's "more than one concurrently active ROTZOOM/AFFINE ref slot" refusal, found by range-laddering the r5 pin against a new aomdec EC_TRACE_MODE instrument: libaom's setup_ref_mv_list fills any mv_ref_list slot the neighbour scan left short with gm_get_motion_vector for that block's own ref, not zero. Our find_mv_stack_with_sign_bias used (0, 0) -- invisible whenever the live ref's global motion is itself identity/translation, wrong the moment it's a real ROTZOOM/AFFINE and a block's own stack (e.g. the very first block of a frame, no neighbours) comes up short. Symbol consumption was already bit-exact (rng matched aomdec before/after mode info); only the predictor value was wrong. Fixed at the fallback (nearest_mv/near_mv now default to gm_mv(gm, ref_frame)); the r5/r6 pin decodes all 24 frames byte-exact through the unmodified decode_stream. The multi-slot refusal that was masking this is lifted (AFFINE-on-single-ref refusal stays). Wedge gate: 10/40 matches -> 33/40 (7 remaining refusals are all an unrelated screen-content-tools capability gap). Full ec-av1 --lib suite: 230/231 green (1 filter_intra gate flake, confirmed non-regression by standalone rerun -- ok).
test(av1): gm r2 -- add NO_GM_MV to mvstack's own compound test call sitesAhmet Kaan Gümüş · aad87a1
test(av1): gm r2 -- add NO_GM_MV to mvstack's own compound test call sites Compile fix only, matches decode.rs leaf8's stub. golden3/golden4/scratch_* pinned-test failures observed this round are pre-existing env-only gaps (hardcoded path to a different session's scratchpad, or need EC_AV1_PIN set manually) unrelated to gm; real pinned gates (golden7, warp) pass green.
wip(av1): gm r2 -- compound mvstack gm threading, GLOBALMV real mv, interp two-predicate split (does not compile yet)Ahmet Kaan Gümüş · 5417eab
wip(av1): gm r2 -- compound mvstack gm threading, GLOBALMV real mv, interp two-predicate split (does not compile yet) Committed by the orchestrator: the builder wrote ~9 edits deep and hit its turn cap before it could commit. Known-incomplete, recorded verbatim so it survives.
wip(av1): mvstack global-motion substitution plumbing (inert: NO_GM_MV, all flags false)Ahmet Kaan Gümüş · 149fd7a
wip(av1): mvstack global-motion substitution plumbing (inert: NO_GM_MV, all flags false) MiInfo gains is_global_mv0/1 (all ctors false), GmMvTable threaded through the single-ref scans, and the TPL zero_mv_ctx comparison now measures against gm_mv instead of zero (mvref_common.c:369-370). decode.rs still passes NO_GM_MV, so behaviour is unchanged until the wiring lands.
2026-08-28
fix(av1): mvstack scan weight inc mins by the candidate's cross axisAhmet Kaan Gümüş · d6cb150
fix(av1): mvstack scan weight inc mins by the candidate's cross axis libaom's scan_row_mbmi mins inc by mi_size_high (candidate height), scan_col by width; ours used the scan's own axis at all 4 sites (single + compound). Square candidates hide it; a 32x16 strip above tied weights, reordering DRL entry 1 and suppressing the -5 extended row scan. rect-flake-2 byte-exact, pin added to the default list; lib 220/0.
fix(av1): rect-flake-1 byte-exact -- MiInfo size_h, rect warp samples/projection dims, OBMC per-pass overlap, deblock tx-height gridAhmet Kaan Gümüş · 8e2b541
fix(av1): rect-flake-1 byte-exact -- MiInfo size_h, rect warp samples/projection dims, OBMC per-pass overlap, deblock tx-height grid Three prediction-side root causes after the CDF rows: (1) neighbour records carry true height (size_h) so a rect strip donates warp samples at ITS center and col scans step/weight by height; find_projection gets the strip's true dims -- wmmat now matches aomdec exactly. (2) obmc_blend: per-pass neighbour caps (width-log2 above, height-log2 left) and overlaps (bh/2 above, bw/2 left). (3) tx_h_grid: deblock horizontal edges gate by transform HEIGHT; the single-scalar grid deblocked the strip seam wrong (1-px chroma drift).
feat(av1): decode non-wedge interintra prediction; fix warp-sample interintra exclusion; reset switchable_interp CDF counterAhmet Kaan Gümüş · a5a10f4
feat(av1): decode non-wedge interintra prediction; fix warp-sample interintra exclusion; reset switchable_interp CDF counter - interintra syntax (flag -> 4-ary mode -> wedge flag, wedge==1 stays a named refusal) + non-wedge smooth blend (II_DC/V/H/SMOOTH, ii_weights1d, all planes) on the 16/32 single-ref path and the 8x8 leaf - interintra blocks record ref_frame1 = INTRA_FRAME(0) in the mi grid so find_samples/num_proj_ref exclude them (libaom av1_findSamples requires ref_frame[1] == NONE_FRAME); mvstack ref-diff scan guards rf1 > 0 - ii-flake-9: switchable_interp was the one Cdfs field missing from reset_counts -- unreset counter saturated past 15 reads and slowed the adaptation rate to >>5 while libaom (per-frame counter reset, av1_reset_cdf_symbol_counters) stays >>4; rows drifted a few counts and the gate flaked on read-dense streams. Field-list audit: no other gap. - new gate a_real_aomenc_stream_with_interintra_decodes_pixel_exact (interintra refusals forbidden, hits counter asserted); pinned-stream test extended to 11 fixtures (ii-flake-1..9) Evidence: 11/11 pins byte-exact; interintra gate 12/12 hammer clean (hits 11-22 per run); warp gate 3/3; ec-av1 lib 218 passed / 0 failed.
test(av1): mvstack unit test asserts entries are clamped (was pinning the pre-fix behaviour)Ahmet Kaan Gümüş · 578beeeBrowse files
fix(av1): clamp every mvstack entry, not just the derived nearest/near pairAhmet Kaan Gümüş · 569067b
fix(av1): clamp every mvstack entry, not just the derived nearest/near pair libaom av1_find_mv_refs clamps each stack entry after the build; the NEWMV predictor is the DRL-selected ENTRY, so a left neighbour coded past the frame edge (col 520 in pinned warp-flake-5.obu) predicted unclamped where libaom used 384 -- an mv drift with IDENTICAL entropy (same diff symbols, range ladder exact at every partition read) surfacing as +-1 warp rounding crumbs in a hidden altref, inherited by shown frames (V-plane assert). Both builders (single + compound). All three warp pins green. class: value-equal narrowing drift (neighbour-votes-all-its-fields family); localization = part-read range ladder exact -> prediction-side, then EC_MV pred diff vs patched aomdec.
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.
wip(av1): r6 root cause -- ref-frame ctx undercounts compound neighboursAhmet Kaan Gümüş · d706250
wip(av1): r6 root cause -- ref-frame ctx undercounts compound neighbours libaom av1_collect_neighbors_ref_counts (mvref_common.h) counts BOTH ref_frame[0] and ref_frame[1] of a compound neighbour; our ref_ctx family took one scalar per side, so every single_ref/comp_ref/comp_bwdref ctx row was wrong next to a compound neighbour -- value-equal decodes with different interval narrowing, drifting entropy state into compound_idx. All vote functions now take each side's pair. Compiles clean. Dying words: rebuild and rerun the failing test, then full proof chain (unmask both blends, seed-45 byte-exact, cdfflake pin re-decode, gates 3x, suite 3x, scratch cleanup).
fix(av1): port libaom's real compound mvstack tpl fold-in and combine dedupAhmet Kaan Gümüş · ac83457
fix(av1): port libaom's real compound mvstack tpl fold-in and combine dedup find_mv_stack_compound carried two documented conservative deviations from libaom's mvref_common.c: the temporal add_tpl_ref_mv fold-in dropped a compound candidate when the crate's own re-lookup happened to fail one side independently, instead of zero-filling; and the extension-pass combine step ran every candidate through the ordinary weight-bump dedup instead of libaom's real is_dup check (setup_ref_mv_list ~735-754: exactly one new entry when the stack already has one, comparing only comp_list[0] against it and taking comp_list[1] on a match; both entries appended unconditionally, un-deduped, when the stack is empty). Both are now exact ports (mvref_common.c:341-433, 692-762), with compound_dedupes_same_pair_and_sums_weight updated to the real two-entries- unmerged outcome the is_dup port actually produces. cargo test --release -p ec-av1 --lib: 205 passed / 0 failed / 16 ignored.
WIP(av1): compound mvstack candidate machinery, not yet wiredAhmet Kaan Gümüş · 368413c
WIP(av1): compound mvstack candidate machinery, not yet wired find_mv_stack_compound: parallel entry point to find_mv_stack_with_sign_bias for a block predicted against a reference-frame pair (spec 7.10.2's is_compound path). Adds: - MiInfo.mv1 (the compound second MV, paired with r3's ref_frame1) - scan_row_compound/scan_col_compound/scan_top_right_compound/ scan_corner_compound: exact-pair-matched twins of the single-ref scans - process_compound_ref_mv_candidate + CompoundRefLists + combine_compound_candidates: the compound extension/topping pass (mvref_common.c's process_compound_ref_mv_candidate + the combine step) - CompoundTplArgs: compound temporal-MV fold-in, reusing motion_field's existing single-ref add_tpl_ref_mv once per side of the pair - new_mv_ctx/ref_mv_ctx reuse the existing (nearest_match, ref_match_count) switch, which libaom's own mode_context switch is ref-count-agnostic about Documented deviations: tpl compound candidates drop (not zero-fill) a missing side; the extension combine step dedups by weight-bump instead of libaom's real is_dup skip-on-first-match. Both noted in find_mv_stack_compound's doc for a later round to tighten if a live compound gate's drl_ctx disagrees. Every existing single-reference caller (find_mv_stack/ find_mv_stack_with_sign_bias and their 23 pre-existing tests) is untouched; this is purely additive, unwired code, same pattern as r1/r3. 6 new tests, cargo test --release -p ec-av1 --lib: 205 passed / 0 failed / 16 ignored.
WIP(av1): carry a compound second reference through MiInfo/NeighboursAhmet Kaan Gümüş · cfa1e23
WIP(av1): carry a compound second reference through MiInfo/Neighbours Step 1 of the compound-decode chain (lane-av1comp): MiInfo grows ref_frame1: Option<i8> (spec RefFrames[1]) and decode.rs's Neighbours grows above_ref1/left_ref1 alongside above_ref/left_ref, mirroring the existing i8 single-ref tracking. Every one of the 24 MiInfo literal sites across decode.rs/encode.rs/mvstack.rs/tile.rs sets it to None -- no decode or encode path here ever produces a compound block yet, so this is pure plumbing: find_mv_stack's scan still matches candidates on ref_frame alone, and reference_mode_ctx/comp_reference_type_ctx (landed r1, 1fcb059) still have no caller. Next: read_ref_frames replacing stream.rs:181-195's reference_select refusal (decodemv.c:966-990/1000+, is_comp_ref_allowed blockd.h:65-67), then inter_compound_mode CDF/tree + compound DRL, then mvstack's dual- ref candidate scan (process_compound_ref_mv_candidate, mvref_common.c:435-455/696-762 -- the largest remaining piece), then the COMPOUND_AVERAGE/dist_wtd_comp_avg MC blend. See the lane-av1comp ledger entries for the full ordered plan.
WIP(av1): compound-reference symbol-reading CDFs and contexts, not yet wiredAhmet Kaan Gümüş · 651448b
WIP(av1): compound-reference symbol-reading CDFs and contexts, not yet wired Spec 5.11.25's read_ref_frames compound path (comp_mode, comp_reference_type, uni_comp_ref/comp_ref/comp_bwdref trees) needs five new default-CDF tables (cdf::COMP_MODE/COMP_REF_TYPE/UNI_COMP_REF/COMP_REF/COMP_BWDREF, ported from libaom entropymode.c) plus their adaptation state (cdf_state.rs), and two new context functions (mvstack::reference_mode_ctx/comp_reference_type_ctx, libaom's av1_get_reference_mode_context/av1_get_comp_reference_type_context) unit-tested against hand-derived cases matching libaom's branch tables. The comp_ref*/comp_bwdref* trees reuse the existing single_ref_p2/p3/p4/p5/p6 context shape (ref_ctx) since libaom's own functions are literally aliases of the single-ref ones; only uni_comp_ref_p1 needed a new vote set. Not yet wired to decode_inter_block or stream.rs's reference_select refusal: that needs Neighbours to carry per-cell compound state (today every decoded neighbour is proven single-ref, so NeighbourRef is exercised only by its unit tests), and reading comp_mode/comp_ref_type still dead-ends at "decode this compound block" with no inter_compound_mode CDF, no compound DRL, no mvstack dual-ref scan, and no distance-weighted MC blend behind it -- porting comp_mode reading alone without that chain would trade one frame-level refusal for an identical per-block one, with no stream this decoder can actually finish. Left as tested, reviewable infrastructure for the next round; see ledger lane-av1comp entries for the precise next steps and libaom line references.