forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 8dbd683068d7f87f21dcc4ed1dfdca786d82c52bFiltered to crates/ec-av1/src/cdf.rsClear filter

2026-08-28

wip(av1): reduced_tx_set=false inter tx sets -- CDFs + inverse transforms, NOT WIRED YETAhmet Kaan Gümüş · 8dbd683
wip(av1): reduced_tx_set=false inter tx sets -- CDFs + inverse transforms, NOT WIRED YET

Compiles clean; NOT YET reachable from any decode path (dying-words WIP,
budget exhausted mid-lane -- entropy layer is done, threading is not).

What this round did (root cause from r1: cdf_state.rs TxbSet::Luma16Inter/
Luma8Inter hardcode the reduced_tx_set=true 2-symbol table; a real aomenc
stream with reduced_tx_set=false needs wider sets there):

1. Transcribed from /tmp/libaom-src (entropymode.c:369-403, entropymode.h:
   169-185, blockd.h:1036-1122, common_data.h:149-159, av1_txfm.h:169-207,
   txb_common.h:32-47, aom_dsp/txfm_common.h:52-68):
   - av1_ext_tx_set_lookup[is_inter=1][tx_size_sqr==TX_16X16] gives, for a
     16x16 inter block, EXT_TX_SET_DTT9_IDTX_1DDCT (12 symbols) -- NOT
     DTT4_IDTX_1DDCT as the r1 handoff guessed (right symbol count, wrong
     set name); for 8x8 (and 4x4) inter, EXT_TX_SET_ALL16 (16 symbols).
   - New cdf.rs tables INTER_TX_TYPE_SET2_16 (TX_16X16 row of
     default_inter_ext_tx_cdf[EXT_TX_SET_DTT9_IDTX_1DDCT]) and
     INTER_TX_TYPE_SET1_8 (TX_8X8 row of
     default_inter_ext_tx_cdf[EXT_TX_SET_ALL16]), transcribed verbatim.
   - New cdf_state.rs storage (inter_tx_type_16_set2, inter_tx_type_8_set1),
     reset1-wired (adaptation) and seeded from the new cdf.rs tables in
     Cdfs::new -- both join the existing reset sweep so a forwarded-CDF
     frame carries them too (av1-cdffwd-three-bugs class: nothing here is a
     new table left off the forwarding/reset map).
   - New TxbSet::Luma16InterSet1/Luma8InterSet1 variants + txb() match arms.

2. Coverage check (tx-class-cross-cutting class, repo memory) -- swept
   every libaom array indexed by tx_type/tx_set for the new TxType members
   this needs (FLIPADST_DCT, DCT_FLIPADST, FLIPADST_FLIPADST, ADST_FLIPADST,
   FLIPADST_ADST, V_ADST, H_ADST, V_FLIPADST, H_FLIPADST -- 9 new variants):
   - transform.rs: TxType gained the 9 variants + from_symbol_set2_12 (12-
     symbol table, av1_ext_tx_inv[EXT_TX_SET_DTT9_IDTX_1DDCT]) +
     from_symbol_all16 (16-symbol, av1_ext_tx_inv[EXT_TX_SET_ALL16]).
   - axes(): FLIPADST reads the *same* 1D ADST kernel as ADST (common_data.h
     vtx_tab/htx_tab map both FLIPADST_1D and ADST_1D to the identical
     butterfly network) -- no new 1D transform to port, confirmed against
     av1_inv_txfm2d.c's inv_txfm2d_add_c (lines 234-316): the flip is pure
     post-processing (lr_flip reverses which column the column-pass reads,
     ud_flip reverses which output row the result lands in), never a
     different arithmetic kernel. Added TxType::flip() and rewired
     inverse_transform_2d_typed to read from an un-mutated `residual`
     buffer into a separate `out` buffer under the flip (the naive in-place
     version has a real RAW hazard: for side/2 columns, a flipped write at
     iteration j clobbers a source column iteration side-1-j will read
     later -- caught before it shipped, not left as a corner-cut).
   - decode.rs TxClass::of: V_ADST/V_FLIPADST -> Vert, H_ADST/H_FLIPADST ->
     Horiz (txb_common.h's tx_type_to_class table), matching V_DCT/H_DCT's
     existing treatment -- coefficient scan/context tables are already
     generic over TxClass, not TxType, so no further surface needed there.
   - decode.rs read_coeffs: CDF-length dispatch (already the crate's own
     idiom, doc'd at the read site) extended from 2-way to 4-way: 17 slots
     -> from_symbol_all16, 13 -> from_symbol_set2_12, 8 -> from_symbol_set1,
     else -> from_symbol (unchanged 2-/5-symbol sets).

3. NOT DONE (why this is WIP, not a fix): no call site actually threads
   reduced_tx_set into TxbSet::Luma16InterSet1/Luma8InterSet1 selection.
   decode_inter_frame_tile_with_cdfs (decode.rs:6197) does not even take a
   reduced_tx_set parameter -- the entire inter tile path hardcodes the
   reduced (2-symbol) inter tables today, unconditionally. Wiring needs:
     - reduced_tx_set: bool added to decode_inter_frame_tile/_with_cdfs
       (decode.rs:6147/6197) and its caller (stream.rs, frame-header
       reduced_tx_set bit -- already parsed for the key-frame/intra path,
       needs finding/threading for inter frames too).
     - threaded through decode_inter_block (4259) and decode_inter_block8
       (5384) as a new parameter, to their four call sites (6399, 6465,
       6535, 7307).
     - TxbSet::Luma16Inter -> Luma16InterSet1 and Luma8Inter ->
       Luma8InterSet1 selection gated on !reduced_tx_set at decode.rs:6484,
       7326 (Luma16*) and 5746, 5940 (Luma8*) -- mirroring txbset_for's
       existing reduced_tx_set match, but for the inter call sites which
       currently have no such helper.
     - the pinned repro (cdfflake-stream-seed45.bin) will not go green
       until this wiring lands; not run this round since the desync path
       is still unreached.
   Intra ext-tx (default_intra_ext_tx_cdf) was NOT re-checked for the same
   hardcoding this round -- r8's comment (Luma8Set1/Luma4Set1 exist) says
   intra's reduced_tx_set split is already handled at 8x8/4x4, and 16x16
   intra is DCT_IDTX-set-only regardless of the flag per
   av1_get_ext_tx_set_type (`tx_size_sqr == TX_16X16` branch skips the
   `use_reduced_set` check for BOTH is_inter values) -- so intra should
   already be correct, but this was reasoned, not re-verified against
   entropymode.c line by line this round.
   Also unaddressed (pre-existing, r1-noted gap): no Luma4Inter path exists
   at all in this crate -- an inter TX_4X4 transform (also EXT_TX_SET_ALL16
   under reduced_tx_set=false, TX_4X4 row of the same CDF, not yet
   transcribed) has nowhere to decode to. Out of this round's scope.
feat(av1): add skip_mode CDF table + adaptation state (unwired)Ahmet Kaan Gümüş · 3403b03
feat(av1): add skip_mode CDF table + adaptation state (unwired)

default_skip_mode_cdfs (libaom entropymode.c, SKIP_MODE_CONTEXTS=3) ported
as cdf::SKIP_MODE, plumbed through Cdfs::new/reset/forwarding the same way
comp_mode/comp_group_idx are. Not yet read by any block decoder -- the
frame-level skip_mode_params() derivation (spec 5.9.22) already lives in
ec-av1-syntax's read_skip_mode_params (SkipModeFrame ref-pair via nearest
forward/backward order-hint distance, matching libaom
av1_setup_skip_mode_allowed bit for bit) and needed no change; the
block-level skip_mode symbol read (spec 7.11.3, forced NEAREST_NEARESTMV
compound + skip=1, decodemv.c read_skip_mode/read_inter_block_mode_info)
is the next round's work, still refused by name at stream.rs:191.
wip(av1): compound r11 — comp_group_idx/compound_idx read, MC blend wired in main pathAhmet Kaan Gümüş · fed4a60
wip(av1): compound r11 — comp_group_idx/compound_idx read, MC blend wired in main path

Round capped mid-wiring; committed by orchestrator after fixing the two
test-wrapper call sites (the five new seq/order-hint params threaded, not
neutralised, where the tile fn has them in scope). 211/211 lib tests green.
Remaining: decode_inter_block8 blend path, record_inter threading of
ref_frame1/mv1/compound_idx, remaining COMPOUND_REFERENCE refusals, firing
gate.
feat(av1): read inter_compound_mode past comp_ref, still refuse MCAhmet Kaan Gümüş · cadc399
feat(av1): read inter_compound_mode past comp_ref, still refuse MC

Ports libaom's default_inter_compound_mode_cdf + compound_mode_ctx_map
(entropymode.c / mvref_common.h) and wires read_inter_compound_mode
into decode_inter_block's COMPOUND_REFERENCE arm: once comp_mode/
comp_ref name the reference pair, find_mv_stack_compound now builds
the real compound mvstack (with CompoundTplArgs when tpl_frame is
live) and the block reads its own compound_mode symbol before still
refusing by name -- compound DRL, MV assignment, and two-reference MC
remain unwired. decode_inter_block8's 8x8-leaf arm is untouched (still
refuses at comp_ref). New COMPOUND_MODE_HITS counter (compound_mode_hits())
mirrors COMP_MODE_HITS for a future firing gate.
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.

2026-08-27

Merge branch 'lane-av1tx4': TX4 luma decode and the 1D transform classesAhmet Kaan Gümüş · 843a5a8
Merge branch 'lane-av1tx4': TX4 luma decode and the 1D transform classes

Seven rounds: TX4 coefficient tables (transcription cross-verified),
V_DCT/H_DCT scan orders and the class-split eob_pt CDF, the leaf8
scan-table fix, and a gate that fires the class-1 path on real aomenc
bytes and decodes pixel-exact. The tx-class lesson: a transform class
is a cross-cutting dimension -- scan, eob table, and context each
carry it.
fix(av1): TX4/TX8 eob_pt CDF is class-split (V_DCT/H_DCT vs 2D)Ahmet Kaan Gümüş · ea55462
fix(av1): TX4/TX8 eob_pt CDF is class-split (V_DCT/H_DCT vs 2D)

libaom's av1_default_eob_multi{16,64}_cdfs carry a [2] dimension this
decoder never read: TX_CLASS_2D vs TX_CLASS_HORIZ/VERT. Read order
(all_zero -> tx_type -> eob) verified against decodetxb.c's
read_coeffs_txb; the class-1 tables transcribed from token_cdfs.h and
checked value-for-value. Wired only where TX_SET_INTRA_1 (the 7-type
set carrying V_DCT/H_DCT) is reachable: Luma4/Luma4Set1/Luma8/Luma8Set1.

Verified: full ec-av1 suite green (172 passed), and a synthetic
8x8-partition intra stream now exercises H_DCT (tx_type=3) through
read_eob's class1 branch without desyncing before an unrelated,
pre-existing refusal later in the same frame (small-partition support
is a separate gap, not this one).

Removed the scratch probe_tx4.rs example used to drive this check.
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): interpolation filters beyond REGULAR, incl. per-block SWITCHABLEAhmet Kaan Gümüş · 10f24e6
feat(av1): interpolation filters beyond REGULAR, incl. per-block SWITCHABLE

The ~13% decodes-but-wrong inter flake was a whole missing filter
family: motion compensation always used the REGULAR subpel tables,
while real encoders pick SMOOTH/SHARP per frame -- or SWITCHABLE,
reading a per-block filter symbol pair this decoder never read (the
silently-unread class again; our own encoder writes one fixed filter).
All four table sets land in mc.rs with an aomdec-pinned unit test, the
switchable_interp CDFs and neighbour context follow libaom's
read_mb_interp_filter, and the filter threads from the frame header
through both inter block paths. The forwarding gate ran 10/10 with
zero pixel mismatches and no vacuous skips.
wip(av1): finish the txb_skip 7-context rewire; find TX16 tx_type mismatchAhmet Kaan Gümüş · dcf1147
wip(av1): finish the txb_skip 7-context rewire; find TX16 tx_type mismatch

Adds the luma_skip_ctx debug trace and a partition_w16 trace print (both
gated behind EC_AV1_TRACE) used to bisect the pinned mb.obu stream against
a fprintf-instrumented aomdec build. The 7-context txb_skip rewire itself
(cdf.rs/cdf_state.rs/decode.rs, prior round) compiles and the whole ec-av1
suite is green, but the pinned stream still desyncs: tracing symbol-by-
symbol against real aomdec's EC_TXBCTX/EC_TXBSKIP/EC_TXTYPE_VAL output
shows the two decoders already disagree on a NON-split 16x16 block's own
tx_type (mi_row=4,mi_col=0 in the second superblock quadrant: real reads
tx_type=3 off a reduced 5-symbol intra set, txs_ctx=2/tx_set_type=2/eset=2;
ours reads tx_type=2) -- upstream of the txb_skip multi-TU logic this round
targeted, and not fixed by it. tx_size_context/get_txb_ctx_general/
SKIP_CONTEXTS were all checked byte-for-byte against libaom's
av1/common/txb_common.h and match.

The gate (a_real_aomenc_intra_stream_with_tx_select_decodes_pixel_exact,
stream.rs) is not wired to this recipe: it still passes today only via its
own soft-skip path (every attempt either refuses or never resolves a split
tx_depth), so wiring it now would just turn a silent skip into the same
real failure traced above. Left unwired until the tx_type mismatch is
fixed.
feat(av1): read tx_depth under TxMode::Select on key framesAhmet Kaan Gümüş · ab94637
feat(av1): read tx_depth under TxMode::Select on key frames

Threads a tx_select flag through decode_key_frame_tile's block walk so an
intra frame using TxMode::Select reads the tx_depth symbol (cat0..3 CDFs,
tx_size_context) instead of assuming TxMode::Largest, resolving to a
per-TU split-luma decode path when the block's transform is smaller than
its own side. A resolved 4x4 luma transform still refuses by name (no 4x4
coefficient tables yet). Narrows the old whole-stream TxMode::Select
refusal to inter frames only, since decode_inter_frame's block loop does
not thread tx_select yet.

Adds tx_depth_hits() (before/after counter, same pattern as
filter_intra_hits/deblock_hits) and a real-aomenc gate test proving a
split transform actually decodes pixel-exact against ffmpeg -- currently
SKIPs (no fixture recipe found in this session reliably lands a stream
that both avoids this decoder's other named round-2 gaps and resolves a
tx_depth split without exhausting to 4x4); it never fails, so the suite
stays green while that fixture search continues.

Investigated a reported suite regression on this branch first: it does
not reproduce against this diff -- the cdf-forwarding inter-sequence gate
(a_real_aomenc_inter_sequence_with_cdf_forwarding_decodes_pixel_exact)
fails at the same ~17% rate with this diff fully reverted, confirmed over
30 stashed runs on HEAD. Pre-existing flake, not a regression.
feat(av1): extend the 8x8-leaf straddle path to inter framesAhmet Kaan Gümüş · cc290f5
feat(av1): extend the 8x8-leaf straddle path to inter frames

Mirrors lane-av1-rect's key-frame 16x16-straddles-one-axis -> up-to-two
8x8-leaf path (code_square side==8, tile.rs write_leaf8) on the inter
side: code_square_inter takes a `side` param (8 or 16) and picks
Luma8Inter/Chroma4 or Luma16Inter/Chroma8 accordingly; the encoder's
inter loop builds `eight` leaves per straddling 16x16 the same way the
key-frame search does, each leaf's own NEARESTMV mv-stack window at
2x2-mi; the tile writer (write_inter_frame_leaf8) and decoder
(decode_inter_block8) mirror that leaf-by-leaf, with the same
prev_leaf skip/intra-inter context override write_leaf8 uses for mode
context (Neighbours' above/left arrays only resolve to SUB=16
granularity). New TxbSet::Luma8Inter/INTER_TX_TYPE_SET3_8 CDF
(libaom default_inter_ext_tx_cdf[EXT_TX_SET_DCT_IDTX][TX_8X8] = 4167,
distinct default+adaptation state from the 16x16/32x32 rows already
carried).

Encoder-side round-trips clean (both-axis-cut still refuses correctly);
a real multi-frame decode round-trip through ffmpeg desyncs starting
at the third coded frame (the second inter frame, U plane) -- logged
as an open dead-end for the next round, not chased further this round.
fix(av1): read the unread use_filter_intra flag; audit the same blindness classAhmet Kaan Gümüş · beeeec5
fix(av1): read the unread use_filter_intra flag; audit the same blindness class

lane-av1real r10 added the FILTER_INTRA/FILTER_INTRA_MODE CDF tables and
Cdfs fields but stopped mid-wiring; this finishes threading
enable_filter_intra (from the sequence header) through decode_key_frame_tile
-> decode_block/decode_leaf8 -> read_intra_mode, which now reads
use_filter_intra after DC_PRED at <=32x32 (spec 5.11.14,
av1_filter_intra_allowed) and refuses use_filter_intra==1 blocks (this
decoder does not implement the 5.11.14 recursive predictor) rather than
silently miscoding.

The pinned CfL stream's actual bug was exactly this: its block reads
use_filter_intra=0, so the flag's own bits were never consumed before,
desyncing every later symbol read self-consistently -- both the Python
cross-checks and debug aomdec traces shared that blindness. With the flag
read, the pin decodes pixel-exact (luma/U/V) against ffmpeg, and the
previously-#[ignore]d a_real_libaom_cfl_stream_decodes_pixel_exact test now
passes green with no split needed.

Blindness-audit sweep of read_intra_frame_mode_info (libaom decodemv.c)
found three more per-block/per-superblock symbols this crate silently never
reads while accepting the header fields that would gate them:
allow_screen_content_tools (intrabc/palette_mode_info), delta.q_present/
delta.lf_present (per-SB delta_q/delta_lf), and segmentation.enabled
(per-block segment_id) -- named refusals added in decode_stream next to the
existing CDEF/TxMode::Select refusals.

Full ec-av1 suite: 165 passed, 0 failed, 12 ignored.
wip(av1): CfL CDFs, alpha reads, and prediction math — r2 checkpointAhmet Kaan Gümüş · e37bffe
wip(av1): CfL CDFs, alpha reads, and prediction math — r2 checkpoint

CfL sign/alpha CDFs converted from AOM_ICDF storage, read_cfl_alphas
wired, cfl.c subsample/average/alpha math ported. The pinned CfL-stream
gate stays ignored: its LUMA decodes near-flat where ffmpeg shows a
gradient, so a bug upstream of the chroma math remains — r3 isolates.
wip(av1): r11 checkpoint — leaf-8 trace instrumentation and partial ctx fixesAhmet Kaan Gümüş · 3a1f168
wip(av1): r11 checkpoint — leaf-8 trace instrumentation and partial ctx fixes

Full suite green (134/0/10); the 40x32 straddle round-trip still desyncs
and stays ignored. Diff spans cdf/cdf_state/encode/tile from the r11
trace session; r12 continues from the committed trace artifacts.
feat(av1): 8x8-leaf CDF, mi-precise neighbour contexts, write_leaf8 (r6, unwired)Ahmet Kaan Gümüş · 83656d8
feat(av1): 8x8-leaf CDF, mi-precise neighbour contexts, write_leaf8 (r6, unwired)

Lands the groundwork for lane-av1-rect's 8x8-leaf write path: the
PARTITION_W8 CDF (+ adapted state field), Neighbours::record_mi/around_mi
(mi-precise coeff-context entry points, the SUB-granularity above_mode/
above_side arrays untouched), and write_leaf8 (mirrors write_block for one
8x8 leaf, reading its intra-mode context from the enclosing 16x16 slot).
BlockCoeffs gained an `eight: Option<Vec<BlockCoeffs>>` carrier and the
coded-mode-validation loop flat_maps it.

The key-frame Quadrant::Split writer now wires write_leaf8 for a straddling
16x16 (one axis only, mod-32==8 targets): the gathered split bit + per-leaf
partition_w8 symbol + write_leaf8, matching the existing 32x32/64x64 edge
pattern.

encode.rs's block-generation loop does NOT populate `.eight` yet: an attempt
to wire it hit an index-out-of-bounds in code_square's edge-sample read
(Plane::edges, encode.rs ~1027) for a leaf at the frame's own edge, and a
"exactly one straddler" geometry assumption that also turned out wrong (a
32x32-aligned straddling 16x16 row/column band is generically two leaves,
not one) -- both are next-round work, not this round's budget. The refusal
at encode.rs's split loop is therefore unchanged; both_writers_refuse_the_
same_strictly_before_half_straddle_size is unchanged and still green.

Suite: 134/0/9, unchanged from cf71e1e.
feat(av1): land TX_8X8/TX_4X4 CDF tables for the mod-32==8 straddle leafAhmet Kaan Gümüş · dc6d790
feat(av1): land TX_8X8/TX_4X4 CDF tables for the mod-32==8 straddle leaf

Extracted byte-exact libaom Default_*_Cdf tables for Luma8/Chroma4
coefficient coding plus the TX_8X8 intra tx_type table, wired through
new TxbSet::Luma8/Chroma4 variants and code_square's third side==8
branch. Not yet reachable from the tile writer -- SPLIT_BLOCKS still
refuses mod-32==8 sizes -- landing the compiling infrastructure layer
per the charter's budget-exhausted fallback; the 16x16-leaf split
emission (tile.rs Quadrant::Split), the leaf-under-leaf carrier, and
aomdec/dav1d parity verification are unstarted.

134 baseline ec-av1 tests still green; no behavior change.
feat(av1): wire NEARESTMV inter coding for 16x16 straddle leaves, gated offAhmet Kaan Gümüş · cac7aab
feat(av1): wire NEARESTMV inter coding for 16x16 straddle leaves, gated off

Adds the full machinery for real inter coding of the 16x16 leaves a
half-straddling 32x32 inter-frame quadrant splits into: a Luma16Inter
TxbSet/CDF table (reduced_tx_set forces the same two-symbol DCT_IDTX set
16x16 already shares the shape of with Luma32Inter), a leaf writer
(write_inter_frame_leaf) that codes is_inter/single_ref/mv-stack/DRL/mv at
this leaf's own 4x4-mi window, and an encode-side NEARESTMV-vs-intra cost
comparison (code_square_inter) with matching per-leaf MvStack/grid updates.

The NEARESTMV selection itself is left gated off (`false &&`, corner-cut
comment at the site) -- enabling it desyncs the decoder ("Invalid data
found") on the existing straddle round-trip test, not yet isolated within
this round's budget. Confirmed via a false/true toggle that the desync is
in the new is_inter leaf path, not in the reduced_tx_set frame-header flag
(that alone round-trips clean). Gate: cargo test -p ec-av1 --release ==
130 passed, 9 ignored, 0 failed (same as baseline).

2026-08-26

fix(av1): code tx_type for inter 32x32 residuals; drop the skip-only corner-cutAhmet Kaan Gümüş · ac63d1d
fix(av1): code tx_type for inter 32x32 residuals; drop the skip-only corner-cut

Spec 5.11.48: an is_inter 32x32 luma transform sits in TX_SET_INTER_3, not
TX_SET_DCTONLY, so the decoder reads a tx_type bit right after all_zero. The
writer reused the intra DCT-only TxbSet for inter blocks and never wrote it,
desyncing every symbol after the first coded inter coefficient. New
TxbSet::Luma32Inter carries the TX_SET_INTER_3 CDF row (libaom
entropymode.c:369); search_inter_block now prices real residuals and derives
skip from the quantized levels.
feat(av1): coefficient CDFs for all four q contextsAhmet Kaan Gümüş · 2edeb94
feat(av1): coefficient CDFs for all four q contexts

Q0/Q1/Q3 tables added alongside the existing Q2 (61..=120) family for
all 34 coefficient CDF groups, transcribed and verified against the
Q2 baseline. tile::q_ctx_of buckets base_q_idx into the four bands
(0..=20, 21..=60, 61..=120, 121..=255) and Cdfs::pick selects the
matching table, so the tile writer now accepts the full 0..=255 range
instead of refusing everything outside 61..=120.

Removed the three test assertions that pinned the old refusal
(a_picture_off_the_block_grid_is_refused, dc_levels_the_base_syntax_-
cannot_carry_are_refused, coefficients_the_writer_cannot_code_are_-
refused) and extended the ffmpeg roundtrip and quantizer-monotonicity
gates to exercise one q index from each context, including the three
context boundaries.
feat(av1): default CDF tables for inter-frame mode and MV syntaxAhmet Kaan Gümüş · e9086ec
feat(av1): default CDF tables for inter-frame mode and MV syntax

Spec 9.4's Default_Intra_Inter_Cdf, Default_Single_Ref_Cdf,
Default_Y_Mode_Cdf, the new/zero/ref-mv and drl-mode families, and the
full per-component motion vector set (joint, class, class0 bit/fr/hp,
bit, fr, hp, sign), transcribed from libaom's own default tables
(av1/common/entropymode.c, entropymv.c) rather than rav1e's transposed
layout. Cdfs gains owned copies, with the MV tables split into a
two-element per-component array so adapting one component cannot leak
into the other.

Compound reference and compound-mode CDFs are left out: this encoder
never sets reference_select.
feat(av1): 32x32 quadrants split into 16x16 blocks when RD says soAhmet Kaan Gümüş · 7d10ec2
feat(av1): 32x32 quadrants split into 16x16 blocks when RD says so

Each quadrant is now coded twice -- whole, and as four 16x16 sub-blocks --
and the cheaper of the two is kept, with the partition symbol's own rate in
both costs. The reconstruction is snapshotted and restored between trials so
prediction always reads the winner, and mode bookkeeping moved to the 16x16
grid the spec's mode context is defined on.

Measured over a three-point ladder against the whole-only encoder: -9.15%
BD-rate on 1080p film, -27.20% on screen capture, -9.05% on a phone clip,
-22.45% on the synthetic diagonal, and +0.00% on stripes, which never splits.

Mixing block sizes exposed a real conformance defect: the chroma txb_skip and
DC-sign contexts were read from a single neighbour cell, while the decoder
gathers over every 4x4 unit the block spans (spec 5.11.39, 8.3.2). Under a
uniform 32x32 encoder the one cell is the whole span, so the bug could not
show; with a 16x16 beside a 32x32 the arithmetic decoder desynchronised as
+-1 sample drift. Neighbours::around now gathers both edges. Two gates added:
a 16x16 inverse-transform comparison against ffmpeg, and a direct test that
the gathered read sees a cell the single-cell read misses.

2026-08-25

feat(av1): a superblock can stay wholeAhmet Kaan Gümüş · da2c24a
feat(av1): a superblock can stay whole

The tile writer coded every superblock as four 32x32 blocks. It now takes
a `Superblock` that is either `Whole` — one 64x64 block with a TX_64X64
luma transform and one 32x32 transform per chroma plane — or `Split` into
the four blocks it coded before, and the two paths share the mode and
plane writers.

Two contexts had to be corrected for the whole path to decode:

  * the superblock partition symbol reads bit three of its neighbours'
    partition context, which only a 32x32 neighbour sets, so the context
    is which neighbours were split rather than which ones exist;
  * the base-range tail of a 64x64 transform is coded with the 32x32
    table, because the size index into that CDF is clamped there.

Both are covered: a 128x64 frame whose left superblock is whole and whose
right one is split decodes to a gradient that runs the full sixty-four
samples beside four quadrants that fall on their own, and reverting
either context fails it.
feat(av1): code a real intra mode per blockAhmet Kaan Gümüş · 6cacc2b
feat(av1): code a real intra mode per block

The tile writer coded DC_PRED for every block. It now takes the luma
intra mode with the block's coefficients and codes it against the
key-frame CDF the block's neighbours select, with the angle delta a
directional mode carries.

The chroma mode stays DC_PRED, but the table it is coded with is
indexed by the luma mode — holding the DC row while the luma mode moved
desynchronised every stream, which is what the new decode test caught
first.

A dav1d decode gates the result on what the modes promise rather than on
pinned bytes: the top-left block carries a basis function that is flat
across it and falls down it, the block to its right is H_PRED and must
repeat its left neighbour's column, and the block below is V_PRED and
must repeat the row above it. Dropping the angle delta, pinning the mode
context or pinning the chroma table each fail it.
feat(av1): code chroma coefficients beside the luma onesAhmet Kaan Gümüş · b99ade1
feat(av1): code chroma coefficients beside the luma ones

The coefficient writer took a luma coefficient list per 32x32 block and
wrote both chroma transform blocks as all-zero. It now takes a
BlockCoeffs per block — luma, U and V — and codes each plane's own
16x16 chroma transform.

The coefficient layer is generalised over the plane rather than
duplicated: a TxbCoding carries the transform's side and the six default
CDF sets that are indexed by plane type and transform size, plus the
end-of-block alphabet, which is a quarter the size at 16x16. The chroma
all-zero flag reads the context its coded neighbours above and to the
left select, so the writer now tracks per plane what each block left
behind rather than only the sign of its luma DC.

Gated by dav1d decodes of derived structure, not pinned bytes: a chroma
basis function must be flat down the block and fall across it, the plane
turned a quarter turn must do the reverse, neither may reach the other
plane or luma, and a block with no DC must average to its prediction.
Three mutations were checked to fail those tests: chroma reading the
luma base table, the chroma all-zero context pinned at 7, and the chroma
end-of-block alphabet taken from luma.
feat(av1): code coefficients anywhere in a 32x32 transformAhmet Kaan Gümüş · 0dac984
feat(av1): code coefficients anywhere in a 32x32 transform

The tile writer could put one DC coefficient in a block. This adds the
rest of the coefficient syntax: an end-of-block position with its group
offset, the base levels of every coefficient down the scan with the
contexts its neighbours and its position give, the base-range tail with
its own contexts, and the signs — the DC's from a CDF and the rest as
raw bits.

The default scan is written as the rule that generates it rather than a
thousand pinned numbers: it walks the anti-diagonals outwards, and the
test checks the rule against what a scan must be — every position once,
the origin first, and every context neighbour of a position scanned
before it, which is what lets a decoder read a context off coefficients
it already has.

The gates decode through ffmpeg and assert structure rather than pinned
samples: a coefficient off the origin decodes to its own basis function
(rows identical, samples falling across the block), a block with no DC
averages to its prediction, and a coefficient in the far corner reaches
the last end-of-block group, whose offset is nine bits wide.
feat(av1): split superblocks into 32x32 DC blocksAhmet Kaan Gümüş · a25e4a3
feat(av1): split superblocks into 32x32 DC blocks

The tile writer coded one 64x64 block per superblock, which left the
partition syntax with one value it ever wrote and the coefficient path
with one transform size it ever used.

A superblock can now be split into four 32x32 blocks, each carrying its
own DC level: the split partition itself with the context its neighbours'
block sizes set, the 32x32 partition below it, the chroma mode from the
table a CFL-capable block reads, and the coefficients on the 32x32 CDFs.
The coefficient body the two writers share is factored out with its
tables passed in, since only the tables differ.

The gate decodes a four-by-four grid of 32x32 blocks over two by two
superblocks, with alternating signs so the walk crosses superblock
boundaries in both directions and the DC sign context lands on all three
of its values. Every sample is checked against the DC prediction from the
block's reconstructed neighbours plus its own pinned residual.
feat(av1): code a DC coefficient in the key frame tileAhmet Kaan Gümüş · c68b3bd
feat(av1): code a DC coefficient in the key frame tile

The tile writer could only say "this block is skipped". It now carries a
single luma DC coefficient through the full coefficient syntax: the
all-zero flag, the end-of-block position, the base level, the base-range
tail for levels above two, and the sign with its neighbour-derived
context. Chroma stays all-zero, so the two chroma flags sit immediately
after the luma block and a desync in it lands on them first.

The q-context CDFs this crate carries are the ones for base_q_idx 61..=120,
so the writer refuses a base_q_idx outside that band rather than coding
against tables the decoder will not be using. Levels are bounded at
+/-14, which is what the base syntax reaches before the Golomb tail.

The gate decodes each level -14..=14 through ffmpeg and asserts the whole
64x64 luma plane lands on a pinned value, chroma is untouched at 128, the
sequence is monotone in the level, and the sign moves the picture the way
it should. The pinned values come from the decoder, not from a derivation:
there is no inverse transform in this crate yet to derive them with.
feat(av1): first frame that a real decoder decodesAhmet Kaan Gümüş · 304ec65
feat(av1): first frame that a real decoder decodes

A tile payload writer for the one block coding the encoder can produce so
far: a key frame whose every superblock is one skipped 64x64 DC-predicted
block. Four symbols per superblock — the partition, the skip flag and the
two intra modes — with the frame header turning off everything that would
add syntax the writer does not code yet (CDEF, loop restoration, filter
intra, screen content tools, transform size selection, CDF adaptation).

The default CDF tables of spec section 9.4 arrive with it, in the same
orientation the symbol coder reads: the partition, skip, key-frame luma
mode and CFL-free chroma mode tables, which is what this syntax touches.

Gated end to end rather than by roundtrip: the stream is handed to ffmpeg
and every sample of the decoded frame must be 128, which is what a DC
prediction with no neighbours and no residual produces. Any desync between
our arithmetic coder and dav1d's shows up as a decode failure or a sample
that is not mid-grey, with no metric in between to hide it.

Frames that are not a whole number of superblocks are refused by name:
a partial superblock forces the partition syntax down the block tree.