Commits
Commits on
cd61dc00762fbbffd07101cda5eb3c4e129238752026-08-27
Merge branch 'lane-av1fintra': filter-intra decode, proven on real aomenc bytesAhmet Kaan Gümüş · cd61dc0
Merge branch 'lane-av1fintra': filter-intra decode, proven on real aomenc bytes The predictor matches av1_filter_intra_predictor_c exactly; the gate test pipes a y4m through the standalone aomenc in-memory, proves the symbol fires via a decode counter, and checks every plane against ffmpeg. The hunt's apparent predictor bug was the in-loop deblocking filter this decoder does not yet have — intra fixtures must encode with the loop filter off, and the missing filter is the next lane.
fix(av1): filter-intra was already correct -- gate against a real aomenc streamAhmet Kaan Gümüş · 2adf290
fix(av1): filter-intra was already correct -- gate against a real aomenc stream The straddling-boundary mismatch against ffmpeg's decode was never the filter-intra predictor: it's a real AV1 deblocking-filter artifact, and this decoder has no in-loop deblocking at all. `--loopfilter-control=0` on the aomenc fixture makes the two decodes byte-exact with zero source changes to intra.rs/decode.rs's prediction math. Adds a permanent gate (crates/ec-av1/src/stream.rs) that shells out to a real standalone aomenc build (ffmpeg's own libaom-av1 wrapper on this box doesn't expose enable-tx-size-search/loopfilter-control through -aom-params), asserts the use_filter_intra symbol actually fired via a new process-global counter (decode::filter_intra_hits), and checks pixel-exact luma/U/V against ffmpeg's own decode of the identical bytes. The encoder's screen-content-tools decision is a real internal PSNR trial, occasionally flips even with palette/intrabc off; the test skips (not fails) the still-unsupported-gap runs the same way the existing CDEF gate test does.
Merge branch 'lane-h265simd': flat transform matrices, profile-ledAhmet Kaan Gümüş · 43a4552
Merge branch 'lane-h265simd': flat transform matrices, profile-led perf named forward_1d/inverse_1d (28%+10% self-time), not the residual/CABAC path the charter guessed. Precomputed flat 32x32 matrix + transpose replace the per-element branch; -8.1% instructions, bit-identical (encode hash now pinned as a real assertion).
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).
feat(av1): filter-intra predictor (spec 7.11.2.3), refusal liftedAhmet Kaan Gümüş · f90ea1e
feat(av1): filter-intra predictor (spec 7.11.2.3), refusal lifted Recursive filter intra: 4x2 sub-blocks, the 7-tap av1_filter_intra_taps table, five modes. use_filter_intra==1 blocks now predict instead of erroring. Existing suite green; the real-stream gate that proves the path against ffmpeg lands next.
fix(opus): 12 kHz input caps bandwidth at Medium, not NarrowAhmet Kaan Gümüş · 6efce81
fix(opus): 12 kHz input caps bandwidth at Medium, not Narrow opus_encode_native's input-rate ceiling has four tiers (<=24k SWB, <=16k WB, <=12k MB, <=8k NB); our match folded 12 kHz into the Narrow arm, coding 12 kHz VoIP a band narrower than the reference would. The opus-rs shim's slower-rates test surfaced it, stale in the other direction: it still expected CELT's 120-sample overlap at every rate, but since the libopus threshold port 16 kHz and below dispatch to SILK at 32 kbps, whose resampler look-ahead is what the encoder reports. Both expectations now follow the dispatch.
Merge branch 'lane-av1inter8': inter frames at 8x8-leaf straddle sizesAhmet Kaan Gümüş · b3bcc7e
Merge branch 'lane-av1inter8': inter frames at 8x8-leaf straddle sizes Extends the mod-32==8 straddle path to inter frames end-to-end (encoder, tile writer, decoder), and fixes the subpel filter selection mc.rs shared with every consumer: blocks 4 wide or tall take the 4-tap table. The 640x360 inter sequence round-trips through ffmpeg pixel-exact.
fix(av1): 4-tap subpel filters for blocks 4 wide or tallAhmet Kaan Gümüş · aad8b59
fix(av1): 4-tap subpel filters for blocks 4 wide or tall Spec 7.11.3.4 selects the filter table per axis: an output dimension of 4 or less reads Subpel_Filters' narrow counterpart (av1_sub_pel_filters_4), whose outer two taps on each side are zero. We fed every block the 8-tap table, so 4:2:0 chroma under an 8x8 luma leaf -- the common chroma shape, not a corner -- reached 3 samples past its edge with nonzero weights and came out +-1 against the reference decoder wherever the extra taps mattered. Found by diffing libaom's dec_calc_subpel_params against ours: the phase matched, the tap table did not. Closes the 640x360 inter straddle sequence's frame-2 U-plane desync; the whole sequence now round-trips through ffmpeg pixel-exact.
test(av1): let the leaf8 straddle-sequence test dump its stream (EC_AV1_DUMP)Ahmet Kaan Gümüş · fd61351
test(av1): let the leaf8 straddle-sequence test dump its stream (EC_AV1_DUMP) Same pattern as the single-frame round-trip test, needed to feed the sequence's frame 2 to an instrumented aomdec for lane-av1inter8 r4's real-decoder mv comparison.
Merge branch 'lane-av1cdef': the CDEF filter, ported and pixel-provenAhmet Kaan Gümüş · 24e74ce
Merge branch 'lane-av1cdef': the CDEF filter, ported and pixel-proven apply_cdef implements spec 7.15 (direction search, primary/secondary taps, per-plane direction zeroing, all-4-mi skip rule); a real libaom stream with CDEF active decodes pixel-exact vs ffmpeg. Only cdef_bits>0 (per-64x64 cdef_idx) remains a named refusal.
feat(av1): finish CDEF in-loop filter (spec 7.15), close r1's borrow errorAhmet Kaan Gümüş · 8425e46
feat(av1): finish CDEF in-loop filter (spec 7.15), close r1's borrow error r1 left decode.rs with a full CDEF port (direction search, primary/ secondary taps, damping, chroma) but an E0502 borrow (closures captured `y.width`/`y.true_*` while `y` was mutably borrowed by the filter call) and several test call sites at the old decode_key_frame_tile/decode_inter_frame_tile arity. Fixed the borrow by copying the plane's stride/extent into locals before the closures, and threaded &CdefParams::default() through every in-crate test caller. Verified two real correctness bugs against libaom's cdef_block.c/cdef.c while porting: - is_skip_txfm only read one of the four 4x4 mi cells an 8x8 CDEF unit covers; libaom's is_8x8_block_skip requires all four skip (a sub-8x8 partition can straddle the unit with mixed skip flags). - av1_cdef_filter_fb zeroes the shared `dir` per plane when *that plane's own* frame-level primary strength is 0 (`pri_strength ? dir : 0`), independent of the per-block adjusted strength and of the other plane; the port was passing the same nonzero dir to both. New hard test (a_real_libaom_gradients_stream_with_cdef_decodes_pixel_exact) encodes a real libaom-av1 stream with CDEF left on (no -enable-cdef 0) and asserts pixel-exact against ffmpeg's own decode -- passed first run after the two fixes above. Full cargo test -p ec-av1 --release: 166 passed, 0 failed, 12 ignored.
feat(av1): extend the 8x8-leaf straddle path to inter framesAhmet Kaan Gümüş · cc290f5
feat(av1): extend the 8x8-leaf straddle path to inter frames Mirrors lane-av1-rect's key-frame 16x16-straddles-one-axis -> up-to-two 8x8-leaf path (code_square side==8, tile.rs write_leaf8) on the inter side: code_square_inter takes a `side` param (8 or 16) and picks Luma8Inter/Chroma4 or Luma16Inter/Chroma8 accordingly; the encoder's inter loop builds `eight` leaves per straddling 16x16 the same way the key-frame search does, each leaf's own NEARESTMV mv-stack window at 2x2-mi; the tile writer (write_inter_frame_leaf8) and decoder (decode_inter_block8) mirror that leaf-by-leaf, with the same prev_leaf skip/intra-inter context override write_leaf8 uses for mode context (Neighbours' above/left arrays only resolve to SUB=16 granularity). New TxbSet::Luma8Inter/INTER_TX_TYPE_SET3_8 CDF (libaom default_inter_ext_tx_cdf[EXT_TX_SET_DCT_IDTX][TX_8X8] = 4167, distinct default+adaptation state from the 16x16/32x32 rows already carried). Encoder-side round-trips clean (both-axis-cut still refuses correctly); a real multi-frame decode round-trip through ffmpeg desyncs starting at the third coded frame (the second inter frame, U plane) -- logged as an open dead-end for the next round, not chased further this round.
Merge branch 'lane-av1real': the unread use_filter_intra bit, CfL, real-stream exactnessAhmet Kaan Gümüş · 588c3e4
Merge branch 'lane-av1real': the unread use_filter_intra bit, CfL, real-stream exactness Eleven rounds: CDEF/TxMode::Select/screen-content/delta/segmentation are named refusals instead of silent miscodes; CfL prediction landed; the pinned real libaom stream decodes pixel-exact on all planes. The root cause was one unread flag bit that every same-transcription oracle validated — only a foreign implementation (debug aomdec) could see it.
fix(av1): read the unread use_filter_intra flag; audit the same blindness classAhmet Kaan Gümüş · beeeec5
fix(av1): read the unread use_filter_intra flag; audit the same blindness class lane-av1real r10 added the FILTER_INTRA/FILTER_INTRA_MODE CDF tables and Cdfs fields but stopped mid-wiring; this finishes threading enable_filter_intra (from the sequence header) through decode_key_frame_tile -> decode_block/decode_leaf8 -> read_intra_mode, which now reads use_filter_intra after DC_PRED at <=32x32 (spec 5.11.14, av1_filter_intra_allowed) and refuses use_filter_intra==1 blocks (this decoder does not implement the 5.11.14 recursive predictor) rather than silently miscoding. The pinned CfL stream's actual bug was exactly this: its block reads use_filter_intra=0, so the flag's own bits were never consumed before, desyncing every later symbol read self-consistently -- both the Python cross-checks and debug aomdec traces shared that blindness. With the flag read, the pin decodes pixel-exact (luma/U/V) against ffmpeg, and the previously-#[ignore]d a_real_libaom_cfl_stream_decodes_pixel_exact test now passes green with no split needed. Blindness-audit sweep of read_intra_frame_mode_info (libaom decodemv.c) found three more per-block/per-superblock symbols this crate silently never reads while accepting the header fields that would gate them: allow_screen_content_tools (intrabc/palette_mode_info), delta.q_present/ delta.lf_present (per-SB delta_q/delta_lf), and segmentation.enabled (per-block segment_id) -- named refusals added in decode_stream next to the existing CDEF/TxMode::Select refusals. Full ec-av1 suite: 165 passed, 0 failed, 12 ignored.
debug(av1): r9 falsifies hypothesis A and rules out qmatrix/delta_q/segmentationAhmet Kaan Gümüş · 120854a
debug(av1): r9 falsifies hypothesis A and rules out qmatrix/delta_q/segmentation Task 1 (frame inventory): manual byte-level OBU parse of pin_cfl.obu (77 bytes total) shows exactly TD(size 0) + SEQUENCE_HEADER(size 10) + one OBU_FRAME(type 6, size 61) to EOF -- no second frame OBU, no show_existing_frame, nothing hidden. ffprobe/ffmpeg (libdav1d) also read exactly 1 frame from the file. decode_stream returns 1 Picture; the test compares frames[0] against ffmpeg_frames[0], the same single frame both decoders parsed. Hypothesis A (ffmpeg showing a different frame) is FALSIFIED for this fixture -- three independent confirmations (manual OBU byte parse, ffprobe frame count, our own frame count) agree on single-frame-single-shown. Task 2 (reconstruction diff), new evidence this round: added EC_AV1_TRACE prints for quantization/segmentation/delta params to scratch_isolate_pinned_mismatch (stream.rs) and confirmed for pin_cfl.obu: using_qmatrix=false, delta_q_y_dc=0 and delta.q_present=false, segmentation.enabled=false, coded_lossless=false, tx_mode=Largest -- so none of those alternate-quantization paths (which decode.rs does not implement) are actually exercised by this stream; ruling them out removes several live hypotheses for the amplitude gap rather than leaving them open. Independently verified the transform math itself: for the block's proven levels ((0,0)=-2,(0,1)=-2,(0,2)=-2, dc_sign negative), dequant at base_q_idx=60 gives [-57,-67,-67], and BOTH a from-scratch scipy `idctn(norm='ortho')` computation and this crate's own `dequant_and_inverse` agree the resulting residual is [-2,-2,-2,-2,-2,-1, -1,-1,-1,-1,0,...,0] across the row -- i.e. our transform pipeline is mathematically self-consistent and correct *given* those coefficients. That residual added to DC_PRED=128 reconstructs to ~126, which is what this decoder outputs; ffmpeg's real decode of the identical bytes is a smooth 41-82 diagonal gradient that cannot come from this residual under any correct reconstruction. So the remaining gap is neither hypothesis A (ruled out above) nor a transform/dequant bug (ruled out here) -- it must be a symbol read upstream of the proven-clean coefficient values (partition_w32, most likely: a single 32x32 PARTITION_NONE forces the whole frame through one DC_PRED block, while a wrong partition context table could silently produce the same "coefficients bit-exact for the symbols we read" result while reading the wrong symbol in the first place). r10: re-derive partition_w32's CDF/context table from entropymode.c independently of both this crate's and r8's prior Python cross-check (which may share the same transcription error), and try forcing a SPLIT decode of this exact stream to see whether a 4-subblock reconstruction (each with its own propagated DC neighbour) produces ffmpeg's smooth gradient shape. Left the EC_AV1_TRACE prints (quantization/delta/segmentation/lossless) in scratch_isolate_pinned_mismatch and a new #[ignore]d scratch_probe_32x32_dequant in transform.rs documenting the independent math check -- both scratch/debug-only, gated behind #[ignore] or env vars, no behavior change. cargo test -p ec-av1 --release: 164 passed, 0 failed, 13 ignored.
debug(av1): r8 clears tile-offset and mode_info as the pinned CfL stream's bugAhmet Kaan Gümüş · fc77857
debug(av1): r8 clears tile-offset and mode_info as the pinned CfL stream's bug Independent from-spec OBU/frame-header parse in Python derives the tile group's start at byte 23 (obu_header -> leb128 -> full sequence_header -> full uncompressed_header bit-by-bit); EC_AV1_TRACE's new key_tile_bytes line proves decode_stream's obu_offset + tile.offset feeds decode_key_frame_tile that same byte 23, and r7's python literal agrees -- three-way match. Extended EC_AV1_TRACE to partition/skip/y_mode/uv_mode (decode.rs read_intra_mode + both partition sites) and cross-checked against an independent Python MSAC decoder whose partition_w32/kf_y_mode/uv_mode_cfl CDF literals this round re-verified byte-for-byte against /tmp/libaom-src/av1/common/entropymode.c (not inherited from a prior round): partition=NONE, skip=0, y_mode=DC_PRED, uv_mode=DC_PRED, matching ours exactly. Both r8 hypotheses from r7's handoff are falsified -- the bitstream genuinely codes DC_PRED with a near-zero residual for this block, and our decode of that is bit-exact. ffmpeg's real output (a smooth diagonal gradient) cannot come from that symbol sequence under any correct DC_PRED reconstruction, so the desync is downstream of symbol decode entirely: intra prediction or the inverse-transform/dequant path. Traces kept (not fixed yet); ignore reason on the pinned CFL test points r9 at crate::intra::predict and dequant_and_inverse_typed.
docs(av1): r7 closes the coefficient-decode hypothesis, points r8 at mode_info/tile offsetAhmet Kaan Gümüş · 222de20Browse files
debug(av1): symbol-level trace clears the coefficient decode, narrows the CfL desync upstreamAhmet Kaan Gümüş · 924ba44
debug(av1): symbol-level trace clears the coefficient decode, narrows the CfL desync upstream lane-av1real r7: added an EC_AV1_TRACE-gated trace to read_coeffs/read_eob and cross-checked the pinned CfL stream's entire Luma32 base/base_eob/br sequence against an independent Python decoder (real libaom default CDFs extracted from token_cdfs.h, get_nz_mag/get_nz_map_ctx_from_stats/get_br_ctx ported from txb_common.h, not from this crate's own code). Every symbol (ctx, value) matches ours bit-for-bit: eob_pt=5, eob_extra=1, eob=15, base_eob ctx=1→1, then base ctx sequence 21/21/21/21/6/6/6/7/7/6/6/1/2/0 with values 0,0,0,0,0,0,0,0,2,0,0,0,2,2 -- three nonzero levels (all magnitude 2) at pos 0/1/2, dc_sign ctx=0→negative. The coefficient decode and its context arithmetic are proven correct for this stream. The mismatch is downstream: dequant_and_inverse_typed on those exact levels (base_q_idx=60) produces a near-flat residual (row0 barely varies, rows 1-31 replicate it, matching what a DCT with energy confined to row 0 should do) landing luma at a uniform ~126 against ffmpeg's real ~50-and-varying output -- too large a gap for three magnitude-2 coefficients to ever close, even correctly transformed. That points to a desync *before* this trace starts (mode_info: partition/skip/y_mode/uv_mode, or the tile-group byte offset itself), not to the coefficient syntax this round instrumented. r8 should trace mode_info symbols the same way and cross-check tile-group start offset against the frame/OBU header parse, rather than the coefficient loop. Trace code is env-gated (EC_AV1_TRACE) and left in place, off by default, for r8 to reuse. CfL test stays #[ignore]d with an updated note.
docs(av1): r6 falsifies the scan-parity hypothesis; note the empirical test and reopen for a symbol-level traceAhmet Kaan Gümüş · 7e7c0c1
docs(av1): r6 falsifies the scan-parity hypothesis; note the empirical test and reopen for a symbol-level trace Read libaom's default_scan_4x4/8x8/32x32 arrays as row-major and found this crate's default_scan even/odd diagonal-walk parity backwards; swapping it in tile.rs and decode.rs regressed the previously ground-truth-exact a_real_libaom_gradients_stream_decodes_pixel_exact (Luma64 whole-SB) test while leaving the CfL/Luma32 test's failure unchanged. Reverted the scan change. Bug is not a pure scan-table parity flip; r7 should resume the symbol-by-symbol Python MSAC cross-check through base/base_eob/br/dc_sign against a temporary Rust trace instead of re-deriving table conventions.
fix(av1): pinned-mismatch scratch test used wrong frame dims; rule harness out, luma bug inAhmet Kaan Gümüş · 2e1d73a
fix(av1): pinned-mismatch scratch test used wrong frame dims; rule harness out, luma bug in scratch_isolate_pinned_mismatch hardcoded 64x64 for a stream that is actually 32x32 (confirmed via ffprobe + raw yuv size) -- an invalid wrong-region compare, now fixed. That was not the CfL gate test's own failure cause though: extending verification through the full coefficient loop rules out the ffmpeg harness (dims already correct there), every Luma32 q-context-1 CDF table (byte-exact vs libaom's token_cdfs.h), and this crate's base/br/eob context arithmetic (hand-verified against libaom's txb_common.h). A live trace found the pinned fixture's uv_mode decodes DC_PRED, not CfL, this run (libaom's already-documented cpu-used 8 nondeterminism), and the real luma mismatch is a genuine wrong-symbol decode inside read_coeffs's base/br loop for a TxbSet::Luma32 BLOCK-granularity transform -- narrowed for r6 in the updated ignore note.
fix(av1): refuse TxMode::Select streams instead of silently desyncingAhmet Kaan Gümüş · 93bc3b1
fix(av1): refuse TxMode::Select streams instead of silently desyncing decode_block never reads tx_depth symbols; a TxMode::Select stream decodes syntactically clean into low-energy garbage (the r3 flat-luma shape's sibling). Named refusal, same pattern as CDEF. The pinned CfL stream's symbols are cross-checked bit-for-bit through the EOB group via an independent from-scratch MSAC decoder; remaining suspects are the coefficient-level symbols and the harness itself (see ignore note).
wip(av1): CfL CDFs, alpha reads, and prediction math — r2 checkpointAhmet Kaan Gümüş · e37bffe
wip(av1): CfL CDFs, alpha reads, and prediction math — r2 checkpoint CfL sign/alpha CDFs converted from AOM_ICDF storage, read_cfl_alphas wired, cfl.c subsample/average/alpha math ported. The pinned CfL-stream gate stays ignored: its LUMA decodes near-flat where ffmpeg shows a gradient, so a bug upstream of the chroma math remains — r3 isolates.
Merge branch 'lane-av1real' (r1): CDEF-active refusal + pixel-exact real-stream gateAhmet Kaan Gümüş · b5e06f8
Merge branch 'lane-av1real' (r1): CDEF-active refusal + pixel-exact real-stream gate The decodes-but-wrong mismatch was CDEF: never applied on our decode path, and cdef_bits==0 keeps bit-sync so pixels silently drift. Active CDEF now refuses by name; a determinism-pinned real libaom stream decodes pixel-exact vs ffmpeg as a hard assertion.
fix(av1): refuse a decodes-but-wrong CDEF path instead of miscoding itAhmet Kaan Gümüş · cef0239
fix(av1): refuse a decodes-but-wrong CDEF path instead of miscoding it A real libaom-av1 stream with active CDEF strength decoded without error (cdef_bits==0 needs no per-block bitstream index) but produced wrong pixels -- neither tile decoder applies the in-loop CDEF filter (spec 7.15) at all. decode_stream now refuses any frame whose CDEF params would actually filter samples, naming the real gap instead of silently miscoding it. Pinned a deterministic real-libaom-av1 fixture (gradients + its own seed=, -threads 1/-row-mt 0/no tiling -- cpu-used 8's RD search is not otherwise stable run-to-run on this box) with CDEF disabled, and hardened the report-only E2E test into a pixel-exact assertion against ffmpeg's own decode of the identical bytes for that fixture. CfL (this round's other target) stays refused: implementing it needs libaom's cfl.c ported (subsample+average+alpha scale, spec 5.11.45/7.11.5) plus new cfl_sign/cfl_alpha CDFs, out of this round's remaining budget -- left as a named gap, not attempted half-done.
Merge branch 'lane-h265rdoq' (r3): frozen-prefix cursor for RDOQ trialsAhmet Kaan Gümüş · 35539ec
Merge branch 'lane-h265rdoq' (r3): frozen-prefix cursor for RDOQ trials Bit-identical (entry-gate equality test + stream hashes at two sizes), -2.45% instructions. Bookkeeping-only caching is now exhausted; the remaining RDOQ cost is the bin coding itself.
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.
Merge branch 'lane-h265rdoq' (r2): incremental RDOQ header stateAhmet Kaan Gümüş · 8dd1aae
Merge branch 'lane-h265rdoq' (r2): incremental RDOQ header state csbf/last_full maintained incrementally across trials instead of an O(n²) rescan per trial; bit-identical (stream hashes match at two sizes), −1.1% cycles. The dominant cost is the per-trial CABAC re-encode itself — next round's dedicated target.
perf(h265): hoist rdoq's per-trial csbf/last_full rescan into incremental stateAhmet Kaan Gümüş · 3a8dac3
perf(h265): hoist rdoq's per-trial csbf/last_full rescan into incremental state encode_residual rescanned the whole block for its coded-sub-block flags and last significant position on every rate-distortion trial, even though a trial only ever changes one coefficient. rdoq() now maintains that header state (a per-sub-block nonzero count plus a lookahead into the still- untouched lower scan positions for the one case where the last position itself moves) and feeds it straight to a new encode_residual_with, instead of re-deriving it from levels each call. Bit-identical output verified by hashing two natural-content streams before/after (1920x1080 and 416x240); measured -1.1% cycles / -1.4% instructions on a 1080p bench frame under perf stat — real but modest, since encode_residual's own CABAC coding (not this header scan) is the dominant cost per r1's structure notes.
Merge branch 'lane-av1adst': ADST and identity inverse transformsAhmet Kaan Gümüş · 45dd615
Merge branch 'lane-av1adst': ADST and identity inverse transforms iadst4/8/16 + iidentity ported stage-for-stage from libaom source, test vectors pinned from a C probe against libaom's own symbols; axis convention read off vtx_tab/htx_tab and gated by asymmetry tests. The decoder reads tx_type from the CDF and dispatches; DCT-only refusal gone.
feat(av1): decode ADST_ADST/ADST_DCT/DCT_ADST/IDTX intra transformsAhmet Kaan Gümüş · a170052
feat(av1): decode ADST_ADST/ADST_DCT/DCT_ADST/IDTX intra transforms Ports av1_iadst4/8/16 and av1_iidentity4/8/16/32 from libaom's own av1_inv_txfm1d.c (stage-for-stage, not hand-derived), wires TxType through read_coeffs -> dequant_and_inverse_typed, and lifts the DCT_DCT-only refusal for TX_SET_INTRA_2's five members. Axis convention (row=htx_tab, col=vtx_tab) read directly off libaom's av1_inv_txfm2d.c tables and gated by an asymmetric-input test. Reference vectors for the 1D ports came from a C probe linked against libaom's own build/decoder-debug/libaom.a, not memory.
chore: drop a stray orchestration scratch file swept in by git add -AAhmet Kaan Gümüş · cff141e
chore: drop a stray orchestration scratch file swept in by git add -A Planning notes, not a repo doc surface; preserved off-repo.
feat(bench): real h265 software-decode row; drop a dead helperAhmet Kaan Gümüş · 746f093
feat(bench): real h265 software-decode row; drop a dead helper The 'encode-only crate, no decoder present' placeholder was a false claim since lane-h265dec merged; the row now times decode_idr_au over the bench's own encoded stream (10.48x realtime at 640x360).
Merge branch 'lane-h265dec' (r5): MPM syntax-mode/pixel-availability splitAhmet Kaan Gümüş · 1f5134fBrowse files
fix(h265): MPM reads syntax-level modes, not pixel availabilityAhmet Kaan Gümüş · c6dece1
fix(h265): MPM reads syntax-level modes, not pixel availability r4's fix marked NxN partitions pixel-available before reconstruction, which let prediction-reference construction (8.4.4.2.1) see samples that do not exist yet — exposed by the merged proxy-ranking encoder's mode choices at 70x50's bottom edge. MPM now reads the assigned-mode grid directly (8.4.2 needs only syntax-level modes, signalled for all four partitions before any reconstructs); pixel availability stays honest.
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.