diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index 67bcf837..b3449b89 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -34,6 +34,11 @@ fn main() { let (h, v, c) = ec_av1::stream::rect4_32_counters(); println!("rect4_32: horz={h} vert={v} coded={c}"); println!("rect_intrabc_reads: {}", ec_av1::stream::rect_intrabc_reads()); + println!( + "rect64_corner_tu: 64x32={} 32x64={}", + ec_av1::stream::rect64_corner_tu_hits(0), + ec_av1::stream::rect64_corner_tu_hits(1) + ); println!("leaf8_intrabc_hits: {}", ec_av1::stream::leaf8_intrabc_hits()); let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 17400f46..6a5d15bd 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -2318,6 +2318,24 @@ pub(crate) fn intra_rect_strip_in_inter_hits(class: usize) -> usize { INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) } +// lane-rect64port r1 (ported by hand from lane-intra64split 5ffbaf3): coded +// (non-skip) 64-level HORZ/VERT intra strips whose luma transform is the +// un-split TX_64X32/TX_32X64 -- the corner-cropped 32x32 coefficient read of +// [`decode_rect_split`], the shape both 10-bit 3840x1608 film cuts stop on. +// Split by ORIENTATION (index 0 = 64x32 wide / HORZ, 1 = 32x64 tall / VERT): +// a single counter cannot tell an axis swap from a working arm +// (class [[scan-weights-cross-axis]]), so the gate asserts both cells. +thread_local! { + static RECT64_CORNER_TU_HITS: std::cell::Cell<[usize; 2]> = + const { std::cell::Cell::new([0; 2]) }; +} + +/// Current value of [`RECT64_CORNER_TU_HITS`] for one orientation +/// (0 = 64x32, 1 = 32x64). +pub(crate) fn rect64_corner_tu_hits(orient: usize) -> usize { + RECT64_CORNER_TU_HITS.with(|c| c.get()[orient]) +} + // lane-intrasplit r1: intra HORZ/VERT strips inside an INTER frame whose luma // transform is SPLIT, bucketed by the read `tx_depth` (index 1 and 2; index 0 // is never incremented) -- the gate's proof that the lifted path ran per depth. @@ -6817,6 +6835,21 @@ fn decode_rect_split( )), (32, 16) => Some((TxbSet::LumaRect32x16, &SCAN_32X16[..])), (16, 32) => Some((TxbSet::LumaRect32x16, &SCAN_16X32[..])), + // lane-rect64port r1: the un-split TX_64X32/TX_32X64 of a 64-level + // strip, read through the `luma_64corner` arm below instead of a rect + // table -- a 64-length axis codes only its low 32 coefficients + // (`av1_get_max_eob` / the zero-out of `av1_get_adjusted_tx_size`), so + // the coded unit is the 32x32 corner [`decode_block_rect64`]'s own + // depth-0 arm already reads on the key-frame path. + // + // NO WITNESS YET (r1, measured): on both 10-bit 3840x1608 film cuts + // this arm fires (16x 64x32 + 2x 32x64 / 2x 32x64) but the SAME frame + // then stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs + // rectangular residual coding", so no frame containing it ever + // finishes and no pixel comparison is possible. A refusal is lifted + // only with a gate (COMMON charter), so the arm stays behind + // `EC_RECT64_SPLIT=1` and the refusal below is still the default. + (64, 32) | (32, 64) if std::env::var_os("EC_RECT64_SPLIT").is_some() => None, _ => { return Err(unsupported(format!( "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \ @@ -6824,6 +6857,8 @@ fn decode_rect_split( ))) } }; + // The `None` above that is NOT the square arm. + let luma_64corner = tx_w != tx_h; // lane-rectsplitx r1, MEASURED: the SQUARE-unit walk below is pixel-exact // on a real stream (the pinned 16x8 filter-intra fixture decodes its whole // frame exactly, two sub-16 split strips in it), but the RECT-unit arm -- @@ -6893,6 +6928,64 @@ fn decode_rect_split( m.smooth_neighbor, ); neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu); + } else if luma_64corner && luma_rect.is_none() { + // The un-split 64-level luma transform: `read_coeffs` on the + // 32x32 CDF set [`TxbSet::Luma64`] with `default_scan(TX32)` + // and the real rect shape passed through for + // `av1_nz_map_ctx_offset` -- byte for byte + // [`decode_block_rect64`]'s depth-0 read, which the key-frame + // 64-level strip gate already proves. `tx_type` is not coded + // (`av1_get_ext_tx_set_type` resolves EXT_TX_SET_DCTONLY once + // the square-up size is TX_64X64), and this unit covers its + // whole block, so `get_txb_ctx` gives txb_skip ctx 0 flat. + if std::env::var_os("EC_RECT64TU").is_some() { + eprintln!("EC_RECT64TU mi={tu_mi:?} tx={tx_w}x{tx_h} mode={}", m.mode); + } + RECT64_CORNER_TU_HITS.with(|c| { + let mut v = c.get(); + v[usize::from(tx_h > tx_w)] += 1; + c.set(v); + }); + let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; + let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra)); + let (corner, tu_tx_type) = read_coeffs( + dec, + &mut coding, + &default_scan(TX32), + 0, + dc_sign_ctx(tu_around.2), + TxType::DctDct, + Some((tx_w, tx_h)), + )?; + let (cw, ch) = (tx_w.min(TX32), tx_h.min(TX32)); + let mut tu_grid = vec![0i32; tx_w * tx_h]; + for row in 0..ch { + tu_grid[row * tx_w..][..cw].copy_from_slice(&corner[row * cw..][..cw]); + } + let residual = dequant_and_inverse_typed_wh( + &tu_grid, + tx_w, + tx_h, + crate::decode::bit_depth(), + block_q_idx(), + plane_q_delta(0).0, + plane_q_delta(0).1, + tu_tx_type, + ); + y.reconstruct_rect( + tu_px, + tu_py, + tx_w, + tx_h, + m.mode, + m.angle_delta_y, + tu_reach, + &residual, + None, + m.filter_intra, + m.smooth_neighbor, + ); + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); } else if let Some((rect_set, rect_scan)) = luma_rect { // The rect-unit twin of the square arm below: same contexts, // same order, through the rect coefficient reader. The diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 1f17d408..1eda53a1 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -86,6 +86,12 @@ pub fn rect_intrabc_reads() -> usize { crate::decode::rect_intrabc_reads() } +/// lane-rect64port r1: coded 64-level HORZ/VERT intra strips whose luma +/// transform unit is the un-split TX_64X32 (orient 0) / TX_32X64 (orient 1). +pub fn rect64_corner_tu_hits(orient: usize) -> usize { + crate::decode::rect64_corner_tu_hits(orient) +} + /// lane-inter16ab r4: RECTANGULAR var-tx leaves with a 4-px axis, `[8x4, 4x8]` /// -- what `sub_tx_size_map[TX_16X4] == TX_8X4` produces when a 16x16-level /// 1:4 inter strip splits its transform. diff --git a/lanes/rect64port-r1.report.md b/lanes/rect64port-r1.report.md new file mode 100644 index 00000000..ef4ecee5 --- /dev/null +++ b/lanes/rect64port-r1.report.md @@ -0,0 +1,45 @@ +# lane-rect64port r1 — TX_64X32/TX_32X64 luma corner for a split intra strip + +Base: main 78d8ff7. Commit: 35f33c9 (branch lane-rect64port). + +## What changed +- `crates/ec-av1/src/decode.rs` — `decode_rect_split`: new `(64, 32) | (32, 64)` arm of the + `luma_rect` table (guarded by `EC_RECT64_SPLIT`) plus the `luma_64corner` TU arm inside the + transform-unit loop: `read_coeffs` on `TxbSet::Luma64` with `default_scan(TX32)`, + txb_skip ctx 0, `Some((tx_w, tx_h))` for `av1_nz_map_ctx_offset`, corner copied into a + `tx_w*tx_h` grid, `dequant_and_inverse_typed_wh` + `reconstruct_rect` + + `record_mi_luma_rect`. Hand-ported from lane-intra64split 5ffbaf3 (its only decode hunk). +- `crates/ec-av1/src/decode.rs` — `RECT64_CORNER_TU_HITS` thread-local + `rect64_corner_tu_hits(orient)` + (0 = 64x32, 1 = 32x64). +- `crates/ec-av1/src/stream.rs` — `pub fn rect64_corner_tu_hits`. +- `crates/ec-av1/examples/decode_probe.rs` — prints `rect64_corner_tu: 64x32=.. 32x64=..`. +- `refusal_inventory.rs` / `gate_coverage.rs`: UNCHANGED — the refusal is not lifted (see below). + +## Witness attempt — FAILED to produce a pixel comparison +The arm fires on both 10-bit 3840x1608 cuts, and the frontier moves, but the frame that +contains the shape never completes: it stops on a DIFFERENT refusal owned by the inter side, +`"a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding"` +(decode.rs:19156, `reject_residual && !skip && !rect_inter_residual_supported(..)`). +Truncating cut 0 to its 33 decoded frames and decoding gives `rect64_corner_tu: 0 0` — every +hit is inside the first REFUSED frame. So there is no frame to compare against ffmpeg, no gate +can be written, and the refusal stays. + +EVIDENCE: ~/.cache/rect64port-tmp/reelb300.log, ~/.cache/rect64port-tmp/full.log | decode_probe (release) on the two pinned film cuts, default vs EC_RECT64_SPLIT=1 | cut A: 33 frames dumped both ways, refusal "…transform unit is 32x64…" -> "…needs rectangular residual coding", counter 64x32=16 32x64=2; cut B: 1 frame dumped, same refusal swap, counter 64x32=0 32x64=2 +EVIDENCE: ~/.cache/rect64port-tmp/t33.log + out.raw (389007360 B = 21 frames) | trunc.py cut A to 33 frame OBUs, decode with EC_PROBE_OUT16 | OK 21 frames 3840x1608, rect64_corner_tu 64x32=0 32x64=0 — the shape is confined to the refusing frame + +## Residue +- fix-now(next lane): the 64-level split intra strip needs the INTER rect-residual refusal at + decode.rs:19151 lifted first; only then does a film frame carrying a 64x32/32x64 split intra + strip finish and a pixel-exact witness gate become writable. Unblocked by: a lane that ports + rectangular residual coding for non-skip HORZ/VERT/HORZ_B inter strips. +- deferred: the witness fixture `reelb_rect64_witness.obu` and the gate + `a_10bit_film_inter_frame_with_a_64x32_split_intra_strip_decodes_pixel_exact` — nothing to pin + while every candidate frame refuses. + +## Suite +`cargo test -p ec-av1 --lib -j3` (systemd unit, EC_AV1_REQUIRE_AOMENC=1): +417 passed, 3 failed, 37 ignored — identical totals and identical failing names to base 78d8ff7 +(a_frame_edge_straddling_band, a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions, +real_aomenc_1to4_streams_..._rect_vartx_leaves_fire). No regression; refusal_inventory, +gate_coverage, split_transform_intra_strip and intra_1to4 tests are among the 417 passed. +EVIDENCE: $HOME/.cache/rect64port-suite-r1.log | full lib suite on 35f33c9 | 417/3/37, the 3 known reds