forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 552edc4cede0dfd9bebbc4e344242802802d15ccFiltered to crates/ec-av1/src/tile.rsClear filter

2026-09-02

test(av1): witness gate for the small-side GLOBALMV and rect warp-reach paths, and 7 gate helpers that deadlocked ffmpegAhmet Kaan Gümüş · 2696d88
test(av1): witness gate for the small-side GLOBALMV and rect warp-reach paths, and 7 gate helpers that deadlocked ffmpeg

New fixture `crates/ec-av1/fixtures/gm_small_side_witness.obu` (1158066 bytes,
sha256 f1cdbcbb8d6d469c7957d70252ab42b24ab75f48a717600ffa25991458775dca,
truncated twice independently to the same hash): the first 50 frame-carrying
OBUs of a 2 s 10-bit 1920x792 128-superblock cut -- 34 decode-order frames, 33
shown, ALL 34 byte-exact against instrumented aomdec. It is the smallest prefix
of that cut which fires `gm_nontrans_small_side` at all (49 OBUs fires 0, 50
fires 1); no fixture already in the repository fires it.

Gate `a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach_decode_pixel_exact`
compares the 33 shown frames against ffmpeg on every plane and hard-asserts
`gm_nontrans_small_side_hits > 0` (1) and `tr_reach_longer_side_hits > 0`
(2295). The 128-superblock inter witness gate additionally hard-asserts
`tr_reach_longer_side` (600 there).

Also: seven copies of one gate helper wrote the whole stream to ffmpeg's stdin
INLINE and only afterwards read stdout, so any fixture whose raw output exceeds
the 64 KiB stdout pipe buffer deadlocks before the input is fully written. The
new 1.1 MB fixture (~150 MB of raw 10-bit frames) hung for 45 minutes with both
processes at 0% CPU. All seven now write on a dedicated thread; the same test
run finishes in 51.5 s.

2026-09-01

fix(av1): have_ffmpeg() SKIPped green under EC_AV1_REQUIRE_AOMENC=1Ahmet Kaan Gümüş · 91c1335
fix(av1): have_ffmpeg() SKIPped green under EC_AV1_REQUIRE_AOMENC=1

Every real-aomenc gate opens `if !have_ffmpeg() || !have_aomenc()`, and
only have_aomenc() asserted under the require flag -- have_ffmpeg() is
evaluated first and short-circuits, so a machine without ffmpeg printed
SKIP and the whole 20-gate batch reported green with the require flag
set (class gate-skips-on-its-own-failure).

have_ffmpeg() now mirrors have_aomenc(): absence panics when
EC_AV1_REQUIRE_FFMPEG=1 or EC_AV1_REQUIRE_AOMENC=1 is set (an aomenc
gate decodes its stream through ffmpeg, so requiring the oracle implies
requiring ffmpeg). Applied to all five copies of the helper
(stream/tile/decode/encode/encoder test modules), which had the same
silent-false shape.

2026-08-30

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): 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).
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.

2026-08-27

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): thread the last leaf's mode past the whole straddling quadrantAhmet Kaan Gümüş · d02638d
fix(av1): thread the last leaf's mode past the whole straddling quadrant

write_leaf8's above_mode[c]/left_mode[r] forced write (r12) ran once per
leaf inside the quadrant's leaf loop, so the first leaf's write clobbered
the true external neighbour mode a second leaf of the *same* straddling
16x16 still needed to read on its non-adjacency axis. Move the write out
of write_leaf8 to run once, after the whole leaf loop, from the last
(bottom/right-most) leaf. a_single_axis_straddle_round_trips_through_ffmpeg
now decodes clean; un-ignored. Lifted the RD-cost guard that kept leaf8
splits from competing on cost (now decoder-proven); full gate 136/0/9.
fix(av1): declare reduced_tx_set in the key-frame header; rng in tracesAhmet Kaan Gümüş · a9fbebe
fix(av1): declare reduced_tx_set in the key-frame header; rng in traces

The writer coded 8x8-leaf tx types against TX_SET_INTRA_2 tables while
the header's reduced_tx_set:false told decoders to read TX_SET_INTRA_1 —
a 7-vs-5-symbol alphabet skew that shifts the arithmetic coder's range
with no symbol value ever differing. All existing sizes still round-trip
bit-exact (16x16 resolves to the same 5-symbol set under both headers).
Straddle test stays ignored: a further divergence remains past leaf(0,8).
fix(av1): 8x8 leaf reads the CFL-allowed uv_mode CDF, threads its mode forwardAhmet Kaan Gümüş · e3b2c93
fix(av1): 8x8 leaf reads the CFL-allowed uv_mode CDF, threads its mode forward

write_leaf8 hardcoded cfl:false for write_intra_mode's chroma-mode CDF, but
is_cfl_allowed (spec 5.11.5) is true up to 32x32 -- every other write_block
caller at 16x16 and up already passes true. The narrower uv_mode_no_cfl
alphabet is one symbol short of uv_mode_cfl, so even an identical DC_PRED
decision consumed a different amount of arithmetic range and derailed the
stream from that leaf onward.

record()'s above_mode/left_mode write is also a no-op at an 8x8 leaf's own
side (side/SUB == 0), and write_leaf8 only called record_mi, never updating
those coarse arrays -- so a second straddling 16x16 quadrant stacked above
or left of the first (outside r11's same-call prev_leaf override) read
whatever stale mode sat in that slot. Fixed by writing the leaf's own mode
into above_mode[c]/left_mode[r] directly.

Full suite still 134/0/10; the straddle round-trip stays ignored -- a
residual divergence now shows up one leaf further in (leaf(2,8) reads its
own luma coefficient block at the wrong tx size), not yet isolated to a
single symbol.
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.
fix(av1): 16x16 partition ctx reads stale coarse side after a leaf8 siblingAhmet Kaan Gümüş · 4353787
fix(av1): 16x16 partition ctx reads stale coarse side after a leaf8 sibling

partition_ctx (SUB-grid) only advances above_side/left_side in whole-16px
steps, so write_leaf8's record_mi (mi-precise only) never updated them: the
next 16x16-level split query after a leaf8 quadrant read a stale side value
instead of 8. Delegate partition_ctx through partition_ctx_mi (same pattern
as around/around_mi), which record already keeps in sync at mi granularity
for every block. Confirmed against a debug aomdec EC_RNG/EC_TRACE2 trace:
the 16x16-level ctx at mi(4,8) now matches libaom's (row 1 both sides,
after subtracting aomdec's shared-cdf bsl*4 offset). Full ec-av1 gate green,
no regressions.

Not sufficient on its own: the 40x32 straddle test still desyncs, now
traced to the BLOCK_8X8 leaf's own partition-symbol context/table, not the
TX_TYPE/EOB_PT pair r8 flagged -- see ledger for handoff.
fix(av1): mi-precise partition ctx for 8x8 leaves; falsify r7's ctx hypothesisAhmet Kaan Gümüş · 9a69856
fix(av1): mi-precise partition ctx for 8x8 leaves; falsify r7's ctx hypothesis

Neighbours gained above_side_mi/left_side_mi (mi-granularity, mirroring
above/left) and partition_ctx_mi, so a straddling 16x16's second 8x8
leaf reads its own finer neighbour state instead of the enclosing
16x16 slot. Spec-accurate improvement, does not regress the gate
(134 passed, 10 ignored, unchanged).

r7's named falsification candidate for the 40x32 dav1d desync --
partition_w8's ctx reading the enclosing slot -- is FALSIFIED by an
EC_RNG/EC_TRACE2 trace diff against a debug aomdec: libaom's own
partition_plane_context masks at bsl=0 for BLOCK_8X8, and every
partition_context_lookup entry a 4x4-free writer ever produces has
bit 0 clear, so ctx is provably 0 on both sides regardless. The real
first divergence is later, inside leaf0's own luma transform
(TxbSet::Luma8/Chroma4, exercised by no other caller): the decoder
reads a wrong EC_EOBPT category (eob=36 vs the writer's real eob=7)
somewhere between the TX_TYPE and EOB_PT symbols. Named in the test's
doc comment for the next round.
fix(av1): Reach tables for side=8, coeff_bits TX4 scan; wire key-frame 8x8-leaf pathAhmet Kaan Gümüş · 51db03e
fix(av1): Reach tables for side=8, coeff_bits TX4 scan; wire key-frame 8x8-leaf path

Root-caused the r6 panic to two independent bugs, both fixed:
- Reach::of's HAS_TOP_RIGHT/HAS_BOTTOM_LEFT tables only ever covered side
  16/32 (libaom's 128-superblock-relative bit tables); side==8 fell through
  to the 16-table with a 16-wide stride and indexed past its 8-byte length.
  Added libaom's has_tr_8x8/has_bl_8x8 as a third table row.
- tile::coeff_bits's SCANS cache had no TX4 entry, so an 8x8 leaf's 4x4
  chroma coefficient search read TX32's 1024-entry scan against a 16-entry
  grid. Added the missing TX4 scan.

Wired encode_key_frame_inner's key-frame block-generation loop to build
BlockCoeffs::eight for a 16x16 sub-block that straddles the true frame edge
on exactly one axis (mirroring `write_leaf8`'s 1-or-2-leaf geometry), while
still refusing a sub straddling on both axes (needs a rectangular transform
neither writer has). The leaf-8 split is only ever taken when the whole
32x32 is illegal (forced) -- never chosen on RD cost over an already-legal
whole block, since the leaf path is not yet proven against a real decoder
and must not regress sizes that already round-tripped correctly.

Narrowed both_writers_refuse_the_same_strictly_before_half_straddle_size
(now key_frame_encodes_the_inter_frame_still_refuses_at_half_straddle_size)
and a_picture_off_the_block_grid_is_refused to the classes that are still
genuinely refused (both-axes-cut, e.g. 40x40) vs. now accepted without
erroring (640x360, 40x32). Added a decoder round-trip test at 40x32,
`#[ignore]`d: the leaf-8 stream is not yet decoder-clean (dav1d rejects it,
"Invalid data found") -- a genuine desync, not yet traced to its first
mismatched symbol. Added EC_PART/EC_TOK tracing to the leaf-8 write path
for that follow-up.
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.
fix(av1): mvstack extended row/col scan, intra-aware coverage; enable 16x16 inter leavesAhmet Kaan Gümüş · b26ee9f
fix(av1): mvstack extended row/col scan, intra-aware coverage; enable 16x16 inter leaves

Ports spec 7.10.2.4's extended row/col scan (libaom scan_row_mbmi/
scan_col_mbmi's idx=2..MVREF_ROW_COLS positions), invisible at pure
8-mi geometry because the immediate scan's own processed_rows/cols
coverage already reaches as far -- but only once that coverage counts
every *coded* neighbour cell, intra or inter, the way libaom's
processed_rows update sits outside add_ref_mv_candidate's ref-frame
match. The straddle-test attempt this round started from computed
coverage only from ref-matching (inter) cells, so an intra neighbour
above an 8-mi query silently un-suppressed the extended scan -- a real
8-mi behavior change, caught by two new differential tests
(extended_{row,col}_scan_is_a_no_op_at_8mi_geometry_even_behind_an_intra_neighbour)
that place a distinctively-MV'd tracer candidate at the extended
offsets and assert it never gets picked up. MiGrid now records intra
cells (encode.rs/tile.rs's else branches) so mvstack sees them.

With the no-op proven, lifts the `false &&` gate on 16x16-leaf
NEARESTMV (encode.rs:1231, wired r1, gated since dead code never
touched write_inter_frame_leaf's real symbol chain): full suite
130+3 new = 133/0/9, straddle and real_clip both green with the gate
live. The 640x384 real-clip fixture tiles exactly into 32x32
quadrants (no true-edge straddle), so its numbers are unchanged
(45.41 dB / 69861 bytes) -- the gate's leaf path is unexercised there;
the straddle test is what proves it live.
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).
fix(av1): inter tile writer codes a true-edge-straddling 32x32 quadrantAhmet Kaan Gümüş · cdfc846
fix(av1): inter tile writer codes a true-edge-straddling 32x32 quadrant

sb_coeff_inter_frame_tile refused every straddling 32x32 quadrant
outright, with a message claiming an 8x8 split it never actually
needs for the common edge-at-or-past-halfway case (e.g. 1280x720,
where 720 mod 32 == 16). Ported the key-frame writer's Quadrant::Split
handling: such a quadrant now splits into up to four 16x16 leaves,
coded through the inter frame's intra branch (no Luma16Inter tx_type
table exists for a genuine inter leaf at that size, and these leaves
only fill the true edge's sliver of real content). The genuine
"strictly before half of a 16x16" class -- which does need a
rectangular transform -- still refuses, with an accurate message.

sb_coeff_inter_frame_tile's `blocks` parameter is now `&[Quadrant]`
(reusing the key-frame writer's own type) instead of `&[BlockCoeffs]`;
encode_inter_frame's search does the matching split, reusing
code_square for the 16x16 leaves.

2026-08-26

fix(av1): port partial-superblock support to the inter tile writerAhmet Kaan Gümüş · 68e9a25
fix(av1): port partial-superblock support to the inter tile writer

Three fixes closing the remaining true-size reds:

1. a_frame_round_trips_at_its_own_size (1920x1080): encode.rs's split-32x32
   search unconditionally pushed all 4 16x16 sub-block trials into
   Quadrant::Split, but tile.rs's writer (mirroring spec decode_partition's
   r>=MiRows||c>=MiCols early return) only expects entries for sub-blocks
   whose own mi origin is inside the true frame. Filter the search loop to
   match, same predicate both sides.

2. a_picture_off_the_block_grid_is_refused: the 32x48 case in this test was
   a symptom of bug 1 (a block-aligned 48-row true height was refused only
   because the split path demanded 4 subs where just 2 are legal), not a
   genuine 8x8-split requirement -- confirmed by adding it to
   ffmpeg_decodes_exactly_what_the_encoder_reconstructed, where it now
   round-trips pixel-exact. Updated the test's expectations to match.

3. sequence_round_trips_at_a_non_multiple_size (160x96, inter): three
   compounding bugs in the inter path, which had zero partial-superblock
   support before this round:
   - sb_coeff_inter_frame_tile checked check_superblocks (whole-SB-multiple
     only) and used mi_cols/mi_rows / SB_MI, dropping any partial trailing
     superblock; switched to check_blocks and the same block_grid ceiling
     sb_coeff_key_frame_tile uses, plus its three-way has_cols/has_rows
     superblock-level signaling (PARTITION_SPLIT / gathered VERT_ALIKE or
     HORZ_ALIKE / nothing) and quadrant-position filtering. A 32x32 quadrant
     that itself straddles the true edge is refused (this writer has no
     rectangular/further-split representation at that level), mirroring the
     key frame writer's own "cannot be left whole" refusal.
   - encode_inter_frame's block-search loop used picture.width/BLOCK (the
     padded coding surface) for its block grid instead of the true,
     mi_cols-derived grid, overrunning the tile writer's expected block
     count whenever the true size is not a 64-multiple.
   - encode_inter_frame built its FrameHeader from the padded picture's own
     width/height instead of `render` (the true size), the same render vs.
     padded-picture split encode_key_frame_inner already makes for
     key_frame_headers_colour -- this alone produced a bitstream dav1d
     rejected outright ("Invalid data") since inter frame_width/mi_cols
     disagreed with the true size the key frame declared.

Gate 122/3/4 (round start) -> 126/1/4: one chroma-content mismatch remains
on the first inter frame at 160x96, unrelated to true-size handling (all
quadrants there are already block-aligned, no partial-block path involved)
-- a pre-existing inter-frame defect this size never exercised before,
left for its own round.
fix(av1): clamp chroma's dc-sign/skip context to its own subsampled true edge; fix a stale padded-decode testAhmet Kaan Gümüş · 82410a6
fix(av1): clamp chroma's dc-sign/skip context to its own subsampled true edge; fix a stale padded-decode test

Neighbours::record clamped chroma the same as luma (true mi_cols/mi_rows),
but libaom rounds a subsampled plane's edge up to its own 4x4 unit before
clamping (ROUND_POWER_OF_TWO(max_blocks_high, subsampling_y) in
av1_write_intra_coeffs_mb, encodetxb.c:456-459): a chroma unit straddling
an odd luma edge is still whole in chroma's own halved grid. Fixed by
rounding the luma bound up to even before clamping planes 1/2. No test in
the current suite exercises an odd true mi_rows/mi_cols with chroma
residual, so this doesn't move the gate; landed as a correctness fix
proven safe (no regression) pending such a case.

an_854x480_picture_round_trips_through_its_padding decoded at the padded
864x480 size and cropped to 854x480 by hand -- stale since 7ba33dd started
writing the true display size into frame_width/frame_height, which makes
ffmpeg crop to 854x480 on its own. Decoding at padded size now reads past
what ffmpeg emits (out.stdout shorter than expected, not a hard decode
error). Fixed the test to decode at the true size directly; it now
exercises the real desync (a luma mismatch, bitstream confirmed
byte-identical to a real decoder via EC_RNG trace, so a reconstruction-side
bug, not an entropy desync) instead of failing on a wrong expectation.

Gate: cargo test -p ec-av1 --release = 124 passed, 3 failed (same three
tests, still red, no regressions), 4 ignored.
fix(av1): gather dc-sign context per 4x4 unit, clamped to the true edgeAhmet Kaan Gümüş · 77b7e14
fix(av1): gather dc-sign context per 4x4 unit, clamped to the true edge

get_txb_ctx_general (libaom av1/common/txb_common.h) sums the DC-sign vote
over every 4x4 mode-info unit a transform spans, not once per coded
neighbour cell; av1_set_entropy_contexts (av1/common/blockd.c) clamps that
per-unit state to the frame's true (unpadded) mi_cols/mi_rows, zeroing
units past the edge even mid-cell. Our writer tracked one vote per 16x16
neighbour cell, so a 32x32 transform straddling the true bottom edge
(mi_rows=30, block rows 24..31) summed 2 cells instead of libaom's 8, and
never zeroed the two invisible mi-rows within the last cell -- producing
dc_sign_ctx=0 where the real decoder reads 2 (traced at mi(24,8), tell
2969, in a 192x120 key frame).

Widens Neighbours' above/left tracking from the 16x16 (SUB) grid to the
4x4 (MI) grid libaom actually keeps it on, and clamps record() to the
frame's true mi_cols/mi_rows the same way av1_set_entropy_contexts does.
mode/side/skip/inter tracking (single-cell lookups, not summed) stays on
the coarser grid.

192x120 (the established repro) now round-trips through ffmpeg bit-exact.
1920x1080 and the 854x480/non-multiple sequence tests still fail at other
positions -- a further defect of the same edge-clamping class, not yet
isolated; not chased further this round per budget.
wip(av1): per-symbol EC_RNG trace through write_coeffs/write_eobAhmet Kaan Gümüş · dcd1644
wip(av1): per-symbol EC_RNG trace through write_coeffs/write_eob

Every coefficient-path symbol (txb_skip, tx type, eob_pt/extra/bits,
base, base-range, DC sign, golomb tail) now prints under EC_RNG in the
same tag format the debug aomdec build emits, so the two traces diff
line-for-line. A plane: Option<usize> argument gates the prints to the
real tile writer -- the rate estimator calls write_coeffs thousands of
times per frame and drowned the trace without it.

The trace names the true-size desync: at mi(24,8), the first whole
32x32 quadrant straddling the true frame height, the writer's DC-sign
context is 0 where the reference decoder computes 2 at the same tell.
Root cause still open on this lane.
wip(av1): EC_RNG per-symbol trace localizes true-size desync to one edge quadrantAhmet Kaan Gümüş · 24b23ce
wip(av1): EC_RNG per-symbol trace localizes true-size desync to one edge quadrant

Adds an env-gated (EC_RNG=1) EC_PART/EC_TOK/EC_PLANE trace to the real
key-frame tile writer (sb_coeff_key_frame_tile), in the same format the
debug aomdec build already prints under the same variable, so encoder and
decoder traces diff line for line. Diffing a 192x120 test_card key frame
(the smallest repro of the three currently-failing round-trip tests)
against aomdec's own trace shows every tell (bit position) identical for
19 superblocks, then a hard divergence entirely inside the coefficient
coding of one 32x32 quadrant: the block at mi (24,8), the frame's first
Whole 32x32 quadrant whose has_cols32 and has_rows32 are both true while
its own extent (y=96..127) still runs past the true frame edge (height
120) into the padded region -- exactly the case the round-3 bisection
named. The writer's own tell after that block is 3019; the same bytes
read back on aomdec land at 3039, a 20-bit gap with no matching event on
our side, so something inside that one block's mode or coefficient
coding chooses a context, CDF, or symbol count the real decoder does not.
Root cause not yet isolated to a line -- see the ledger DELTA for what
is ruled out and what stays open. No behavior change: the trace is off
by default (one atomic load per call) and the three tests stay red at
124/127, unchanged from before this commit.
wip(av1): gather 32x32-level partial partitions; refusal test names the true-frame messagesAhmet Kaan Gümüş · ec3ad48
wip(av1): gather 32x32-level partial partitions; refusal test names the true-frame messages

The 32x32 recursion level now recomputes has_cols/has_rows the way
decode_partition does at every depth: both true writes the full partition
symbol, one false writes the single gathered split_or_horz/split_or_vert
bool, neither writes nothing and the split is inferred. The refusal test
sweeps the two sizes whose edge forces an 8x8 split this writer does not
code, and asserts on the messages both paths actually produce.

Still open on this lane: true-size streams >=192 wide with a partial mi
row corrupt at the first whole 32x32 edge quadrant (192x120 repro);
sb_coeff_inter_frame_tile still assumes whole superblocks.
wip(av1): write the true display size as frame_width/height, not the padded oneAhmet Kaan Gümüş · 6b1cdcc
wip(av1): write the true display size as frame_width/height, not the padded one

Frame headers now carry the picture's true (unpadded) size as
frame_width/frame_height, with mi_cols/mi_rows derived from that true size
via spec compute_image_size (2*((w+7)>>3)) instead of the padded picture's
width/4 -- mirroring rav1e/libaom, so a decoder crops to the true size
instead of the coded (padded-to-32/64) one. render_width/render_height come
out equal to frame_width/frame_height, so render_and_frame_size_different is
false and no render_size bits are written.

tile.rs: check_blocks no longer requires mi_cols/mi_rows to be an exact
multiple of the 32x32 block grid (a true size need not be); a new
block_grid() ceiling-divides mi_cols/mi_rows into the block-column/row count
actually coded, shared by sb_coeff_key_frame_tile, split_coeff_key_frame_tile
and (now) encode_key_frame_inner's own block/superblock generation loop,
which used to derive its cols/rows straight from the padded picture's width
-- it must agree with the tile writer's own count exactly.

KNOWN REGRESSION, not yet root-caused: three existing round-trip tests that
used a size not a whole 32x32 (or, for the facade, 64x64) block now fail
ffmpeg/dav1d decode with "Invalid data found" (an_854x480_picture_round_
trips_through_its_padding, a_frame_round_trips_at_its_own_size at 1920x1080/
640x352/1280x720, sequence_round_trips_at_a_non_multiple_size at 160x96).
Reasoned through the cols/rows/has_cols/has_rows arithmetic by hand for the
BLOCK(32)-alignment case and it should be invariant (true mi_cols/mi_rows
land in the same (padded-8, padded] window that keeps every BLOCK_MI(8)-
aligned threshold's comparison unchanged) -- confirmed by an EC_RNG-gated
rng-per-symbol trace (temporary, reverted) diverging from aomdec's own trace
from the very first symbol, which does not match that reasoning and was not
resolved before the turn budget ran out. The three tests' own assertions
were updated to expect the new true-size ffprobe/decode behaviour (that part
is not in question); the decode failure itself is the open defect.

Not attempted: sb_coeff_inter_frame_tile has no has_cols/has_rows-style
partial-superblock handling at all (always PARTITION_SPLIT, always 4
quadrants) -- a true size that isn't a 64x64 (SUPERBLOCK) multiple needs that
ported from the key-frame writer before an inter/multi-frame stream can use
a true, non-superblock-aligned size. The facade's key-frame path already
regresses today for the same underlying reason before inter frames are even
reached.
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): inter tile writer sb_coeff_inter_frame_tileAhmet Kaan Gümüş · 302d3c4
feat(av1): inter tile writer sb_coeff_inter_frame_tile

Flat 32x32-block-grid writer for inter frames: skip -> is_inter (ctx
from above/left skip+inter tracking) -> intra path (Y_MODE by size
group, not KF_Y_MODE) or inter path (single_ref chain, find_mv_stack,
read_inter_mode NEWMV/NEARESTMV, DRL idx 0 only, mv_joint + per
component symbols) -> existing coefficient path. Widens
SymbolDecoder::symbol to pub(crate) for cross-module roundtrip tests.

One-line encode.rs fix required for BlockCoeffs' two new fields
(skip, inter) via ..BlockCoeffs::default() at its one non-spread
construction site.

Corner-cuts (documented in tile.rs): whole-superblock frames only,
DRL always index 0, allow_high_precision_mv=0 assumed (validated,
not silently rounded), InterMode limited to NearestMv/NewMv.
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.
feat(av1): the tile adapts its CDFs as it writesAhmet Kaan Gümüş · 8a54f53
feat(av1): the tile adapts its CDFs as it writes

AV1's symbol decoder updates every non-literal CDF it reads, so an encoder
that leaves `disable_cdf_update` off has to keep the same state and update it
in the same order. This adds that state and writes the key frame's tile
through it.

Tables the decoder keeps one copy of are one copy here too: a 64x64 luma
transform reads the 32x32 base-range rows, both luma sets share one DC sign
and one 1024-position end-of-block table, and both chroma sets share their own
sign table. The gathered partition CDF an edge superblock reads is built for
the read and thrown away, so nothing adapts there.

The coefficient rate term still prices against the defaults: the mode search
runs before the tile is written, so the adapted state does not exist yet.

BD-rate against the same encoder with adaptation off, over a three-point
ladder: -3.52% on a 1080p film frame, -5.63% on a screen capture, -11.25% on
the test card. The ffmpeg/dav1d roundtrips are the gate -- a decoder adapting
its own tables desyncs the moment the order or the sharing differs.

2026-08-25

feat(av1): the mode search prices its coefficients through the writer's CDFsAhmet Kaan Gümüş · 870ed18
feat(av1): the mode search prices its coefficients through the writer's CDFs

The mode search costed the mode symbol exactly and the levels with a
magnitude estimate. Now the levels go through write_coeffs on a throwaway
encoder, so a trial is ranked by the bits the tile writer will really spend
on it: end-of-block position, base levels, base range, signs and the Golomb
tail, under the block's own contexts.

The bit account prices the interval narrowing each symbol performs rather
than its table entry, because the coder's eight-bit range multiply and its
EC_MIN_PROB floor put the table entry 8% off the bytes actually written.

Worth -1.19% BD-rate on a 1080p film frame and -0.20% on a screen capture
against the estimate; LAMBDA_SCALE stays 0.1, re-swept.
feat(av1): the six directional intra modes, and a mode-rate termAhmet Kaan Gümüş · 223aa7c
feat(av1): the six directional intra modes, and a mode-rate term

Adds D45, D67, D113, D135, D157 and D203 per spec 7.11.2.4, with the
edge construction of 7.11.2.2 and the availability the decoder derives
from clear_block_decoded_flags: for the 32x32 quadrants of a superblock
the above row reaches past the superblock's right edge (sbWidth4 is
measured to the tile's end column) for all but the last quadrant, and
the left column continues below only for the first.

The mode search now also pays for naming a mode, scored through the tile
writer's own CDFs -- the KF_Y_MODE symbol under the neighbours' context,
the ANGLE_DELTA zero symbol, and the chroma mode symbol the luma mode
indexes. Without it a directional mode looked free and cost 1.1% rate on
a picture that did not want one. With it, and with LAMBDA_SCALE re-swept
to 0.1, the same picture costs 0.41% and the clips that do want a
direction gain up to 0.35%.

ffmpeg decodes all thirteen modes bit-exactly at 128x96 and 160x96.
feat(av1): forward transform and quantizer, gated end to end through ffmpegAhmet Kaan Gümüş · 5f0963e
feat(av1): forward transform and quantizer, gated end to end through ffmpeg

AV1 specifies only the inverse transform, so the encoder half is written
against a measurement of it: one dequantized coefficient at a time comes
back out as its orthonormal basis function scaled by dq_denom(side)/8, at
every size and position. The dequantizer's own denominator cancels that,
leaving a size-independent level = 8 * orthonormal(residual) / q.

The gates are the roundtrip error (must be the quantizer and nothing else),
the 64x64 band limit (only the top-left 32x32 is coded), and an end-to-end
picture that ffmpeg decodes sample-exactly into what the encoder
reconstructed. A transposed column pass and the previous, coarser gain
constant are both killed.
feat(av1): dequantization and the inverse DCTAhmet Kaan Gümüş · 6a83833
feat(av1): dequantization and the inverse DCT

An encoder that cannot say what the decoder will show cannot choose
coefficients by what they cost against what they are worth. This adds the
decode-side arithmetic to ec-av1: the dequantizer of spec 7.12.3 and the
inverse DCT of 7.13, written from the specification's own butterfly stage
list so that one network serves every size from 4 to 64.

The gate is agreement with a real decoder, sample for sample: two key frames
whose first block carries coefficients from DC to the far corner decode
under ffmpeg to exactly 128 plus the residual this code computes, over all
1024 and 4096 samples. Beneath that sit the two tables of decoder-pinned
DC residuals the tile tests already carried, all 28 levels of each, plus
structural gates for the transpose, the sign rounding, and the row shifts of
the four sizes the frame syntax cannot reach.

Mutation-checked: a cosine table entry off by one, and an 8x8 row shift off
by one, each fail a named test.
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): the Golomb tail carries levels the base range cannot reachAhmet Kaan Gümüş · 0eba770
feat(av1): the Golomb tail carries levels the base range cannot reach

The base and base-range syntax reach level fourteen between them, and
until now the writer refused anything above it. The spec carries the
rest as a Golomb tail — the remainder plus one, as its bit length in
unary followed by its own bits — written after the coefficient's sign
rather than beside its level, which is where `write_golomb` now puts it.
The refusal moves up to the largest level the spec's twenty-bit reader
can read back.

Two gates. The spec's own `read_golomb`, written from the pseudocode,
must hand back the level that was asked for over the whole range, which
fails the moment the tail is a bit long, a bit short, or written against
the wrong base. And ffmpeg must decode a run of DC levels either side of
the threshold into a run of steadily brighter blocks, with the negatives
of the same levels steadily darker, which fails if the tail lands in the
wrong place in the syntax.
feat(av1): frames that are not a whole number of superblocksAhmet Kaan Gümüş · 7f9b390
feat(av1): frames that are not a whole number of superblocks

A superblock at the right-hand or bottom edge of a frame may be half
outside it. The spec codes that case as a gathered two-symbol flag —
split_or_horz when the right half is missing, split_or_vert when the
bottom half is — rather than the full partition symbol, and infers the
split with no symbol at all when both halves are outside. The gather
sums the probability of every partition type the flag stands for, which
is what `gather` builds from the partition CDF.

The coefficient writer now sizes its block grid from the frame rather
than from whole superblocks, refuses only frames that are not a whole
number of 32x32 blocks, and skips the quadrants that fall outside.

The gate decodes a 96x64 frame — a superblock and a half across — whose
six blocks alternate between a basis function flat down the block and
one flat across it, so a block written into the wrong place or a flag
read as a different number of bits shows up as the other block's shape.
Three mutations fail it: writing the full partition symbol at the
partial superblock, coding the out-of-frame quadrants, and (already)
sizing the grid off superblocks.
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): a DC level per superblock, with the real sign contextAhmet Kaan Gümüş · 154aa4b
feat(av1): a DC level per superblock, with the real sign context

The tile writer carried one level for the whole frame, which meant every
block saw the same DC sign context and the context derivation was never
observed: a frame of one sign reaches two of the three contexts and never
the one where the neighbours cancel.

Levels now arrive one per superblock, and the sign context is read off the
blocks above and to the left the way a decoder reads it -- each 4x4 unit
of a coded neighbour voting its sign, the left column dropped at the start
of every superblock row.

The gate decodes two 128x128 grids whose levels differ in sign and checks
every sample of every block. Its expectation is derived rather than pinned
this time: a block's grey is the DC prediction from its reconstructed
neighbours plus its own residual, so the test also holds the prediction
propagating across the frame, which the single-block frames could not.
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.