Merge branch 'lane-rect64port' (d08f9c6): TX_64X32/TX_32X64 split-intra-strip luma corner ported onto main behind EC_RECT64_SPLIT (no film witness yet; the next wall is the inter rect-residual refusal)
Browse files at this commit4 changed files +149 -0
- crates/ec-av1/examples/decode_probe.rs +5 -0
- crates/ec-av1/src/decode.rs +93 -0
- crates/ec-av1/src/stream.rs +6 -0
- lanes/rect64port-r1.report.md +45 -0
crates/ec-av1/examples/decode_probe.rsmodified+5 -0
| @@ -34,6 +34,11 @@ fn main() { | |||
| 34 | let (h, v, c) = ec_av1::stream::rect4_32_counters(); | 34 | let (h, v, c) = ec_av1::stream::rect4_32_counters(); |
| 35 | println!("rect4_32: horz={h} vert={v} coded={c}"); | 35 | println!("rect4_32: horz={h} vert={v} coded={c}"); |
| 36 | println!("rect_intrabc_reads: {}", ec_av1::stream::rect_intrabc_reads()); | 36 | println!("rect_intrabc_reads: {}", ec_av1::stream::rect_intrabc_reads()); |
| 37 | + println!( | ||
| 38 | + "rect64_corner_tu: 64x32={} 32x64={}", | ||
| 39 | + ec_av1::stream::rect64_corner_tu_hits(0), | ||
| 40 | + ec_av1::stream::rect64_corner_tu_hits(1) | ||
| 41 | + ); | ||
| 37 | println!("leaf8_intrabc_hits: {}", ec_av1::stream::leaf8_intrabc_hits()); | 42 | println!("leaf8_intrabc_hits: {}", ec_av1::stream::leaf8_intrabc_hits()); |
| 38 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); | 43 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); |
| 39 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); | 44 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); |
crates/ec-av1/src/decode.rsmodified+93 -0
| @@ -2318,6 +2318,24 @@ pub(crate) fn intra_rect_strip_in_inter_hits(class: usize) -> usize { | |||
| 2318 | INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) | 2318 | INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) |
| 2319 | } | 2319 | } |
| 2320 | 2320 | ||
| 2321 | +// lane-rect64port r1 (ported by hand from lane-intra64split 5ffbaf3): coded | ||
| 2322 | +// (non-skip) 64-level HORZ/VERT intra strips whose luma transform is the | ||
| 2323 | +// un-split TX_64X32/TX_32X64 -- the corner-cropped 32x32 coefficient read of | ||
| 2324 | +// [`decode_rect_split`], the shape both 10-bit 3840x1608 film cuts stop on. | ||
| 2325 | +// Split by ORIENTATION (index 0 = 64x32 wide / HORZ, 1 = 32x64 tall / VERT): | ||
| 2326 | +// a single counter cannot tell an axis swap from a working arm | ||
| 2327 | +// (class [[scan-weights-cross-axis]]), so the gate asserts both cells. | ||
| 2328 | +thread_local! { | ||
| 2329 | + static RECT64_CORNER_TU_HITS: std::cell::Cell<[usize; 2]> = | ||
| 2330 | + const { std::cell::Cell::new([0; 2]) }; | ||
| 2331 | +} | ||
| 2332 | + | ||
| 2333 | +/// Current value of [`RECT64_CORNER_TU_HITS`] for one orientation | ||
| 2334 | +/// (0 = 64x32, 1 = 32x64). | ||
| 2335 | +pub(crate) fn rect64_corner_tu_hits(orient: usize) -> usize { | ||
| 2336 | + RECT64_CORNER_TU_HITS.with(|c| c.get()[orient]) | ||
| 2337 | +} | ||
| 2338 | + | ||
| 2321 | // lane-intrasplit r1: intra HORZ/VERT strips inside an INTER frame whose luma | 2339 | // lane-intrasplit r1: intra HORZ/VERT strips inside an INTER frame whose luma |
| 2322 | // transform is SPLIT, bucketed by the read `tx_depth` (index 1 and 2; index 0 | 2340 | // transform is SPLIT, bucketed by the read `tx_depth` (index 1 and 2; index 0 |
| 2323 | // is never incremented) -- the gate's proof that the lifted path ran per depth. | 2341 | // is never incremented) -- the gate's proof that the lifted path ran per depth. |
| @@ -6817,6 +6835,21 @@ fn decode_rect_split( | |||
| 6817 | )), | 6835 | )), |
| 6818 | (32, 16) => Some((TxbSet::LumaRect32x16, &SCAN_32X16[..])), | 6836 | (32, 16) => Some((TxbSet::LumaRect32x16, &SCAN_32X16[..])), |
| 6819 | (16, 32) => Some((TxbSet::LumaRect32x16, &SCAN_16X32[..])), | 6837 | (16, 32) => Some((TxbSet::LumaRect32x16, &SCAN_16X32[..])), |
| 6838 | + // lane-rect64port r1: the un-split TX_64X32/TX_32X64 of a 64-level | ||
| 6839 | + // strip, read through the `luma_64corner` arm below instead of a rect | ||
| 6840 | + // table -- a 64-length axis codes only its low 32 coefficients | ||
| 6841 | + // (`av1_get_max_eob` / the zero-out of `av1_get_adjusted_tx_size`), so | ||
| 6842 | + // the coded unit is the 32x32 corner [`decode_block_rect64`]'s own | ||
| 6843 | + // depth-0 arm already reads on the key-frame path. | ||
| 6844 | + // | ||
| 6845 | + // NO WITNESS YET (r1, measured): on both 10-bit 3840x1608 film cuts | ||
| 6846 | + // this arm fires (16x 64x32 + 2x 32x64 / 2x 32x64) but the SAME frame | ||
| 6847 | + // then stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | ||
| 6848 | + // rectangular residual coding", so no frame containing it ever | ||
| 6849 | + // finishes and no pixel comparison is possible. A refusal is lifted | ||
| 6850 | + // only with a gate (COMMON charter), so the arm stays behind | ||
| 6851 | + // `EC_RECT64_SPLIT=1` and the refusal below is still the default. | ||
| 6852 | + (64, 32) | (32, 64) if std::env::var_os("EC_RECT64_SPLIT").is_some() => None, | ||
| 6820 | _ => { | 6853 | _ => { |
| 6821 | return Err(unsupported(format!( | 6854 | return Err(unsupported(format!( |
| 6822 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \ | 6855 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \ |
| @@ -6824,6 +6857,8 @@ fn decode_rect_split( | |||
| 6824 | ))) | 6857 | ))) |
| 6825 | } | 6858 | } |
| 6826 | }; | 6859 | }; |
| 6860 | + // The `None` above that is NOT the square arm. | ||
| 6861 | + let luma_64corner = tx_w != tx_h; | ||
| 6827 | // lane-rectsplitx r1, MEASURED: the SQUARE-unit walk below is pixel-exact | 6862 | // lane-rectsplitx r1, MEASURED: the SQUARE-unit walk below is pixel-exact |
| 6828 | // on a real stream (the pinned 16x8 filter-intra fixture decodes its whole | 6863 | // on a real stream (the pinned 16x8 filter-intra fixture decodes its whole |
| 6829 | // frame exactly, two sub-16 split strips in it), but the RECT-unit arm -- | 6864 | // frame exactly, two sub-16 split strips in it), but the RECT-unit arm -- |
| @@ -6893,6 +6928,64 @@ fn decode_rect_split( | |||
| 6893 | m.smooth_neighbor, | 6928 | m.smooth_neighbor, |
| 6894 | ); | 6929 | ); |
| 6895 | neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu); | 6930 | neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu); |
| 6931 | + } else if luma_64corner && luma_rect.is_none() { | ||
| 6932 | + // The un-split 64-level luma transform: `read_coeffs` on the | ||
| 6933 | + // 32x32 CDF set [`TxbSet::Luma64`] with `default_scan(TX32)` | ||
| 6934 | + // and the real rect shape passed through for | ||
| 6935 | + // `av1_nz_map_ctx_offset` -- byte for byte | ||
| 6936 | + // [`decode_block_rect64`]'s depth-0 read, which the key-frame | ||
| 6937 | + // 64-level strip gate already proves. `tx_type` is not coded | ||
| 6938 | + // (`av1_get_ext_tx_set_type` resolves EXT_TX_SET_DCTONLY once | ||
| 6939 | + // the square-up size is TX_64X64), and this unit covers its | ||
| 6940 | + // whole block, so `get_txb_ctx` gives txb_skip ctx 0 flat. | ||
| 6941 | + if std::env::var_os("EC_RECT64TU").is_some() { | ||
| 6942 | + eprintln!("EC_RECT64TU mi={tu_mi:?} tx={tx_w}x{tx_h} mode={}", m.mode); | ||
| 6943 | + } | ||
| 6944 | + RECT64_CORNER_TU_HITS.with(|c| { | ||
| 6945 | + let mut v = c.get(); | ||
| 6946 | + v[usize::from(tx_h > tx_w)] += 1; | ||
| 6947 | + c.set(v); | ||
| 6948 | + }); | ||
| 6949 | + let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; | ||
| 6950 | + let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra)); | ||
| 6951 | + let (corner, tu_tx_type) = read_coeffs( | ||
| 6952 | + dec, | ||
| 6953 | + &mut coding, | ||
| 6954 | + &default_scan(TX32), | ||
| 6955 | + 0, | ||
| 6956 | + dc_sign_ctx(tu_around.2), | ||
| 6957 | + TxType::DctDct, | ||
| 6958 | + Some((tx_w, tx_h)), | ||
| 6959 | + )?; | ||
| 6960 | + let (cw, ch) = (tx_w.min(TX32), tx_h.min(TX32)); | ||
| 6961 | + let mut tu_grid = vec![0i32; tx_w * tx_h]; | ||
| 6962 | + for row in 0..ch { | ||
| 6963 | + tu_grid[row * tx_w..][..cw].copy_from_slice(&corner[row * cw..][..cw]); | ||
| 6964 | + } | ||
| 6965 | + let residual = dequant_and_inverse_typed_wh( | ||
| 6966 | + &tu_grid, | ||
| 6967 | + tx_w, | ||
| 6968 | + tx_h, | ||
| 6969 | + crate::decode::bit_depth(), | ||
| 6970 | + block_q_idx(), | ||
| 6971 | + plane_q_delta(0).0, | ||
| 6972 | + plane_q_delta(0).1, | ||
| 6973 | + tu_tx_type, | ||
| 6974 | + ); | ||
| 6975 | + y.reconstruct_rect( | ||
| 6976 | + tu_px, | ||
| 6977 | + tu_py, | ||
| 6978 | + tx_w, | ||
| 6979 | + tx_h, | ||
| 6980 | + m.mode, | ||
| 6981 | + m.angle_delta_y, | ||
| 6982 | + tu_reach, | ||
| 6983 | + &residual, | ||
| 6984 | + None, | ||
| 6985 | + m.filter_intra, | ||
| 6986 | + m.smooth_neighbor, | ||
| 6987 | + ); | ||
| 6988 | + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); | ||
| 6896 | } else if let Some((rect_set, rect_scan)) = luma_rect { | 6989 | } else if let Some((rect_set, rect_scan)) = luma_rect { |
| 6897 | // The rect-unit twin of the square arm below: same contexts, | 6990 | // The rect-unit twin of the square arm below: same contexts, |
| 6898 | // same order, through the rect coefficient reader. The | 6991 | // same order, through the rect coefficient reader. The |
crates/ec-av1/src/stream.rsmodified+6 -0
| @@ -86,6 +86,12 @@ pub fn rect_intrabc_reads() -> usize { | |||
| 86 | crate::decode::rect_intrabc_reads() | 86 | crate::decode::rect_intrabc_reads() |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | +/// lane-rect64port r1: coded 64-level HORZ/VERT intra strips whose luma | ||
| 90 | +/// transform unit is the un-split TX_64X32 (orient 0) / TX_32X64 (orient 1). | ||
| 91 | +pub fn rect64_corner_tu_hits(orient: usize) -> usize { | ||
| 92 | + crate::decode::rect64_corner_tu_hits(orient) | ||
| 93 | +} | ||
| 94 | + | ||
| 89 | /// lane-inter16ab r4: RECTANGULAR var-tx leaves with a 4-px axis, `[8x4, 4x8]` | 95 | /// lane-inter16ab r4: RECTANGULAR var-tx leaves with a 4-px axis, `[8x4, 4x8]` |
| 90 | /// -- what `sub_tx_size_map[TX_16X4] == TX_8X4` produces when a 16x16-level | 96 | /// -- what `sub_tx_size_map[TX_16X4] == TX_8X4` produces when a 16x16-level |
| 91 | /// 1:4 inter strip splits its transform. | 97 | /// 1:4 inter strip splits its transform. |
lanes/rect64port-r1.report.mdadded+45 -0
| @@ -0,0 +1,45 @@ | |||
| 1 | +# lane-rect64port r1 — TX_64X32/TX_32X64 luma corner for a split intra strip | ||
| 2 | + | ||
| 3 | +Base: main 78d8ff7. Commit: 35f33c9 (branch lane-rect64port). | ||
| 4 | + | ||
| 5 | +## What changed | ||
| 6 | +- `crates/ec-av1/src/decode.rs` — `decode_rect_split`: new `(64, 32) | (32, 64)` arm of the | ||
| 7 | + `luma_rect` table (guarded by `EC_RECT64_SPLIT`) plus the `luma_64corner` TU arm inside the | ||
| 8 | + transform-unit loop: `read_coeffs` on `TxbSet::Luma64` with `default_scan(TX32)`, | ||
| 9 | + txb_skip ctx 0, `Some((tx_w, tx_h))` for `av1_nz_map_ctx_offset`, corner copied into a | ||
| 10 | + `tx_w*tx_h` grid, `dequant_and_inverse_typed_wh` + `reconstruct_rect` + | ||
| 11 | + `record_mi_luma_rect`. Hand-ported from lane-intra64split 5ffbaf3 (its only decode hunk). | ||
| 12 | +- `crates/ec-av1/src/decode.rs` — `RECT64_CORNER_TU_HITS` thread-local + `rect64_corner_tu_hits(orient)` | ||
| 13 | + (0 = 64x32, 1 = 32x64). | ||
| 14 | +- `crates/ec-av1/src/stream.rs` — `pub fn rect64_corner_tu_hits`. | ||
| 15 | +- `crates/ec-av1/examples/decode_probe.rs` — prints `rect64_corner_tu: 64x32=.. 32x64=..`. | ||
| 16 | +- `refusal_inventory.rs` / `gate_coverage.rs`: UNCHANGED — the refusal is not lifted (see below). | ||
| 17 | + | ||
| 18 | +## Witness attempt — FAILED to produce a pixel comparison | ||
| 19 | +The arm fires on both 10-bit 3840x1608 cuts, and the frontier moves, but the frame that | ||
| 20 | +contains the shape never completes: it stops on a DIFFERENT refusal owned by the inter side, | ||
| 21 | +`"a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding"` | ||
| 22 | +(decode.rs:19156, `reject_residual && !skip && !rect_inter_residual_supported(..)`). | ||
| 23 | +Truncating cut 0 to its 33 decoded frames and decoding gives `rect64_corner_tu: 0 0` — every | ||
| 24 | +hit is inside the first REFUSED frame. So there is no frame to compare against ffmpeg, no gate | ||
| 25 | +can be written, and the refusal stays. | ||
| 26 | + | ||
| 27 | +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 | ||
| 28 | +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 | ||
| 29 | + | ||
| 30 | +## Residue | ||
| 31 | +- fix-now(next lane): the 64-level split intra strip needs the INTER rect-residual refusal at | ||
| 32 | + decode.rs:19151 lifted first; only then does a film frame carrying a 64x32/32x64 split intra | ||
| 33 | + strip finish and a pixel-exact witness gate become writable. Unblocked by: a lane that ports | ||
| 34 | + rectangular residual coding for non-skip HORZ/VERT/HORZ_B inter strips. | ||
| 35 | +- deferred: the witness fixture `reelb_rect64_witness.obu` and the gate | ||
| 36 | + `a_10bit_film_inter_frame_with_a_64x32_split_intra_strip_decodes_pixel_exact` — nothing to pin | ||
| 37 | + while every candidate frame refuses. | ||
| 38 | + | ||
| 39 | +## Suite | ||
| 40 | +`cargo test -p ec-av1 --lib -j3` (systemd unit, EC_AV1_REQUIRE_AOMENC=1): | ||
| 41 | +417 passed, 3 failed, 37 ignored — identical totals and identical failing names to base 78d8ff7 | ||
| 42 | +(a_frame_edge_straddling_band, a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions, | ||
| 43 | +real_aomenc_1to4_streams_..._rect_vartx_leaves_fire). No regression; refusal_inventory, | ||
| 44 | +gate_coverage, split_transform_intra_strip and intra_1to4 tests are among the 417 passed. | ||
| 45 | +EVIDENCE: $HOME/.cache/rect64port-suite-r1.log | full lib suite on 35f33c9 | 417/3/37, the 3 known reds | ||