forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on af9550052a8ca1ddb593bc5a5f0bf8be5589b428

2026-08-26

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.
Merge branch 'lane-av1-facade': I11 streaming encoder facade with colour signallingAhmet Kaan Gümüş · ec4c3f6
Merge branch 'lane-av1-facade': I11 streaming encoder facade with colour signalling

Av1Encoder{new,encode,coded_size,display_size} one-in-one-out;
EncoderConfig{width,height,base_q_idx,gop,colour}; Colour maps to CICP
(BT709/BT601 limited, unspecified) wired into the key-frame sequence
header; encode_sequence and the facade share encode_key_frame_inner/
encode_inter_frame. Gate: cargo test -p ec-av1 --release 123 passed / 5 ignored.
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.
fix(image): close a TIFF LZW dictionary-corruption cycle that grew unboundedAhmet Kaan Gümüş · 55b1d36
fix(image): close a TIFF LZW dictionary-corruption cycle that grew unbounded

A code strictly greater than the dictionary's next slot was accepted into
the KwKwK branch and stored as `previous`; a later entry then chained
through that out-of-range value, breaking the prefix-chain invariant and
letting the decode walk cycle, growing `stack` to gigabytes on a
fuzzed 8950-byte fixture. Require code == next for KwKwK; anything else
is corrupt input, not a decodable stream.
feat(av1): diamond/log integer + half/quarter-pel motion searchAhmet Kaan Gümüş · 5986059
feat(av1): diamond/log integer + half/quarter-pel motion search

Adds crates/ec-av1/src/motion.rs: a log/diamond integer-pel search over one
reference plane through mc::predict, refined by one half-pel then one
quarter-pel round. Cost is SAD + lambda * mv_bits, where mv_bits prices the
MV residual (joint/class/bit/fraction/hp) by interval-narrowing through
encode::symbol_bits against the cdf::MV_* tables, matching the tile writer's
own convention rather than a per-entry probability lookup.

SEARCH_INITIAL_STEP_PEL=8 landed from a three-way sweep (4/8/16) recorded in
motion.rs's own inline test. SAD chosen over SSE per a doc-comment measurement.
Merge remote-tracking branch 'origin/main' into lane-image-tiffAhmet Kaan Gümüş · fd823fc
Merge remote-tracking branch 'origin/main' into lane-image-tiff

# Conflicts:
#	crates/ec-image/src/lib.rs
fix(av1): exact spec 7.10.2.8 mvstack contexts, 7.10.2.14 MV clampingAhmet Kaan Gümüş · 23d548c
fix(av1): exact spec 7.10.2.8 mvstack contexts, 7.10.2.14 MV clamping

Replaces the documented monotonic stand-in NewMvContext/RefMvContext/
ZeroMvContext/DrlCtx with an exact port of libaom's av1_find_mv_stack
mode_context switch and av1_drl_ctx (mvref_common.c/.h), which collapse
to closed forms given this module's already-reduced scan (no extended
row/col offsets, no temporal MV projection): ref_match_count ==
nearest_match always, so drl_ctx is always 0 (every candidate gets the
REF_CAT_LEVEL nearest-bonus), and zero_mv_ctx is always 0 (GLOBALMV_OFFSET
is only ever set by temporal MV projection). Adds MiInfo::is_new_mv so
new_mv_ctx can read whether a neighbour was itself coded NEWMV, matching
libaom's newmv_count. Adds clamp_mv_ref (7.10.2.14) applied to
nearest_mv/near_mv/pred_mv, requiring find_mv_stack's new mi_cols/mi_rows
params. Adds single_ref_ctx: the LAST-only reduction collapses libaom's
three single_ref_p1/p3/p4 context functions to one two-valued test since
LAST2/LAST3/GOLDEN/backward counts are always zero here.

Ledger: does not include the inter tile writer (ec-av1 tile.rs) this
lane's charter also scoped -- see HANDOFF for the exact block-writer
design (symbol order, size groups, MV component coding) worked out but
not yet landed.
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): MV prediction stack (spec 7.10.2, single-ref reduction)Ahmet Kaan Gümüş · ec98d16
feat(av1): MV prediction stack (spec 7.10.2, single-ref reduction)

find_mv_stack scans row-above/col-left/top-right neighbours over a
block's whole 4x4-mi span, dedupes into a weighted RefStackMv, and
derives NearestMv/NearMv/PredMv plus NewMv/RefMv/ZeroMv/DRL contexts.
Compound refs, temporal MV projection and bit-exact context tables are
deliberately out of scope until a consumer needs them.
feat(av1): default CDF tables for inter-frame mode and MV syntaxAhmet Kaan Gümüş · e9086ec
feat(av1): default CDF tables for inter-frame mode and MV syntax

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

Compound reference and compound-mode CDFs are left out: this encoder
never sets reference_select.
feat(av1): sub-pel motion compensation (spec 7.11.3, EIGHTTAP regular)Ahmet Kaan Gümüş · 082d993
feat(av1): sub-pel motion compensation (spec 7.11.3, EIGHTTAP regular)

Two-stage separable 8-tap filter, InterRound0=3/InterRound1=11 for
8-bit non-compound per spec 7.11.3.2, edge samples clamped rather than
read out of range. Not yet wired into encode.rs (later lane).
fix(image): budget every header-declared allocation; bound LZW growthAhmet Kaan Gümüş · 81c7624
fix(image): budget every header-declared allocation; bound LZW growth

Both 2026-08-26 machine OOMs were crates/ec-image tests/fuzz: decoders
allocated from wire-declared fields with no budget. Class fix:

- Limits::check_bytes + AllocBudget: per-buffer cap lowered to 1 GiB,
  decode-wide total of 4 GiB; GIF/WebP animation paths spend the budget
  per frame, closing the frame_count x canvas multiplier.
- GIF frame rectangles get their own limits check (they need not fit the
  canvas the screen descriptor bounded).
- lzw_decode stops once the declared frame is full instead of expanding
  a bomb stream to ~400 MB from a 155 KB input.
- HEVC slice headers reject num_ref_idx_lX_active_minus1 > 14 (7.4.7.1)
  before pred_weight_table sizes vectors from it.

Fuzz suite holds under a 4G scope (max RSS 3.1G, was 27G); differential
and real-library suites stay green.
feat(infra): cap every cargo-run test binary in a 10G systemd scopeAhmet Kaan Gümüş · df0c158
feat(infra): cap every cargo-run test binary in a 10G systemd scope

Three kernel OOM kills in 48h came from test binaries launched outside the
omp-worker scope; a cap that lives in the launcher misses every other path.
The cargo target runner now wraps each test/bin in a transient user scope
(MemoryMax=10G, MemorySwapMax=2G), resolved via git rev-parse so every
worktree checkout carries it. EC_NOMEMGUARD=1 bypasses; fails open where
systemd is absent.
feat(image): decode BMP, including the shapes ImageMagick will not writeAhmet Kaan Gümüş · f1f296e
feat(image): decode BMP, including the shapes ImageMagick will not write

gpui names ImageFormat::Bmp, so the shim needed a decoder behind it. This
reads every shape the format defines: 1/2/4/8/16/24/32-bit samples, palettes
with three- or four-byte entries, BI_RLE4 and BI_RLE8, arbitrary BI_BITFIELDS
masks, bottom-up and top-down rows, and headers of every defined length from
the 12-byte OS/2 v1 to the 124-byte BITMAPV5HEADER.

Two shapes that started as refusals are decoded instead. BI_PNG and BI_JPEG
files are a BMP header wrapped around a whole file of another format, so they
are handed to this crate's own PNG and JPEG decoders. The 16-byte OS/2 v2
header is the Windows layout truncated where the two stop agreeing, so it is
read through those 16 bytes -- which is what ffmpeg does, and what the
incumbent image crate refuses.

Gate: fourteen fixtures pixel-exact against image 0.25.10, the two wrapper
files exact against the incumbent decoding their payloads directly, and the
OS/2 v2 file exact against the same picture in a header the incumbent reads.
Twenty thousand fuzz mutations across the plain and run-length paths, no
panics. Full report in lanes/image-bmp-r1.report.md.
feat(image-shim): the gpui-only surface, behind a cargo featureAhmet Kaan Gümüş · c6f0f87
feat(image-shim): the gpui-only surface, behind a cargo feature

gpui consumes half an image crate this shim never needed: Frame, Delay,
AnimationDecoder, GifDecoder, WebPDecoder, guess_format,
load_from_memory_with_format, ImageBuffer, and the Gif/Bmp/Tiff format
names. None of it belongs to still-image decoding, so it lives behind a
`gpui` feature the way chrono keeps its serde impls behind one -- a build
that does not draw windows compiles none of it, and the default surface is
unchanged.

Served by ec_image: the animation paths go through decode_animation, and
WebPDecoder::has_animation answers from webp::is_animated.
set_background_color accepts only a fully transparent colour, which is
what gpui asks for and what the frames are composited onto.
feat(image): animated WebP, composited frame by frameAhmet Kaan Gümüş · 275d306
feat(image): animated WebP, composited frame by frame

decode_frames walks the ANMF chunks and composites them onto the canvas:
frame rectangles, both blending methods, and dispose-to-background applied
before the next frame is drawn. is_animated answers from the container
alone. The still and animated paths now share one payload decoder.

The incumbent decoder ignores the dispose-to-background flag, so it cannot
be the oracle for the frame after a disposal: that fixture is gated
against libwebp's own composited frames instead, pixel-exact, and the
incumbent remains the oracle for the opaque fixture. ffmpeg refuses
animated WebP outright and cannot arbitrate.

Adds a lossless fixture whose three frames carry alpha and exercise both
blending methods and the disposal rectangle -- the existing animation is
opaque and disposes nothing.
feat(image): GIF decoding and a format-agnostic animation surfaceAhmet Kaan Gümüş · 166bcc8
feat(image): GIF decoding and a format-agnostic animation surface

A GIF87a/GIF89a decoder written to the spec: LSB-first LZW with the
one-code-early width bump and the cScSc case, sub-block chains, the
four-pass interlace, graphic control extensions, local and global colour
tables, and frame compositing with all four disposal methods.

Adds decode_animation(), which every format answers -- a still is one
frame with a zero delay -- so a caller that wants to play something never
branches on the format. One colour form is chosen for the whole
animation, so the pixel layout cannot change under a caller mid-walk.

Gated pixel-exact against the incumbent decoder: 6/6 fixtures, and 7/7
real GIFs on this machine over 454 frames, frame count and per-frame
delays included. Two 10 000-round mutation sweeps cover the still and
the animation path.
feat(h265): in-loop deblocking filter, on by defaultAhmet Kaan Gümüş · 96b7b12
feat(h265): in-loop deblocking filter, on by default

Spec 8.7.2, written from the text. An intra-only stream simplifies it
twice over: intra prediction reads unfiltered reconstruction, so the
filter is a post-pass over the finished picture and the picture-hash SEI
stays honest; and every edge has bS = 2, so the whole strength
derivation reduces to finding the transform-block boundaries.

TuMap carries one byte per 4x4 unit -- log2 of the transform covering
it. Transform blocks of side S are aligned to multiples of S, so an edge
at x is a boundary exactly when x % S == 0, and no edge list is needed.
Each wavefront worker publishes its band; the encoder stitches them,
filters every vertical edge, then every horizontal one over the result.

Writing the filter exposed an encoder bug: the RQT split trial marks
four child transform blocks, and when the nosplit trial won nothing
rewrote those cells, so the map reported a boundary inside a 32x32
transform. Reconstruction and coefficients were restored between trials;
the side map was not. The nosplit branch now marks its own transform,
and tu_log2 rides the CU-depth meta snapshot.

ffmpeg decodes every shape bit-exactly with the filter on. BD-PSNR
against a deblocking x265, our filter off then on: film -0.197 ->
+0.063 dB, screen capture +0.606 -> +0.693, web clip +0.567 -> +0.686,
phone clip +0.113 -> +0.162, synthetic +8.781 -> +8.796. Every clip
improves, so it defaults on.
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(h265): a 64x64 coding tree block may stay one coding unitAhmet Kaan Gümüş · 826a8f8
feat(h265): a 64x64 coding tree block may stay one coding unit

HEVC's largest transform is 32x32, so a 64x64 intra coding unit splits its
transform tree without a split_transform_flag -- the split is inferred from
log2TrafoSize > MaxTbLog2SizeY -- and predicts per 32x32 transform block in
z-order, each quadrant marked coded before the next reads its neighbours.
What the coding unit buys is three split flags and three mode signallings,
against one luma direction for the whole 64x64.

On by default; only reachable with ctb_size 64, which is not the default.
Against always splitting a 64x64 tree block it is worth +0.002 dB BD-PSNR on
a film frame and +0.098 dB on a screen capture.
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.