Commits
Commits on
cd61dc00762fbbffd07101cda5eb3c4e12923875Filtered to crates/ec-av1/src/decode.rsClear filter2026-08-27
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.
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.
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.
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.
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): 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.
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.
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.
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.
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)
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.
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.
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.
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(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.