Commits
2026-11-23
2026-10-23
Restore edith_codecs after local data loss (2026-10-23)Ahmet Kaan Gümüş · b7434a2
Restore edith_codecs after local data loss (2026-10-23) On 2026-10-23 an automated agent ran `rm -rf $HOME` and deleted the local repository with all of its history. This commit restores the working tree from the newest surviving copy, the host-c server lane mirror. That mirror matches local main as of the testcut Phase 2 reports, including the tool cache, the nextest fast profile and changed-crates.sh. The history before this commit was not recovered.
2026-09-29
lane-av1pixprobe: land the EC_AV1_PIXPROBE rung re-anchored + diffwtd_mask's cast move and its 8/10-bit gateAhmet Kaan Gümüş · 4b28b49
lane-av1pixprobe: land the EC_AV1_PIXPROBE rung re-anchored + diffwtd_mask's cast move and its 8/10-bit gate
The two items lanes/av1cheapwins.report.md §C triaged "land after rebase".
A: the env-gated one-sample write probe from lane-av1-ibcwrite @ 25f5c729,
re-anchored by hand -- the branch's two mc store hunks no longer attach
because those stores now live in reconstruct_mc_rect (lane-perf4 /
lane-recoparse reshaped it: row-at-a-time slices, an early
residual.is_empty() return, and a w/h block extent with side demoted to the
prediction stride). pix_write("mc_copy"/"mc_add", x, y, w, ...) reports w,
not the branch's side, because that is what the block=(bx,by)+SIDE field
means for a rectangular inter block. Fires on the pinned R5 fixture
(sha256 bc699af4..., re-encoded here byte-identically) at px (296,128), three
stores one per plane; prints nothing with the variable unset.
B: 295dc3fe's u8 cast move in diffwtd_mask plus its 8/10-bit libaom
transcription gate. The cast is value-preserving: clamp(0,64) leaves m in
{0..=64}, so `as u8` is a no-op on the binding and both uses
(forward `m`, inverse `64 - m`, which is 1..=64) emit the same mask byte as
the old `m as u8` / `(64 - m) as u8` pair. The gate is the 10-bit coverage
diffwtd_mask's (bd - 8) term landed without; adapted to main's
blend_masked_compound, whose `subsampled: bool` is now subw/subh. Proven
non-vacuous at both depths, including a 10-bit-only round mutation that is
inert at 8-bit and still fails the gate.
C: the 189-vs-170 intrabc partition defect is recorded, not chased -- and
does not reproduce on merged main (the fixture decodes byte-exact vs ffmpeg
at 1d47ff54; the measuring tree 37a64d99 is 439 commits stale). The hand-off
row carries the original coordinates and numbers plus that caveat, so the
next charter re-bisects instead of trusting the coordinates.
Report: lanes/av1pixprobe.report.md2026-09-25
ec-av1: lane-av1-422sub8rect -- the sub-8 inter 4:2:2 chroma ported to its real shapesAhmet Kaan Gümüş · 19f693e
ec-av1: lane-av1-422sub8rect -- the sub-8 inter 4:2:2 chroma ported to its real shapes decode_inter_block8's whole chroma half moves to the BLOCK_4X8 plane block: one TX_4X8 ChromaRect8x4/SCAN_4X8 unit per plane through read_inter_plane_rect (offset-7 ctx, inherited luma tx type, around_mi_422_chroma walk), with the MC build, warp, masked-compound, interintra, OBMC and skip pushes reshaped per axis; the intra-in-inter arm reads the key-frame arm's rect reader. decode_inter_sub8_split4's shared group unit is replaced by what the oracle traces actually code at ss (1,0): every non-skipped odd-column piece is its plane's own chroma reference and codes U+V TX_4X4 at the floored chroma cell (build_inter_predictors_sub8x8 halves -- left from the left piece, right from own; mixed groups whole-from-own), intra pieces route through sub8_leaf_chroma422, and the 4:2:0 group tail is gated off at 4:2:2. Shared helpers made ss-exact (4:2:0/4:4:4 identical): blend_masked_compound and interintra_blend take per-axis mask subsampling (aom blend-a64-mask's four branches), obmc_plan/obmc_run derive chroma extents by the plane ss, TxParams::strided sizes stride*h (equal to the old square for every existing caller). decode_inter_block's square-cut 4:2:2 chroma blend keeps the pre-port direct mask read (stop-note: owning parent-lane surface). Frame 0 of the pinned t422 fixture stays byte-exact at all four stages; inter frames 1..10 decode and diverge ~15% less than the parent ladder (no frame exactness claimed -- further 4:2:2 classes remain, trace: EC_RECTCHROMA_GAP 16x8/8x32). Refusal unchanged; bypass never committed. cargo check 0 warnings; 4:2:0 inter pixel-exact witness and refusal gates green.
2026-09-24
lane-av112bitc: lift the 12-bit compound gate to the witnessed setAhmet Kaan Gümüş · 70849e0
lane-av112bitc: lift the 12-bit compound gate to the witnessed set The parent lifted single-ref 12-bit MC and left compound refused by name. A reaching stream existed already in its own battery recipe (six frames, warp off): the pre-fix tree refuses it at the compound mode read, so the witness is non-vacuous. - decode.rs: both 12-bit compound refusal sites deleted; nothing else in the parse changes (the guard sat after the mode symbol read, before any prediction). - mc.rs: no arithmetic change -- the parent's combines already absorb the CONV_BUF gain drop (INTER_POST_ROUND - delta; diffwtd + (bd-8) - delta, reconinter.c:307). Stale doc sentence corrected; mc_subpel_hits carries the test-only-reader allow so --all-targets checks warning-free. - refusal_inventory: 38 -> 37, every proven refusal still names a test. - stream.rs: the refusal gate becomes the two-arm witness a_real_aomenc_12bit_compound_inter_sequence_decodes_pixel_exact -- default recipe (15 compound blocks, 1 diffwtd) and --enable-dist-wtd-comp=0 (18 compound, 6 diffwtd), both byte-exact vs ffmpeg on every plane, hard-asserting compound/masked/diffwtd counters. - fixtures: av112bit-compound.obu (a839cff5...), av112bit-compound-masked.obu (83625de2...), re-encode cmp clean, dump_yuv == ffmpeg whole-stream on all 6 frames. - warp, grain, screen content stay refused by name; the parent's 12-bit key and single-ref inter witnesses and both 10-bit film gates stay exact. Wedge-masked compound at 12 bits recorded as an open half (unwitnessed; same blend function, bit-depth-free mask codebook).
lane-av112bit: lift the 12-bit gate to the witnessed setAhmet Kaan Gümüş · 0531387
lane-av112bit: lift the 12-bit gate to the witnessed set
The blanket bit-depth-12 refusal (hdr report section 4.2) becomes four
named refusals, each pinned by a real aomenc --bit-depth=12 stream:
warp, compound inter blocks, film grain, and screen content tools
(palette/intrabc). Everything else 12-bit is lifted behind two
byte-exact-vs-ffmpeg witnesses: a key frame and a key+inter sequence
with sub-pixel motion, CDEF and loop restoration ON (cdef_idx and
Wiener/SGR unit counters hard-asserted; a new MC_SUBPEL_HITS counter
proves the frame's own round_0/round_1 ran).
The rounding rule is libaom convolve.h:81..86 verbatim: round_0 +=
bd - 10, non-compound round_1 -= bd - 10 (mc.rs round_pair, threaded
through scalar and SIMD passes, the identity fast paths, the scaled
walk, and the compound combines' post-rounds; the Wiener pair likewise).
Wiener's intermediate clamp keeps the corpus-proven constant structure
- the exact per-sample C transform moved the 10-bit 128-sb film gate
and is recorded as the lane's open half in lanes/av112bit.report.md.
8/10-bit regression: the three 10-bit film fixture gates, the 10-bit
key/inter/grain gates and 8-bit spot arms all green; refusal_inventory
and gate_coverage updated and green. Fixtures av112bit-{key,inter}.obu
committed with sha256 provenance in the report.2026-09-08
instrument(av1): a LAST2 SAD census and a frame-level interpolation filter knobAhmet Kaan Gümüş · 012b9fc
instrument(av1): a LAST2 SAD census and a frame-level interpolation filter knob The census answers whether a second retained past reference is worth its slot bookkeeping and its second motion search before either is built; the filter knob makes the frame's kernel reach the search, the trials and the trial decode through FrameCtx instead of a hardwired Regular in mc::predict.
2026-09-06
perf(av1): the filter stage's capture decode replaced by one more filter replayAhmet Kaan Gümüş · 2d19659
perf(av1): the filter stage's capture decode replaced by one more filter replay The stage decoded the coded tile a SECOND time after the search -- 10% of a 4K frame's encode -- only to reach the post-CDEF plane the loop restoration search reads and the picture the stage splices back. Both come out of one more replay of the winning deblock/CDEF parameters on the pre-filter planes the search already captured: the same two kernels, on the same input, in the same order. The re-coded tile still carries the cdef_idx literals, which the replay is handed directly. Also gates the per-trial stage timers on par::stage_times: two Instant::now() ran per transform trial and per mc::predict call in every cfg(test) build whether or not anyone read the breakdown.
2026-09-05
perf(av1): route every gate counter through hit!/hit_do! behind a default-on gate-counters featureAhmet Kaan Gümüş · 04187f1Browse files
perf(av1): the compound vertical pass runs the whole block per callAhmet Kaan Gümüş · f2203de
perf(av1): the compound vertical pass runs the whole block per call vpass_row takes the block's row count too, and the compound kernel accumulates straight into its i32 destination and rounds it in one sweep, dropping the per-row accumulator round trip along with the per-row tap setup. Byte-exact: all four gate streams hash to their references.
perf(av1): the vertical pass sets its taps up once per block, not once per rowAhmet Kaan Gümüş · 3702d63
perf(av1): the vertical pass sets its taps up once per block, not once per row vpass_row_u16 and its AVX2/SSE4.1 kernels take the block's row count, so the tap pairs, the rounding vector and the clamp vector are built once per predict call. Byte-exact: all four gate streams hash to their references.
perf(av1): the horizontal pass sets its taps up once per block, not once per rowAhmet Kaan Gümüş · e27ea46
perf(av1): the horizontal pass sets its taps up once per block, not once per row hpass_avx2/hpass_sse2 take the block's row count and source stride, so the tap broadcast, the rounding vector and the SIMD dispatch happen once per predict call instead of once for each of the block_h+7 rows. Byte-exact: all four gate streams hash to their references.
perf(av1): MC hoists the interior row test and fuses whole-pel-horizontal blocks onto the referenceAhmet Kaan Gümüş · 37ae497
perf(av1): MC hoists the interior row test and fuses whole-pel-horizontal blocks onto the reference The unscaled horizontal pass tested the vertical clamp, the interior window, the slice bounds, the tap narrowing and the SIMD level once per row; when the whole footprint is inside the reference -- the common case -- every one of those has the same answer for all rows, so the test is hoisted and the loop is a walk of the stride. A whole-pel horizontal position makes the horizontal pass the identity tap, whose intermediate is exactly `s << 4`, so the vertical pass is the same 8-tap sum taken straight off the reference rows with the taps scaled by 16. Both the single and the compound kernel now take that path for interior blocks, which drops the intermediate entirely; the vertical kernels gained a source-stride parameter to read it. Byte-exact: all four gate streams hash to their references.
perf(av1): constant-length row copies on the whole-pel inter pathAhmet Kaan Gümüş · 3a35e5f
perf(av1): constant-length row copies on the whole-pel inter path A whole-pel prediction is a clamped copy, and its per-row `copy_from_slice` compiled to a `memcpy` call with a runtime length -- for the 8-sample row of an 8x8 block (the most common inter shape on real 4K content) the call costs more than the move it makes. The three common widths get a constant length, which inlines. -0.11% instructions on the 4K segment (523.67 -> 523.07 G at one thread), -5.4% cumulative; all twelve gate hashes unchanged.
perf(av1): fuse the inter vertical pass's rounding into its kernelAhmet Kaan Gümüş · 209d003
perf(av1): fuse the inter vertical pass's rounding into its kernel The vertical pass stored a row of unrounded `i32` sums to a scratch buffer that the very next loop read back to round, clamp and narrow to the block's `u16` samples. The sums never need to reach memory: `packus_epi32` IS the clamp's lower half (a negative sum saturates to zero) and `min_epu16` its upper, so `round2(sum, InterRound1).clamp(0, max)` is two instructions on the register the taps were accumulated in. `vpass_row` keeps its unrounded form for the compound intermediate and for restoration's wiener pass, whose roundings differ. -1.7% instructions on the 4K segment (532.7 -> 523.7 G at one thread), -5.3% cumulative for the lane; all four gate hashes unchanged.
perf(av1): 16-bit motion-compensation intermediate, vertical pass on maddAhmet Kaan Gümüş · ad664df
perf(av1): 16-bit motion-compensation intermediate, vertical pass on madd The separable inter filter kept its horizontal output in `i32`, so the vertical pass spent one `mullo_epi32` per tap per 8 columns and moved twice the bytes it had to. The intermediate provably fits `i16` at the bit depths this decoder accepts -- a phase's positive taps sum to at most 156, so `Round2(1023 * 156, 3)` is 19948, and 12-bit (where `InterRound0` itself changes) is refused in stream.rs. With the buffer narrowed, a row PAIR interleaved by `unpack_epi16` is exactly `madd_epi16`'s shape: two taps of 16 columns per instruction. The horizontal kernels store through `packs_epi32`, whose saturation is unreachable on a motion-compensation path (the new `horizontal_intermediate_fits_i16` enumerates every filter kind, table and phase to prove it) and composes with the wiener clamp on the restoration path, whose bounds are inside `i16` at 8- and 10-bit. -3.7% instructions on the 4K segment (553.2 -> 532.7 G at one thread); all four gate hashes unchanged.
2026-09-04
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.
refactor(av1): FrameCtx stays crate-private -- public signatures back to what they wereAhmet Kaan Gümüş · 1c71b70
refactor(av1): FrameCtx stays crate-private -- public signatures back to what they were The FrameCtx refactor threaded `&crate::decode::FrameCtx` through 21 `pub fn` signatures, which put a `pub(crate)` type in the crate's public API: external callers of `Av1Encoder::encode` stopped compiling (tools/ec-bench). `Av1Encoder` now owns its `FrameCtx` -- one per stream, not per frame, since the inter-frame inheritance guards carry state across frames -- so `encode` takes `(&mut self, picture)` again. `encode_key_frame`, `encode_key_frame_with_modes` and `encode_sequence` keep their old public signatures as wrappers over `pub(crate) *_with_ctx` inners that make the context. The other 14 helpers that gained the parameter (intra/mc/warp/motion predictors, `decode_key_frame_tile`) have no caller outside the crate and become `pub(crate)`. `Av1Encoder` is still `Send` (compile-time assert), but owning cells makes it `!Sync`; nothing in the workspace shares one by reference.
refactor(av1): the 38 per-frame decode-state thread_locals become one FrameCtxAhmet Kaan Gümüş · b9a9498
refactor(av1): the 38 per-frame decode-state thread_locals become one FrameCtx Every per-frame/per-stream decode state in ec-av1 lived in a thread_local! static, so a decode was a function of the calling THREAD's history rather than of the bitstream, and a worker thread saw empty state -- the blocker for frame-parallel decoding. All 38 (SB128, BIT_DEPTH, SUPERRES, CDEF_*, DELTA_Q_*/DELTA_LF_*, CURRENT_Q_IDX, QUANT_DELTAS, the 9 SEG* maps, TX_SELECT_INTER, REDUCED_TX_SET_INTER, ENABLE_FILTER_INTRA_INTER, PALETTE_PRED, INTRABC_*, LUMA_TX_TYPE, INTRA_IN_INTER_MODE, INTER_STRIP_CHROMA, INTER_LAST_MC, ENABLE_EDGE_FILTER, LAST_FRAME_WIDE_MARGIN, REACH_SB_PX, GRAIN_BIT_DEPTH) are now fields of decode::FrameCtx, owned by decode_stream_with and threaded as `fctx: &FrameCtx` down the decode call graph (~1200 call sites). The fields keep the Cell/RefCell interior mutability the statics had, so every read/write site is byte-identical and this is a pure ownership move; Cell/RefCell also make FrameCtx !Sync on purpose -- one context per decoding thread, never shared. The scratch pools, gate hit counters and trace switches stay thread_local by design.
perf(av1): Wiener restoration runs on the motion-compensation kernelsAhmet Kaan Gümüş · 91d30fe
perf(av1): Wiener restoration runs on the motion-compensation kernels `apply_loop_restoration_plane` was 6.3% of a 4K decode's self time, and Wiener owns most of it: on the two 4K probe inputs Wiener units cover 82% and 95% of all restored pixels (instrumented, then reverted). Its two passes ARE `mc.rs`'s: a 7-tap `i16` convolution over contiguous samples rounded by `Round2(_, 3) == INTER_ROUND_0`, then a 7-tap `i32` one rounded by `Round2(_, 11) == INTER_ROUND_1`. Zeroing an eighth tap makes both `mc::hpass_contig`/`mc::vpass_row` calls exactly -- so this reuses those AVX2/SSE kernels rather than growing a third copy of the same convolution. That also removes the horizontal pass's real cost: it called `lr_sample` (stripe-boundary substitution plus a column clamp) once per tap, seven times per output. Which buffer and row a sample comes from depends only on the row, so `lr_sample` is now that resolution (`lr_src_row`) plus its clamp, and the pass resolves it once per row and convolves straight over the plane -- only a unit touching the plane's left or right edge still copies through the clamp. 4K decode 40.6 s -> 35.7 s and the LR-heavy 4K input 40.1 s -> 34.1 s (interleaved medians of 3 against this lane's base), byte-exact on all four probe inputs.
perf(av1): AVX2 luma film-grain rowAhmet Kaan Gümüş · a620a4d
perf(av1): AVX2 luma film-grain row `add_noise_to_block` was 7% of a 1080p decode's self time, and its luma arm is the larger half: one scaling-LUT read, one multiply, a `Round2` and a clip per sample. AVX2 does eight at a time -- the LUT read is a `vpgatherdd`, the rest is the same i32 arithmetic -- and every other CPU runs the scalar loop, which stays the reference. The gather index is clamped to the LUT's last entry so the load cannot leave the table; the scalar form indexes unclamped (it would panic), and the LUT spans the whole sample range the grain bit depth allows, so the two agree wherever the scalar one does not panic. Pinned against the scalar row over 8/10/12-bit sample and LUT ranges, every `grain_scaling_minus_8` shift, restricted and full clip ranges, and row lengths covering the 8-lane body plus every tail. Interleaved medians, 1080p: 10.51 s -> 10.40 s (11.01 s at the lane's base). Byte-exact on all three probe inputs.
perf(av1): explicit SIMD for both motion-compensation passesAhmet Kaan Gümüş · 66498f4
perf(av1): explicit SIMD for both motion-compensation passes The two separable-filter inner loops were 18.7% of a 1080p decode's self time after lane-perf4 (`vpass_row` 10.4%, `horizontal_pass_unscaled` 8.3%). Both are now hand-vectorised with `std::arch::x86_64` intrinsics behind a level detected once per process (`OnceLock`): AVX2 where the CPU has it, SSE4.1 otherwise, and the existing scalar loops everywhere else -- they stay the reference implementation, not a dead fallback. The horizontal pass's `_mm*_madd_epi16` sums two taps of one output per lane, so even and odd output columns accumulate separately and are interleaved back into order (`unpack` + `permute2x128`); 16 outputs per AVX2 iteration, 8 per SSE2 one, a 4-column tail scalar. The vertical pass stays i32 (`mullo_epi32` + `add_epi32`), as 12-bit needs. Rounding is unchanged in both: the same `Round2` add-then-arithmetic-shift. This is why the crate is now `deny(unsafe_code)` rather than `forbid`: intrinsics are unsafe by signature. The exception is confined to `mc`'s `simd` module and its two dispatch sites, each with its own `#[allow(unsafe_code)]` and documented in the crate header, and every kernel is pinned lane-for-lane against the scalar function it replaces over all widths, all 16 phases, both tables of all four filter kinds and the 8/10/12-bit ranges. Interleaved medians, 1080p: 11.07 s -> 10.51 s (horizontal pass alone was 11.37 -> 11.24; the vertical pass is where the win is). 4K 57.59 -> 57.12. Byte-exact on all three probe inputs.
feat(av1): all three scaled-reference (superres) refusals lifted -- 8x8 leaf, sub-8x8, warpAhmet Kaan Gümüş · 421ae92
feat(av1): all three scaled-reference (superres) refusals lifted -- 8x8 leaf, sub-8x8, warp
The 8x8-leaf guard's own comment blamed a below-8x8 desync ("a 4th symbol
out of a 3-symbol alphabet"). That premise was stale: deleting the guard
decodes the pinned --superres-denominator=12 stream straight through to the
NEXT refusal. One wrong alphabet was behind all three.
Root cause (class wrong-alphabet-same-value / branch-dropped-as-unreachable):
decode_inter_block8 read the 3-symbol motion_mode row under a SCALED
reference, where libaom motion_mode_allowed makes WARPED_CAUSAL eligible
only if (num_proj_ref >= 1 && (allow_warped_motion && !av1_is_scaled(sf))) --
so the alphabet shrinks to the 2-symbol obmc one (with OBMC off, no symbol
at all). The 16x16+ path already had `&& !ref_is_scaled`; the leaf's own
comment asked whoever lifted the refusal to add it, and nobody could reach
the code to notice. First-bad without it: 96x96 denom-12 warped stream,
decode-order frame 3, luma (15,54), 7652 samples wrong, max 155.
Lifted, each byte-exact vs ffmpeg with its own hit counter:
* "an 8x8 partition leaf under a scaled reference"
* "a sub-8x8 inter block under a scaled reference" (both sub8 readers)
* "warp prediction with a scaled reference" -- its translational fallback
was already implemented and the refusal sat in FRONT of it (class
refusal-short-circuits-its-own-code); the r1 mismatch that kept it alive
was the strip chroma piece below, not the fallback.
Same-shape sweep of "every caller that computes a scaled start position":
* mc::predict_maybe_scaled -- the one dispatch the sub-8x8 luma/chroma
callers now share instead of hardcoding the unscaled walk.
* the 16x4/4x16 strip's sub-8x8 chroma piece was SKIPPED entirely under a
scaled reference (silent wrong pixels, no refusal); it now rebuilds from
the PREVIOUS strip's own reference and that reference's own scale factor.
* allow_warp's scale bail-out was missing at the 8x8-leaf single-ref warp
and at both compound warp sites (PER SLOT: one tap can be scaled while
its sibling still warps).
Gate: real_superres_streams_with_sub8_leaf8_and_warp_decode_pixel_exact --
two 96x96 denom-12 streams, every unrelated tool off, pixel-exact vs ffmpeg;
arm A hard-asserts scaled leaf8 + sub8 hits, arm B asserts a WARPED_CAUSAL
eligibility was suppressed by scale. The r27 census now asserts none of the
three strings can come back. Inventory rows removed.perf(av1): whole-pel axes skip the pass they do not needAhmet Kaan Gümüş · c8bf4a0
perf(av1): whole-pel axes skip the pass they do not need A motion vector with a whole-pel component still ran the full two-pass filter. Fraction 0 is the identity tap, so each axis has an exact shortcut: Round2(128 * s, InterRound0) == 16 * s horizontally, and vertically Round2(128 * a, InterRound1) == Round2(a, InterRound1 - 7) (== a for the compound round), which also means the 3 rows above and 4 below the block never have to be filtered -- a 4-tall chroma block drops from 11 horizontal rows to 4. Byte-exact: 1080p 10-bit and 2160p HDR EC_PROBE_OUT16 dumps both cmp identical to the pre-lane binary. Interleaved medians on the 1080p segment, 6 pairs against the previous commit: 19.08 s -> 17.42 s (faster in 5 of 6).
perf(av1): horizontal MC taps multiply at 16 bitsAhmet Kaan Gümüş · dcac6b3
perf(av1): horizontal MC taps multiply at 16 bits The interior horizontal row had auto-vectorised, but into pmuludq/pshufd chains: an i32 x i32 lane multiply is three instructions on SSE2. A tap is |x| <= 128 and a sample is bounded by the bit depth (<= 4095 at 12-bit), so narrowing both factors to i16 before the widening multiply gives exactly the same products and one instruction per pair. Byte-exact: 1080p 10-bit and 2160p HDR EC_PROBE_OUT16 dumps both cmp identical to the pre-lane binary. Interleaved medians on the 1080p segment: 22.25 s base -> 16.64 s.
perf(av1): unscaled compound MC leaves the scaled walkAhmet Kaan Gümüş · 8c7cbe4
perf(av1): unscaled compound MC leaves the scaled walk horizontal_scaled_pass was 14% of decode self time, and almost none of that was scaling: every compound prediction routed through it whatever the reference's scale, so an unscaled block paid a per-column integer-position derivation, a per-column filter-phase lookup, a column-major read of the reference and a per-tap clamp. At REF_NO_SCALE that walk reduces algebraically to the fixed x0/xfrac split (pos_x_q10 == x_q4 * 64 + 32 makes int_pel == x_q4 / 16 and (x_qn & 1023) >> 6 == x_q4 % 16 for every column), so a new horizontal_pass router sends it to the contiguous unscaled pass and leaves the general walk for superres. Both vertical passes now accumulate tap-major over contiguous slices and reuse the thread-local scratch, as the single-reference one does. Byte-exact: 1080p 10-bit (299 frames) and 2160p HDR EC_PROBE_OUT16 dumps both cmp identical to the pre-lane binary. Interleaved medians on the 1080p segment: 23.39 s base -> 18.21 s (12.8 -> 16.4 fps).
perf(av1): unscaled MC does one contiguous horizontal pass, no per-call allocAhmet Kaan Gümüş · 62f159c
perf(av1): unscaled MC does one contiguous horizontal pass, no per-call alloc predict_with_filters_kern spent 17% of decode self time in a doubly nested per-sample loop: every tap re-read the filter table, every sample went through the Clip3 edge helper, and each call allocated its own (h+7)-row intermediate. Restructured dav1d style, keeping the rounding chain untouched: taps are fetched once into a [i32; 8]; a row whose whole 8-tap footprint is inside the reference's true extent is one contiguous slice walked with windows(8) (the clamped form stays for edge rows and is what a past-the-edge motion vector still takes); the vertical pass accumulates tap-major over two contiguous i32 slices and skips the zero taps the 4-tap kernels carry; the whole-pel case copies a row at a time. The intermediate is a thread-local scratch buffer instead of a per-call Vec. Byte-exact: EC_PROBE_OUT16 dumps of a 299-frame 1080p 10-bit segment and a 4 s 2160p HDR segment both cmp identical to the pre-change binary. Interleaved medians on the 1080p segment: 22.61 s -> 20.66 s.
perf(av1): read every EC_* debug flag once instead of per blockAhmet Kaan Gümüş · ba458d2
perf(av1): read every EC_* debug flag once instead of per block `std::env::var*` is a getenv + strlen + CStr validation on every call, and this crate reads its trace flags from per-block, per-TU and per-MC-call paths -- 11.6% of a 1080p10 decode's self time went to that, with the two worst sites inside the motion-compensation kernels themselves. Nothing in the crate or its tests calls `set_var`, so each name is a process constant. New `envflags` module: `env_flag!(NAME)` keeps one `LazyLock<bool>` per CALL SITE (atomic load after the first call, no hashing), `envflags::var` serves the value sites from a single snapshot of the environment. Semantics are unchanged at every site -- `is_some()`, `is_none()` and the `Result<String, VarError>` shape are preserved -- and the decoder's output is byte-identical. 160 sites in decode.rs, 2 in mc.rs. Header/tool-lookup sites that run once per stream are left alone. 1080p10 299-frame segment, interleaved medians of 3: 24.47 s -> 22.03 s (12.2 -> 13.6 fps), output byte-exact. (cherry picked from commit 318e0cce54fe7697a2d23c02d3b0d385f0e1401a)
2026-09-02
Merge branch 'lane-mc64' (2be1f92): pinned 192x128 stream with a 64x64 intra block in an inter frameAhmet Kaan Gümüş · 361f8be
Merge branch 'lane-mc64' (2be1f92): pinned 192x128 stream with a 64x64 intra block in an inter frame Adds crates/ec-av1/fixtures/av1_192x128_8bit_intra64_in_inter.obu and its gate, plus the EC_MC_TRACE rung. Conflicts: kept main's per-var dump_stage_idx over the lane's single-counter stage_dump_idx, and main's sub-8x8 strip chroma footprint (the lane branched before it) with the lane's MC trace line. Gates: pinned_rect_stream (1), refusal_inventory (3), gate_coverage (9), base_ctx_rect_offsets (1) -- 14 passed, 0 failed.
fix(av1): rect inter blocks picked the 4-tap chroma kernel from the square prediction buffer, not the blockAhmet Kaan Gümüş · 759e688
fix(av1): rect inter blocks picked the 4-tap chroma kernel from the square prediction buffer, not the block decode_inter_block predicts a rectangular block over its enclosing square buffer (side x side, chroma_side x chroma_side; write_w/write_h govern only the pixel write). The narrow-block decision lived in mc::predict_with_filters and read that buffer's dimensions, while libaom av1_get_interp_filter_params_with_block_size takes it per axis from the prediction block's own w/h -- so the chroma of an 8x16 / 16x8 inter block (4x8 / 8x4) used the 8-tap kernel where libaom uses the 4-tap one. Luma is never <= 4 wide on this path, which is why such streams decoded luma-exact and differed by +-1 on scattered chroma samples (lane-interedge r1's 192x128 control, no frame-edge node, cdef/LR off). mc gains predict_with_filters_kern / predict_scaled_kern / predict_compound_intermediate_kern (old entry points delegate with kern = block dims) plus a RECT_NARROW_KERN_HITS counter; decode_inter_block's 12 prediction calls pass write_w/write_h and write_chroma_w/write_chroma_h. New gate a_real_aomenc_rect_inter_block_predicts_chroma_with_the_narrow_kernel_pixel_exact: real aomenc mandelbrot 192x128 and 128x192, 8- and 10-bit, cq 20/32/45, 6 frames, lag-in-frames=0, every decode-order frame compared on Y, U and V; 12/12 arms exact, narrow-kernel counter nonzero at both depths and in both orientations. Same recipe mismatched chroma in all arms before the fix.
fix(av1): per-frame stage dumps + MC trace, and re-localise the 192x128 frame-2 mismatch to a 64x64 INTRA blockAhmet Kaan Gümüş · f866759
fix(av1): per-frame stage dumps + MC trace, and re-localise the 192x128 frame-2 mismatch to a 64x64 INTRA block EC_AV1_POSTDEBLOCK_DUMP/EC_AV1_POSTCDEF_DUMP wrote .f0 for every frame, so any per-frame filter-stage bisection silently compared the last decoded frame; they are now keyed on the decode-order picture index like the prefilt dump. EC_MC_TRACE prints every mc::predict_with_filters / predict_compound_intermediate / warp_affine call with its q4 position, block size, subpel fractions and kernels, placed before the whole-pel fast path, plus EC_IB at decode_inter_block entry and is_inter/skip on EC_MODE -- an absent MC call is now visible. With that: the 192x128 8-bit stream's frame-2 luma-only mismatch at px(128,64) is a 64x64 PARTITION_NONE INTRA block in an inter frame, not the inter NEWMV block the charter described (that mv belongs to frame 1's split superblock, which is exact). Zero MC calls for the block in either decoder; chroma bit-exact, so the 64-length luma transform is the suspect. Stream pinned as a fixture because its aomenc recipe does not reproduce it.
2026-09-01
fix(av1): a prediction block 4 or fewer samples wide reads the REGULAR narrow subpel kernel under EIGHTTAP_SHARP too -- spec 7.11.3.4 filterIdx sends EIGHTTAP and EIGHTTAP_SHARP to filter index 4, and libaom's av1_interp_4tap[MULTITAP_SHARP] is av1_sub_pel_filters_4 (filter.h:239-244, comment "For w<=4, MULTITAP_SHARP is the same as EIGHTTAP_REGULAR"); we used the 8-tap sharp table there, invisible above 4 samples so it only bit 4-wide chroma. Cherry-picked from lane-gmaffine 3bb10f1; unit test pins all four narrow mappings (regular->4, smooth->4smooth, sharp->4, bilinear->bilinear).Ahmet Kaan Gümüş · 53b4e56
fix(av1): a prediction block 4 or fewer samples wide reads the REGULAR narrow subpel kernel under EIGHTTAP_SHARP too -- spec 7.11.3.4 filterIdx sends EIGHTTAP and EIGHTTAP_SHARP to filter index 4, and libaom's av1_interp_4tap[MULTITAP_SHARP] is av1_sub_pel_filters_4 (filter.h:239-244, comment "For w<=4, MULTITAP_SHARP is the same as EIGHTTAP_REGULAR"); we used the 8-tap sharp table there, invisible above 4 samples so it only bit 4-wide chroma. Cherry-picked from lane-gmaffine 3bb10f1; unit test pins all four narrow mappings (regular->4, smooth->4smooth, sharp->4, bilinear->bilinear).
Merge branch 'lane-scaledref': compound/OBMC/interintra under scaled references; WARPED_CAUSAL alphabet dropped when the ref is scaled (was silent wrong pixels); one-sided chroma OBMC for 8x8 luma; EC_PROBE_OUT (verifier PASS, 268/0/23)Ahmet Kaan Gümüş · ea8bda8Browse files
fix(av1): combine_compound folded two shifts libaom keeps separateAhmet Kaan Gümüş · cc39f29
fix(av1): combine_compound folded two shifts libaom keeps separate libaom's `av1_highbd_dist_wtd_convolve_2d_c` (and its lowbd twin) applies a TRUNCATING `>> DIST_PRECISION_BITS` to the weighted sum and only then `ROUND_POWER_OF_TWO(.., round_bits)`. We folded both into `Round2(sum, 8)`, which rounds one LSB high whenever `(sum >> 4) + 8` is one below a multiple of 16 and the dropped low 4 bits are non-zero. Bit-depth independent (the CONV_BUF round_offset cancels exactly in this crate's unbiased intermediate domain), so it is a rare off-by-one at any depth -- raised by lane-cwarp's measurement that 10-bit compound still mismatches frame 1 luma while single-reference 10-bit is 6/6 exact. Unverified against that fixture. cargo test -p ec-av1 --lib -j3 compound: 16 passed, 0 failed, 73.58s (includes the real-aomenc 8-bit compound and masked-compound gates).
fix(av1): 10-bit loop restoration, diffwtd mask and warp all ran with 8-bit constantsAhmet Kaan Gümüş · 42752a0
fix(av1): 10-bit loop restoration, diffwtd mask and warp all ran with 8-bit constants lane-hbdinter r1. The charter's premise (a 10-bit inter frame 2 mismatch) did NOT reproduce with the tool-restricted inter recipe; widening the recipe to real loop restoration did, and the defect turned out to be bit-depth-wide, not inter-specific -- it fires on the KEY frame too, and lane-hbd's 10-bit gate simply had `--enable-restoration=0`. Four sites carried hardcoded 8-bit constants, all checked against the oracle source (~/.cache/aom-oracle/src): - restoration.rs `compute_ab`: libaom `restoration.c:660-662` scales the box sums back to the 8-bit range before forming `p` (`a = Round2(A, 2*(bd-8))`, `b = Round2(B, bd-8)`; `B[k]` keeps the raw sum). We never did -> wrong `z`, wrong blend factor at 10-bit. This is the site the gate attributes the mismatch to (ablation below). - restoration.rs `apply_wiener_stripe`: the horizontal intermediate was clamped to a fixed `[0, 8191]`, i.e. `WIENER_CLAMP_LIMIT(3, bd=8) - 1` (`convolve.h:43`), in this crate's *unbiased* domain. Correct bounds are the libaom limit shifted down by its `1 << (bd + 3)` bias. At 8-bit neither end is reachable (which is why every 8-bit gate passed); at 10-bit the top of the range is 16368, so most Wiener intermediates were truncated. - mc.rs `diffwtd_mask`: libaom `reconinter.c:307` rounds the CONV_BUF difference by `INTER_POST_ROUND + (bd - 8)`; we used the constant 4. - warp.rs `warp_affine`: `const BD: i32 = 8` fed both offset terms and the final `sum - (1<<(bd-1)) - (1<<bd)` (tip from lane-gmaffine, confirmed against `av1_warp_affine_c`). Non-compound sub-pel MC needs no change: libaom only shifts round_0/round_1 when `bd + FILTER_BITS - round_0 + 2 > 16` (`convolve.h:83`), which is 12-bit only -- 10-bit keeps 3/11 and 3/7. Gate: `a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact` (stream.rs) -- real aomenc yuv420p10le, 128x64, 16 frames, forward P frames, deblock + loop restoration on, hard-asserting the new `mc::inter_pred_hits` counter, `deblock_hits`, and a non-RESTORE_NONE LR filter, comparing all 16 frames against ffmpeg's own 10-bit decode. Green with the fix; reverting only the `compute_ab` scaling turns it red at frame 0 (V plane, sample 52: ours 289, ffmpeg 288). cargo test -p ec-av1 --lib: 268 passed, 0 failed, 23 ignored (664s).
2026-08-30
Merge branch 'main' into lane-superresAhmet Kaan Gümüş · 17c9a9c
Merge branch 'main' into lane-superres Resolves the scaled-MC conflict in decode.rs in favour of the lane's structure, and widens predict_scaled to u16 for main's high-bit-depth sample type (fixture included). Lane state after the merge: 264 passed, 1 failed -- the lane's own gate a_real_aomenc_key_and_inter_superres_sequence_decodes_pixel_exact. That is the lane's deliverable, not merge fallout, so this does not go to main yet.
feat(av1): u16 widen compiles clean, 263/263 tests pass, 8-bit output bit-exactAhmet Kaan Gümüş · 35100f3
feat(av1): u16 widen compiles clean, 263/263 tests pass, 8-bit output bit-exact Closes the 42-error checkpoint from r1's saved diff. decode.rs/warp.rs/mc.rs call sites widened through OBMC and interintra blend chains; encode.rs and motion.rs's own buffers stay u8 (encoder is 8-bit only this round) with a local u16 round-trip box (intra_predict_u8 in encode.rs, inline conversion in mc_trial and motion::search_traced_from_step) at their 4 call sites into the now-widened intra::predict/mc::predict. bit_depth != 8 refusal untouched, no 10-bit gate added.
wip(hbd): r1's u16 widen in flight at the cap (does not compile; error count is the progress metric)Ahmet Kaan Gümüş · 31976a1Browse files
wip(superres): builder's in-flight edits, committed verbatim at the 75-turn cap (state unverified by me)Ahmet Kaan Gümüş · ddad1b5Browse files
feat(av1): mc::predict_scaled + frame_width threaded through decode_inter_blockAhmet Kaan Gümüş · bc2ef3d
feat(av1): mc::predict_scaled + frame_width threaded through decode_inter_block mc::predict_scaled/scale_factor/REF_NO_SCALE per r8's derived spec 7.11.3.3 algorithm (horizontal-only scaled sampling grid, vertical pass untouched); pinned at REF_NO_SCALE reproducing predict_with_filters bit-exact for every subpel fraction and block width 4/8/16. decode_inter_block gains a frame_width: usize parameter (18 call sites end allow_screen_content_tools, one test call site ends false,), not yet consumed -- prediction and refusal wiring is next.
2026-08-28
feat(av1): port the DIFFWTD masked-compound blend (comp_group_idx==1), wedge still refusedAhmet Kaan Gümüş · ddb5bef
feat(av1): port the DIFFWTD masked-compound blend (comp_group_idx==1), wedge still refused diffwtd_mask/blend_masked_compound in mc.rs, algebraically re-derived onto this crate's unbiased predict_compound_intermediate domain (libaom's round_offset bias cancels exactly in both the mask diff and the blend weight sum, proven in the doc comments -- no offset bookkeeping needed). Both comp_group_idx==1 decode.rs sites now build+apply the real blend for COMPOUND_DIFFWTD; COMPOUND_WEDGE still refuses by name (wedge codebook out of r2 scope per the charter's mergeable-partial fallback). Fixed a real latent bug while wiring this in: compound_idx was read unconditionally, missing libaom's comp_group_idx==0 outer gate (dead code before this round since the masked path always errored earlier). Gate a_real_aomenc_stream_with_masked_compound_decodes_pixel_exact flipped to hard assert (masked_compound_hits() > 0) with DIFFWTD refusals now forbidden; hammered 8/8 green, zero pixel mismatches. Full ec-av1 lib suite: 220 passed, 0 failed, 17 ignored.
feat(av1): compound CONV_BUF blend + distance-weight assign, not wired yetAhmet Kaan Gümüş · 181a784
feat(av1): compound CONV_BUF blend + distance-weight assign, not wired yet mc.rs: predict_compound_intermediate (round_1=7, no clip, mirrors libaom's COMPOUND_ROUND1_BITS path) and combine_compound (spec 7.11.3.15 weighted average, shift = InterPostRound + DIST_PRECISION_BITS) -- pinned against a whole-pel identity case that round-trips exactly through both stages. compound.rs (new): dist_wtd_comp_weight_assign, a pure port of libaom's av1_dist_wtd_comp_weight_assign (quant_dist_weight/quant_dist_lookup_table search), tested standalone against hand-worked order-hint cases. Neither is wired into decode.rs yet -- comp_group_idx/compound_idx reads, Neighbours compound_idx tracking, and the reconstruction call sites are still open (see HANDOFF).
2026-08-27
feat(av1): interpolation filters beyond REGULAR, incl. per-block SWITCHABLEAhmet Kaan Gümüş · 10f24e6
feat(av1): interpolation filters beyond REGULAR, incl. per-block SWITCHABLE The ~13% decodes-but-wrong inter flake was a whole missing filter family: motion compensation always used the REGULAR subpel tables, while real encoders pick SMOOTH/SHARP per frame -- or SWITCHABLE, reading a per-block filter symbol pair this decoder never read (the silently-unread class again; our own encoder writes one fixed filter). All four table sets land in mc.rs with an aomdec-pinned unit test, the switchable_interp CDFs and neighbour context follow libaom's read_mb_interp_filter, and the filter threads from the frame header through both inter block paths. The forwarding gate ran 10/10 with zero pixel mismatches and no vacuous skips.
fix(av1): filter-intra was already correct -- gate against a real aomenc streamAhmet Kaan Gümüş · 2adf290
fix(av1): filter-intra was already correct -- gate against a real aomenc stream The straddling-boundary mismatch against ffmpeg's decode was never the filter-intra predictor: it's a real AV1 deblocking-filter artifact, and this decoder has no in-loop deblocking at all. `--loopfilter-control=0` on the aomenc fixture makes the two decodes byte-exact with zero source changes to intra.rs/decode.rs's prediction math. Adds a permanent gate (crates/ec-av1/src/stream.rs) that shells out to a real standalone aomenc build (ffmpeg's own libaom-av1 wrapper on this box doesn't expose enable-tx-size-search/loopfilter-control through -aom-params), asserts the use_filter_intra symbol actually fired via a new process-global counter (decode::filter_intra_hits), and checks pixel-exact luma/U/V against ffmpeg's own decode of the identical bytes. The encoder's screen-content-tools decision is a real internal PSNR trial, occasionally flips even with palette/intrabc off; the test skips (not fails) the still-unsupported-gap runs the same way the existing CDEF gate test does.
fix(av1): 4-tap subpel filters for blocks 4 wide or tallAhmet Kaan Gümüş · aad8b59
fix(av1): 4-tap subpel filters for blocks 4 wide or tall Spec 7.11.3.4 selects the filter table per axis: an output dimension of 4 or less reads Subpel_Filters' narrow counterpart (av1_sub_pel_filters_4), whose outer two taps on each side are zero. We fed every block the 8-tap table, so 4:2:0 chroma under an 8x8 luma leaf -- the common chroma shape, not a corner -- reached 3 samples past its edge with nonzero weights and came out +-1 against the reference decoder wherever the extra taps mattered. Found by diffing libaom's dec_calc_subpel_params against ours: the phase matched, the tap table did not. Closes the 640x360 inter straddle sequence's frame-2 U-plane desync; the whole sequence now round-trips through ffmpeg pixel-exact.
perf(av1): bypass sub-pel filtering for whole-pel motion predictionAhmet Kaan Gümüş · ef383d9
perf(av1): bypass sub-pel filtering for whole-pel motion prediction Profiled the inter path (stage_timing_breakdown_inter, 720p GOP): 403 of a 408ms motion-search bucket was crate::mc::predict, almost entirely from the search's own whole-pel log/diamond stage. SUBPEL_FILTERS[0] is the identity tap and both rounding shifts are exactly that filter's gain, so the two 8-tap passes reproduce the reference sample byte-for-byte at zero fraction (integer_mv_is_identity already pinned this) -- a clamped direct copy is bit-identical, not an approximation. Motion search bucket 408.55ms -> 181.85ms, frame total 818.88ms -> 585.24ms, same 997 output bytes.
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%).
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
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).