forge
Explore
Log in

Don't you dare go Hollow

TX_64X32/TX_32X64 luma corner read for a split intra strip, behind EC_RECT64_SPLIT=1 (no witness yet)

Browse files at this commit

42d7c3952a813be618ed5c03c6a6864100f2709cAhmet Kaan GümüşParent: 6f01e4d
  • feat
    • TX_64X32/TX_32X64 luma corner read for a split intra strip, behind EC_RECT64_SPLIT=1 (no witness yet)
Show full message
feat(av1): TX_64X32/TX_32X64 luma corner read for a split intra strip, behind EC_RECT64_SPLIT=1 (no witness yet)

Hand-port of the lane-intra64split decode hunk onto main 78d8ff7: a 64-level
HORZ/VERT intra strip whose luma transform unit is the un-split TX_64X32 /
TX_32X64 reads its coded 32x32 corner through TxbSet::Luma64 with
default_scan(TX32) and the real rect shape passed to av1_nz_map_ctx_offset --
byte for byte decode_block_rect64's depth-0 key-frame arm. Per-orientation
counter rect64_corner_tu_hits(0|1) exported through stream.rs and printed by
decode_probe.

NOT lifted: measured on both 10-bit 3840x1608 cuts, the arm fires (16x 64x32 +
2x 32x64 on the first cut, 2x 32x64 on the second) but the SAME frame then
stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular
residual coding", so no frame containing the shape ever completes and no pixel
comparison exists. A refusal is lifted only with a gate, so the arm sits behind
EC_RECT64_SPLIT=1 and the refusal stays the default; refusal_inventory and
gate_coverage unchanged.
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 luma2339 // 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 02340 // 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.
@@ -6807,6 +6825,21 @@ fn decode_rect_split(
6807 )),6825 )),
6808 (32, 16) => Some((TxbSet::LumaRect32x16, &SCAN_32X16[..])),6826 (32, 16) => Some((TxbSet::LumaRect32x16, &SCAN_32X16[..])),
6809 (16, 32) => Some((TxbSet::LumaRect32x16, &SCAN_16X32[..])),6827 (16, 32) => Some((TxbSet::LumaRect32x16, &SCAN_16X32[..])),
6828+ // lane-rect64port r1: the un-split TX_64X32/TX_32X64 of a 64-level
6829+ // strip, read through the `luma_64corner` arm below instead of a rect
6830+ // table -- a 64-length axis codes only its low 32 coefficients
6831+ // (`av1_get_max_eob` / the zero-out of `av1_get_adjusted_tx_size`), so
6832+ // the coded unit is the 32x32 corner [`decode_block_rect64`]'s own
6833+ // depth-0 arm already reads on the key-frame path.
6834+ //
6835+ // NO WITNESS YET (r1, measured): on both 10-bit 3840x1608 film cuts
6836+ // this arm fires (16x 64x32 + 2x 32x64 / 2x 32x64) but the SAME frame
6837+ // then stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs
6838+ // rectangular residual coding", so no frame containing it ever
6839+ // finishes and no pixel comparison is possible. A refusal is lifted
6840+ // only with a gate (COMMON charter), so the arm stays behind
6841+ // `EC_RECT64_SPLIT=1` and the refusal below is still the default.
6842+ (64, 32) | (32, 64) if std::env::var_os("EC_RECT64_SPLIT").is_some() => None,
6810 _ => {6843 _ => {
6811 return Err(unsupported(format!(6844 return Err(unsupported(format!(
6812 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \6845 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \
@@ -6814,6 +6847,8 @@ fn decode_rect_split(
6814 )))6847 )))
6815 }6848 }
6816 };6849 };
6850+ // The `None` above that is NOT the square arm.
6851+ let luma_64corner = tx_w != tx_h;
6817 // lane-rectsplitx r1, MEASURED: the SQUARE-unit walk below is pixel-exact6852 // lane-rectsplitx r1, MEASURED: the SQUARE-unit walk below is pixel-exact
6818 // on a real stream (the pinned 16x8 filter-intra fixture decodes its whole6853 // on a real stream (the pinned 16x8 filter-intra fixture decodes its whole
6819 // frame exactly, two sub-16 split strips in it), but the RECT-unit arm --6854 // frame exactly, two sub-16 split strips in it), but the RECT-unit arm --
@@ -6883,6 +6918,64 @@ fn decode_rect_split(
6883 m.smooth_neighbor,6918 m.smooth_neighbor,
6884 );6919 );
6885 neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu);6920 neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu);
6921+ } else if luma_64corner && luma_rect.is_none() {
6922+ // The un-split 64-level luma transform: `read_coeffs` on the
6923+ // 32x32 CDF set [`TxbSet::Luma64`] with `default_scan(TX32)`
6924+ // and the real rect shape passed through for
6925+ // `av1_nz_map_ctx_offset` -- byte for byte
6926+ // [`decode_block_rect64`]'s depth-0 read, which the key-frame
6927+ // 64-level strip gate already proves. `tx_type` is not coded
6928+ // (`av1_get_ext_tx_set_type` resolves EXT_TX_SET_DCTONLY once
6929+ // the square-up size is TX_64X64), and this unit covers its
6930+ // whole block, so `get_txb_ctx` gives txb_skip ctx 0 flat.
6931+ if std::env::var_os("EC_RECT64TU").is_some() {
6932+ eprintln!("EC_RECT64TU mi={tu_mi:?} tx={tx_w}x{tx_h} mode={}", m.mode);
6933+ }
6934+ RECT64_CORNER_TU_HITS.with(|c| {
6935+ let mut v = c.get();
6936+ v[usize::from(tx_h > tx_w)] += 1;
6937+ c.set(v);
6938+ });
6939+ let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0];
6940+ let mut coding = cdfs.txb(TxbSet::Luma64, fi_tx_row(m.mode, m.filter_intra));
6941+ let (corner, tu_tx_type) = read_coeffs(
6942+ dec,
6943+ &mut coding,
6944+ &default_scan(TX32),
6945+ 0,
6946+ dc_sign_ctx(tu_around.2),
6947+ TxType::DctDct,
6948+ Some((tx_w, tx_h)),
6949+ )?;
6950+ let (cw, ch) = (tx_w.min(TX32), tx_h.min(TX32));
6951+ let mut tu_grid = vec![0i32; tx_w * tx_h];
6952+ for row in 0..ch {
6953+ tu_grid[row * tx_w..][..cw].copy_from_slice(&corner[row * cw..][..cw]);
6954+ }
6955+ let residual = dequant_and_inverse_typed_wh(
6956+ &tu_grid,
6957+ tx_w,
6958+ tx_h,
6959+ crate::decode::bit_depth(),
6960+ block_q_idx(),
6961+ plane_q_delta(0).0,
6962+ plane_q_delta(0).1,
6963+ tu_tx_type,
6964+ );
6965+ y.reconstruct_rect(
6966+ tu_px,
6967+ tu_py,
6968+ tx_w,
6969+ tx_h,
6970+ m.mode,
6971+ m.angle_delta_y,
6972+ tu_reach,
6973+ &residual,
6974+ None,
6975+ m.filter_intra,
6976+ m.smooth_neighbor,
6977+ );
6978+ neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid);
6886 } else if let Some((rect_set, rect_scan)) = luma_rect {6979 } else if let Some((rect_set, rect_scan)) = luma_rect {
6887 // The rect-unit twin of the square arm below: same contexts,6980 // The rect-unit twin of the square arm below: same contexts,
6888 // same order, through the rect coefficient reader. The6981 // 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-level96 /// -- 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.