From 0f5742b8c08d01dc6e1a8fd10d981426352ccb64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Sep 2026 16:37:43 +0300 Subject: [PATCH] feat(av1): the 32x32-level 1:4 inter strip codes its rectangular residual (32x8/8x32) MEASURED first: an env-gated print at the refusal site (EC_RECTRES=1) on both 10-bit 3840x1608 film cuts and four offsets of the 10-bit 1920x792 stream gives 6/6 refusals at w=32 h=8 or w=8 h=32, non-skip, inter -- nothing else. The 64-axis shapes the charter expected were already supported and never fire. TX_32X8 codes all 256 positions. New TxbSet::LumaRect32x8Inter = the intra LumaRect32x8 tables (get_txsize_entropy_ctx = TX_16X16, txsize_log2_minus4 = 4) plus a tx_type table the intra twin has none of: av1_get_ext_tx_set_type at tx_size_sqr_up == TX_32X32 is EXT_TX_SET_DCT_IDTX for inter with or without reduced_tx_set, read at the txsize_sqr_map[TX_32X8] == TX_8X8 row. Chroma pair is one 16x4/4x16 unit (ss_size_lookup[BLOCK_32X8] = BLOCK_16X4) = Chroma8's tables. Scans, sub_tx_size_map[TX_32X8] = TX_16X8 var-tx leaves and the rect coefficient reader were already shape-general. Gate a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_their_rect_residual: real aomenc, --enable-1to4-partitions=1 --enable-tx-size-search=1 --min-partition-size=8 --max-partition-size=32, 16 attempts x 8/10-bit, both orientations, every decode-order frame Y/U/V vs ffmpeg, oos_mismatch == 0, one hard assert per lifted shape on the PIXEL-COMPARED counter: 32x8=7 8x32=8, 0 refusals, 0 mismatches. A 72-run recipe sweep found that only 32-pixel motion bands at cq >= 48 make aomenc code a NON-SKIP strip; narrower bands give the same partition with skip set and prove nothing about the residual. Film frontier: the 10-bit 3840x1608 cut still shows 33 frames -- the gain is inside frame 34, which now codes a 32x8 residual unit and stops on a different wall (an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition). All six cuts moved to that same next refusal. The rect64 refusal is NOT lifted: the clean prefix reports rect64_corner_tu 0/0, so no witness exists yet. --- crates/ec-av1/examples/decode_probe.rs | 4 + crates/ec-av1/src/cdf_state.rs | 20 +++ crates/ec-av1/src/decode.rs | 39 ++++ crates/ec-av1/src/refusal_inventory.rs | 6 + crates/ec-av1/src/stream.rs | 236 +++++++++++++++++++++++++ lanes/rectres-r1.report.md | 97 ++++++++++ 6 files changed, 402 insertions(+) create mode 100644 lanes/rectres-r1.report.md diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index b3449b89..64efabcf 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -106,6 +106,10 @@ fn main() { "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", ir.0, ir.1, ir.2, ir.3, ir.4, ir.5 ); + // lane-rectres r1: how many of those 32x8/8x32 strips coded a real + // rectangular residual transform unit (a skipped one codes none). + let r328 = ec_av1::stream::rect32x8_inter_tu_hits(); + println!("rect32x8_inter_tu: 32x8={} 8x32={}", r328[0], r328[1]); }; // lane-tiles: the tiling a real stream actually uses is a decision input // (every gate in `stream.rs` picks its own `--tile-columns`), so report it diff --git a/crates/ec-av1/src/cdf_state.rs b/crates/ec-av1/src/cdf_state.rs index 40ce2898..a3095872 100644 --- a/crates/ec-av1/src/cdf_state.rs +++ b/crates/ec-av1/src/cdf_state.rs @@ -118,6 +118,14 @@ pub(crate) enum TxbSet { /// block, so the encoder writes none (same reason /// [`LumaRect32x16`](TxbSet::LumaRect32x16) has none). LumaRect32x8, + /// lane-rectres r1: [`LumaRect32x8`](TxbSet::LumaRect32x8)'s INTER twin -- + /// the 32x32-level 1:4 strip (`max_txsize_rect_lookup[BLOCK_32X8] == + /// TX_32X8`). Same coefficient tables (`get_txsize_entropy_ctx` = TX_16X16, + /// `txsize_log2_minus4` = 4, 256 positions), but an inter unit DOES code a + /// `tx_type`: `av1_get_ext_tx_set_type` at `tx_size_sqr_up == TX_32X32` is + /// `EXT_TX_SET_DCT_IDTX` for inter regardless of `reduced_tx_set`, read at + /// the `txsize_sqr_map[TX_32X8] == TX_8X8` CDF row. + LumaRect32x8Inter, LumaRect32x16, /// lane-inter4 r2: [`LumaRect32x16`](TxbSet::LumaRect32x16)'s INTER twin -- /// same coefficient tables (`get_txsize_entropy_ctx` reduces TX_32X16 and @@ -1761,6 +1769,18 @@ impl Cdfs { tx_type: None, eob_pt_class1: Some(&mut self.eob_pt_1024_chroma_class1), }, + TxbSet::LumaRect32x8Inter => TxbTables { + side: 16, + txb_skip: &mut self.txb_skip_luma_16, + eob_pt: &mut self.eob_pt_256_luma, + eob_extra: &mut self.eob_extra_luma_16, + base: &mut self.base_luma_16, + base_eob: &mut self.base_eob_luma_16, + br: &mut self.br_luma_16, + dc_sign: &mut self.dc_sign_luma, + tx_type: Some(self.inter_tx_type_8.as_mut_slice()), + eob_pt_class1: Some(&mut self.eob_pt_256_luma_class1), + }, TxbSet::LumaRect32x8 => TxbTables { side: 16, txb_skip: &mut self.txb_skip_luma_16, diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 6a5d15bd..5f0a0812 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -1027,6 +1027,9 @@ thread_local! { // (64x32/32x64/64x16/16x64), whose coefficients are coded as the // truncated low-32 corner. static RECT64_INTER_TU_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; + // lane-rectres r1: whole-block luma transform units of a 32x32-level 1:4 + // inter strip, `[32x8, 8x32]`. + static RECT32X8_INTER_TU_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32]. static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; // lane-inter16ab r4: rectangular var-tx leaves with a 4-px axis, [8x4, 4x8] @@ -1084,6 +1087,12 @@ pub(crate) fn rect64_inter_tu_hits() -> usize { RECT64_INTER_TU_HITS.with(|c| c.get()) } +/// Current value of [`RECT32X8_INTER_TU_HITS`] (lane-rectres r1): `[32x8, 8x32]` +/// whole-block luma units of a 32x32-level 1:4 inter strip. +pub(crate) fn rect32x8_inter_tu_hits() -> [usize; 2] { + RECT32X8_INTER_TU_HITS.with(|c| c.get()) +} + /// Current value of [`VARTX_RECT_LEAF_HITS`] (lane-r14 r3): how many /// rectangular var-tx leaf transform units were coded, `[32x16, 16x32]`. pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] { @@ -13622,6 +13631,13 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool { // TX_64X64 units read through the mu-chunk loop, same as the // 128x128 NONE block's four. | (128, 64) | (64, 128) + // lane-rectres r1: the 32x32-level 1:4 strips -- THE shape both + // 10-bit film cuts and every measured 1080p offset stop on + // (measured: 6/6 probes refuse at 32x8 or 8x32, nothing else). + // `max_txsize_rect_lookup[BLOCK_32X8] == TX_32X8` codes all 256 + // positions, and its chroma pair is a 16x4 / 4x16 unit + // (`ss_size_lookup[BLOCK_32X8]` = BLOCK_16X4). + | (32, 8) | (8, 32) ) } @@ -13666,6 +13682,11 @@ fn rect_inter_luma_set(w: usize, h: usize) -> Result { // `get_txsize_entropy_ctx`/`txsize_log2_minus4` agree with the // adjusted size, so the existing sets are bit-exact. Neither carries a // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot. + // lane-rectres r1: `tx_size_sqr_up[TX_32X8] == TX_32X32`, so + // `av1_get_ext_tx_set_type` is `EXT_TX_SET_DCT_IDTX` for inter with or + // without `reduced_tx_set` -- one set, no `REDUCED_TX_SET_INTER` + // branch, read at the `txsize_sqr_map[TX_32X8] == TX_8X8` row. + (32, 8) | (8, 32) => TxbSet::LumaRect32x8Inter, (64, 32) | (32, 64) => TxbSet::Luma64, (64, 16) | (16, 64) => TxbSet::LumaRect32x16, _ => { @@ -13691,6 +13712,10 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> Result { // `txsize_log2_minus4` = 4), same as the intra strip path uses. (32, 16) | (16, 32) => TxbSet::ChromaRect32x16, (32, 8) | (8, 32) => TxbSet::Chroma16, + // lane-rectres r1: chroma of a 32x8/8x32 strip. `Chroma8` is the exact + // set for TX_16X4/TX_4X16 (`get_txsize_entropy_ctx` = TX_8X8, + // `txsize_log2_minus4` = 2, 64-coefficient `eob_pt`). + (16, 4) | (4, 16) => TxbSet::Chroma8, _ => { return Err(unsupported( "a rectangular inter chroma transform unit whose shape has no coefficient table set here", @@ -13945,6 +13970,13 @@ fn read_inter_plane_rect( if plane_idx == 0 && w.max(h) == 64 { RECT64_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); } + if plane_idx == 0 && (w, h) == (32, 8) || plane_idx == 0 && (w, h) == (8, 32) { + RECT32X8_INTER_TU_HITS.with(|c| { + let mut v = c.get(); + v[usize::from(w == 8)] += 1; + c.set(v); + }); + } let (corner, tx_type) = if (cw, ch) == (32, 32) { let scan32 = default_scan(TX32); read_coeffs( @@ -19191,6 +19223,13 @@ fn decode_inter_block( && !rect_inter_residual_supported(write_w, write_h) && (is_inter || (write_w == side && write_h == side)) { + if std::env::var_os("EC_RECTRES").is_some() { + eprintln!( + "EC_RECTRES w={write_w} h={write_h} side={side} skip={} is_inter={} mi_row={rmi} mi_col={cmi}", + u8::from(skip), + u8::from(is_inter) + ); + } return Err(unsupported( "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", )); diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 6320ad0d..00aa0a27 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -58,6 +58,12 @@ const REFUSALS: &[&str] = &[ "a frame naming primary_ref_frame at a reference slot with no saved CDF state", "a frame with no mode-info grid", "a frame whose segmentation enables SEG_LVL_REF_FRAME/SKIP/GLOBALMV (this decoder reads segment_id but never lets a segment override a block's reference, skip or mode)", + // Still live, but NARROWED: lane-rectres r1 added the 32x32-level 1:4 + // strips (32x8 / 8x32) to `rect_inter_residual_supported` -- THE shape both + // 10-bit 3840x1608 film cuts and every measured 1080p offset stopped on + // (gate `a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_\ + // their_rect_residual`). The string stays because the shapes below 8x8 and + // the AB-partition footprints still have no rectangular residual path. "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it", "a reference picture whose height does not match this frame's own true size", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 1eda53a1..9aebbe31 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -74,6 +74,12 @@ pub fn rect64_inter_tu_hits() -> usize { crate::decode::rect64_inter_tu_hits() } +/// lane-rectres r1: whole-block luma transform units of a 32x32-level 1:4 +/// inter strip (`TX_32X8`/`TX_8X32`), `[32x8, 8x32]`. +pub fn rect32x8_inter_tu_hits() -> [usize; 2] { + crate::decode::rect32x8_inter_tu_hits() +} + /// lane-r14 r3: RECTANGULAR var-tx leaf transform units, `[32x16, 16x32]` -- /// the leaves `sub_tx_size_map` produces when a 1:4 strip with a 64-px axis /// splits its transform (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`). @@ -8864,6 +8870,236 @@ mod tests { } } + /// lane-rectres r1: a 32x32-level 1:4 INTER strip (32x8 / 8x32) that codes + /// a REAL rectangular residual. THIS is the shape both 10-bit 3840x1608 + /// film cuts and every measured 1080p offset stopped on -- six of six + /// `decode_probe` runs refused at "a non-skip rectangular (HORZ/VERT/ + /// HORZ_B) strip needs rectangular residual coding" with `w=32 h=8` or + /// `w=8 h=32`, nothing else. + /// + /// `max_txsize_rect_lookup[BLOCK_32X8] == TX_32X8` codes all 256 of its + /// positions ([`TxbSet::LumaRect32x8Inter`]: `get_txsize_entropy_ctx` = + /// TX_16X16 so the coefficient tables are the luma-16 ones, + /// `txsize_log2_minus4` = 4 so `eob_pt` is the 256-position alphabet), and + /// unlike the INTRA twin it DOES code a `tx_type`: + /// `av1_get_ext_tx_set_type` at `tx_size_sqr_up == TX_32X32` is + /// `EXT_TX_SET_DCT_IDTX` for inter with or without `reduced_tx_set`, read + /// at the `txsize_sqr_map[TX_32X8] == TX_8X8` CDF row (class + /// table-indexed-by-raw-size: the coefficient tables follow the ADJUSTED + /// size, the `tx_type` row the SQUARE one -- they disagree here). + /// Its chroma pair is one 16x4 / 4x16 unit (`ss_size_lookup[BLOCK_32X8]` + /// = BLOCK_16X4, `Chroma8`'s tables, 64-position `eob_pt`), and a split + /// transform gives 16x8 / 8x16 leaves (`sub_tx_size_map[TX_32X8] == + /// TX_16X8`) the rect var-tx path already reads. + /// + /// `--enable-1to4-partitions=1 --min-partition-size=8 + /// --max-partition-size=32 --enable-tx-size-search=1` (each spelled once, + /// last occurrence wins -- aomenc keeps the LAST `--enable-*`) is what + /// lets aomenc pick a 32x32-level HORZ_4 / VERT_4; the 8-pixel banded + /// translating source is what makes those strips the RD winner and keeps + /// them non-skip so the residual is really coded. Both orientations, 8-bit + /// AND 10-bit, every decode-order frame compared to ffmpeg on Y/U/V, + /// refusals counted (never SKIPped), attempts that carried no 32x8/8x32 + /// residual unit counted separately and still required pixel-exact. + #[test] + fn a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_their_rect_residual() { + const NAME: &str = + "a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_their_rect_residual"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); + return; + } + let frame_count = 6usize; + let (mut proved_32x8, mut proved_8x32) = (0usize, 0usize); + let (mut fired_32x8, mut fired_8x32) = (0usize, 0usize); + for bit_depth in [8u32, 10u32] { + let (mut named_refusals, mut compared, mut out_of_scope, mut oos_mismatch) = + (0u32, 0u32, 0u32, 0u32); + for attempt in 0..16u32 { + // Two orientations (the transposed pair a one-sided gate could + // never separate) x four quantisers x two motion steps. + let vertical = attempt % 2 == 1; + let (width, height) = (192usize, 128usize); + let cq = [48, 52, 56, 60][(attempt / 2 % 4) as usize]; + let sp = 3 + (attempt / 8) * 4; + // 32-pixel bands, each translating at its OWN speed across the + // other axis: that is what makes aomenc's RD split a 32x32 + // block into four 32x8 (or 8x32) strips with distinct motion + // vectors, and the texture inside a band is what keeps a strip + // non-skip. MEASURED (72-run recipe sweep, 192x128..256x192, + // cq 24..60, bands 8/16/32/64): only 32-pixel bands at cq >= 48 + // make aomenc code a NON-SKIP one -- attempt 0 (cq 48, + // horizontal source) codes an 8x32 residual unit, attempt 7 + // (cq 60, the transposed source) five 32x8 ones. Narrower + // bands give the same strips with `skip` set, which proves the + // partition symbol and nothing about the residual. + let geq = if vertical { + format!("128+62*sin((Y+N*({sp}+7*mod(floor(X/32),4)))/6)+28*sin(X/9)") + } else { + format!("128+62*sin((X+N*({sp}+7*mod(floor(Y/32),4)))/6)+28*sin(Y/9)") + }; + let duration = frame_count as f64 / 25.0; + let source = format!( + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ + geq=lum='{geq}',format=yuv420p" + ); + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; + let y4m = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let cq_arg = format!("--cq-level={cq}"); + let depth_arg = format!("--bit-depth={bit_depth}"); + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); + let args: Vec<&str> = vec![ + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", + "--lag-in-frames=0", + // Per-arm overrides go LAST: aomenc keeps the last + // occurrence of a repeated --enable-* flag. + "--enable-tx64=0", "--enable-rect-partitions=1", + "--enable-ab-partitions=0", "--enable-1to4-partitions=1", + "--enable-tx-size-search=1", + "--enable-dual-filter=0", "--enable-obmc=0", + // aomenc's min-partition-size bounds the SMALLER side of a + // 1:4 strip, so 32x8 needs 8 (memory + // aomenc-min-partition-bounds-smaller-side). + "--min-partition-size=8", "--max-partition-size=32", + "--obu", "-o", "-", "-", + ]; + let mut child = Command::new(aomenc_path()) + .args(&args) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m.stdout) + .expect("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + let before = crate::stream::rect32x8_inter_tu_hits(); + let frames = match decode_stream(&stream) { + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ + attempt {attempt}): {msg}" + ); + let after = crate::stream::rect32x8_inter_tu_hits(); + // Firing counted on a refused stream is kept apart from + // the pixel-proved tally (class + // counter-from-refused-stream). + fired_32x8 += after[0] - before[0]; + fired_8x32 += after[1] - before[1]; + named_refusals += 1; + eprintln!( + "{NAME} {bit_depth}-bit attempt {attempt} refusal (32x8 residual \ + units decoded before it: {}, 8x32: {}): {msg}", + after[0] - before[0], + after[1] - before[1] + ); + continue; + } + Ok(frames) => frames, + }; + let after = crate::stream::rect32x8_inter_tu_hits(); + let (h, v) = (after[0] - before[0], after[1] - before[1]); + fired_32x8 += h; + fired_8x32 += v; + let ffmpeg_frames = if bit_depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) + } else { + ffmpeg_decode_sequence(&stream, width, height, frame_count) + }; + assert_eq!(frames.len(), frame_count); + let mismatched = frames + .iter() + .zip(&ffmpeg_frames) + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); + if h + v == 0 { + out_of_scope += 1; + if mismatched { + oos_mismatch += 1; + eprintln!( + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ + 32x8/8x32 inter residual units -- another shape's defect" + ); + } + continue; + } + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); + } + proved_32x8 += h; + proved_8x32 += v; + compared += 1; + } + eprintln!( + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {compared} \ + pixel-exact attempts carrying the arm, {out_of_scope} attempts carried none \ + ({oos_mismatch} of them mismatched)" + ); + assert_eq!( + oos_mismatch, 0, + "{NAME}: {oos_mismatch} attempt(s) with no 32x8/8x32 inter residual unit \ + decoded but mismatched ffmpeg -- a defect of another shape, not a pass" + ); + assert!( + compared + out_of_scope > 0, + "{NAME} ({bit_depth}-bit): every attempt refused -- the gate compared no pixels" + ); + } + eprintln!( + "{NAME}: pixel-compared 32x32-level 1:4 inter residual units 32x8={proved_32x8} \ + 8x32={proved_8x32} (decoded anywhere in the sweep 32x8={fired_32x8} \ + 8x32={fired_8x32})" + ); + // The firing half, one assert per lifted shape. Both orientations must + // be PIXEL-PROVED: a transposed table passes one and fails the other + // (class reference-layout-not-spec). + assert!( + proved_32x8 > 0, + "{NAME}: no 32x8 inter residual transform unit was decoded inside a pixel-exact \ + attempt (decoded anywhere: {fired_32x8}) -- the lift is unproved" + ); + assert!( + proved_8x32 > 0, + "{NAME}: no 8x32 inter residual transform unit was decoded inside a pixel-exact \ + attempt (decoded anywhere: {fired_8x32}) -- the lift is unproved" + ); + } + /// lane-sbrect10 r1: a 64x64 INTRA block inside an INTER frame, whose /// `uv_mode` alphabet libaom's `is_cfl_allowed` (`blockd.h`: `wide <= 32 /// && high <= 32`) narrows to the 13-symbol NO-CFL table. Reading the diff --git a/lanes/rectres-r1.report.md b/lanes/rectres-r1.report.md new file mode 100644 index 00000000..eeb23d37 --- /dev/null +++ b/lanes/rectres-r1.report.md @@ -0,0 +1,97 @@ +# lane-rectres r1 — the 32x32-level 1:4 inter strip's rectangular residual + +## Step 1 MEASURE — the shape histogram (this is the whole finding) + +An env-gated one-liner at the refusal site (`crates/ec-av1/src/decode.rs`, in the +`reject_residual` block, `EC_RECTRES=1`) prints `(w, h, side, skip, is_inter, mi_row, mi_col)`. +Six probes, `EC_RECT64_SPLIT=1 EC_RECTRES=1`, each under `systemd-run --scope -p MemoryMax=6G`: + +| stream | refusing shape | skip | is_inter | at | +|---|---|---|---|---| +| 10-bit 3840x1608 cut 0 | **32x8** | 0 | 1 | mi 16,744 | +| 10-bit 3840x1608 cut 300 | **32x8** | 0 | 1 | mi 0,64 | +| 10-bit 1920x792 @900 | **8x32** | 0 | 1 | mi 24,148 | +| 10-bit 1920x792 @5400 | **32x8** | 0 | 1 | mi 20,448 | +| 10-bit 1920x792 @6300 | **8x32** | 0 | 1 | mi 0,56 | +| 10-bit 1920x792 @8100 | **32x8** | 0 | 1 | mi 10,184 | + +6 of 6 are the 32x32-level 1:4 strip. No 64-axis shape, no AB footprint, nothing else. +The charter's "most likely 32x64/64x32 and 64x16/16x64" premise is WRONG for these films — +those shapes are already supported and the films never stop on them. + +EVIDENCE: shell probe, 6 streams | `EC_RECT64_SPLIT=1 EC_RECTRES=1 decode_probe ` | histogram above, 32x8 x4 / 8x32 x2, 0 other shapes + +## Step 2 IMPLEMENT — one shape family + +`max_txsize_rect_lookup[BLOCK_32X8] == TX_32X8`, all 256 positions coded. + +* `crates/ec-av1/src/cdf_state.rs` — new `TxbSet::LumaRect32x8Inter`: the existing INTRA + `LumaRect32x8` tables (`get_txsize_entropy_ctx(TX_32X8)` = TX_16X16 -> luma-16 coefficient + tables; `txsize_log2_minus4` = 4 -> 256-position `eob_pt`) **plus** a `tx_type` table the + intra twin has none of. `av1_get_ext_tx_set_type` at `tx_size_sqr_up == TX_32X32` is + `EXT_TX_SET_DCT_IDTX` for inter with *or without* `reduced_tx_set` (no branch), read at the + `txsize_sqr_map[TX_32X8] == TX_8X8` row -> `inter_tx_type_8`. Class + `table-indexed-by-raw-size`: the coefficient tables follow the ADJUSTED size and the + `tx_type` row the SQUARE one, and here the two disagree. +* `crates/ec-av1/src/decode.rs` `rect_inter_residual_supported` — `+ (32, 8) | (8, 32)`. +* `crates/ec-av1/src/decode.rs` `rect_inter_luma_set` — `(32, 8) | (8, 32) => LumaRect32x8Inter`. +* `crates/ec-av1/src/decode.rs` `rect_inter_chroma_set` — `(16, 4) | (4, 16) => Chroma8` + (`ss_size_lookup[BLOCK_32X8]` = BLOCK_16X4; TX_16X4 entropy ctx = TX_8X8, 64-position `eob_pt`). +* Counter `RECT32X8_INTER_TU_HITS` `[32x8, 8x32]` + `stream::rect32x8_inter_tu_hits()`, and + `decode_probe` prints `rect32x8_inter_tu:`. + +Nothing else was needed: `SCAN_32X8`/`SCAN_8X32` already exist (the intra strip path uses them), +`sub_tx_size_map(32,8) == (16,8)` is an already-supported rect var-tx leaf, and +`read_inter_plane_rect`/`read_coeffs_rect` are shape-general. + +## Step 3 GATE + +`a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_their_rect_residual` +(`crates/ec-av1/src/stream.rs`) — real aomenc, `--enable-1to4-partitions=1 +--enable-rect-partitions=1 --enable-tx-size-search=1 --min-partition-size=8 +--max-partition-size=32` (per-arm overrides last: aomenc keeps the last `--enable-*`), +16 attempts x {8-bit, 10-bit}, both orientations, every decode-order frame compared on Y/U/V +against ffmpeg, refusals counted never SKIPped, `oos_mismatch == 0` asserted, and one +hard assert per lifted shape on the PIXEL-COMPARED counter (a refused stream's hits are +tallied separately, class `counter-from-refused-stream`). + +Recipe found by a 72-run sweep (192x128..256x192, cq 24..60, bands 8/16/32/64): only +**32-pixel** motion bands at **cq >= 48** make aomenc code a NON-SKIP 32x32-level 1:4 strip. +Narrower bands give the same strips with `skip` set — they prove the partition symbol and +nothing about the residual (class `gate-blind-to-feature`). + +``` +cargo test -p ec-av1 --lib a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips -- --nocapture +8-bit : 0 named refusals, 5 pixel-exact attempts carrying the arm, 11 carried none (0 mismatched) +10-bit: 0 named refusals, 4 pixel-exact attempts carrying the arm, 12 carried none (0 mismatched) +pixel-compared units 32x8=7 8x32=8 (decoded anywhere 32x8=7 8x32=8) +test result: ok. 1 passed; 0 failed +``` + +EVIDENCE: /home/user/.cache/rectres-gate2.log | aomenc 32 streams (8+10 bit) -> decode -> ffmpeg Y/U/V compare | 15 pixel-compared 32x8/8x32 residual TUs, 0 mismatches + +`refusal_inventory.rs`: the string stays (sub-8x8 and AB footprints still have no rect +residual path) with a comment recording the narrowing. `gate_coverage.rs` needs no change — +it derives from `--enable-*` flags and this gate turns no tool off that others turn on. + +## Film frontier — before / after + +hg cut 0 (10-bit 3840x1608, 73 frame OBUs): **33 shown frames before, 33 after.** The gain is +INSIDE frame 34, not across frames: at prefix 50 that frame now decodes a 32x8 residual unit +(`rect32x8_inter_tu: 32x8=1`) and stops on a *different* wall — +`an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition`. All six cuts moved to +that same next refusal. So this lane removed one of at least two refusals in the films' +first blocking frame; the shown-frame count cannot move until the other lane lands. + +EVIDENCE: /home/user/.cache/rectres-bisect.log + probe on the 50-OBU prefix | trunc.py bisect over frame-OBU prefixes, decode_probe each | max OK prefix 49 OBUs = 33 shown frames; prefix 50 refuses on the intra-1:4 wall after coding one 32x8 residual TU + +## rect64 refusal — NOT lifted + +deferred: removing the `EC_RECT64_SPLIT` bypass — no witness exists. The 49-OBU prefix that +decodes clean reports `rect64_corner_tu: 64x32=0 32x64=0`; every rect64 hit (22 + 4) lives +inside the frame that still refuses on the intra 16x4/4x16 wall. Confirms the ledger dead-end +`lane-rect64port r1`. Unblocked by: the intra-16x4/4x16-in-inter-1:4 lane. + +## Suite + +See the r1 handoff/report tail for `cargo test -p ec-av1 --lib` totals.