Commits
Commits on
00c1b3ff2d80d84fef71bb6208110dedbbd95fc4Filtered to crates/ec-h265/src/cabac.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): begin a software HEVC decoder — CABAC decode + CTU quadtreeAhmet Kaan Gümüş · d55730b
feat(h265): begin a software HEVC decoder — CABAC decode + CTU quadtree Module map (crates/ec-h265): - cabac.rs: CabacDecoder, the arithmetic-decode mirror of CabacEncoder, sharing RANGE_TAB_LPS/TRANS_IDX_LPS/TRANS_IDX_MPS/Contexts. Promoted from a test-only RefDecoder that already existed and matched the spec flowcharts; added decode_bin/decode_bypass/decode_terminate and a WPP byte_position_aligned() helper. - residual.rs: decode_residual, a bin-for-bin mirror of encode_residual. Round-trip tested against encode_residual across every block size/scan/plane/sign-hiding combination. - decode.rs (new): the coding-tree/transform-tree walk ec-h265 had no decode-shaped twin for. Reuses crate::intra and crate::transform as-is. decode_idr_au() parses VPS/SPS/PPS + one I slice and refuses inter slices with a stated reason. Gates: decoder_inverts_the_encoder_bin_by_bin and decode_residual_inverts_encode_residual green; tests/decode.rs round-trip green at 32x32 and 96x64 (WPP), 70x50 checkpoint-ignored (same coded dims as the passing 96x64 case — content-triggered desync, documented for the next round). Pre-existing cargo test -p ec-h265 --release: 15/15 green.
2026-08-25
feat(h265): transform skip on 4x4 transform unitsAhmet Kaan Gümüş · f5dbd0b
feat(h265): transform skip on 4x4 transform units A 4x4 transform unit may now code its residual samples directly instead of transforming them (transform_skip_flag, 7.3.8.11), which is what screen content wants: sharp edges spread over every basis function, and the transform costs bits to undo them. The PPS carries transform_skip_enabled_flag, the flag itself is coded per 4x4 TU on its own pair of contexts (luma and chroma, init value 139 in Table 9-25), and the residual path swaps the integer transform for a pair of shifts. Those shifts are the whole feature: the decoder scales what it reads by tsShift = 5 + Log2(nTbS) and takes the bit-depth shift of 12 back off, so a coefficient carries the sample scaled by the difference. Writing the encoder's own shift as tsShift instead was caught by the decode: 3117 samples of a 64x64 picture differed. Off by default, so every existing stream stays byte-identical; the BD gate reaches it through EC_H265_TSKIP. Gated by ffmpeg decoding three picture shapes sample for sample against the encoder's reconstruction, and by a unit round trip over every 8-bit residual value. Three mutations were checked to fail those: tsShift one short, the flag never written, and one wrong context init value.
2026-08-14
feat(h265): full-depth quadtree search, VA-API check, parse-side fuzzAhmet Kaan Gümüş · b19a281
feat(h265): full-depth quadtree search, VA-API check, parse-side fuzz The search goes down to 8x8 by default because on real pictures that is both better and no slower: measured on a 1080p camera frame at QP 22, -27% bits and +1.5 dB against stopping at 16x16, at the same wall time. The 16x16 floor stays available as a setting. Two defects the earlier tests could not see, both found by pointing the encoder at real footage: - stopping the search early skipped split_cu_flag entirely, while the sequence still allowed a split. Every picture decoded to noise. The flag is written now whatever the search decides. - a fuzzed SPS could name a 45-bit POC field and take ec-core's bit reader past its documented contract. Picture size, POC width and long-term set count are validated where they are parsed. Also: VA-API decode of the encoder's own output is a test (radeonsi, real GPU), progress counters are one per cache line - twelve workers polling eight counters per line spend their time invalidating each other - and waits back off to a sleep instead of spinning on a core someone needs.
feat(h265): integer transforms, quantiser and the CABAC coderAhmet Kaan Gümüş · 990d3ac
feat(h265): integer transforms, quantiser and the CABAC coder The inverse transform and the dequantiser are the normative ones, so the encoder's reconstruction is what a decoder produces. Only the first 16 columns of the 32x32 matrix are typed in; the rest follow from the matrix's own symmetry, and tests check both the printed second half and orthogonality, because a mistyped column is the classic defect here. The CABAC coder can run in counting mode - identical context updates, no bytes kept - which is how rate-distortion decisions are priced at the rate they actually cost. A spec-derived decoder in the tests reads back what the encoder writes.