forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 8fd360ca80fc0cfde591fccb4eba42f66f52fb36Filtered to crates/ec-av1/src/transform.rsClear filter

2026-09-07

feat(av1): lossless key frames decode exact; lossless inter refused by nameAhmet Kaan Gümüş · 1e1a080
feat(av1): lossless key frames decode exact; lossless inter refused by name

Key/intra-only lossless frames decode sample-exact at 8 and 10 bit (64x64,
256x128 8-bit, 192x96 10-bit libaom -crf 0 streams, 0 sample diffs vs
ffmpeg). The inter path's luma leaves are synthesized as TX_4X4 but its
chroma plane is still one transform per block, so a lossless INTER frame is
refused by name and the refusal inventory carries it. The old refusal gate
becomes a_lossless_libaom_key_frame_decodes_sample_exact.
feat(av1): a lossless key frame decodes sample-exactAhmet Kaan Gümüş · b0db8e9
feat(av1): a lossless key frame decodes sample-exact

The rect strip readers take the per-transform-unit walk on a lossless frame
(depth_to_tx_wh returns TX_4X4 before it looks at the block), their chroma is
coded as 4x4 units plane-major with get_txb_ctx's +10 offset rows, and the
Walsh-Hadamard orientation is pinned by measurement. A 64x64 libaom -crf 0
key frame now decodes sample-exact against ffmpeg (6488 entropy steps
identical to aomdec's EC_TRACE_COEFF, 0 sample diffs).
feat(av1): lossless decode groundwork -- WHT, TX_4X4 forcing, CfL narrowingAhmet Kaan Gümüş · f0a5a15
feat(av1): lossless decode groundwork -- WHT, TX_4X4 forcing, CfL narrowing

The 4x4 Walsh-Hadamard inverse (libaom av1_iwht4x4_16_add_c) with its own
round-trip test, a per-frame CodedLossless flag replacing the refusal (a
frame mixing lossless and lossy segments is still refused by name), the
TX_4X4 forcing in the square and 8x8-leaf intra readers, no tx_type symbol
(libaom read_tx_type: qindex 0 returns early), DCT_DCT on every plane, the
is_cfl_allowed narrowing to a 4x4 chroma plane block, and the +10 chroma
txb_skip rows at TX_4X4 that only a lossless frame reaches.

2026-09-06

test(av1): pin the typed forward transform bit-identical to its strided formAhmet Kaan Gümüş · e70dd64
test(av1): pin the typed forward transform bit-identical to its strided form

Compares raw bit patterns, not an epsilon: the contiguous-basis rewrite is
exact only because it moved the loop over the outputs and left each output's
term order alone, so a reassociation would surface here as a last-place
difference. Covers every non-flipped non-DCT type at 4/8/16/32, with an
all-zero residual and a half-zero-rows residual so both skips are walked.
perf(av1): exact integer SAD/SSE and a vectorizable typed forward basisAhmet Kaan Gümüş · fae8c1b
perf(av1): exact integer SAD/SSE and a vectorizable typed forward basis

Two byte-exact rewrites on the encoder search's hottest loops, both proved
by the enc_probe FNV set on the three gate clips at four q points.

`Plane::block_sad`/`block_sse` replace four hand-rolled `f64` accumulations
that ran an integer division and remainder per sample to recover (row, col)
from a flat index. The sums they replace are whole numbers far below 2^28,
so `f64` held every partial sum exactly and neither the order of the adds
nor the accumulator type can change the result.

`forward_transform_2d_typed`'s two matmuls summed over a strided basis,
which no vectorizer can touch. `axis_basis_t` caches the transposed basis so
the pass is contiguous in the basis index and strided in nothing; each
lane's terms stay in the same order, so the levels are unchanged. The row
pass now also records which rows it filled, and the column pass walks only
those.

1080p ladder, 12 frames, 4 q points: 111.09e9 -> 101.65e9 instructions:u
(-8.5%, ABAB x2).
perf(av1): the forward transform skips an all-zero residual, and the quantizer stops dividing per coefficientAhmet Kaan Gümüş · eca6458
perf(av1): the forward transform skips an all-zero residual, and the quantizer stops dividing per coefficient

A census of the BD gate's own ladder (12 frames, four quality points):
4.14M DCT_DCT forward transforms (67% 4x4, 24% 8x8, 6% 16x16, 2% 32x32) of
which 72% carry an all-zero residual, and 1.86M non-DCT ones (77% 4x4, 23%
8x8) of which 68% do. The fixed-point path skipped those row by row and
column by column but still allocated the row buffer; the f64 analysis basis
the non-DCT types use had no skip at all and ran both matmuls over zeros.

Both now return early -- exactly, since a row of zeros contributes only
`0.0 * b` terms and a sum of zeros is `+0.0` -- and `quantize` walks rows
and columns instead of recovering them with a division per coefficient.

Byte-exact: 1080p gate ladder unchanged (same FNV-1a per stream);
6.61s -> 6.24s.
perf(av1): ten headroom bits under the forward network, measured on BDAhmet Kaan Gümüş · 636712f
perf(av1): ten headroom bits under the forward network, measured on BD

Six bits of headroom left the fixed-point network's rounding worth 3.9 BD
points on screen capture against libaom. Ten put the coefficient
resolution at 1/256 of a unit of the `8 * orthonormal` scale a level is
formed on, which is where the BD gate stops moving -- 13 bits measures
identical -- and stays under 2^27 for a 12-bit residual through two
64-point passes.

BD-rate vs libaom 216.6/233.5/289.8 (base 216.4/235.5/289.2), vs rav1e
157.4/175.9/138.1 (base 157.8/178.3/141.1), 1080p/2160p/screen: six of
the eight numbers improve, screen-vs-libaom is +0.6 and 1080p-vs-libaom
+0.2.

Also measured and REVERTED: the row pass's `Vec` in a thread-local
scratch, as the inverse transform's is, +5.0% instructions -- reusing the
buffer needs a `memset` where a fresh allocation is already zeroed, and
that zeroing is what the all-zero-row skip reads. Noted at the function.
perf(av1): form the levels off the forward transform's own fixed pointAhmet Kaan Gümüş · 1be1614
perf(av1): form the levels off the forward transform's own fixed point

`forward_and_quantize` transformed into a `Vec<f64>` of coefficients and
then read it back to quantize. With the network already in fixed point
the column pass can hand each column straight to the level formation
while it is still in `t`, so the coefficient buffer and the pass over it
are gone -- and a 64-point transform's uncoded columns (everything
outside the top-left 32x32 the syntax carries) are not transformed at
all.

209.0 G -> 178.9 G instructions:u on the sequence bench (-14.4%).

Two eight-wide column passes were measured and REVERTED: the `[i32; 8]`
Lane over eight columns is +3.4%, an in-place whole-buffer column pass
+2.3%. Both lose the per-column zero skip and the register-resident level
formation, which this encoder's mostly-small transforms live on. Noted at
the call site.
perf(av1): the encoder's forward DCT is the decoder's network, transposedAhmet Kaan Gümüş · eb8e099
perf(av1): the encoder's forward DCT is the decoder's network, transposed

The forward transform was an f64 FFT (Complex math, per-row/column) and
had become the encoder's single largest cost -- `transform::dct1d` 23.6%
of the profile. It is replaced by the transpose of the decoder's own
fixed-point butterfly network: a network's transpose is that network run
backwards with each elementary matrix transposed, and all of this one's
elements are symmetric except the unflipped rotation, whose transpose is
the same rotation at the negated angle. So the forward body IS the
inverse's stages reversed, its unflipped angles negated, its bit-reversal
moved to the end -- generated from the inverse's source, then measured.

Only the quantized levels reach the decoder, so a forward transform owes
a good analysis basis, not a specified one; the gain the levels are
formed on is measured from the network (`forward_gain`, sqrt(n/2) per
pass) rather than asserted, and the residual carries six headroom bits so
the network's own rounding stays well under one unit of the 8x
orthonormal scale a level is formed on.

-13.1% instructions:u on the sequence bench (209.0 G -> 181.6 G).
feat(av1): chroma searches its own uv_mode instead of coding DC unconditionallyAhmet Kaan Gümüş · b0a80f3
feat(av1): chroma searches its own uv_mode instead of coding DC unconditionally

Both chroma planes were predicted DC_PRED at every block because that is all
the tile writer coded. They now search the seven modes that read no further
than the row directly above and the column directly to the left -- DC, V, H,
SMOOTH, SMOOTH_V, SMOOTH_H, PAETH -- which is exactly the set a chroma block
coded with `Reach::none()` may offer; the eight directional modes read past
that and UV_CFL_PRED needs its own alpha syntax.

A chroma block never codes a tx_type symbol: the decoder derives it from the
chroma mode (`Intra_Mode_To_Tx_Type`, spec 9.3), so a non-DC uv_mode moves
chroma onto an ADST-bearing transform. The forward half of that is new here
and measured off the decoder's own inverse network -- a unit coefficient
through `inverse_1d` IS the basis function it synthesises -- rather than
written out, which is safe because only the levels and the derived type reach
the decoder: the reconstruction the search scores still comes back through
the exact inverse.

BD-rate vs libaom 234.0/260.3/318.5 -> 216.4/235.5/289.2 and vs rav1e
171.9/203.2/155.3 -> 157.8/178.3/141.1 (1080p/2160p/screen), down on all
three against both references. Wall 9.8s -> ~11.1s per clip ladder. The gate's
own ffmpeg-decodes-sample-exact assertion holds, so the writer's uv_mode and
angle_delta_uv syntax and the derived chroma transform agree with a real
decoder. Fire counts printed per clip: DC wins 79.1/84.1/43.8%, PAETH
7.1/6.6/29.0%, H 3.3/2.5/16.6%.
perf(av1): cached FFT stage twiddles, stack scratch for a motion-compensated trialAhmet Kaan Gümüş · 56cc232
perf(av1): cached FFT stage twiddles, stack scratch for a motion-compensated trial

Two allocation/libm costs on the encoder's hottest paths, neither of which
changes a single output byte:

- `fft`'s stage twiddle depends only on the stage length, so its two
  `sincos` calls per stage per call become one lazily-built table of the
  seven values that exist (`__sincos_fma` was 9% of the encoder profile).
- `mc_trial` heap-allocated a `u16` prediction and a `u8` copy of it for
  every candidate trial; both are at most 32x32 and now live on the stack.

instructions:u on the 24-frame 1280x720 sequence bench: 283.6G -> 263.5G
(-7.1%); output bytes unchanged (64931), BD-rate unchanged on all three
gate clips.

2026-09-05

perf(av1): answer 'this unit coded nothing' by pointer, not by scanning its gridAhmet Kaan Gümüş · 7002e78
perf(av1): answer 'this unit coded nothing' by pointer, not by scanning its grid

The zero grid is now shared (previous commit), so is_zero_grid recognises it
with one pointer compare. The dequantizer's all-zero test and the neighbour
state's cul_level sum both walked the whole grid for the 60% of transform
units that code no coefficient -- the sum has no early exit at all.
-1.2% instructions:u at 1 thread, -0.7% at (16,4,2); byte-exact.
perf(av1): put the AVX2 feature on the Lane methods themselvesAhmet Kaan Gümüş · b848139
perf(av1): put the AVX2 feature on the Lane methods themselves

The column pass measured -3.7% instructions when the network was
`#[inline(always)]`d into the `target_feature` wrapper -- and then measured
FLAT again after an unrelated refactor moved the size dispatch into its own
`target_feature` function: the generic network stopped landing inside an AVX2
context, and with it every `_mm256_*` went back to being an out-of-line call
(9.5% + 3.7% of the profile, 65 `vpmuldq` in the binary against 339 now).

Relying on inlining to carry the feature is what was fragile. `Lane`'s two
methods are `unsafe fn` now -- the only form rustc lets an impl carry
`#[target_feature]` -- so the AVX2 impl compiles its intrinsics inline no
matter how its callers are arranged. The scalar impls require nothing of
their callers, and `M256` values still exist only inside the feature-detected
`simd::column_pass_dct`.

seg4k at one thread: 523.15 -> 502.36 G instructions:u (-3.97%), stable across
runs. All 12 gate hashes unchanged.
test(av1): the AVX2 column pass against the scalar network over the full i32 rangeAhmet Kaan Gümüş · 1b7f343
test(av1): the AVX2 column pass against the scalar network over the full i32 range

The intrinsics claim exact 64-bit products, so the gate sweeps `i32::MIN`/
`MAX`, both clamp boundaries at every `r` the decoder uses (16/18/20) and
uniform full-range noise at every size, not only the dequantizer's own bound
-- a single differing lane would be a silent pixel drift on whatever stream
first reached it.
perf(av1): explicit AVX2 inverse-DCT column pass, and an empty all-zero residualAhmet Kaan Gümüş · ef53b7e
perf(av1): explicit AVX2 inverse-DCT column pass, and an empty all-zero residual

The eight-wide column pass lane-tx introduced went through `[i32; 8]`, which
LLVM never vectorised (the butterfly products are 64-bit). This adds an
explicit AVX2 `Lane` impl -- `_mm256_mul_epi32` on the even/odd halves, so
every product is exact in 64 bits and the pass is byte-exact with the scalar
network on every input, not only on conformant ones -- dispatched off
`mc::simd_level()`, with the scalar impl kept as the reference.

`inverse_dct_n` is `#[inline(always)]` because the AVX2 instantiation has to
land inside the `target_feature` wrapper: without it every `_mm256_*` stayed
an out-of-line call and the "SIMD" pass measured 5.6% WORSE.

Second, the 60% of transform units that carry no coefficient now return an
EMPTY residual instead of `w * h` zeros: the reconstruction loops expand the
marker against one static zero block, so the per-unit zero `Vec`, its `to_vec`
clone into the recorded op, and (for a deferred unit) the coefficient-grid
clone all disappear.

seg4k at one thread: 523.1 -> 503.5 G instructions:u (-3.7%), min-of-5
cycles:u 142.1 -> 136.4 G. All 12 gate hashes unchanged.
perf(av1): monomorphise the inverse DCT per size, take the column pass eight columns at a time, skip all-zero transform unitsAhmet Kaan Gümüş · 484b7c3
perf(av1): monomorphise the inverse DCT per size, take the column pass eight columns at a time, skip all-zero transform units

The inverse transform was ~10% of a 4K decode. Three measured steps, all
byte-exact (12/12 gate hashes at 1/4/16 threads unchanged):

- the spec's one generic butterfly network is now monomorphised on
  `N = log2(size)`, so every size guard, every `brev` fold and every
  butterfly angle is a compile-time constant instead of per-call work
  (-1.03%);
- the column pass runs eight neighbouring columns through one network
  (a `Lane` trait with an `i32` and an `[i32; 8]` impl, so the network
  itself is still written once), turning the strided per-column gather
  into a contiguous load (-2.67%);
- 60% of the transform units on the 4K perf segment carry no coefficient
  at all (3.46M of 5.7M, measured with a temporary histogram): a zero
  level grid dequantizes to zero and inverse-transforms to zero, so one
  scan replaces the dequantization and both passes (-1.55%).

Together 559.05 -> 530.19 G instructions:u at one thread on the 4K
segment, -5.16%.

Two steps measured flat and are not here: compiling the eight-wide
network a second time with AVX2 enabled (LLVM emits the same scalar code
either way -- the i64 butterfly products do not vectorise, so an
explicit vpmuldq kernel is the remaining lever), and an in-place
bit-reversal permute.

2026-09-04

perf(av1): run the inverse DCT network on a fixed-size scratch arrayAhmet Kaan Gümüş · e428d82
perf(av1): run the inverse DCT network on a fixed-size scratch array

Every butterfly, Hadamard and permutation of the spec's DCT network
indexes the 64-entry scratch with a computed index, and on a `&mut [i32]`
each one carried its own bounds check against a length the optimiser
could not see. The network now runs on `&mut [i32; 64]`, which discharges
them against the constant length; `inverse_dct` keeps its slice-taking
signature as a wrapper for callers outside the 2D driver, and `inverse_1d`
calls the fixed-size body directly.

Byte-exact on seg1080/seg4k/seg4k_lr/palette_screen_witness. seg1080
189.06 G instructions (was 190.19 G, -0.59%); seg4k 599.04 G (was
602.71 G, -0.61%).
perf(av1): broadcast the column transform when the row pass leaves one constant rowAhmet Kaan Gümüş · 7086b91
perf(av1): broadcast the column transform when the row pass leaves one constant row

The dominant inter residual is DC-only: the row pass then writes a single
non-zero row that is constant along its length, and the column pass runs
the same `inverse_1d` on the same input vector once per column, `w` times
over.

`inverse_transform_2d_typed_wh` now counts the non-zero rows the row pass
produced and whether the first of them is constant. When there is at most
one such row, one column transform is run and its output broadcast across
each output row -- byte-identical to the `w` transforms it replaces
(`inverse_1d` is a pure function of its input), and the per-column gather
goes with them.

Byte-exact on seg1080/seg4k/seg4k_lr/palette_screen_witness. seg1080
190.19 G instructions (was 193.75 G, -1.84%); seg4k 602.71 G (was
604.37 G, -0.28%).
chore(av1): clear the ec-av1 compiler warnings (300 -> 0 on the release lib)Ahmet Kaan Gümüş · 16efbd9
chore(av1): clear the ec-av1 compiler warnings (300 -> 0 on the release lib)

No arithmetic, control flow or public signature changes; the four perf6
decode hashes are byte-identical.

- gate-counter accessors and other test-only items carry
  `#[allow(dead_code)]` with the reason on the line (they are read from the
  `#[cfg(test)]` gates, which the plain lib build cannot see);
- `///` blocks sitting on `thread_local!`/macro invocations become `//`
  (rustc never attached them to anything);
- `cdf.rs` tables and the `InterpFilterKind` variants get a one-line doc;
- unused locals/params prefixed `_` where the value is genuinely unused;
  dead initializers dropped where the compiler proves every read is
  preceded by an assignment;
- `decode_key_frame_tile` import is now `#[cfg(test)]` (its only user).

Left standing on purpose, as findings rather than hidden warnings:
`stream.rs` census counters `other` and `rect_residual_refusals` are
incremented and never read back by their gates.
perf(av1): dequantize into a reused buffer, with the loop invariants hoistedAhmet Kaan Gümüş · 32f9ae5
perf(av1): dequantize into a reused buffer, with the loop invariants hoisted

`dequant_wh` was a `map`/`collect` building a fresh `Vec<i32>` per transform
unit (7.8% self time, the third-hottest symbol in the decode profile), and
inside it every coefficient repeated the whole per-coefficient spec function:
two quantizer-table lookups with their own clamps, the area denominator's
match, and the bound shift -- all of which depend on the transform, not on
the coefficient.

`dequant_wh_into` hoists them and writes a caller-owned buffer, which the
one hot caller (`dequant_and_inverse_typed_wh`) keeps thread-local. A zero
level dequantizes to zero for every parameter set, so the all-but-EOB tail
of a grid now costs a compare rather than a 64-bit multiply and divide. The
arithmetic on a non-zero level is untouched; `dequant_wh` keeps its `Vec`
signature for the other callers.

`buffered_dequant_matches_the_per_coefficient_form` checks the buffered form
against `dequant_coeff_wh` over six transform shapes, three bit depths, three
quantizer/delta sets and both level signs.

Byte-exact: `EC_PROBE_OUT16` dumps cmp IDENTICAL against the lane's baseline
binary on 1080p 10-bit, 2160p HDR and the 8-bit palette fixture. Interleaved
medians against the previous commit: 1080p 13.46 s -> 12.15 s, 4K 67.11 s ->
63.38 s.
perf(av1): inverse transform without per-call allocation or runtime bit-reversalAhmet Kaan Gümüş · ee4e975
perf(av1): inverse transform without per-call allocation or runtime bit-reversal

`perf annotate` of `inverse_dct` (12.3% self time) opened every call with a
`malloc`/`memcpy` pair -- `permute`'s `Vec` -- and then spent its hottest
single instruction in the inlined `brev` bit-fold, recomputed per butterfly
index. `cos128` was a four-way branch per butterfly, and the 2D driver
(7.6% self) allocated two more `Vec`s per transform unit while looking up
`row_shift_wh` through a match once per output sample.

All four are now compile-time or loop-invariant: `brev` and the whole-circle
cosine are const tables, `permute` copies into a stack array, the row pass
writes a thread-local scratch it fully overwrites, and the shift is hoisted.
The row and column passes also skip an all-zero vector, which is exact rather
than approximate -- every butterfly and Hadamard of zeros is zero and
`Round2(0, n)` is zero at every `n` -- and is what makes rows 32..64 of a
64-point transform, and the tail of any EOB-limited block, free.
`a_zero_vector_transforms_to_zero` pins that property per 1D transform and
end to end.

Byte-exact: `EC_PROBE_OUT16` dumps cmp IDENTICAL against the pre-change
binary on a 299-frame 1080p 10-bit segment, a 4 s 2160p HDR segment and the
8-bit palette fixture. Interleaved medians: 1080p 16.72 s -> 13.74 s
(17.9 -> 21.8 fps), 4K 78.74 s -> 70.05 s.

2026-08-30

fix(av1): thread per-plane quantizer deltas (delta_q_y_dc/u_dc/u_ac/v_dc/v_ac) into dequantAhmet Kaan Gümüş · 8560456
fix(av1): thread per-plane quantizer deltas (delta_q_y_dc/u_dc/u_ac/v_dc/v_ac) into dequant

Spec 5.9.12/7.12.2: these were parsed by ec-av1-syntax and used for nothing
but the lossless[] check. Threaded QuantDeltas through dequant_coeff_wh/
dequant_wh/dequant_and_inverse_typed(_wh) and all 8 decode.rs leaf call
sites, plane-correct (Y has no AC delta). decode_stream's 5 call sites now
pass header.quantization.delta_q_*; convenience wrappers pass ::default().
Plain 4-arg dequant/dequant_coeff/dequant_and_inverse (~20 external callers
in tile.rs/encode.rs/transform.rs) unchanged.

Blast radius measured, not assumed: EC_AV1_TRACE now prints the 5 deltas at
parse time. Measured zero on the r10 pinned repro (seed42.obu, base_q_idx
180) and on every stream the scoped decode::/quant::/transform:: suites
exercise (27/27 green) -- no gate was passing "for the wrong reason".

Charter's 81-vs-76 defect is NOT this: deltas are genuinely zero for
seed42, disproven by measurement per the charter's own fallback clause.
Pinned repro currently panics on an unrelated pre-existing gap (32x32
partition value=4, later superblock, same shape as the r9 part32-AB
dead-end) before it can even reach the pixel comparison. Report names the
next suspect (CURRENT_Q_IDX per-superblock delta-q state / segmentation
qindex) with a one-line instrumentation step, left for the next round.

Red: pinned_sbpart_stream_decodes_pixel_exact still fails (pre-existing,
unrelated gap, not a regression from this diff).
wip(av1): rectangular inverse transform + libaom dump harness (in progress)Ahmet Kaan Gümüş · 1a9fc2c
wip(av1): rectangular inverse transform + libaom dump harness (in progress)

Committed by the orchestrator: the builder hit its turn cap mid-verification.

2026-08-28

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

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

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

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

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

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

2026-08-27

feat(av1): the seven-type TX_SET_INTRA_1 tx_type row, V_DCT/H_DCT, gate firesAhmet Kaan Gümüş · 2411791
feat(av1): the seven-type TX_SET_INTRA_1 tx_type row, V_DCT/H_DCT, gate fires

A reduced_tx_set=0 frame's 8x8-and-under intra transforms read tx_type
from the seven-symbol TX_SET_INTRA_1, not the five-symbol reduced row
our tables carried (the row-held-constant class, on the tx-set
dimension -- our own encoder always writes reduced_tx_set=1, the same
writer-never-needs-it trap as mv_hp). New set-1 CDF row, the set-1
symbol order from av1_ext_tx_inv, and the V_DCT/H_DCT inverse
transforms (one-axis DCT, identity on the other). The tx-select gate
now actually FIRES: mandelbrot content at min-partition 16 splits
16x16 blocks into TX8 TUs that read the set-1 rows and decode
pixel-exact vs ffmpeg, 4/4 runs, no skips. Resolved 4x4 luma stays a
named refusal (no TX4 coefficient tables yet).
debug(av1): r9 falsifies hypothesis A and rules out qmatrix/delta_q/segmentationAhmet Kaan Gümüş · 120854a
debug(av1): r9 falsifies hypothesis A and rules out qmatrix/delta_q/segmentation

Task 1 (frame inventory): manual byte-level OBU parse of pin_cfl.obu (77
bytes total) shows exactly TD(size 0) + SEQUENCE_HEADER(size 10) +
one OBU_FRAME(type 6, size 61) to EOF -- no second frame OBU, no
show_existing_frame, nothing hidden. ffprobe/ffmpeg (libdav1d) also read
exactly 1 frame from the file. decode_stream returns 1 Picture; the test
compares frames[0] against ffmpeg_frames[0], the same single frame both
decoders parsed. Hypothesis A (ffmpeg showing a different frame) is
FALSIFIED for this fixture -- three independent confirmations (manual OBU
byte parse, ffprobe frame count, our own frame count) agree on
single-frame-single-shown.

Task 2 (reconstruction diff), new evidence this round: added
EC_AV1_TRACE prints for quantization/segmentation/delta params to
scratch_isolate_pinned_mismatch (stream.rs) and confirmed for pin_cfl.obu:
using_qmatrix=false, delta_q_y_dc=0 and delta.q_present=false,
segmentation.enabled=false, coded_lossless=false, tx_mode=Largest -- so
none of those alternate-quantization paths (which decode.rs does not
implement) are actually exercised by this stream; ruling them out removes
several live hypotheses for the amplitude gap rather than leaving them
open.

Independently verified the transform math itself: for the block's proven
levels ((0,0)=-2,(0,1)=-2,(0,2)=-2, dc_sign negative), dequant at
base_q_idx=60 gives [-57,-67,-67], and BOTH a from-scratch scipy
`idctn(norm='ortho')` computation and this crate's own
`dequant_and_inverse` agree the resulting residual is [-2,-2,-2,-2,-2,-1,
-1,-1,-1,-1,0,...,0] across the row -- i.e. our transform pipeline is
mathematically self-consistent and correct *given* those coefficients.
That residual added to DC_PRED=128 reconstructs to ~126, which is what
this decoder outputs; ffmpeg's real decode of the identical bytes is a
smooth 41-82 diagonal gradient that cannot come from this residual under
any correct reconstruction. So the remaining gap is neither hypothesis A
(ruled out above) nor a transform/dequant bug (ruled out here) -- it must
be a symbol read upstream of the proven-clean coefficient values
(partition_w32, most likely: a single 32x32 PARTITION_NONE forces the
whole frame through one DC_PRED block, while a wrong partition context
table could silently produce the same "coefficients bit-exact for the
symbols we read" result while reading the wrong symbol in the first
place). r10: re-derive partition_w32's CDF/context table from
entropymode.c independently of both this crate's and r8's prior Python
cross-check (which may share the same transcription error), and try
forcing a SPLIT decode of this exact stream to see whether a 4-subblock
reconstruction (each with its own propagated DC neighbour) produces
ffmpeg's smooth gradient shape.

Left the EC_AV1_TRACE prints (quantization/delta/segmentation/lossless)
in scratch_isolate_pinned_mismatch and a new #[ignore]d
scratch_probe_32x32_dequant in transform.rs documenting the independent
math check -- both scratch/debug-only, gated behind #[ignore] or env
vars, no behavior change. cargo test -p ec-av1 --release: 164 passed, 0
failed, 13 ignored.
feat(av1): decode ADST_ADST/ADST_DCT/DCT_ADST/IDTX intra transformsAhmet Kaan Gümüş · a170052
feat(av1): decode ADST_ADST/ADST_DCT/DCT_ADST/IDTX intra transforms

Ports av1_iadst4/8/16 and av1_iidentity4/8/16/32 from libaom's own
av1_inv_txfm1d.c (stage-for-stage, not hand-derived), wires TxType
through read_coeffs -> dequant_and_inverse_typed, and lifts the
DCT_DCT-only refusal for TX_SET_INTRA_2's five members. Axis
convention (row=htx_tab, col=vtx_tab) read directly off libaom's
av1_inv_txfm2d.c tables and gated by an asymmetric-input test.

Reference vectors for the 1D ports came from a C probe linked
against libaom's own build/decoder-debug/libaom.a, not memory.
perf(av1): replace the forward DCT's matmul with an FFT factorizationAhmet Kaan Gümüş · 5bfacbb
perf(av1): replace the forward DCT's matmul with an FFT factorization

forward_transform_2d ran an O(n^2) dot product against a cached DCT-II
basis per row and column, on every RD trial. Replaced with Makhoul's
FFT-based DCT-II reduction (O(n log n)), with the twist table and FFT
stage twiddles precomputed per size and the 1D transform working on
fixed-size stack buffers -- both measured necessary; a first cut with
runtime cos/sin and heap Vec scratch was slower than the matmul it
replaced.

The old matmul is kept under #[cfg(test)] as the differential oracle
for a new fast_forward_matches_the_naive_matmul test. All existing
transform tests, including the quantizer roundtrip and 64x64 coded-
quarter tests, pass unchanged.
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.

2026-08-25

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.