forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

d792.report.md12.4 KiBHistoryRawDownload

lane-d792 — the reference-ladder decode failures on the 1920x792 (straddling) crop

Working notes, kept current from the first commit. Streams and logs under $HOME/.cache/d792/ (streams/, small/, stage/).

Reproduction (standalone, without the 7-minute BD gate)

12 frames of film A from 00:35:00, crop=1920:792:0:0 (film A IS coded 1920x792, so the gate's EC_AV1_NATIVE_CROP=1920x792 is its whole frame), encoded with the gate's own ladder recipes and decoded through examples/dump_yuv vs ffmpeg -pix_fmt yuv420p:

point our decode vs ffmpeg
libaom -cpu-used 6 -crf 5/20/35/45 EXACT, all 4
rav1e speed=6 quantizer=50/100/150/200 DIFFERS, all 4, every frame (4-6 k samples/frame, max abs 24)

So the chartered "libaom crf-5 Golomb refusal" does NOT reproduce at 046dbe0e on this source/recipe; only the rav1e ±1 class does. (Charter premise re-checked, not assumed.)

Where the rav1e divergence lives

All diffs sit in the LAST rows of the frame: luma rows 760..791 of 792, chroma 382..395 of 396 — the bottom straddle (792 = 12*64 + 24).

Stage bisect (our EC_AV1_*_DUMP vs the instrumented aomdec's twin dumps, $HOME/.cache/d792/stage/), rav1e q150 frame 0:

stage first differing row (luma)
pre-filter reconstruction 769
post-deblock 766
post-CDEF 760
final (post-LR) 760

So the loop filters only SPREAD it: the defect is in reconstruction, in mi rows 192..197 — the 24 px the frame edge cuts off the last superblock row.

Small repro (fast iteration)

$HOME/.cache/d792/small/f100.obu: 4 frames of film A cropped to 384x152 (= 2*64 + 24 straddle), rav1e speed=6 quantizer=100. Our pre-filter reconstruction differs from aomdec's in rows 144..151 only (the last 8 rows), all columns; ~1800 luma samples on frame 0.

What is ruled OUT so far

  • Parse (block level) is in sync: EC_TRACE_MODE_STEP on both decoders gives identical mode/skip/uv_mode/angle_y/angle_uv sequences for the 1518 blocks of the 1920x792 key frame (the only surplus lines in ours are intra-in-inter y_mode rungs aomdec names differently).
  • Intra prediction is byte-exact at the first differing block. The oracle was patched this round with an EC_PREDOUT8 rung (8-bit predicted block; the existing one was high-bitdepth only) and the block at mi_row=36 mi_col=0 of the small repro gives sum=6959 row0=82,74,65,56,50,47,46,45 col0=82,85,85,85,85,85,85,85 on BOTH sides. Edge lengths agree too (n_left = 8 for a 16-tall TU with 8 rows inside, i.e. libaom's AOMMIN(txhpx, yd + txhpx) clip is already ours).
  • Loop restoration's last-stripe substitution matches libaom's get_stripe_boundary_info (copy_below = 0 at the frame bottom).

Where it IS (open, in progress)

The residual. EC_TRACE_COEFF on both decoders over the small repro: eob sequences are IDENTICAL (514 transform units) but the symbol streams below them are not — ours reads extra br (base-range) symbols and fewer sign/base ones (aom 23085 base / 7966 sign / 3338 br; ours 23634 / 7715 / 3351). First divergence is an extra br at trace line ~22951 of 44647. Next: resolve that line to its transform unit and read the rule that differs there.

Elimination chain (all measured on the 384x152 small repro, frame 0)

The first differing sample is inside the luma block at x=0 y=144, a 16x8 intra block in the bottom straddle (PARTITION_HORZ is forced there by the frame edge). For that block:

  1. Prediction: identical. OUR_PRED sum=6959 row0=[82,74,65,56,50,47,46,45] col0=[82,85,85,85,85,85,85,85] == the oracle's new EC_PREDOUT8 line for mi_row=36 mi_col=4(sic: mi_col=0), to the sample.
  2. Coefficient bitstream: in sync. EC_TRACE_COEFF's all_zero range value agrees at ALL 750 transform units; eob agrees at all 514.
  3. Transform type: identical. The oracle now prints the resolved txtype/txsize; the 514-long sequence matches ours entry for entry. All 19 TX_16X8 units are DCT_DCT.
  4. Transform unit shapes: identical. Both decoders code 19 16x8, 27 8x4 and 1 32x16 rectangular units (the oracle's new EC_DQCOEFF rung vs our new OUR_LEVELS rung).
  5. Level grids: identical. The first three 16x8 units' non-zero (row/col, level) sets match the oracle's EC_DQCOEFF dump converted out of libaom's column-major input[c * h + r] layout -- which also re-verifies SCAN_16X8 against av1_default_scan_16x8.
  6. The 16x8 inverse transform is correct. New pin transform::d792_tests::a_16x8_inverse_matches_libaoms_own_dqcoeff_and_residual feeds our inverse_transform_2d_typed_wh libaom's own dequantized grid and asserts libaom's own residual (aomdec reconstruction minus the identical prediction): PASSES.
  7. The q index is frame-constant. aomdec's current_base_qindex is 127 for all 1518 blocks of the 1920x792 key frame; no delta-q is in play.

So the residual our decoder ADDS differs (ours col0 = [-6,-3,4,13,21,26,28, 28], libaom's [-7,-2,6,17,27,34,36,37], roughly a 0.77 factor) while the levels, the shape, the type and the transform kernel all agree. The remaining link is the DEQUANT step between them -- dequant_and_inverse_typed_wh at the intra rect call sites (decode.rs:9487/9543/9713/10826...), where the suspects are the (w, h) argument order (class adjacent same-typed args; a transposed grid would weaken exactly the vertical response we see) and the q index / DC-AC delta that site passes.

Instruments added this round

  • Oracle (~/.cache/aom-oracle/src, build2): EC_PREDOUT8 on both 8-bit prediction paths, txtype=/txsize= on the tag=tx_type rung, and EC_DQCOEFF (the dequantized grid the inverse transform runs on).
  • Ours: OUR_RECON (reconstructed row0/col0 beside EC_PRED's prediction) and OUR_LEVELS (a rect unit's level grid, EC_DQCOEFF=1).

NOT done this round (budget)

  • deferred: the root cause and its fix -- the dequant link above is the one unchecked step -- unblocked by dumping the dequantized grid at the rect intra call site and diffing it against the oracle's EC_DQCOEFF line
  • deferred: the libaom crf-5 "Golomb tail" refusal -- it does NOT reproduce standalone at 046dbe0e (all four libaom points decode exact), so it needs the gate arm itself re-run to confirm it is stale
  • deferred: the synthetic straddling fixtures (384x152 / 384x184 gates), the 1920x792 green arm, the suite and the workspace check -- they gate a fix that does not exist yet

ROOT CAUSE (round 2) — the rect intra dequant dropped the block's segment quantizer

OUR_DQ (our new dequantized-grid rung) against the oracle's EC_DQCOEFF for the same 16x8 unit: the level grids agree, but ours dequantizes with q = 75 where libaom uses the quantizer of q-index ~96 (dc 111 / ac 104 vs our 82 / 82) -- the 0.77 residual factor exactly.

OUR_Q (the segment rung) named it: frame 0 of the small repro has THREE segments (base = 75; seg 0 -> 67, seg 1 -> 81, seg 2 -> 96 through SEG_LVL_ALT_Q), and the rect intra path was dequantizing with fctx.current_q_idx -- the FRAME's index -- instead of [block_q_idx], which adds the block's own segment feature. Every square path already used block_q_idx, which is why the defect was invisible until a frame edge forced rectangular partitions: only the cut superblock row codes 16x8 / 8x4 units in these streams.

Class: parsed-then-discarded -- the segmentation ALT_Q is parsed, applied at 21 dequant sites, and dropped at 6 of them. (Sibling shape to override slot on one arm: the rect ARM of a two-arm path missed the adjustment its square twin had.)

Fix: block_q_idx(fctx) at all six, in crates/ec-av1/src/decode.rs (the split rect path's chroma, the 16x8/8x16 luma+chroma trio, and two 8x4/rect leaf sites at 16240 / 31147).

Sweep: every dequant_and_inverse* call site in the decoder (27) now takes either block_q_idx or a TxParams::q_idx that was itself built from block_q_idx; grep -n "current_q_idx" decode.rs leaves only the frame-level cell itself, block_q_idx's own read of it and a RECT64_QIDX_DRIFT_HITS counter.

Result

  • small repro 384x152 rav1e q100 and q150: EXACT vs ffmpeg, all frames.
  • the whole 1920x792 reference ladder -- libaom crf 5/20/35/45 AND rav1e quantizer 50/100/150/200, 12 frames each: EXACT vs ffmpeg on every point ($HOME/.cache/d792/streams, decoded with examples/dump_yuv).

The gate, and what it took to make it see the defect

stream::tests::a_straddling_frame_decodes_exactly_on_both_reference_encoders_ladders (2.7 s) has two halves:

  • Generated rows -- 4 frames at 384x152 (2 SB + 24 px, the 1920x792 straddle) and 384x184 (2 SB + 56 px, the 1080p straddle), through librav1e (quantizer 50/100/150/200) and libaom (-cpu-used 6 -crf 5/20/35/45 -aq-mode 1), each decoded by ffmpeg and by us and compared sample by sample.
  • Recipe rows (lane-golomb2) -- a SYNTHETIC source built for the feature: half flat grey, half heavy noise (hstacked in lavfi), encoded by libaom -cpu-used 6 -crf 20/35 -aq-mode 1 at both straddling sizes. libaom's activity segmentation answers that contrast with segments whose quantizers differ, which the row asserts through the decoder's own decode::block_q_span() (measured: q 33..106 at crf 20, 89..160 at crf 35).

That split is not decoration. The generated ladder rows alone do NOT catch this defect: with the fix reverted under them, first a testsrc2 source and then the repo's own h264-1080p-23.976-8bit.mp4 fixture (which is colour bars, per the standing note) both PASSED at all 16 points, because neither codes more than one segment, and the defect only exists where SEG_LVL_ALT_Q does (class gate-blind-to-feature). The recipe rows fail pre-fix at segmented 384x152 crf 20, frame 0 plane U sample (160, 64): ours 126 vs ffmpeg 123 (the six sites of e4cab216 reverted by hand, gate re-run) and pass after, so the gate's defect-catching power is measured, not assumed.

The two pinned streams this gate used to carry (fixtures/d792_straddle_rav1e_384x152_q{100,150}.obu) were crops of a real film: untracked, uncommittable, and SKIPped on any fresh clone, i.e. blind where it mattered most (class gate-skips-on-its-own-failure). They are deleted; the recipe rows replace them.

Verification

check result
cargo test -p ec-av1 --release --lib a_straddling_frame 18 straddling reference points sample-exact, 2.7 s
the same gate with the fix reverted FAILED at (17, 140) of the pinned q100 row
the 1920x792 ladder, 12 frames, decoded standalone (examples/dump_yuv vs ffmpeg) libaom crf 5/20/35/45 EXACT, rav1e quantizer 50/100/150/200 EXACT -- all 8 points, i.e. what external_ladder's reference-decode assertion checks
cargo check --workspace --all-targets -j4 0 errors; 0 ec-av1 warnings (the 21 ec-opus missing-doc + 1 ec-vorbis dead-code ones are pre-existing)

The 1920x792 arm itself (EC_AV1_NATIVE_CROP=1920x792, film A row)

cargo test -p ec-av1 --release --lib -- --ignored --exact encode::tests::bd_rate_screen_native, 494 s, log $HOME/.cache/d792/native.log:

  • 8 of the 9 failures are gone. All four rav1e points now decode exactly; the BD row itself is unchanged (+22.5% vs libaom, -2.3% vs rav1e, 44.03/45.60/46.92/48.20 dB at 68847/109557/178345/426318 B -- lane-corner's post-lift numbers to the digit).
  • One remains, and it is NOT a straddle defect: libaom-av1 ["-cpu-used","6","-b:v","0","-crf","5"]: our decoder refused the stream (a Golomb tail longer than this decoder reads). The same recipe run standalone this round decoded EXACT, so libaom's crf-5 output is not reproducible run-to-run here and the refusal is hit by some of its streams: a coefficient-magnitude limit at the very lowest quantizer, not an edge case of the frame geometry. deferred: the crf-5 Golomb-tail refusal -- read the refusal site's own bound against libaom's read_golomb (which reads up to 20 bits + the level bound), reproduce by looping the crf-5 encode until a refusing stream is captured, pin that stream as a fixture -- it is lane-dgolomb's standing debt and needs its own round

Suite

cargo test -p ec-av1 --release (detached, 893 s): 572 passed, 0 failed, 46 ignored, RC=0 -- 570 before plus this lane's two (the 16x8 transform pin and the straddle gate). The pin test the_encoders_own_streams_are_byte_identical_to_their_pins is inside it, so the 8562 / 33357 byte pins are unchanged.