Commits
Commits on
f44b4582d6385a443312e64a368e59f1d7c19f13Filtered to crates/ec-av1/src/transform.rsClear filter2026-08-27
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.