Commits
Commits on
552edc4cede0dfd9bebbc4e344242802802d15ccFiltered to crates/ec-h264/src/deblock.rsClear filter2026-08-14
perf(h264): close the decode gap on inter contentAhmet Kaan Gümüş · 4cab1f0
perf(h264): close the decode gap on inter content Instruction counts, single thread, measured with perf over whole streams: 1080p WEB-DL 100 frames 38.23G -> 30.02G (-21.5%), QCIF B streams -47% and -29%. The changes, each measured on its own and kept only where it paid: - chroma interpolation takes a const-width kernel plus a full-sample copy path, so the 2x2 blocks that dominate real motion stop paying for eight lanes and four multiplies they discard; - single-list, default-weight prediction interpolates straight into the picture at the picture's pitch, and declares no scratch at all; - boundary strength is decided once per macroblock for all 24 internal edges (intra gives 3, no coefficients plus one motion vector gives 0) instead of 24 times from the block tables; - the luma half-sample filter splits by partition width, because a 16-lane vector is two SSE2 registers and half of it is thrown away for an 8- or 4-wide partition; - a horizontal chroma edge deblocks as one 8-lane pass; - the rounded average is written as the plain byte idiom the compiler turns into pavgb; - an output frame is grown row by row rather than allocated zeroed; - a direct-mode quadrant whose four 4x4 blocks derive the same motion compensates once as an 8x8 (interpolation is position-invariant, so this is bit-exact). Reverted, measured worse: combining at the picture pitch (+6 to +9%), blanket 8-lane luma taps (+2.2%), window slices for the deblock line filters (+0.8%). Conformance unchanged: 22 conformance tests and 55 unit tests green, JVT full sequences and the real library sweep still bit-exact.
feat(h264): CAVLC intra decoder, bit-exact on 18 JVT streamsAhmet Kaan Gümüş · f985e44
feat(h264): CAVLC intra decoder, bit-exact on 18 JVT streams I-slice scope: I_4x4 / I_16x16 / I_PCM, full CAVLC residual decode, all intra prediction modes, 4x4 inverse transform + DC Hadamard, dequant with scaling-list support, and the complete in-loop deblocking filter. Everything outside scope (CABAC, FMO, interlace, non-I slices, 8x8 transform, 4:2:2/4:4:4, >8-bit) refuses with a named Unsupported error backed by tests on real conformance streams - never wrong pixels. Perf-first layout: padded planes sized for future inter overreach; per-MB state in flat struct-of-arrays (nz counts, intra modes, QP, slice ids) with no per-MB heap objects; a register-cached BitCursor for slice data; residual parse fused with reconstruction so empty blocks cost one coeff_token read; wide i16x16 SIMD for horizontal deblock edges (a gather/scatter vertical variant measured slower and stayed scalar). Steady-state decode loop is zero-alloc, proven by a counting allocator in the conformance harness. Conformance: first IDR bit-exact vs the JVT reference YUV and ffmpeg on 18 CAVLC streams incl. multi-slice and I_PCM; 6 CABAC/FMO/interlaced streams verified to refuse by name; deterministic corrupt-input sweep (truncations + 2000 single-byte mutations) never panics. Measured on this machine, single thread, deblock included: 1324 ns/MB (193 Mpx/s) on BA1_Sony_D at idle; 1007 ns/MB (254 Mpx/s) on the no-deblock NL1_Sony_D even under background load.