Commits
Commits on
a5a892bb95f102bfc3e3bc91e5039246a87eced82026-08-27
Merge branch 'lane-h265dec' (r4): HEVC decoder handles all odd sizesAhmet Kaan Gümüş · a5a892b
Merge branch 'lane-h265dec' (r4): HEVC decoder handles all odd sizes NxN availability-timing fix: the decoder now marks each NxN partition available immediately, matching the encoder; 70x50/150x94/41x33 round-trip byte-exact.
fix(h265): NxN partitions mark availability per partition, matching the encoderAhmet Kaan Gümüş · 296a501
fix(h265): NxN partitions mark availability per partition, matching the encoder decode_cu_nxn deferred decoded[idx]=true to the post-loop mark_coded while the encoder flips availability immediately per partition — the decoder's mpm_at saw a same-CU sibling as unavailable-DC and derived a different MPM triple, desyncing every bin after. All odd sizes now round-trip byte-exact (70x50, 150x94, 41x33 added); full gate green.
Merge branch 'lane-av1dec' (r6): real-stream probes — interior 8x8 splits, TX_64X64 fixAhmet Kaan Gümüş · 2354a75
Merge branch 'lane-av1dec' (r6): real-stream probes — interior 8x8 splits, TX_64X64 fix Real libaom streams drove two fixes: interior 16x16 splits decode via the leaf8 machinery, and the TX_64X64 zero-pad path dequantizes at the true transform size. Gap ladder for remaining real-world features recorded.
fix(av1dec): decode a real (non-straddle) SPLIT of a 16x16 leaf, fix the whole-64x64-superblock dequant scaleAhmet Kaan Gümüş · 761f32c
fix(av1dec): decode a real (non-straddle) SPLIT of a 16x16 leaf, fix the whole-64x64-superblock dequant scale decode_stream on real libaom-produced streams hit "partition below 16x16" on over half of a cpu/crf sweep -- the key-frame tile decoder only handled SPLIT-to-8x8 when the true frame edge forced it (lane-av1-rect straddle case), refusing the same split when RD picked it on an interior 16x16. Reuses the already-tested decode_leaf8 recursion unconditionally instead. Separately, that fix exposed a live bug in the TX_64X64 zero-pad path: read_plane built a tx_side x tx_side (32x32) dequant grid and called dequant_and_inverse/reconstruct with tx_side, both wrong -- dqDenom (spec 7.12.3) is keyed by the true 64 transform size, not the 32x32 coded corner, and only a quarter of the block was ever reconstructed. The corner now goes into the top-left of a side x side (64x64) grid, inverse-transformed and reconstructed at the true size. gate: cargo test -p ec-av1 --release -- 155 passed, 0 failed, 10 ignored (unchanged from baseline)
Merge branch 'lane-av1dec' (r5): decoder reads the 8x8-leaf path; RD guard liftedAhmet Kaan Gümüş · 24df967
Merge branch 'lane-av1dec' (r5): decoder reads the 8x8-leaf path; RD guard lifted decode_leaf8 mirrors write_leaf8 (mi-precise contexts, CFL alphabet, Luma8/Chroma4 sets); 40x32 and 640x360 byte-exact vs recon, 40x32 agrees with ffmpeg. leaf8 splits now compete on RD cost everywhere.
feat(av1dec): teach the decoder the 8x8-leaf straddle path, lift the RD guardAhmet Kaan Gümüş · ca24626
feat(av1dec): teach the decoder the 8x8-leaf straddle path, lift the RD guard decode.rs's key-frame partition walk now mirrors write_leaf8: at a straddling 16x16 (exactly one axis in-frame at the 16 level), it reads the gathered split bool, then per in-frame 8x8 leaf reads partition_w8 NONE and decodes mode + Luma8/Chroma4 coefficients (decode_leaf8), carrying the mi-precise Neighbours split (above_side_mi/left_side_mi, record_mi/around_mi/partition_ctx_mi) already used for the coefficient context, and mirroring the r15 above_mode/left_mode writeback rule from the last leaf. 40x32 and 640x360 key frames decode byte-exact against the encoder's own reconstruction, and 40x32 agrees with ffmpeg. With the read path proven, encode.rs's `!has_leaf8` RD-cost guard is lifted: leaf8 can now win on cost anywhere, not just when forced by an illegal whole block. Full gate: 155 passed, 0 failed, 10 ignored.
fix(av1): keep the leaf8 RD-cost guard until crate::decode reads leaf8Ahmet Kaan Gümüş · 1d41e74
fix(av1): keep the leaf8 RD-cost guard until crate::decode reads leaf8 r15 proved the 8x8-leaf path against ffmpeg, but the in-crate software decoder has no leaf8 read path yet; letting leaf8 win on cost at sizes decode_stream round-trips broke 3 decoder tests. Guard re-instated with the new reason; lifts when decode.rs learns the path.
Merge branch 'lane-av1-rect': mod-32==8 key frames — the 8x8-leaf straddle pathAhmet Kaan Gümüş · e05f550
Merge branch 'lane-av1-rect': mod-32==8 key frames — the 8x8-leaf straddle path Fifteen rounds: side-8 CDF layer (TX_8X8/TX_4X4, partition_w8), Reach and scan tables for 8x8 leaves, mi-precise partition/mode contexts, the CFL alphabet, reduced_tx_set declared in the key-frame header, and the leaf mode-neighbour write moved out of the per-leaf loop. 640x360-class key frames now encode and round-trip through ffmpeg bit-exact; the 8x8-leaf split competes on RD cost; 40x40-class both-axes sizes still refuse.
fix(av1): thread the last leaf's mode past the whole straddling quadrantAhmet Kaan Gümüş · d02638d
fix(av1): thread the last leaf's mode past the whole straddling quadrant write_leaf8's above_mode[c]/left_mode[r] forced write (r12) ran once per leaf inside the quadrant's leaf loop, so the first leaf's write clobbered the true external neighbour mode a second leaf of the *same* straddling 16x16 still needed to read on its non-adjacency axis. Move the write out of write_leaf8 to run once, after the whole leaf loop, from the last (bottom/right-most) leaf. a_single_axis_straddle_round_trips_through_ffmpeg now decodes clean; un-ignored. Lifted the RD-cost guard that kept leaf8 splits from competing on cost (now decoder-proven); full gate 136/0/9.
fix(h265): decoder true-size base, NxN chroma log2, encoder MPM remainderAhmet Kaan Gümüş · 9c113d7
fix(h265): decoder true-size base, NxN chroma log2, encoder MPM remainder Three fixes from the odd-size hunt: - decode.rs sizes the picture from pic_width/height_in_luma_samples, not the CTB-rounded grid; split_cu_flag inference desynced at every non-CTB-multiple size against the encoder's true-size boundary checks. - reconstruct_chroma for an NxN CU takes the covering 8x8 CU's log2, not a 4x4 partition's; the old value underflowed decode_residual. - ENCODER: rem_intra_luma_pred_mode binarization must compare the running remainder while walking sorted MPMs descending, not the fixed mode; wrong bitstream whenever two MPM candidates straddle the chosen mode. ffmpeg bit-exact conformance stays green (suite content never fired it). 70x50/150x94 stay ignored: residual desync narrowed to PART_NxN at a boundary-forced 8x8 leaf (2Nx2N-forced round-trips clean).
fix(av1): declare reduced_tx_set in the key-frame header; rng in tracesAhmet Kaan Gümüş · a9fbebe
fix(av1): declare reduced_tx_set in the key-frame header; rng in traces The writer coded 8x8-leaf tx types against TX_SET_INTRA_2 tables while the header's reduced_tx_set:false told decoders to read TX_SET_INTRA_1 — a 7-vs-5-symbol alphabet skew that shifts the arithmetic coder's range with no symbol value ever differing. All existing sizes still round-trip bit-exact (16x16 resolves to the same 5-symbol set under both headers). Straddle test stays ignored: a further divergence remains past leaf(0,8).
Merge branch 'lane-av1dec' (r4): public decode_stream + NEARMV + real bench rowAhmet Kaan Gümüş · 3816297
Merge branch 'lane-av1dec' (r4): public decode_stream + NEARMV + real bench row decode_stream walks raw OBUs via the syntax parser and threads the DPB; GOP round-trips + ffmpeg agreement green; av1 software decode benches at 3.30x realtime on the 640x384 GOP shape.
feat(av1dec): public decode_stream OBU walker, bench decode row, NEARMV liftAhmet Kaan Gümüş · 16b0ce0
feat(av1dec): public decode_stream OBU walker, bench decode row, NEARMV lift decode_stream(&[u8]) walks a raw AV1 stream via ec-av1-syntax's Av1Parser, extracts each Frame OBU's header + tile payload and dispatches to the existing decode_key_frame_tile/decode_inter_frame_tile, threading a single-slot DPB -- the first real entry point that does not need Encoded's pub(crate) fields. ec-bench's av1 row now times decode_stream instead of reporting "no decoder present". decode_inter_block also reconstructs NEARMV (mvstack already carries the second stack candidate), tested by hand-driving a symbol stream since this crate's own encoder never chooses that mode.
Merge branch 'lane-h265perf2': closed-form bit proxy for h265 mode rankingAhmet Kaan Gümüş · 555bbde
Merge branch 'lane-h265perf2': closed-form bit proxy for h265 mode ranking estimate_residual_bits replaces per-candidate encode_residual in choose_luma_mode; BD-PSNR within 0.05dB on both ladders (winner still gets real RDOQ). Real remaining lever is RDOQ's own inner trial loop.
feat(h265): cheap coefficient-statistics proxy for mode-ranking bitsAhmet Kaan Gümüş · c8c466c
feat(h265): cheap coefficient-statistics proxy for mode-ranking bits choose_luma_mode's per-candidate cost used the real CABAC-costed encode_residual to rank ~6 intra mode survivors; replace it with a closed-form proxy (last-position binarization + a log2 magnitude estimate per level, no context updates) so ranking no longer pays for a full residual_coding() walk per candidate. The winner still gets the real encode_residual/RDOQ below. Magnitude scale swept against bd_psnr_vs_x265 on the synthetic clip and a real screen capture; 1.5 lands within 0.05 dB of the real-bits baseline on both.
fix(av1): 8x8 leaf reads the CFL-allowed uv_mode CDF, threads its mode forwardAhmet Kaan Gümüş · e3b2c93
fix(av1): 8x8 leaf reads the CFL-allowed uv_mode CDF, threads its mode forward write_leaf8 hardcoded cfl:false for write_intra_mode's chroma-mode CDF, but is_cfl_allowed (spec 5.11.5) is true up to 32x32 -- every other write_block caller at 16x16 and up already passes true. The narrower uv_mode_no_cfl alphabet is one symbol short of uv_mode_cfl, so even an identical DC_PRED decision consumed a different amount of arithmetic range and derailed the stream from that leaf onward. record()'s above_mode/left_mode write is also a no-op at an 8x8 leaf's own side (side/SUB == 0), and write_leaf8 only called record_mi, never updating those coarse arrays -- so a second straddling 16x16 quadrant stacked above or left of the first (outside r11's same-call prev_leaf override) read whatever stale mode sat in that slot. Fixed by writing the leaf's own mode into above_mode[c]/left_mode[r] directly. Full suite still 134/0/10; the straddle round-trip stays ignored -- a residual divergence now shows up one leaf further in (leaf(2,8) reads its own luma coefficient block at the wrong tx size), not yet isolated to a single symbol.
Merge branch 'lane-h265dec' (r1): software HEVC decoder coreAhmet Kaan Gümüş · 84c3ac5
Merge branch 'lane-h265dec' (r1): software HEVC decoder core CabacDecoder + bin-for-bin residual decode + full CTU quadtree walk with WPP; round-trips byte-exact vs encoder recon at whole-CTB sizes; the 70x50 content-triggered desync stays a documented ignored test for r2.
Merge branch 'lane-av1dec' (r3): inter-frame decode + ffmpeg cross-oracleAhmet Kaan Gümüş · 57878ee
Merge branch 'lane-av1dec' (r3): inter-frame decode + ffmpeg cross-oracle Single-ref NEARESTMV/NEWMV inter decode with MC against a single-slot DPB; GOP round-trips byte-exact vs encoder recon at 128x64 and 216x96, and ffmpeg agrees with our decoder on key frames and a full GOP.
wip(av1): r11 checkpoint — leaf-8 trace instrumentation and partial ctx fixesAhmet Kaan Gümüş · 3a1f168
wip(av1): r11 checkpoint — leaf-8 trace instrumentation and partial ctx fixes Full suite green (134/0/10); the 40x32 straddle round-trip still desyncs and stays ignored. Diff spans cdf/cdf_state/encode/tile from the r11 trace session; r12 continues from the committed trace artifacts.
feat(av1dec): ffmpeg cross-oracle + inter-frame GOP decodeAhmet Kaan Gümüş · 8f45f31
feat(av1dec): ffmpeg cross-oracle + inter-frame GOP decode decode.rs now decodes single-reference NEARESTMV/NEWMV inter frames (whole 32x32 blocks and the 16x16-leaf split at a straddling true edge), motion-compensating from the previous decoded frame and chaining frame-to-frame like a single-slot DPB, byte-exact against the encoder's own reconstruction across a GOP (incl. an odd frame size) and cross-checked against ffmpeg on both a lone key frame and a full GOP.
Merge branch 'lane-h264perf': profile harness + bit-identical SIMD satd4Ahmet Kaan Gümüş · f3161e4Browse files
perf(h264): vectorize satd4 with the crate's wide-SIMD idiomAhmet Kaan Gümüş · 9d613d5
perf(h264): vectorize satd4 with the crate's wide-SIMD idiom Bit-identical: sha256 of all access units over the 640x360x30 bench clip matches the scalar build exactly (15b0075e...); full suite green.
Merge branch 'lane-av1dec' (r2): decoder covers directional modes, skip, odd sizesAhmet Kaan Gümüş · 468f128
Merge branch 'lane-av1dec' (r2): decoder covers directional modes, skip, odd sizes All 13 intra modes, skip=1 blocks, and non-superblock-aligned frames now decode byte-exact against the encoder reconstruction (854x480, 216x96, 128x128, 192x128). Fixes a right-by-coincidence txb mode index from r1.
feat(av1dec): decode skip blocks, directional intra modes, odd frame sizesAhmet Kaan Gümüş · 632319a
feat(av1dec): decode skip blocks, directional intra modes, odd frame sizes Extends the software key-frame tile decoder past round 1's whole-superblock DC_PRED-only scope: skip=1 blocks decode to pure prediction (no residual read); all thirteen intra modes decode via crate::intra::predict, reusing encode.rs's Reach edge/reach rules (made pub(crate)) for the directional above-right/below-left reads; frames that are not a whole number of 64x64 superblocks or 32x32 blocks decode via the same gathered-CDF partial-block path tile.rs's writer uses, with a duplicated (not shared -- tile.rs is another lane's territory) Neighbours/gather implementation kept in step by the byte-exact round-trip tests. Fixed along the way: read_plane's cdfs.txb() lookup was hardcoded to DC_PRED's table for every plane, which only worked by coincidence while every stream really was DC_PRED; real modes need the block's own luma mode there (matching write_block_planes) even though chroma's own prediction mode stays DC_PRED. decode_key_frame_tile's signature grows frame_width/frame_height (the header's separate true render size) to crop the reconstruction the same way crop_encoded does, since mi_cols/mi_rows alone cannot invert to it losslessly.
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.
Merge branch 'lane-av1dec' (r1): software AV1 key-frame decoder coreAhmet Kaan Gümüş · 2023929
Merge branch 'lane-av1dec' (r1): software AV1 key-frame decoder core decode.rs decodes the encoder's own key-frame tiles byte-exact against the encoder reconstruction (DC_PRED, whole-superblock frames this round); msac SymbolDecoder promoted to a public reader. Directional/inter/skip and odd sizes refuse with named errors — lane continues.
feat(av1): begin a software key-frame decoder (round 1)Ahmet Kaan Gümüş · e6eadb9
feat(av1): begin a software key-frame decoder (round 1) Promotes msac's test-only SymbolDecoder to a real, non-test decoder (the inverse of SymbolEncoder, already spec-derived and roundtrip tested), and adds crates/ec-av1/src/decode.rs: a from-spec reader that mirrors tile.rs's sb_coeff_key_frame_tile symbol order (partition tree through 64x64/32x32/16x16, coefficient base/base-range/EOB/Golomb/sign syntax, CDF adaptation) without importing from tile.rs, which a sibling lane is editing concurrently. Round 1 scope: key frames only, DC_PRED blocks only, unskipped, and frames a whole number of 64x64 superblocks -- everything else refuses with a named error rather than miscoding. Within that scope, real encoder output (encode_key_frame_with_modes forced to DC_PRED, two sizes, real quantised AC/DC residual) decodes byte-exact against the encoder's own reconstruction. Encoded gains three pub(crate) fields (tile, mi_cols, mi_rows, base_q_idx) so a decoder test can reach the raw tile payload without re-deriving it from the OBU stream. Deferred to round 2: non-DC_PRED intra modes (needs the directional edge-reach plumbing), inter frames, skipped blocks, and the partial-superblock/gathered-CDF true-edge path.
chore(h264): add a throwaway profiling example for the encode bench shapeAhmet Kaan Gümüş · dfbf8b3
chore(h264): add a throwaway profiling example for the encode bench shape lane-h264perf r1: MEASURE FIRST. tools/ec-bench mixes every codec's rows into one process, so perf can't isolate ec-h264 encode; this repeats the bench's own 640x360x30-frame encode loop N times against a pre-extracted raw yuv file so perf record has enough samples on just this path.
fix(av1): 16x16 partition ctx reads stale coarse side after a leaf8 siblingAhmet Kaan Gümüş · 4353787
fix(av1): 16x16 partition ctx reads stale coarse side after a leaf8 sibling partition_ctx (SUB-grid) only advances above_side/left_side in whole-16px steps, so write_leaf8's record_mi (mi-precise only) never updated them: the next 16x16-level split query after a leaf8 quadrant read a stale side value instead of 8. Delegate partition_ctx through partition_ctx_mi (same pattern as around/around_mi), which record already keeps in sync at mi granularity for every block. Confirmed against a debug aomdec EC_RNG/EC_TRACE2 trace: the 16x16-level ctx at mi(4,8) now matches libaom's (row 1 both sides, after subtracting aomdec's shared-cdf bsl*4 offset). Full ec-av1 gate green, no regressions. Not sufficient on its own: the 40x32 straddle test still desyncs, now traced to the BLOCK_8X8 leaf's own partition-symbol context/table, not the TX_TYPE/EOB_PT pair r8 flagged -- see ledger for handoff.
Merge branch 'lane-h265perf': RDOQ refines the winner onlyAhmet Kaan Gümüş · 7173115
Merge branch 'lane-h265perf': RDOQ refines the winner only choose_luma_mode ran the full per-coefficient RDOQ search on every prescreened candidate just to rank them; candidates now score with the dead-zone quantiser and RDOQ runs once on the winning mode. Bench row 15621ms->4008ms (0.02x->0.08x RTF); BD-PSNR vs x265 unchanged above floor.
perf(h265): score mode candidates without RDOQ, refine only the winnerAhmet Kaan Gümüş · 32fb6a8
perf(h265): score mode candidates without RDOQ, refine only the winner encode_residual was 73% of encode wall time (perf record, ec-bench h265 row). choose_luma_mode ran full RDOQ (its per-coefficient CABAC-costed search) for every SATD-prescreened mode candidate just to rank them, then discarded all but the winner's levels. RDOQ's expensive refinement loop now runs once, after the winning mode is picked, instead of once per candidate (~6x fewer calls into the hot loop). ec-bench h265 row: 15621ms -> 4008ms wall (0.02x -> 0.08x RTF), ~3.9x. cargo test -p ec-h265 --release: 27+15+1+3 green, including bd_psnr_vs_x265 (+7.98/+8.44 dB, comfortably above its floor) and the RDOQ/RQT/cu64/threads bit-exactness conformance tests.
fix(av1): mi-precise partition ctx for 8x8 leaves; falsify r7's ctx hypothesisAhmet Kaan Gümüş · 9a69856
fix(av1): mi-precise partition ctx for 8x8 leaves; falsify r7's ctx hypothesis Neighbours gained above_side_mi/left_side_mi (mi-granularity, mirroring above/left) and partition_ctx_mi, so a straddling 16x16's second 8x8 leaf reads its own finer neighbour state instead of the enclosing 16x16 slot. Spec-accurate improvement, does not regress the gate (134 passed, 10 ignored, unchanged). r7's named falsification candidate for the 40x32 dav1d desync -- partition_w8's ctx reading the enclosing slot -- is FALSIFIED by an EC_RNG/EC_TRACE2 trace diff against a debug aomdec: libaom's own partition_plane_context masks at bsl=0 for BLOCK_8X8, and every partition_context_lookup entry a 4x4-free writer ever produces has bit 0 clear, so ctx is provably 0 on both sides regardless. The real first divergence is later, inside leaf0's own luma transform (TxbSet::Luma8/Chroma4, exercised by no other caller): the decoder reads a wrong EC_EOBPT category (eob=36 vs the writer's real eob=7) somewhere between the TX_TYPE and EOB_PT symbols. Named in the test's doc comment for the next round.
Merge branch 'lane-bench': standing codec performance harnessAhmet Kaan Gümüş · 9fab3bf
Merge branch 'lane-bench': standing codec performance harness tools/ec-bench sweeps real library media through every public decode/encode surface and prints a ranked realtime-factor table — the optimization queue and regression baseline for the all-codecs perf push.
feat(bench): cover ec-image decode (all sniffed formats) and ec-inflateAhmet Kaan Gümüş · 1ee915b
feat(bench): cover ec-image decode (all sniffed formats) and ec-inflate Extends the harness with the two remaining tractable groups: ec-image's single decode() entry point runs over every real still and fixture, and ec-inflate is measured on the zlib stream a real PNG's own IDAT chain already carries.
Merge branch 'lane-av1-fdct': FFT-based forward DCTAhmet Kaan Gümüş · 6fe6ddf
Merge branch 'lane-av1-fdct': FFT-based forward DCT Makhoul DCT-II via FFT replaces the basis matmul in forward_transform_2d; naive path kept as the test oracle. 4K 13-mode key frame 11.30s->8.52s, suite wall 7.62s->5.43s; 16x16 keeps a small constant-overhead regression.
feat(bench): standing realtime-factor harness across every codec crateAhmet Kaan Gümüş · 4d8621c
feat(bench): standing realtime-factor harness across every codec crate One new bin (tools/ec-bench) that drives each crate's own public one-shot API against real media (h264/h265/av1 video, aac/mp3/opus/vorbis/flac/alac audio via ec-probe's unified reader) and prints a ranked markdown table — the baseline every future optimization lane measures against.
perf(av1): replace the forward DCT's matmul with an FFT factorizationAhmet Kaan Gümüş · 5bfacbb
perf(av1): replace the forward DCT's matmul with an FFT factorization forward_transform_2d ran an O(n^2) dot product against a cached DCT-II basis per row and column, on every RD trial. Replaced with Makhoul's FFT-based DCT-II reduction (O(n log n)), with the twist table and FFT stage twiddles precomputed per size and the 1D transform working on fixed-size stack buffers -- both measured necessary; a first cut with runtime cos/sin and heap Vec scratch was slower than the matmul it replaced. The old matmul is kept under #[cfg(test)] as the differential oracle for a new fast_forward_matches_the_naive_matmul test. All existing transform tests, including the quantizer roundtrip and 64x64 coded- quarter tests, pass unchanged.
Merge branch 'lane-av1-ratectl': quality/size targeting surface over base_q_idxAhmet Kaan Gümüş · baab8caBrowse files
feat(av1): a quality/size targeting surface over base_q_idxAhmet Kaan Gümüş · a55d2ef
feat(av1): a quality/size targeting surface over base_q_idx
RateTarget::{QIndex,Quality,BytesPerFrame} on Av1Encoder::with_rate_target,
additive alongside the existing EncoderConfig::base_q_idx path. Quality
maps to base_q_idx via the calibration sweep's linear fit; BytesPerFrame
steers it with a clamped proportional controller (no accumulated debt, so
no windup class to bound). Calibration sweep test records the curve.Merge branch 'lane-av1-msearch': whole-pel fast path in mc::predictAhmet Kaan Gümüş · a717fd8
Merge branch 'lane-av1-msearch': whole-pel fast path in mc::predict Motion-search bucket 408.55ms->181.85ms, inter frame total 818.88ms->585.24ms at 720p, bit-identical output (SUBPEL_FILTERS[0] is the exact identity kernel).
fix(av1): Reach tables for side=8, coeff_bits TX4 scan; wire key-frame 8x8-leaf pathAhmet Kaan Gümüş · 51db03e
fix(av1): Reach tables for side=8, coeff_bits TX4 scan; wire key-frame 8x8-leaf path Root-caused the r6 panic to two independent bugs, both fixed: - Reach::of's HAS_TOP_RIGHT/HAS_BOTTOM_LEFT tables only ever covered side 16/32 (libaom's 128-superblock-relative bit tables); side==8 fell through to the 16-table with a 16-wide stride and indexed past its 8-byte length. Added libaom's has_tr_8x8/has_bl_8x8 as a third table row. - tile::coeff_bits's SCANS cache had no TX4 entry, so an 8x8 leaf's 4x4 chroma coefficient search read TX32's 1024-entry scan against a 16-entry grid. Added the missing TX4 scan. Wired encode_key_frame_inner's key-frame block-generation loop to build BlockCoeffs::eight for a 16x16 sub-block that straddles the true frame edge on exactly one axis (mirroring `write_leaf8`'s 1-or-2-leaf geometry), while still refusing a sub straddling on both axes (needs a rectangular transform neither writer has). The leaf-8 split is only ever taken when the whole 32x32 is illegal (forced) -- never chosen on RD cost over an already-legal whole block, since the leaf path is not yet proven against a real decoder and must not regress sizes that already round-tripped correctly. Narrowed both_writers_refuse_the_same_strictly_before_half_straddle_size (now key_frame_encodes_the_inter_frame_still_refuses_at_half_straddle_size) and a_picture_off_the_block_grid_is_refused to the classes that are still genuinely refused (both-axes-cut, e.g. 40x40) vs. now accepted without erroring (640x360, 40x32). Added a decoder round-trip test at 40x32, `#[ignore]`d: the leaf-8 stream is not yet decoder-clean (dav1d rejects it, "Invalid data found") -- a genuine desync, not yet traced to its first mismatched symbol. Added EC_PART/EC_TOK tracing to the leaf-8 write path for that follow-up.
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.
feat(av1): 8x8-leaf CDF, mi-precise neighbour contexts, write_leaf8 (r6, unwired)Ahmet Kaan Gümüş · 83656d8
feat(av1): 8x8-leaf CDF, mi-precise neighbour contexts, write_leaf8 (r6, unwired) Lands the groundwork for lane-av1-rect's 8x8-leaf write path: the PARTITION_W8 CDF (+ adapted state field), Neighbours::record_mi/around_mi (mi-precise coeff-context entry points, the SUB-granularity above_mode/ above_side arrays untouched), and write_leaf8 (mirrors write_block for one 8x8 leaf, reading its intra-mode context from the enclosing 16x16 slot). BlockCoeffs gained an `eight: Option<Vec<BlockCoeffs>>` carrier and the coded-mode-validation loop flat_maps it. The key-frame Quadrant::Split writer now wires write_leaf8 for a straddling 16x16 (one axis only, mod-32==8 targets): the gathered split bit + per-leaf partition_w8 symbol + write_leaf8, matching the existing 32x32/64x64 edge pattern. encode.rs's block-generation loop does NOT populate `.eight` yet: an attempt to wire it hit an index-out-of-bounds in code_square's edge-sample read (Plane::edges, encode.rs ~1027) for a leaf at the frame's own edge, and a "exactly one straddler" geometry assumption that also turned out wrong (a 32x32-aligned straddling 16x16 row/column band is generically two leaves, not one) -- both are next-round work, not this round's budget. The refusal at encode.rs's split loop is therefore unchanged; both_writers_refuse_the_ same_strictly_before_half_straddle_size is unchanged and still green. Suite: 134/0/9, unchanged from cf71e1e.
fix(av1): correct the r4 chroma-granularity assumption for 8x8 leavesAhmet Kaan Gümüş · b91e4ec
fix(av1): correct the r4 chroma-granularity assumption for 8x8 leaves libaom's is_chroma_reference (av1_common_int.h) is unconditionally true for bsize >= BLOCK_8X8 (4:2:0 or not), so a split 16x16's 8x8 children each code their own chroma at 4x4 -- chroma does not stay at the parent's 8x8 granularity as the r4 doc comments claimed (never checked against a real decoder). Corrects TxbSet::Chroma4's doc and flips code_square's still-unreached side==8 branch to the chroma set a real caller will need, so the next lane does not inherit a wrong premise. No behavior change (134/0/9, unchanged): the branch has no caller yet.
feat(av1): land TX_8X8/TX_4X4 CDF tables for the mod-32==8 straddle leafAhmet Kaan Gümüş · dc6d790
feat(av1): land TX_8X8/TX_4X4 CDF tables for the mod-32==8 straddle leaf Extracted byte-exact libaom Default_*_Cdf tables for Luma8/Chroma4 coefficient coding plus the TX_8X8 intra tx_type table, wired through new TxbSet::Luma8/Chroma4 variants and code_square's third side==8 branch. Not yet reachable from the tile writer -- SPLIT_BLOCKS still refuses mod-32==8 sizes -- landing the compiling infrastructure layer per the charter's budget-exhausted fallback; the 16x16-leaf split emission (tile.rs Quadrant::Split), the leaf-under-leaf carrier, and aomdec/dav1d parity verification are unstarted. 134 baseline ec-av1 tests still green; no behavior change.
Merge branch 'lane-av1-regr2': the real-content gate now covers a straddle sizeAhmet Kaan Gümüş · f44b458
Merge branch 'lane-av1-regr2': the real-content gate now covers a straddle size A sibling of the standing quality gate at 704x400 -- height mod 32 is 16, so every inter frame splits its bottom superblock row into the 16x16 NEARESTMV leaves that landed in e19bb47 (probed live: 22 splits a frame). Eight real frames must decode through dav1d, hold 44.98 dB mean luma PSNR and 62703 bytes (measured 45.48 dB / 54525 bytes, 2026-08-27, same margins as the aligned sibling).
test(av1): exercise the 16x16 straddle-leaf inter path on real contentAhmet Kaan Gümüş · cdf3858
test(av1): exercise the 16x16 straddle-leaf inter path on real content real_clip_encodes_within_its_quality_and_size_budget uses 640x384 (both axes 32-aligned), so Quadrant::Split never fires and the e19bb47 NEARESTMV leaf path was untouched by real, mixed intra/inter content. Add a sibling at 704x400 (400 mod 32 == 16, the exactly-half straddle class), same three gates: dav1d decodes every frame, mean luma PSNR floor, byte ceiling.
Merge branch 'lane-av1-ileaf': real inter coding for 16x16 straddle leavesAhmet Kaan Gümüş · 3ac79d5
Merge branch 'lane-av1-ileaf': real inter coding for 16x16 straddle leaves An inter frame whose true size straddles a 32x32 boundary at exactly half used to code the whole straddling row intra. Its 16x16 leaves now weigh NEARESTMV against intra like any other block. Underneath: the mv stack gains spec 7.10.2.4's extended row/col scan -- invisible at 8-mi geometry only because coverage from the immediate scan suppresses it, so coverage must advance from ANY coded neighbour, intra included (three no-op differential tests pin that), and the mi grid now records intra cells, which it previously left indistinguishable from uncoded. Straddle sequences round-trip bit-exact through dav1d with the leaves live; 32-aligned streams are untouched.
fix(av1): mvstack extended row/col scan, intra-aware coverage; enable 16x16 inter leavesAhmet Kaan Gümüş · b26ee9f
fix(av1): mvstack extended row/col scan, intra-aware coverage; enable 16x16 inter leaves
Ports spec 7.10.2.4's extended row/col scan (libaom scan_row_mbmi/
scan_col_mbmi's idx=2..MVREF_ROW_COLS positions), invisible at pure
8-mi geometry because the immediate scan's own processed_rows/cols
coverage already reaches as far -- but only once that coverage counts
every *coded* neighbour cell, intra or inter, the way libaom's
processed_rows update sits outside add_ref_mv_candidate's ref-frame
match. The straddle-test attempt this round started from computed
coverage only from ref-matching (inter) cells, so an intra neighbour
above an 8-mi query silently un-suppressed the extended scan -- a real
8-mi behavior change, caught by two new differential tests
(extended_{row,col}_scan_is_a_no_op_at_8mi_geometry_even_behind_an_intra_neighbour)
that place a distinctively-MV'd tracer candidate at the extended
offsets and assert it never gets picked up. MiGrid now records intra
cells (encode.rs/tile.rs's else branches) so mvstack sees them.
With the no-op proven, lifts the `false &&` gate on 16x16-leaf
NEARESTMV (encode.rs:1231, wired r1, gated since dead code never
touched write_inter_frame_leaf's real symbol chain): full suite
130+3 new = 133/0/9, straddle and real_clip both green with the gate
live. The 640x384 real-clip fixture tiles exactly into 32x32
quadrants (no true-edge straddle), so its numbers are unchanged
(45.41 dB / 69861 bytes) -- the gate's leaf path is unexercised there;
the straddle test is what proves it live.feat(av1): wire NEARESTMV inter coding for 16x16 straddle leaves, gated offAhmet Kaan Gümüş · cac7aab
feat(av1): wire NEARESTMV inter coding for 16x16 straddle leaves, gated off
Adds the full machinery for real inter coding of the 16x16 leaves a
half-straddling 32x32 inter-frame quadrant splits into: a Luma16Inter
TxbSet/CDF table (reduced_tx_set forces the same two-symbol DCT_IDTX set
16x16 already shares the shape of with Luma32Inter), a leaf writer
(write_inter_frame_leaf) that codes is_inter/single_ref/mv-stack/DRL/mv at
this leaf's own 4x4-mi window, and an encode-side NEARESTMV-vs-intra cost
comparison (code_square_inter) with matching per-leaf MvStack/grid updates.
The NEARESTMV selection itself is left gated off (`false &&`, corner-cut
comment at the site) -- enabling it desyncs the decoder ("Invalid data
found") on the existing straddle round-trip test, not yet isolated within
this round's budget. Confirmed via a false/true toggle that the desync is
in the new is_inter leaf path, not in the reduced_tx_set frame-header flag
(that alone round-trips clean). Gate: cargo test -p ec-av1 --release ==
130 passed, 9 ignored, 0 failed (same as baseline).