forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 00c1b3ff2d80d84fef71bb6208110dedbbd95fc4Filtered to crates/ec-av1/src/encode.rsClear filter

2026-08-27

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(av1dec): decode skip blocks, directional intra modes, odd frame sizesAhmet Kaan Gümüş · 632319a
feat(av1dec): decode skip blocks, directional intra modes, odd frame sizes

Extends the software key-frame tile decoder past round 1's whole-superblock
DC_PRED-only scope: skip=1 blocks decode to pure prediction (no residual
read); all thirteen intra modes decode via crate::intra::predict, reusing
encode.rs's Reach edge/reach rules (made pub(crate)) for the directional
above-right/below-left reads; frames that are not a whole number of 64x64
superblocks or 32x32 blocks decode via the same gathered-CDF partial-block
path tile.rs's writer uses, with a duplicated (not shared -- tile.rs is
another lane's territory) Neighbours/gather implementation kept in step by
the byte-exact round-trip tests.

Fixed along the way: read_plane's cdfs.txb() lookup was hardcoded to
DC_PRED's table for every plane, which only worked by coincidence while
every stream really was DC_PRED; real modes need the block's own luma mode
there (matching write_block_planes) even though chroma's own prediction
mode stays DC_PRED.

decode_key_frame_tile's signature grows frame_width/frame_height (the
header's separate true render size) to crop the reconstruction the same way
crop_encoded does, since mi_cols/mi_rows alone cannot invert to it losslessly.
feat(av1): begin a software key-frame decoder (round 1)Ahmet Kaan Gümüş · e6eadb9
feat(av1): begin a software key-frame decoder (round 1)

Promotes msac's test-only SymbolDecoder to a real, non-test decoder
(the inverse of SymbolEncoder, already spec-derived and roundtrip
tested), and adds crates/ec-av1/src/decode.rs: a from-spec reader that
mirrors tile.rs's sb_coeff_key_frame_tile symbol order (partition tree
through 64x64/32x32/16x16, coefficient base/base-range/EOB/Golomb/sign
syntax, CDF adaptation) without importing from tile.rs, which a
sibling lane is editing concurrently.

Round 1 scope: key frames only, DC_PRED blocks only, unskipped, and
frames a whole number of 64x64 superblocks -- everything else refuses
with a named error rather than miscoding. Within that scope, real
encoder output (encode_key_frame_with_modes forced to DC_PRED, two
sizes, real quantised AC/DC residual) decodes byte-exact against the
encoder's own reconstruction. Encoded gains three pub(crate) fields
(tile, mi_cols, mi_rows, base_q_idx) so a decoder test can reach the
raw tile payload without re-deriving it from the OBU stream.

Deferred to round 2: non-DC_PRED intra modes (needs the directional
edge-reach plumbing), inter frames, skipped blocks, and the
partial-superblock/gathered-CDF true-edge path.
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.
feat(av1): a quality/size targeting surface over base_q_idxAhmet Kaan Gümüş · a55d2ef
feat(av1): a quality/size targeting surface over base_q_idx

RateTarget::{QIndex,Quality,BytesPerFrame} on Av1Encoder::with_rate_target,
additive alongside the existing EncoderConfig::base_q_idx path. Quality
maps to base_q_idx via the calibration sweep's linear fit; BytesPerFrame
steers it with a clamped proportional controller (no accumulated debt, so
no windup class to bound). Calibration sweep test records the curve.
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): correct the r4 chroma-granularity assumption for 8x8 leavesAhmet Kaan Gümüş · b91e4ec
fix(av1): correct the r4 chroma-granularity assumption for 8x8 leaves

libaom's is_chroma_reference (av1_common_int.h) is unconditionally true
for bsize >= BLOCK_8X8 (4:2:0 or not), so a split 16x16's 8x8 children
each code their own chroma at 4x4 -- chroma does not stay at the
parent's 8x8 granularity as the r4 doc comments claimed (never checked
against a real decoder). Corrects TxbSet::Chroma4's doc and flips
code_square's still-unreached side==8 branch to the chroma set a real
caller will need, so the next lane does not inherit a wrong premise.

No behavior change (134/0/9, unchanged): the branch has no caller yet.
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.
test(av1): exercise the 16x16 straddle-leaf inter path on real contentAhmet Kaan Gümüş · cdf3858
test(av1): exercise the 16x16 straddle-leaf inter path on real content

real_clip_encodes_within_its_quality_and_size_budget uses 640x384 (both
axes 32-aligned), so Quadrant::Split never fires and the e19bb47
NEARESTMV leaf path was untouched by real, mixed intra/inter content.
Add a sibling at 704x400 (400 mod 32 == 16, the exactly-half straddle
class), same three gates: dav1d decodes every frame, mean luma PSNR
floor, byte ceiling.
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): key the probe stream's temp file per call, not per processAhmet Kaan Gümüş · f9d5fb9
fix(av1): key the probe stream's temp file per call, not per process

ffprobe_size named its temp file by process id alone, so every test in
the binary shared one path; a parallel test's cleanup could delete the
stream another test's ffprobe was mid-read on. This was the recurring
first-run gate flake (127/2 after 3cb60f6, 128/1 after 78fc36c) -- an
atomic counter now makes each call's path distinct.
test(av1): standing real-content regression gate on encode.rsAhmet Kaan Gümüş · 7b73e56
test(av1): standing real-content regression gate on encode.rs

Two recent regressions (a padded-size inter FrameHeader dav1d rejected;
a 1280x720 export refusal) were only caught by a downstream repo's
gate. real_clip_encodes_within_its_quality_and_size_budget encodes 12
frames of a real 1080p H.264 fixture clip, scaled to 640x384, and
asserts dav1d decodes every frame, mean luma PSNR stays within 0.5 dB
of the measured 45.41 dB, and the stream stays within 15% of the
measured 69861 bytes.
feat(av1): SAD-prescreen search_inter_block's intra loop, default K=3Ahmet Kaan Gümüş · 1120e46
feat(av1): SAD-prescreen search_inter_block's intra loop, default K=3

search_inter_block ran every one of the 13 intra candidates through a
full RD trial (forward transform, quantize, reconstruct, coeff_bits)
even though NEWMV/NEARESTMV usually wins on an inter block. Wire the
same SAD-prescreen rule search_block already uses (DC always kept,
cheapest top_k by SAD-plus-mode-cost) into this loop via a new
Plane::intra_scores + shared prune_by_sad, gated by its own
Search::top_k default (INTER_PRUNE_TOP_K, env EC_AV1_PRUNE_K_INTER) so
the key-frame path's default stays untouched.

Real-clip sweep (prune_k_quality_sweep_inter: 3 clips, q 60/150, K in
{3,4,6}) clears the same PSNR/bytes rule for every K tried (worst
-0.011dB / +0.147% bytes), so K=3 -- the cheapest -- ships as the new
inter-path default. sequence_bench_sanity: 807ms/frame -> 556ms/frame
at K=3 (-31%), 73622 -> 73759 bytes (+0.19%). top_k forced unpruned
reproduces byte-identical output vs the pre-change build (73622 bytes
both).
perf(av1): stop repricing an inter block's chroma trial 13 times overAhmet Kaan Gümüş · cc09bf2
perf(av1): stop repricing an inter block's chroma trial 13 times over

An inter frame's intra-candidate loop in search_inter_block always coded
both chroma planes as DC_PRED, independent of which of the 13 luma modes
the loop was on -- so the identical transform/quantize/coeff_bits call
ran twelve times for nothing on every inter block. Hoist it out of the
loop and clone the one result in (bit-identical: same call, same inputs,
same output, verified by the full 129-test suite and an equal output
byte count on the stage_timing_breakdown_inter probe, 1356 bytes before
and after).

Also add stage_timing_breakdown_inter, an #[ignore]d probe that breaks
one inter frame's time into motion search / mc::predict / transform+
quantize / coeff_bits buckets, which is how this was found: transform+
quantize was the largest bucket (454.78ms of 980.36ms), not motion
search (267.26ms, of which 257.01ms is genuine sub-pel interpolation
work already spent inside the diamond search).

1280x720 inter frame: 980.36ms -> 772.05ms (-21%).
test(av1): add prune_k quality sweep + 24-frame 720p sequence sanity probesAhmet Kaan Gümüş · 6c0d621
test(av1): add prune_k quality sweep + 24-frame 720p sequence sanity probes

In-process thread_local override lets prune_k_quality_sweep compare
Search::top_k pruned vs unpruned in one build without env-var races
(#![forbid(unsafe_code)] rules out std::env::set_var here). Both stay
#[ignore] perf/quality probes, not gates -- numbers reported in the
lane report.
perf(av1): SAD-prescreen the 13-mode intra search, gated off by defaultAhmet Kaan Gümüş · 7f9b971
perf(av1): SAD-prescreen the 13-mode intra search, gated off by default

search_block now predicts every mode once (unchanged cost) and ranks by
a cheap SAD-plus-mode-bits pre-pass before spending the full RD trial
(forward transform, quantize, reconstruct, coeff_bits) on the winners;
Search::top_k picks how many survive plus DC, always. Default stays
None (all 13 modes, byte-identical output, 129/0/5 green) until the
quality gate sweep in the lane report picks a K to ship as default.
style(av1): cargo fmtAhmet Kaan Gümüş · 8593d36
style(av1): cargo fmt

cargo test -p ec-av1 --release: 129 passed, 0 failed, 5 ignored.
perf(av1): cache the forward DCT basis; make it contiguous, both bit-exactAhmet Kaan Gümüş · 91b85b5
perf(av1): cache the forward DCT basis; make it contiguous, both bit-exact

Added stage_timing_breakdown (a perf probe, #[ignore]d like the existing
sweeps): 1920x1080 13-mode key frame was 3.97s. forward_and_quantize alone
was 32.25us/call at 32x32, more than inverse+entropy combined -- because
dct_basis() recomputed side*side cosines from scratch on every single
mode trial, size-invariant work redone thousands of times a frame.

Two levers, both exact (same summation order, so identical bits out):
- dct_basis is now built once per transform size and cached (OnceLock),
  not recomputed per trial.
- forward_transform_2d's two matrix passes are written as contiguous
  dot products (row of residual/basis, then a transposed row pass)
  instead of one strided index loop, so the optimizer can vectorize them.

forward_and_quantize: 32.25us -> 15.38us per 32x32 call.
1920x1080 13-mode key frame: 3.97s -> 1.78s (2.2x).
3840x2160: 10.60s -> 7.08s (1.5x).

cargo test -p ec-av1 --release: 129 passed, 0 failed, 5 ignored (the new
probe). All streams stay byte-identical to their own reconstruction.
test(av1): widen the own-size sweep; close hp-mv dead codeAhmet Kaan Gümüş · 1457eaa
test(av1): widen the own-size sweep; close hp-mv dead code

64x56 now round-trips clean through ffmpeg (its historical wrong-V-plane
bug is closed by later MC/edge fixes) -- added alongside 854x480,
216x96, 192x120 to the existing own-size sweep, all green.

Dropped MvComponentCdfs::class0_hp/hp: this encoder always sets
allow_high_precision_mv=false, so the spec syntax that reads them
(mv_class0_hp/mv_hp) never fires -- genuinely dead, not staged.

cargo test -p ec-av1 --release: 129 passed, 0 failed, 4 ignored.
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.
fix(av1): clamp inter MC reads to the reference's true extent, not its coding strideAhmet Kaan Gümüş · 8d520ef
fix(av1): clamp inter MC reads to the reference's true extent, not its coding stride

sequence_round_trips_at_a_non_multiple_size (160x96) failed on inter-frame
chroma/luma content: a spec decoder's reference buffer holds exactly
FrameWidth x FrameHeight (mi_cols*4 x mi_rows*4) -- a superblock's partition
stops early at has_cols/has_rows and never codes syntax for padding
columns/rows beyond the true edge, so those samples are never part of the
decoded picture. MC's Clip3 (spec 7.11.3.4) must clamp reference reads to
that true extent, replicating the true edge, not to this crate's own
padded-to-SUPERBLOCK coding surface.

`mc::sample`/`mc::predict` used one width/height pair for both the buffer's
row stride and the Clip3 clamp bound, conflating the two; split into a
`stride` param (the buffer's real row length, unchanged) plus
`true_width`/`true_height` (the clamp bound, now `Plane::true_width`/
`true_height` at the call site) threaded through `motion::search` and
`encode::mc_trial`.

Gate: 126 passed/1 failed/4 ignored -> 127 passed/0 failed/4 ignored.

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 intra reference reads to the true edge even off a block's own row/colAhmet Kaan Gümüş · dc2d88c
fix(av1): clamp intra reference reads to the true edge even off a block's own row/col

libaom's av1_predict_intra_block (av1/common/reconintra.c) derives xr/yd --
the distance from a block's own right/bottom to the frame edge -- from
mb_to_right_edge/mb_to_bottom_edge, which are built from mi_cols/mi_rows
(the true, decodable extent), never any padded coding surface. n_top_px/
n_left_px is min(side, xr + side) even for a block whose own extent
straddles that edge legally (has_half) -- prediction does not get real
reconstructed pixels past the true edge for its own row/column either,
only reach ever got that clamp before. Plane::edges() now clamps the
own-portion the same way libaom's xr/yd do.

Verified pixel-exact against aomdec on the 216x96 col-edge repro
(mi(8,48)) that was silently wrong before (0 diffs, previously untested).
Gate unchanged at 124/127 -- the remaining 3 reds (854x480, 1920x1080,
non-multiple-size sequence) trace to a separate, not-yet-isolated defect:
a uniform -3 luma offset across every straddling block in a column strip,
first appearing at mi_row=8 mi_col=208 in 854x480 with a nonzero DC
coefficient present, i.e. downstream of this fix (dequant/IDCT or mode
choice, not reference-sample availability).
fix(av1): narrow the true-edge availability clamp to the reach extension onlyAhmet Kaan Gümüş · 01cb49b
fix(av1): narrow the true-edge availability clamp to the reach extension only

A block's own edge read (no `reach`) can land on a block that is legally
whole despite straddling the true frame edge (spec hasRows/hasCols, this
crate's has_half): such a block gets a real transform over its full
padded extent, not a garbage tail, and both this encoder and a real
decoder reconstruct it that way, so clamping that base read to the true
bound (mi_cols*4/mi_rows*4) was wrong -- verified by comparing against a
worktree at the prior commit: it moved the first luma mismatch in both
a_frame_round_trips_at_its_own_size (1920x1080) and
an_854x480_picture_round_trips_through_its_padding earlier in the frame
instead of fixing them, gate unchanged at 124/3/4 either way. Only a
`reach` extension (above-right/below-left) crosses into a block that may
never be coded past the true edge at all, so only that portion still
clamps to true_width/true_height; re-verified against the same baseline
worktree that this leaves the three pre-existing failures at their exact
prior mismatch positions (byte-for-byte), i.e. a true no-op for them,
while still fixing the genuine reach-based true-edge case this lane's
prior commit targeted.
fix(av1): clamp intra reference-sample availability to the true frame edge, not the padded coding surfaceAhmet Kaan Gümüş · f79d3fd
fix(av1): clamp intra reference-sample availability to the true frame edge, not the padded coding surface

Plane::width/height is the picture padded to a 32-aligned coding surface
(Picture::padded_to); Reach::of and Plane::edges used it both to decide
whether a directional mode's above-right/below-left extension is available
and to clamp how far the above/left reference rows read, so a block near
the true frame edge (but still inside the padded surface) read real
padded-reconstruction samples a real decoder never has -- it stops at
mi_cols*4 / mi_rows*4 (spec compute_image_size; libaom
av1/common/reconintra.c build_intra_predictors clamps the same way via
mb_to_right_edge/mb_to_bottom_edge) and replicates the last valid sample
instead. Plane now carries that true bound (true_width/true_height,
mi_cols*4/mi_rows*4) separately from its padded width/height, and Reach::of
plus the edge-row clamp use it.

A partition trial can still price a sub-block whose own origin already
sits past that true bound (kept only for cost comparison against a split
this frame goes on to refuse) -- across/down can now land at or below x/y
for such a block, so edges() treats an empty read range as unavailable
(None) rather than crashing on an empty "last sample" the same way y==0/
x==0 already do.
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.
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.
Merge branch 'lane-av1-pad854': Reach tables indexed at libaom's 128px strideAhmet Kaan Gümüş · af95500
Merge branch 'lane-av1-pad854': Reach tables indexed at libaom's 128px stride

854x480 padded key frame closed: HAS_TOP_RIGHT/HAS_BOTTOM_LEFT are libaom's
has_tr_*/has_bl_* tables, indexed there with row stride 128/side (its
compile-time max superblock), not our 64/side — one 16x16 read bit 10
instead of bit 18 and lost its bottom-left neighbour, drifting the
reconstruction by one blend step. Boundary checks stay 64-relative.
New sweep test cross-checks Reach against a fresh transcription of
libaom's has_top_right/has_bottom_left at every position.

Gate: cargo test -p ec-av1 --release -- --include-ignored 122 passed / 0 failed.
fix(av1): Reach's has_top_right/has_bottom_left table stride was 64-relativeAhmet Kaan Gümüş · d1d8e10
fix(av1): Reach's has_top_right/has_bottom_left table stride was 64-relative

Round-2 of the 854x480 padded key frame desync: a debug aomdec trace of
has_top_right/has_bottom_left at the exact first-mismatch block (a 16x16 at
mi (40, 88)) found libaom indexing its pinned has_bl_16x16 table at bit 18
(row * 8 + col), while Reach::bottom_left indexed the same table at bit 10
(row * 4 + col) -- different bits, one true one false. libaom's tables are
pinned to its compile-time maximum superblock (128px, MAX_MIB_SIZE_LOG2 = 5),
not the superblock size a stream actually uses, so the row stride for a
16x16/32x32 block is 128 / side, not SUPERBLOCK / side (this crate's 64px
superblock) -- Reach::of's own row/col position within the superblock was
already right; only the table's row stride was wrong.

Un-ignores open_defect_854x480_padded_key_frame_desyncs, renamed
an_854x480_picture_round_trips_through_its_padding, and adds
reach_matches_libaom_has_top_right_and_has_bottom_left, a from-scratch
transcription of libaom's has_top_right/has_bottom_left checked against
Reach for every 16x16/32x32 position across three superblocks square,
including every superblock edge -- the class this bug was (an index stride
silently wrong for one block size, plausible for the other).
docs(av1): redirect the 854x480 pad desync hunt from CDF desync to ReachAhmet Kaan Gümüş · f1da657
docs(av1): redirect the 854x480 pad desync hunt from CDF desync to Reach

An EC_RNG-per-symbol trace of this frame's writer against a debug libaom
decoder (od_ec_decode_cdf_q15/od_ec_decode_bool_q15 instrumented) proved the
arithmetic coder is byte-for-byte identical to libaom across all 51188
symbols -- the bitstream itself is not desynced, and the (has_cols, has_rows)
partial-superblock partition code at tile.rs:783-795 this lane was told to
suspect first is exercised correctly here.

The real divergence: our own Encoded::reconstruction reports 147 at luma
(161, 369) where both a debug aomdec decode of our own bitstream and ffmpeg
agree on 148 -- an exact off-by-one that cascades rightward through
everything predicted from that block. Every mismatch in the frame is
`ours == correct - 1`. That points at encode.rs's Reach::of /
Reach::top_right / Reach::bottom_left (the pinned HAS_TOP_RIGHT/
HAS_BOTTOM_LEFT tables deciding how far a directional intra predictor may
read past a block's own edges) computing different above-right/below-left
availability than the real decoder for this specific block position, not a
partition/edge-superblock bug.

Left #[ignore]d with the corrected diagnosis in its doc comment; instrumentation
(EC_RNG-gated msac.rs tracing, matching aomdec build at
/tmp/libaom-src/build/decoder-debug, dump-and-diff scripts) reverted, none of
it kept in the tree.
feat(av1): streaming encoder facade with configurable colour (I11)Ahmet Kaan Gümüş · f421d98
feat(av1): streaming encoder facade with configurable colour (I11)

Av1Encoder is the one-in-one-out surface edith_replica's engine will call
in place of rav1e: EncoderConfig{width,height,base_q_idx,gop,colour} in,
encode(&Picture) -> Packet{data,key,order} out, gop-cadenced key frames
predicting inter frames from the previous reconstruction like
encode_sequence already did. encode_key_frame_inner/encode_inter_frame
are now shared (pub(crate)) between encode_sequence and the facade
instead of being duplicated. The sequence header's colour_config is wired
to Colour::{Bt709Limited,Bt601Limited,Unspecified} (spec 5.5.2's CICP
triple + range), replacing the hardcoded "unspecified" -- verified against
ffprobe.
Merge branch 'lane-av1-size': pad-to-32 with cropped reconstructionsAhmet Kaan Gümüş · 77b8ab9
Merge branch 'lane-av1-size': pad-to-32 with cropped reconstructions

The merge exposed a latent mvstack defect the two lanes could only trip
together: real inter residuals (lane-av1-desync) on padded content
(lane-av1-size) hit a block whose ref_mv context libaom derives from a
diagonal corner probe our reduction never ran. Folded into this merge:

- port libaom's scan_blk_mbmi(-1,-1) corner probe; ref_mv_ctx now
  splits (nearest_match, ref_match_count) exactly as mvref_common.c does
- fix the REF_CAT_LEVEL DRL boost comparison (was trivially true);
  weights are boosted in place before the corner probe can add an
  unboosted entry
- SymbolEncoder::tell(), the od_ec_enc_tell mirror the hunt relied on

Gate: cargo test -p ec-av1 --release = 116 passed, 5 ignored.
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): arbitrary even frame sizes via block-grid padding + render cropAhmet Kaan Gümüş · 51570f6
feat(av1): arbitrary even frame sizes via block-grid padding + render crop

Picture::check_even() replaces the whole-32x32-blocks requirement at the
public encode_key_frame/encode_key_frame_with_modes/encode_sequence entry
points; any even, nonzero width/height is accepted. Picture::padded_to()
pads by edge replication to the block coder's own grid (32 for a lone key
frame, 64 for a sequence, so an inter frame's reference always matches the
frame coded against it) and is identity when already aligned. Encoded's
public reconstruction is always cropped back to the caller's own size
(crop_encoded/crop_plane); render_width/render_height are set correctly in
the frame header regardless.

Also fixes an internal regression this surfaced: padded_to previously
padded every path to 64, which broke the existing 32-aligned-but-not-64
fast path (96x64) for a lone key frame.

Leaves one open, pre-existing-looking defect this lane's sweep found:
854x480 padded to 864x480 desyncs against ffmpeg's decode at a spot well
inside the real (non-padded) region -- content-dependent, not padding
wiring (864x480 coded directly, no padding, is bit-exact). Documented and
left #[ignore]d as open_defect_854x480_padded_key_frame_desyncs rather than
silently dropped from the size sweep.
feat(av1): inter encode loop — decoded-reference sequence codingAhmet Kaan Gümüş · 50130dc
feat(av1): inter encode loop — decoded-reference sequence coding

encode_sequence keys the first picture and codes every later one against the
previous frame's own decoded reconstruction (single LAST slot). Per-block RD
weighs the intra modes against NEARESTMV and NEWMV, mv bits priced through the
CDF intervals. Inter residuals are corner-cut to skip=true pending the tile
writer's is_inter coefficient desync fix; the ceiling and reinstatement point
are named at the corner-cut comment.
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): write inter frame headers, referencing one reference slotAhmet Kaan Gümüş · d95e550
feat(av1): write inter frame headers, referencing one reference slot

Extends write_frame_header to shown inter frames: error_resilient_mode,
primary_ref_frame, refresh_frame_flags, the ref_order_hint loop (when
error-resilient), frame_refs_short_signaling (off) + ref_frame_idx[0..7],
allow_high_precision_mv, interpolation_filter (EIGHTTAP, non-switchable),
is_motion_mode_switchable, use_ref_frame_mvs, reference_select (forced off,
non-zero refused by name along with the skip mode and warped motion it
gates), and per-reference is_global (forced identity, non-identity global
motion refused by name). Adds inter_frame_headers() beside key_frame_headers,
reusing its sequence header verbatim and pointing every ref_frame_idx at the
slot holding the previous decoded frame.

New inline test parses a key + two inter frame header sequence back through
ec_av1_syntax::Av1Parser's own FrameState threading and checks every field
(after taking the reader's own derived fields — showable_frame, OrderHints,
RefFrameSignBias, header_bits — from the parse) plus written-vs-consumed bit
length, per frame.
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): seven intra modes, picked per block by rate-distortionAhmet Kaan Gümüş · 4331d17
feat(av1): seven intra modes, picked per block by rate-distortion

The predictors of spec 7.11.2 that read no further than the row above and the
column left of a block -- DC, V, H, SMOOTH, SMOOTH_V, SMOOTH_H and PAETH -- with
the edge construction that fills a missing side from the side that exists. Each
32x32 luma block now codes under all seven and keeps the one whose squared error
and estimated rate come out cheapest; chroma stays DC, which is the mode the tile
writer codes for it.

The weight on rate was swept over three real clips and two synthetic pictures at
six values; 0.05 step-squared per bit is the best point on every one. Against DC
alone it saves 11.5% of the rate on screen capture, 7.8% on the test card and
59.5% on a picture that runs one way. Against libaom the gap at matched size on a
film frame narrows from 2.4 dB to 2.0 dB.

Every mode is gated forced over a whole picture, with ffmpeg's reconstruction
equal sample for sample, and striped pictures gate the search on picking the
direction the picture runs -- a transposed predictor passes every symmetric test.
feat(av1): encode a key-frame pictureAhmet Kaan Gümüş · a4fb030
feat(av1): encode a key-frame picture

DC intra prediction over the reconstruction, the forward transform and
quantizer, and the tile writer, joined into an encoder that takes a planar
4:2:0 picture and produces a stream. Blocks are 32x32 luma and 16x16
chroma, coded in the order a decoder walks a superblock's quadrants.

The gate is an equality: ffmpeg's decode of the stream matches the
encoder's own reconstruction sample for sample, on every plane, for test
cards at three sizes and for a frame of real video. Prediction reads the
reconstruction, so a single sample of drift would spread through every
block below and to the right of it.

At q_idx 100 a 640x352 film frame costs 32 366 bytes at 39.26 dB, which is
about 2.4 dB behind libaom at the same rate -- the size of what is not
implemented yet: one block size, one transform type, DC prediction only,
no rate-distortion decision, no CDF adaptation.