Commits
Commits on
b91e4ecf7a2ec70e9d36330272eccbe02cad3cb92026-08-27
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).Merge branch 'lane-tmpsweep': close out the shared-temp-path race classAhmet Kaan Gümüş · 4114098
Merge branch 'lane-tmpsweep': close out the shared-temp-path race class Repo-wide audit of every process::id()-keyed temp path after 9b60697: ec-h264's ffmpeg_decode and x264_encode_qp keyed theirs by stream length and qp value -- six and two concurrent tests respectively could collide on the same name -- and now carry a per-call sequence number. The twelve other sites are safe by construction: a single test per binary, or a distinct literal name per caller.
fix(h264): key ffmpeg/x264 scratch files per call, not per processAhmet Kaan Gümüş · 3c9d243
fix(h264): key ffmpeg/x264 scratch files per call, not per process ffmpeg_decode and x264_encode_qp named their temp files by process id plus stream length / qp alone. Both helpers are called from several #[test] functions that cargo test runs on parallel threads, so two concurrent calls with the same stream length or qp shared a path -- one call's cleanup (remove_file) could delete a file another call's ffmpeg child was still reading. An atomic per-call sequence number now makes every path distinct, matching the ec-av1 fix in 9b60697. Audited every other process::id()-keyed temp path in the repo (ec-flac, ec-opus, ec-ogg, ec-mp3, ec-vorbis, ec-alac, ec-h265, ec-probe, ec-truehd): each is either called from a single #[test] in its binary or discriminated by a unique literal/tag per caller, so none of those share a path across concurrent tests.
fix(av1): key the probe stream's temp file per call, not per processAhmet Kaan Gümüş · f9d5fb9
fix(av1): key the probe stream's temp file per call, not per process ffprobe_size named its temp file by process id alone, so every test in the binary shared one path; a parallel test's cleanup could delete the stream another test's ffprobe was mid-read on. This was the recurring first-run gate flake (127/2 after 3cb60f6, 128/1 after 78fc36c) -- an atomic counter now makes each call's path distinct.
Merge branch 'lane-av1-regr': a standing real-content quality gateAhmet Kaan Gümüş · 417cf64
Merge branch 'lane-av1-regr': a standing real-content quality gate Twelve frames of a real 1080p H.264 fixture clip, scaled to 640x384 and encoded at q100, must decode back through dav1d, hold a 44.91 dB mean luma PSNR floor and a 80340-byte ceiling (measured 45.41 dB / 69861 bytes, 2026-08-27, margins -0.5 dB / x1.15). Runs in the suite proper -- 2.2 s -- so a quality or compatibility regression fails in-repo instead of surfacing in a downstream export.
test(av1): standing real-content regression gate on encode.rsAhmet Kaan Gümüş · 7b73e56
test(av1): standing real-content regression gate on encode.rs Two recent regressions (a padded-size inter FrameHeader dav1d rejected; a 1280x720 export refusal) were only caught by a downstream repo's gate. real_clip_encodes_within_its_quality_and_size_budget encodes 12 frames of a real 1080p H.264 fixture clip, scaled to 640x384, and asserts dav1d decodes every frame, mean luma PSNR stays within 0.5 dB of the measured 45.41 dB, and the stream stays within 15% of the measured 69861 bytes.
Merge branch 'lane-av1-mot2': SAD-prescreen the inter path's intra candidatesAhmet Kaan Gümüş · dda53a8
Merge branch 'lane-av1-mot2': SAD-prescreen the inter path's intra candidates search_inter_block now ranks its 13 intra candidates by SAD plus mode cost and full-RD-trials only the top K, DC always kept -- the same prescreen the key-frame path carries, wired through its own knob (EC_AV1_PRUNE_K_INTER / INTER_PRUNE_TOP_K). Here it ships ON at K=3: a 3-clip x 2-quantizer real-content sweep puts the worst cell at -0.011 dB and +0.15% bytes, and a 24-frame 720p GOP drops from 807 to 556 ms a frame. The key-frame default stays unpruned; forcing K>=13 reproduces the old stream byte for byte.
feat(av1): SAD-prescreen search_inter_block's intra loop, default K=3Ahmet Kaan Gümüş · 1120e46
feat(av1): SAD-prescreen search_inter_block's intra loop, default K=3
search_inter_block ran every one of the 13 intra candidates through a
full RD trial (forward transform, quantize, reconstruct, coeff_bits)
even though NEWMV/NEARESTMV usually wins on an inter block. Wire the
same SAD-prescreen rule search_block already uses (DC always kept,
cheapest top_k by SAD-plus-mode-cost) into this loop via a new
Plane::intra_scores + shared prune_by_sad, gated by its own
Search::top_k default (INTER_PRUNE_TOP_K, env EC_AV1_PRUNE_K_INTER) so
the key-frame path's default stays untouched.
Real-clip sweep (prune_k_quality_sweep_inter: 3 clips, q 60/150, K in
{3,4,6}) clears the same PSNR/bytes rule for every K tried (worst
-0.011dB / +0.147% bytes), so K=3 -- the cheapest -- ships as the new
inter-path default. sequence_bench_sanity: 807ms/frame -> 556ms/frame
at K=3 (-31%), 73622 -> 73759 bytes (+0.19%). top_k forced unpruned
reproduces byte-identical output vs the pre-change build (73622 bytes
both).Merge branch 'lane-av1-mot': stop repricing an inter block's chroma trial 13xAhmet Kaan Gümüş · 348639c
Merge branch 'lane-av1-mot': stop repricing an inter block's chroma trial 13x The intra-candidate loop inside search_inter_block recomputed the u/v chroma Trial -- always DC_PRED, independent of the luma mode -- on all 13 iterations. One computation, cloned. Bit-identical (probe frame's bytes unchanged), and a 24-frame 720p GOP drops 994.5 -> 797.0 ms/frame. A stage_timing_breakdown_inter probe now attributes inter-frame time; the remaining big bucket is the same loop's 13 full luma RD trials.
perf(av1): stop repricing an inter block's chroma trial 13 times overAhmet Kaan Gümüş · cc09bf2
perf(av1): stop repricing an inter block's chroma trial 13 times over An inter frame's intra-candidate loop in search_inter_block always coded both chroma planes as DC_PRED, independent of which of the 13 luma modes the loop was on -- so the identical transform/quantize/coeff_bits call ran twelve times for nothing on every inter block. Hoist it out of the loop and clone the one result in (bit-identical: same call, same inputs, same output, verified by the full 129-test suite and an equal output byte count on the stage_timing_breakdown_inter probe, 1356 bytes before and after). Also add stage_timing_breakdown_inter, an #[ignore]d probe that breaks one inter frame's time into motion search / mc::predict / transform+ quantize / coeff_bits buckets, which is how this was found: transform+ quantize was the largest bucket (454.78ms of 980.36ms), not motion search (267.26ms, of which 257.01ms is genuine sub-pel interpolation work already spent inside the diamond search). 1280x720 inter frame: 980.36ms -> 772.05ms (-21%).
Merge branch 'lane-av1-perf2': an opt-in SAD prescreen for the intra mode searchAhmet Kaan Gümüş · 091129f
Merge branch 'lane-av1-perf2': an opt-in SAD prescreen for the intra mode search Modes rank by SAD-on-residual plus a rate term and only the top K (DC always kept) pay the full RD trial: 2.5x at K=3 on the key-frame stage, every real-clip PSNR delta under 0.05 dB. Default stays the full 13-mode search -- bytes rise up to 0.7% pruned, and a 24-frame 720p GOP bench shows inter frames hide the win anyway (23.9s -> 23.4s): export time lives in motion search, which this does not touch. EC_AV1_PRUNE_K opts in; K=6 is the best of the swept tradeoffs.
test(av1): add prune_k quality sweep + 24-frame 720p sequence sanity probesAhmet Kaan Gümüş · 6c0d621
test(av1): add prune_k quality sweep + 24-frame 720p sequence sanity probes In-process thread_local override lets prune_k_quality_sweep compare Search::top_k pruned vs unpruned in one build without env-var races (#![forbid(unsafe_code)] rules out std::env::set_var here). Both stay #[ignore] perf/quality probes, not gates -- numbers reported in the lane report.
perf(av1): SAD-prescreen the 13-mode intra search, gated off by defaultAhmet Kaan Gümüş · 7f9b971
perf(av1): SAD-prescreen the 13-mode intra search, gated off by default search_block now predicts every mode once (unchanged cost) and ranks by a cheap SAD-plus-mode-bits pre-pass before spending the full RD trial (forward transform, quantize, reconstruct, coeff_bits) on the winners; Search::top_k picks how many survive plus DC, always. Default stays None (all 13 modes, byte-identical output, 129/0/5 green) until the quality gate sweep in the lane report picks a K to ship as default.
Merge branch 'lane-av1-perf': cache the DCT basis; the sweep gains four edge sizesAhmet Kaan Gümüş · 2e9837a
Merge branch 'lane-av1-perf': cache the DCT basis; the sweep gains four edge sizes forward_and_quantize recomputed side^2 cosines on every mode trial; a OnceLock-cached basis plus contiguous dot-product passes (same summation order, bit-identical output) takes a 1080p key frame from 3.97s to 1.78s and 3840x2160 from 10.6s to 7.1s. The own-size sweep now covers 64x56 (historical V-plane bug confirmed closed), 854x480, 216x96 and 192x120; the never-written high-precision-mv CDF fields are gone.
style(av1): cargo fmtAhmet Kaan Gümüş · 8593d36
style(av1): cargo fmt cargo test -p ec-av1 --release: 129 passed, 0 failed, 5 ignored.
perf(av1): cache the forward DCT basis; make it contiguous, both bit-exactAhmet Kaan Gümüş · 91b85b5
perf(av1): cache the forward DCT basis; make it contiguous, both bit-exact Added stage_timing_breakdown (a perf probe, #[ignore]d like the existing sweeps): 1920x1080 13-mode key frame was 3.97s. forward_and_quantize alone was 32.25us/call at 32x32, more than inverse+entropy combined -- because dct_basis() recomputed side*side cosines from scratch on every single mode trial, size-invariant work redone thousands of times a frame. Two levers, both exact (same summation order, so identical bits out): - dct_basis is now built once per transform size and cached (OnceLock), not recomputed per trial. - forward_transform_2d's two matrix passes are written as contiguous dot products (row of residual/basis, then a transposed row pass) instead of one strided index loop, so the optimizer can vectorize them. forward_and_quantize: 32.25us -> 15.38us per 32x32 call. 1920x1080 13-mode key frame: 3.97s -> 1.78s (2.2x). 3840x2160: 10.60s -> 7.08s (1.5x). cargo test -p ec-av1 --release: 129 passed, 0 failed, 5 ignored (the new probe). All streams stay byte-identical to their own reconstruction.
test(av1): widen the own-size sweep; close hp-mv dead codeAhmet Kaan Gümüş · 1457eaa
test(av1): widen the own-size sweep; close hp-mv dead code 64x56 now round-trips clean through ffmpeg (its historical wrong-V-plane bug is closed by later MC/edge fixes) -- added alongside 854x480, 216x96, 192x120 to the existing own-size sweep, all green. Dropped MvComponentCdfs::class0_hp/hp: this encoder always sets allow_high_precision_mv=false, so the spec syntax that reads them (mv_class0_hp/mv_hp) never fires -- genuinely dead, not staged. cargo test -p ec-av1 --release: 129 passed, 0 failed, 4 ignored.
Merge branch 'lane-av1-interedge': inter frames split edge-straddling quadrants like key framesAhmet Kaan Gümüş · 0e70b27
Merge branch 'lane-av1-interedge': inter frames split edge-straddling quadrants like key frames A 32x32 inter quadrant straddling the true frame edge at or past halfway now splits into filtered 16x16 leaves (coded intra, matching the key-frame writer's only 16x16 path) instead of refusing the whole export; 1280x720 -- 720 mod 32 = 16 -- is exactly this case. The genuine gap keeps its refusal with an accurate message and a test on both writers: an edge strictly before halfway of a 16x16 leaf needs the rectangular-transform path this encoder does not have.
fix(av1): inter tile writer codes a true-edge-straddling 32x32 quadrantAhmet Kaan Gümüş · cdfc846
fix(av1): inter tile writer codes a true-edge-straddling 32x32 quadrant sb_coeff_inter_frame_tile refused every straddling 32x32 quadrant outright, with a message claiming an 8x8 split it never actually needs for the common edge-at-or-past-halfway case (e.g. 1280x720, where 720 mod 32 == 16). Ported the key-frame writer's Quadrant::Split handling: such a quadrant now splits into up to four 16x16 leaves, coded through the inter frame's intra branch (no Luma16Inter tx_type table exists for a genuine inter leaf at that size, and these leaves only fill the true edge's sliver of real content). The genuine "strictly before half of a 16x16" class -- which does need a rectangular transform -- still refuses, with an accurate message. sb_coeff_inter_frame_tile's `blocks` parameter is now `&[Quadrant]` (reusing the key-frame writer's own type) instead of `&[BlockCoeffs]`; encode_inter_frame's search does the matching split, reusing code_square for the 16x16 leaves.
Merge branch 'lane-av1-truesize': write the true frame size, reconstruct it like a decoderAhmet Kaan Gümüş · 5a60e3d
Merge branch 'lane-av1-truesize': write the true frame size, reconstruct it like a decoder AV1 streams now declare the true display size as frame_width/height (mi dims from 2*((w+7)>>3)) instead of a 32-aligned padded size with a render_size hint players ignore. Everything the padded convention hid had to be fixed to survive it: per-level partition legality with gathered split bools, DC-sign/skip contexts gathered per 4x4 unit with true-edge zeroing (chroma at its own subsampled edge), intra reference reads clamped to the true bound with spec replication (dc() included), partial-superblock signaling in the inter tile writer, inter frame headers on the true size, and motion compensation clamping reads to the true extent instead of the encoder's own padding. Gate 127/0/4; 854x480 and other off-grid sizes round-trip bit-exact through ffmpeg/dav1d at their own size.
fix(av1): clamp inter MC reads to the reference's true extent, not its coding strideAhmet Kaan Gümüş · 8d520ef
fix(av1): clamp inter MC reads to the reference's true extent, not its coding stride sequence_round_trips_at_a_non_multiple_size (160x96) failed on inter-frame chroma/luma content: a spec decoder's reference buffer holds exactly FrameWidth x FrameHeight (mi_cols*4 x mi_rows*4) -- a superblock's partition stops early at has_cols/has_rows and never codes syntax for padding columns/rows beyond the true edge, so those samples are never part of the decoded picture. MC's Clip3 (spec 7.11.3.4) must clamp reference reads to that true extent, replicating the true edge, not to this crate's own padded-to-SUPERBLOCK coding surface. `mc::sample`/`mc::predict` used one width/height pair for both the buffer's row stride and the Clip3 clamp bound, conflating the two; split into a `stride` param (the buffer's real row length, unchanged) plus `true_width`/`true_height` (the clamp bound, now `Plane::true_width`/ `true_height` at the call site) threaded through `motion::search` and `encode::mc_trial`. Gate: 126 passed/1 failed/4 ignored -> 127 passed/0 failed/4 ignored.
2026-08-26
fix(av1): port partial-superblock support to the inter tile writerAhmet Kaan Gümüş · 68e9a25
fix(av1): port partial-superblock support to the inter tile writer
Three fixes closing the remaining true-size reds:
1. a_frame_round_trips_at_its_own_size (1920x1080): encode.rs's split-32x32
search unconditionally pushed all 4 16x16 sub-block trials into
Quadrant::Split, but tile.rs's writer (mirroring spec decode_partition's
r>=MiRows||c>=MiCols early return) only expects entries for sub-blocks
whose own mi origin is inside the true frame. Filter the search loop to
match, same predicate both sides.
2. a_picture_off_the_block_grid_is_refused: the 32x48 case in this test was
a symptom of bug 1 (a block-aligned 48-row true height was refused only
because the split path demanded 4 subs where just 2 are legal), not a
genuine 8x8-split requirement -- confirmed by adding it to
ffmpeg_decodes_exactly_what_the_encoder_reconstructed, where it now
round-trips pixel-exact. Updated the test's expectations to match.
3. sequence_round_trips_at_a_non_multiple_size (160x96, inter): three
compounding bugs in the inter path, which had zero partial-superblock
support before this round:
- sb_coeff_inter_frame_tile checked check_superblocks (whole-SB-multiple
only) and used mi_cols/mi_rows / SB_MI, dropping any partial trailing
superblock; switched to check_blocks and the same block_grid ceiling
sb_coeff_key_frame_tile uses, plus its three-way has_cols/has_rows
superblock-level signaling (PARTITION_SPLIT / gathered VERT_ALIKE or
HORZ_ALIKE / nothing) and quadrant-position filtering. A 32x32 quadrant
that itself straddles the true edge is refused (this writer has no
rectangular/further-split representation at that level), mirroring the
key frame writer's own "cannot be left whole" refusal.
- encode_inter_frame's block-search loop used picture.width/BLOCK (the
padded coding surface) for its block grid instead of the true,
mi_cols-derived grid, overrunning the tile writer's expected block
count whenever the true size is not a 64-multiple.
- encode_inter_frame built its FrameHeader from the padded picture's own
width/height instead of `render` (the true size), the same render vs.
padded-picture split encode_key_frame_inner already makes for
key_frame_headers_colour -- this alone produced a bitstream dav1d
rejected outright ("Invalid data") since inter frame_width/mi_cols
disagreed with the true size the key frame declared.
Gate 122/3/4 (round start) -> 126/1/4: one chroma-content mismatch remains
on the first inter frame at 160x96, unrelated to true-size handling (all
quadrants there are already block-aligned, no partial-block path involved)
-- a pre-existing inter-frame defect this size never exercised before,
left for its own round.fix(av1): replicate truncated true-edge samples before DC averages themAhmet Kaan Gümüş · ad1509f
fix(av1): replicate truncated true-edge samples before DC averages them dc_predict averaged only the real samples a true-edge-clamped above/left slice held, undercounting against libaom's build_intra_predictors, which replicates the last real sample out to the full side length before dc_predictor runs. That produced a uniform DC offset across whole blocks straddling the true edge (854x480, first bad block mi(8,208): -3 luma across the entire 32x32, repeated in blocks below). Extend both edges to `side` by repetition, matching Edges::build's existing behavior for every other mode, before averaging.
fix(av1): clamp intra reference reads to the true edge even off a block's own row/colAhmet Kaan Gümüş · dc2d88c
fix(av1): clamp intra reference reads to the true edge even off a block's own row/col libaom's av1_predict_intra_block (av1/common/reconintra.c) derives xr/yd -- the distance from a block's own right/bottom to the frame edge -- from mb_to_right_edge/mb_to_bottom_edge, which are built from mi_cols/mi_rows (the true, decodable extent), never any padded coding surface. n_top_px/ n_left_px is min(side, xr + side) even for a block whose own extent straddles that edge legally (has_half) -- prediction does not get real reconstructed pixels past the true edge for its own row/column either, only reach ever got that clamp before. Plane::edges() now clamps the own-portion the same way libaom's xr/yd do. Verified pixel-exact against aomdec on the 216x96 col-edge repro (mi(8,48)) that was silently wrong before (0 diffs, previously untested). Gate unchanged at 124/127 -- the remaining 3 reds (854x480, 1920x1080, non-multiple-size sequence) trace to a separate, not-yet-isolated defect: a uniform -3 luma offset across every straddling block in a column strip, first appearing at mi_row=8 mi_col=208 in 854x480 with a nonzero DC coefficient present, i.e. downstream of this fix (dequant/IDCT or mode choice, not reference-sample availability).
fix(av1): narrow the true-edge availability clamp to the reach extension onlyAhmet Kaan Gümüş · 01cb49b
fix(av1): narrow the true-edge availability clamp to the reach extension only A block's own edge read (no `reach`) can land on a block that is legally whole despite straddling the true frame edge (spec hasRows/hasCols, this crate's has_half): such a block gets a real transform over its full padded extent, not a garbage tail, and both this encoder and a real decoder reconstruct it that way, so clamping that base read to the true bound (mi_cols*4/mi_rows*4) was wrong -- verified by comparing against a worktree at the prior commit: it moved the first luma mismatch in both a_frame_round_trips_at_its_own_size (1920x1080) and an_854x480_picture_round_trips_through_its_padding earlier in the frame instead of fixing them, gate unchanged at 124/3/4 either way. Only a `reach` extension (above-right/below-left) crosses into a block that may never be coded past the true edge at all, so only that portion still clamps to true_width/true_height; re-verified against the same baseline worktree that this leaves the three pre-existing failures at their exact prior mismatch positions (byte-for-byte), i.e. a true no-op for them, while still fixing the genuine reach-based true-edge case this lane's prior commit targeted.
fix(av1): clamp intra reference-sample availability to the true frame edge, not the padded coding surfaceAhmet Kaan Gümüş · f79d3fd
fix(av1): clamp intra reference-sample availability to the true frame edge, not the padded coding surface Plane::width/height is the picture padded to a 32-aligned coding surface (Picture::padded_to); Reach::of and Plane::edges used it both to decide whether a directional mode's above-right/below-left extension is available and to clamp how far the above/left reference rows read, so a block near the true frame edge (but still inside the padded surface) read real padded-reconstruction samples a real decoder never has -- it stops at mi_cols*4 / mi_rows*4 (spec compute_image_size; libaom av1/common/reconintra.c build_intra_predictors clamps the same way via mb_to_right_edge/mb_to_bottom_edge) and replicates the last valid sample instead. Plane now carries that true bound (true_width/true_height, mi_cols*4/mi_rows*4) separately from its padded width/height, and Reach::of plus the edge-row clamp use it. A partition trial can still price a sub-block whose own origin already sits past that true bound (kept only for cost comparison against a split this frame goes on to refuse) -- across/down can now land at or below x/y for such a block, so edges() treats an empty read range as unavailable (None) rather than crashing on an empty "last sample" the same way y==0/ x==0 already do.
fix(av1): clamp chroma's dc-sign/skip context to its own subsampled true edge; fix a stale padded-decode testAhmet Kaan Gümüş · 82410a6
fix(av1): clamp chroma's dc-sign/skip context to its own subsampled true edge; fix a stale padded-decode test Neighbours::record clamped chroma the same as luma (true mi_cols/mi_rows), but libaom rounds a subsampled plane's edge up to its own 4x4 unit before clamping (ROUND_POWER_OF_TWO(max_blocks_high, subsampling_y) in av1_write_intra_coeffs_mb, encodetxb.c:456-459): a chroma unit straddling an odd luma edge is still whole in chroma's own halved grid. Fixed by rounding the luma bound up to even before clamping planes 1/2. No test in the current suite exercises an odd true mi_rows/mi_cols with chroma residual, so this doesn't move the gate; landed as a correctness fix proven safe (no regression) pending such a case. an_854x480_picture_round_trips_through_its_padding decoded at the padded 864x480 size and cropped to 854x480 by hand -- stale since 7ba33dd started writing the true display size into frame_width/frame_height, which makes ffmpeg crop to 854x480 on its own. Decoding at padded size now reads past what ffmpeg emits (out.stdout shorter than expected, not a hard decode error). Fixed the test to decode at the true size directly; it now exercises the real desync (a luma mismatch, bitstream confirmed byte-identical to a real decoder via EC_RNG trace, so a reconstruction-side bug, not an entropy desync) instead of failing on a wrong expectation. Gate: cargo test -p ec-av1 --release = 124 passed, 3 failed (same three tests, still red, no regressions), 4 ignored.
fix(av1): gather dc-sign context per 4x4 unit, clamped to the true edgeAhmet Kaan Gümüş · 77b7e14
fix(av1): gather dc-sign context per 4x4 unit, clamped to the true edge get_txb_ctx_general (libaom av1/common/txb_common.h) sums the DC-sign vote over every 4x4 mode-info unit a transform spans, not once per coded neighbour cell; av1_set_entropy_contexts (av1/common/blockd.c) clamps that per-unit state to the frame's true (unpadded) mi_cols/mi_rows, zeroing units past the edge even mid-cell. Our writer tracked one vote per 16x16 neighbour cell, so a 32x32 transform straddling the true bottom edge (mi_rows=30, block rows 24..31) summed 2 cells instead of libaom's 8, and never zeroed the two invisible mi-rows within the last cell -- producing dc_sign_ctx=0 where the real decoder reads 2 (traced at mi(24,8), tell 2969, in a 192x120 key frame). Widens Neighbours' above/left tracking from the 16x16 (SUB) grid to the 4x4 (MI) grid libaom actually keeps it on, and clamps record() to the frame's true mi_cols/mi_rows the same way av1_set_entropy_contexts does. mode/side/skip/inter tracking (single-cell lookups, not summed) stays on the coarser grid. 192x120 (the established repro) now round-trips through ffmpeg bit-exact. 1920x1080 and the 854x480/non-multiple sequence tests still fail at other positions -- a further defect of the same edge-clamping class, not yet isolated; not chased further this round per budget.
wip(av1): per-symbol EC_RNG trace through write_coeffs/write_eobAhmet Kaan Gümüş · dcd1644
wip(av1): per-symbol EC_RNG trace through write_coeffs/write_eob Every coefficient-path symbol (txb_skip, tx type, eob_pt/extra/bits, base, base-range, DC sign, golomb tail) now prints under EC_RNG in the same tag format the debug aomdec build emits, so the two traces diff line-for-line. A plane: Option<usize> argument gates the prints to the real tile writer -- the rate estimator calls write_coeffs thousands of times per frame and drowned the trace without it. The trace names the true-size desync: at mi(24,8), the first whole 32x32 quadrant straddling the true frame height, the writer's DC-sign context is 0 where the reference decoder computes 2 at the same tell. Root cause still open on this lane.
wip(av1): EC_RNG per-symbol trace localizes true-size desync to one edge quadrantAhmet Kaan Gümüş · 24b23ce
wip(av1): EC_RNG per-symbol trace localizes true-size desync to one edge quadrant Adds an env-gated (EC_RNG=1) EC_PART/EC_TOK/EC_PLANE trace to the real key-frame tile writer (sb_coeff_key_frame_tile), in the same format the debug aomdec build already prints under the same variable, so encoder and decoder traces diff line for line. Diffing a 192x120 test_card key frame (the smallest repro of the three currently-failing round-trip tests) against aomdec's own trace shows every tell (bit position) identical for 19 superblocks, then a hard divergence entirely inside the coefficient coding of one 32x32 quadrant: the block at mi (24,8), the frame's first Whole 32x32 quadrant whose has_cols32 and has_rows32 are both true while its own extent (y=96..127) still runs past the true frame edge (height 120) into the padded region -- exactly the case the round-3 bisection named. The writer's own tell after that block is 3019; the same bytes read back on aomdec land at 3039, a 20-bit gap with no matching event on our side, so something inside that one block's mode or coefficient coding chooses a context, CDF, or symbol count the real decoder does not. Root cause not yet isolated to a line -- see the ledger DELTA for what is ruled out and what stays open. No behavior change: the trace is off by default (one atomic load per call) and the three tests stay red at 124/127, unchanged from before this commit.
wip(av1): gather 32x32-level partial partitions; refusal test names the true-frame messagesAhmet Kaan Gümüş · ec3ad48
wip(av1): gather 32x32-level partial partitions; refusal test names the true-frame messages The 32x32 recursion level now recomputes has_cols/has_rows the way decode_partition does at every depth: both true writes the full partition symbol, one false writes the single gathered split_or_horz/split_or_vert bool, neither writes nothing and the split is inferred. The refusal test sweeps the two sizes whose edge forces an 8x8 split this writer does not code, and asserts on the messages both paths actually produce. Still open on this lane: true-size streams >=192 wide with a partial mi row corrupt at the first whole 32x32 edge quadrant (192x120 repro); sb_coeff_inter_frame_tile still assumes whole superblocks.
wip(av1): write the true display size as frame_width/height, not the padded oneAhmet Kaan Gümüş · 6b1cdcc
wip(av1): write the true display size as frame_width/height, not the padded one Frame headers now carry the picture's true (unpadded) size as frame_width/frame_height, with mi_cols/mi_rows derived from that true size via spec compute_image_size (2*((w+7)>>3)) instead of the padded picture's width/4 -- mirroring rav1e/libaom, so a decoder crops to the true size instead of the coded (padded-to-32/64) one. render_width/render_height come out equal to frame_width/frame_height, so render_and_frame_size_different is false and no render_size bits are written. tile.rs: check_blocks no longer requires mi_cols/mi_rows to be an exact multiple of the 32x32 block grid (a true size need not be); a new block_grid() ceiling-divides mi_cols/mi_rows into the block-column/row count actually coded, shared by sb_coeff_key_frame_tile, split_coeff_key_frame_tile and (now) encode_key_frame_inner's own block/superblock generation loop, which used to derive its cols/rows straight from the padded picture's width -- it must agree with the tile writer's own count exactly. KNOWN REGRESSION, not yet root-caused: three existing round-trip tests that used a size not a whole 32x32 (or, for the facade, 64x64) block now fail ffmpeg/dav1d decode with "Invalid data found" (an_854x480_picture_round_ trips_through_its_padding, a_frame_round_trips_at_its_own_size at 1920x1080/ 640x352/1280x720, sequence_round_trips_at_a_non_multiple_size at 160x96). Reasoned through the cols/rows/has_cols/has_rows arithmetic by hand for the BLOCK(32)-alignment case and it should be invariant (true mi_cols/mi_rows land in the same (padded-8, padded] window that keeps every BLOCK_MI(8)- aligned threshold's comparison unchanged) -- confirmed by an EC_RNG-gated rng-per-symbol trace (temporary, reverted) diverging from aomdec's own trace from the very first symbol, which does not match that reasoning and was not resolved before the turn budget ran out. The three tests' own assertions were updated to expect the new true-size ffprobe/decode behaviour (that part is not in question); the decode failure itself is the open defect. Not attempted: sb_coeff_inter_frame_tile has no has_cols/has_rows-style partial-superblock handling at all (always PARTITION_SPLIT, always 4 quadrants) -- a true size that isn't a 64x64 (SUPERBLOCK) multiple needs that ported from the key-frame writer before an inter/multi-frame stream can use a true, non-superblock-aligned size. The facade's key-frame path already regresses today for the same underlying reason before inter frames are even reached.
Merge branch 'lane-av1-interdesync': corner-only matches raise new_mv_ctxAhmet Kaan Gümüş · c47074a
Merge branch 'lane-av1-interdesync': corner-only matches raise new_mv_ctx Closes the I8 verifier's CLASS B real-content inter desync at aligned sizes.
fix(av1): new_mv_ctx case-0 takes the corner-derived ref_match_count bitAhmet Kaan Gümüş · d5bf53b
fix(av1): new_mv_ctx case-0 takes the corner-derived ref_match_count bit Real-motion content desynced from inter frame 3-4 at aligned sizes: a block whose only neighbour match is the diagonal corner has nearest_match == 0 but ref_match_count == 1, and libaom sets mode_context |= 1 there (mvref_common.c ~621) while our arm hardcoded 0 — wrong NEWMV CDF row, rng drift, decoder rejects the tile. Sibling of the ref_mv_ctx corner fix; zero_mv_ctx checked, no such dependency. New test pins the corner-only-match shape. Both I8 failing clips re-encode to 10/10 clean aomdec+ffmpeg decodes, byte-exact vs reconstruction.
Merge branch 'lane-av1-pad854': Reach tables indexed at libaom's 128px strideAhmet Kaan Gümüş · af95500
Merge branch 'lane-av1-pad854': Reach tables indexed at libaom's 128px stride 854x480 padded key frame closed: HAS_TOP_RIGHT/HAS_BOTTOM_LEFT are libaom's has_tr_*/has_bl_* tables, indexed there with row stride 128/side (its compile-time max superblock), not our 64/side — one 16x16 read bit 10 instead of bit 18 and lost its bottom-left neighbour, drifting the reconstruction by one blend step. Boundary checks stay 64-relative. New sweep test cross-checks Reach against a fresh transcription of libaom's has_top_right/has_bottom_left at every position. Gate: cargo test -p ec-av1 --release -- --include-ignored 122 passed / 0 failed.
fix(av1): Reach's has_top_right/has_bottom_left table stride was 64-relativeAhmet Kaan Gümüş · d1d8e10
fix(av1): Reach's has_top_right/has_bottom_left table stride was 64-relative Round-2 of the 854x480 padded key frame desync: a debug aomdec trace of has_top_right/has_bottom_left at the exact first-mismatch block (a 16x16 at mi (40, 88)) found libaom indexing its pinned has_bl_16x16 table at bit 18 (row * 8 + col), while Reach::bottom_left indexed the same table at bit 10 (row * 4 + col) -- different bits, one true one false. libaom's tables are pinned to its compile-time maximum superblock (128px, MAX_MIB_SIZE_LOG2 = 5), not the superblock size a stream actually uses, so the row stride for a 16x16/32x32 block is 128 / side, not SUPERBLOCK / side (this crate's 64px superblock) -- Reach::of's own row/col position within the superblock was already right; only the table's row stride was wrong. Un-ignores open_defect_854x480_padded_key_frame_desyncs, renamed an_854x480_picture_round_trips_through_its_padding, and adds reach_matches_libaom_has_top_right_and_has_bottom_left, a from-scratch transcription of libaom's has_top_right/has_bottom_left checked against Reach for every 16x16/32x32 position across three superblocks square, including every superblock edge -- the class this bug was (an index stride silently wrong for one block size, plausible for the other).
docs(av1): redirect the 854x480 pad desync hunt from CDF desync to ReachAhmet Kaan Gümüş · f1da657
docs(av1): redirect the 854x480 pad desync hunt from CDF desync to Reach An EC_RNG-per-symbol trace of this frame's writer against a debug libaom decoder (od_ec_decode_cdf_q15/od_ec_decode_bool_q15 instrumented) proved the arithmetic coder is byte-for-byte identical to libaom across all 51188 symbols -- the bitstream itself is not desynced, and the (has_cols, has_rows) partial-superblock partition code at tile.rs:783-795 this lane was told to suspect first is exercised correctly here. The real divergence: our own Encoded::reconstruction reports 147 at luma (161, 369) where both a debug aomdec decode of our own bitstream and ffmpeg agree on 148 -- an exact off-by-one that cascades rightward through everything predicted from that block. Every mismatch in the frame is `ours == correct - 1`. That points at encode.rs's Reach::of / Reach::top_right / Reach::bottom_left (the pinned HAS_TOP_RIGHT/ HAS_BOTTOM_LEFT tables deciding how far a directional intra predictor may read past a block's own edges) computing different above-right/below-left availability than the real decoder for this specific block position, not a partition/edge-superblock bug. Left #[ignore]d with the corrected diagnosis in its doc comment; instrumentation (EC_RNG-gated msac.rs tracing, matching aomdec build at /tmp/libaom-src/build/decoder-debug, dump-and-diff scripts) reverted, none of it kept in the tree.
Merge branch 'lane-av1-facade': I11 streaming encoder facade with colour signallingAhmet Kaan Gümüş · ec4c3f6
Merge branch 'lane-av1-facade': I11 streaming encoder facade with colour signalling
Av1Encoder{new,encode,coded_size,display_size} one-in-one-out;
EncoderConfig{width,height,base_q_idx,gop,colour}; Colour maps to CICP
(BT709/BT601 limited, unspecified) wired into the key-frame sequence
header; encode_sequence and the facade share encode_key_frame_inner/
encode_inter_frame. Gate: cargo test -p ec-av1 --release 123 passed / 5 ignored.feat(av1): streaming encoder facade with configurable colour (I11)Ahmet Kaan Gümüş · f421d98
feat(av1): streaming encoder facade with configurable colour (I11)
Av1Encoder is the one-in-one-out surface edith_replica's engine will call
in place of rav1e: EncoderConfig{width,height,base_q_idx,gop,colour} in,
encode(&Picture) -> Packet{data,key,order} out, gop-cadenced key frames
predicting inter frames from the previous reconstruction like
encode_sequence already did. encode_key_frame_inner/encode_inter_frame
are now shared (pub(crate)) between encode_sequence and the facade
instead of being duplicated. The sequence header's colour_config is wired
to Colour::{Bt709Limited,Bt601Limited,Unspecified} (spec 5.5.2's CICP
triple + range), replacing the hardcoded "unspecified" -- verified against
ffprobe.Merge branch 'lane-av1-size': pad-to-32 with cropped reconstructionsAhmet Kaan Gümüş · 77b8ab9
Merge branch 'lane-av1-size': pad-to-32 with cropped reconstructions The merge exposed a latent mvstack defect the two lanes could only trip together: real inter residuals (lane-av1-desync) on padded content (lane-av1-size) hit a block whose ref_mv context libaom derives from a diagonal corner probe our reduction never ran. Folded into this merge: - port libaom's scan_blk_mbmi(-1,-1) corner probe; ref_mv_ctx now splits (nearest_match, ref_match_count) exactly as mvref_common.c does - fix the REF_CAT_LEVEL DRL boost comparison (was trivially true); weights are boosted in place before the corner probe can add an unboosted entry - SymbolEncoder::tell(), the od_ec_enc_tell mirror the hunt relied on Gate: cargo test -p ec-av1 --release = 116 passed, 5 ignored.
Merge branch 'lane-av1-desync': tx_type for inter residuals, real RD skipAhmet Kaan Gümüş · f588327Browse files
fix(av1): code tx_type for inter 32x32 residuals; drop the skip-only corner-cutAhmet Kaan Gümüş · ac63d1d
fix(av1): code tx_type for inter 32x32 residuals; drop the skip-only corner-cut Spec 5.11.48: an is_inter 32x32 luma transform sits in TX_SET_INTER_3, not TX_SET_DCTONLY, so the decoder reads a tx_type bit right after all_zero. The writer reused the intra DCT-only TxbSet for inter blocks and never wrote it, desyncing every symbol after the first coded inter coefficient. New TxbSet::Luma32Inter carries the TX_SET_INTER_3 CDF row (libaom entropymode.c:369); search_inter_block now prices real residuals and derives skip from the quantized levels.
feat(av1): arbitrary even frame sizes via block-grid padding + render cropAhmet Kaan Gümüş · 51570f6
feat(av1): arbitrary even frame sizes via block-grid padding + render crop Picture::check_even() replaces the whole-32x32-blocks requirement at the public encode_key_frame/encode_key_frame_with_modes/encode_sequence entry points; any even, nonzero width/height is accepted. Picture::padded_to() pads by edge replication to the block coder's own grid (32 for a lone key frame, 64 for a sequence, so an inter frame's reference always matches the frame coded against it) and is identity when already aligned. Encoded's public reconstruction is always cropped back to the caller's own size (crop_encoded/crop_plane); render_width/render_height are set correctly in the frame header regardless. Also fixes an internal regression this surfaced: padded_to previously padded every path to 64, which broke the existing 32-aligned-but-not-64 fast path (96x64) for a lone key frame. Leaves one open, pre-existing-looking defect this lane's sweep found: 854x480 padded to 864x480 desyncs against ffmpeg's decode at a spot well inside the real (non-padded) region -- content-dependent, not padding wiring (864x480 coded directly, no padding, is bit-exact). Documented and left #[ignore]d as open_defect_854x480_padded_key_frame_desyncs rather than silently dropped from the size sweep.