Commits
Commits on
00c1b3ff2d80d84fef71bb6208110dedbbd95fc4Filtered to crates/ec-h265/tests/rdoq_cache_hash.rsClear filter2026-08-28
perf(h265): estimated per-context fracbits table replaces exact CABAC replay in RDOQ trial costingAhmet Kaan Gümüş · 50e18de
perf(h265): estimated per-context fracbits table replaces exact CABAC replay in RDOQ trial costing RDOQ's per-candidate rate was priced by re-simulating the exact adaptive CABAC coder for every trial (encode_subblock measured 26% self time, cost structural to exact counting since range/low/context state carries forward). Adds an x265/HM-`entropyBits`-style estimated fractional-bit table (ENTROPY_BITS[64], entropy of the current CDF/probability state via the CABAC probability-state geometric model, alpha=0.9493) and a CabacEncoder `estimating` mode that looks it up instead of replaying range/renorm arithmetic. Only RDOQ's dedicated counting instrument (`rdoq_enc`) ever estimates; the committing encoder always writes exact bits, so streams stay conformant. Measured: ec-bench h265 640x360x10f encode ~2953ms -> ~1833ms (1.61x, 4-run median each). bd_psnr_vs_x265 (synthetic clip): BD-PSNR-YUV +7.880 -> +7.948 dB vs x265 (a gain, not a loss), wall time 28.85s -> 20.70s. Both comfortably clear the repo's adopt bar (speedup >=1.15x, BD loss <=0.05 dB) with room to spare, so `EncoderConfig::rdoq_estimate` defaults on; `false` keeps the exact-replay path for A/B. rdoq_cache_hash's pinned bytes re-pinned to the new default's output.
2026-08-27
feat(h265): all-zero-CBF early out for the RQT split trialAhmet Kaan Gümüş · 4275e27
feat(h265): all-zero-CBF early out for the RQT split trial Mirror the CU-quadtree's existing last_cu_empty skip one level down at the transform tree: when a coding unit's luma and both chroma planes already quantised to nothing, commit it as one leaf transform unit without running the four-child split trial (which can only add split_transform_flag and mode-signalling bits on top of an SSD floor that split cannot beat). Measured neutral-to-positive, not a double-digit speedup: -0.02% instructions on a synthetic 1080p gradient/texture profile clip (the CU-level early out already catches most flat regions before this code path is reached), BD-PSNR vs x265 +0.003 dB luma / +0.004 dB YUV on a 1080p film clip and flat / +0.025 dB YUV on a 2560x1440 screen capture (both real library files, no regression on either). Kept because it's exactly the lever the charter named and is bit-safe-by-construction, not because it clears the lane's own >10%-instructions bar — flagged honestly in the report. Re-pins rdoq_cache_hash_is_pinned: this intentionally changes output on any content where the RQT trial used to flip a leaf to split.
perf(h265): flatten the transform matrix branch out of the hot butterfly loopsAhmet Kaan Gümüş · c180d55
perf(h265): flatten the transform matrix branch out of the hot butterfly loops Profiled the encode path first (perf record --call-graph dwarf on a 1080p single-thread encode_idr loop): forward_1d is 28% of self-time, inverse_1d 9.7%, well ahead of anything in residual.rs/cabac.rs (residual::rdoq is 2.2%, cabac put_bit 0.9%) -- the RDOQ/CABAC bookkeeping levers named in the charter are not where the time is; the integer transform is. m32() computed each matrix entry on the fly with a branch (col<16 / row parity) inside forward_1d's and inverse_1d's innermost multiply-accumulate loop. Mirrored the same values out to two flat 32x32 tables at compile time (FULL_MATRIX and its transpose FULL_MATRIX_T, both built by a const fn that literally calls m32 -- so this is m32 evaluated ahead of time, not a new derivation) and index them instead, so the hot loop is a branchless multiply-add over a contiguous array read. perf stat -e instructions,cycles on the same 4-frame 1080p single-thread workload, best of 3: 105.7B -> 97.2B instructions (-8.1%), 22.6B -> 17.8B cycles (-21%, before run noisy at +-10.5%). Short of the 15% instruction target; intra::predict (12% of self-time) and quantize_offset (6.4%) are the next levers and are untouched. Bit-identical: rdoq_cache_hash's 416x240 and 1920x1080 encodes hash the same (da5d606db0755d97, f08a816c9fa9ca2c) with git-stashed transform.rs before this change as with it; pinned that equality as an assertion (rdoq_cache_hash_is_pinned) since the existing test only printed. Full ec-h265 --release suite green (56 tests across 7 binaries).
perf(h265): sub-block frozen-prefix CABAC cache for RDOQ trialsAhmet Kaan Gümüş · 4c5b62b
perf(h265): sub-block frozen-prefix CABAC cache for RDOQ trials rdoq() re-encoded every sub-block from last_sub down to 0 on every trial, even though a trial only ever changes one coefficient. Sub-blocks above the one being trialed never change (csbf-neighbour lookups and the greater1_ctx carry both flow from a higher scan sub-block to a lower one, never the reverse), so a cursor now caches the CABAC state right before the sub-block under trial and is advanced one committed sub-block at a time as trials move to lower ones; only a trial that moves the block's last significant position (the header itself changing) still falls back to a full re-encode from the block's start. Entry-gate test (sub_block_cursor_matches_full_recompute) checks the new cursor path against always-full-recompute bit-for-bit across sizes 8/16/32, every scan, 8 seeds, both sign-hiding states, including trials that drop the last significant coefficient, empty a whole sub-block, and cross the greater1/greater2 escape boundary. Output verified bit-identical before/after by FNV-1a hash of 1920x1080 and 416x240 natural-content encodes (rdoq_cache_hash.rs). perf stat on the 1080p hash encode: -2.45% instructions, -1.29% cycles — real but modest, since most of encode_residual's cost is the CABAC bin coding itself, not the header/context bookkeeping this round targeted.