diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 2021b887..a0f7c60f 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -394,6 +394,40 @@ pub(crate) fn tx_depth_hits() -> usize { TX_DEPTH_HITS.with(|c| c.get()) } +// How many `partition_w16` reads (a 16x16 block's own partition symbol, key +// intra-frame path) resolved to `PARTITION_VERT_B` -- lane-rect16 r1: a +// plain default-settings aomenc run over lavfi mandelbrot hits this arm on +// frame 0's very first non-NONE/SPLIT `partition_w16` symbol (mi=(3,2)), not +// the plain HORZ/VERT this lane's charter assumed. Left rect (8x16, real +// `decode_block_rect`) + two 8x8 leaves stacked on the right (`decode_leaf8`, +// chained via `prev_leaf` exactly like the existing 16x16-SPLIT-into-4x8x8 +// path above). +thread_local! { + static VERT_B_INTRA_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`VERT_B_INTRA_HITS`]. +pub(crate) fn vert_b_intra_hits() -> usize { + VERT_B_INTRA_HITS.with(|c| c.get()) +} + +// How many `partition_w16` reads resolved to a plain `PARTITION_HORZ`/ +// `PARTITION_VERT` (lane-rect16 r2): re-measuring after the VERT_B fix above +// showed mandelbrot's real first-hit blocker is this plain arm at mi=(0,7), +// not VERT_B (`refusal-names-a-correlate`; the VERT_B write-up's "frame 0's +// very first non-NONE/SPLIT symbol" claim was about decode ORDER within one +// superblock's z-order recursion, not raster mi position). +thread_local! { + static HORZ_VERT_INTRA_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`HORZ_VERT_INTRA_HITS`]. +pub(crate) fn horz_vert_intra_hits() -> usize { + HORZ_VERT_INTRA_HITS.with(|c| c.get()) +} + // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D` // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every // call on the current thread -- the same before/after counter pattern as @@ -3191,6 +3225,21 @@ fn decode_block_rect( vec![0i32; chroma_w * chroma_h], ], ); + } else if (bw, bh) != (32, 16) && (bw, bh) != (16, 32) { + // lane-rect16 r1: a real (non-skip) coefficient read at this size + // (8x16/16x32 VERT_B's own left strip) is not ported -- it needs its + // own `TxbSet`/`eob_pt` tables (a true 128-position luma group has no + // `EOB_PT_128_LUMA` in this decoder yet, only the *chroma* one + // `lane-rectwire` built for `ChromaRect16x8`) and, unlike the 32x32 + // sqr-up case `LumaRect32x16` safely skips, `get_ext_tx_set_type` + // does NOT return `EXT_TX_SET_DCTONLY` at a 16x16 sqr-up under this + // encoder's reduced_tx_set -- a real `tx_type` symbol may be coded + // that no table here reads. Refused by name rather than guess-decoded + // or silently desynced. + return Err(unsupported( + "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only \ + the skip case at this size)", + )); } else { // lane-rectwire r2: real coefficients. `get_txsize_entropy_ctx` // reduces both size pairs to their square-up CDF sets @@ -3370,6 +3419,156 @@ fn decode_block_rect( Ok(()) } +/// Decodes one `bw`x`bh` rect strip of a plain 16x16-level `PARTITION_HORZ`/ +/// `PARTITION_VERT` (lane-rect16 r2), sibling to [`decode_block_rect`] but +/// addressed by REAL mi coordinates rather than derived from an [`SUB`]-grid +/// `outer_at`, the same relationship [`decode_leaf8`] has to `decode_block`: +/// the second strip of a HORZ/VERT split sits offset by half the 16x16 +/// parent, which `decode_block_rect`'s `at`-derived `px = c * SUB` can't +/// name. `prev_leaf` mirrors `decode_leaf8`'s own convention -- when the +/// previous strip is directly above (same column, `mi_h` rows up) or +/// directly left (same row, `mi_w` cols over), its mode overrides the coarse +/// per-16x16-cell `above_mode`/`left_mode` slot for THIS strip's own mode +/// context read, and bookkeeping goes through the `_mi`/`_rect` neighbour +/// writers (`record_mi_rect`, `fill_skip_grid_rect`, `fill_lf_grid_rect`) at +/// this strip's real position, never the coarse `record_rect` (which the +/// caller uses once, after both strips, exactly like the `VERT_B` arm next +/// to it). Only the skip case is ported -- see [`decode_block_rect`]'s own +/// doc for why a coded rect strip below 16x16 has no coefficient tables here +/// yet. +#[allow(clippy::too_many_arguments)] +fn decode_leaf_rect( + dec: &mut SymbolDecoder, + cdfs: &mut Cdfs, + neighbours: &mut Neighbours, + outer_at: (usize, usize), + leaf_mi: (usize, usize), + bw: usize, + bh: usize, + prev_leaf: Option<((usize, usize), usize)>, + y: &mut PlaneBuf, + u: &mut PlaneBuf, + v: &mut PlaneBuf, + enable_filter_intra: bool, + allow_screen_content_tools: bool, + base_q_idx: u8, + tx_select: bool, +) -> Result { + let _ = base_q_idx; + let (r, c) = outer_at; + let mut above_mode = neighbours.above_mode[c]; + let mut left_mode = neighbours.left_mode[r]; + let (mi_w, mi_h) = (bw / MI, bh / MI); + if let Some(((pr, pc), pmode)) = prev_leaf { + if pc == leaf_mi.1 && leaf_mi.0 == pr + mi_h { + above_mode = pmode; + } else if pr == leaf_mi.0 && leaf_mi.1 == pc + mi_w { + left_mode = pmode; + } + } + let smooth_neighbor = + is_smooth_mode(above_mode) || is_smooth_mode(left_mode); + if smooth_neighbor { + SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); + } + let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra) = + read_intra_mode_rect( + dec, + cdfs, + above_mode, + left_mode, + true, + bw, + bh, + enable_filter_intra, + neighbours.skip_txfm_ctx(leaf_mi.0, leaf_mi.1), + allow_screen_content_tools, + leaf_mi.0, + leaf_mi.1, + )?; + if filter_intra.is_some() { + return Err(unsupported( + "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", + )); + } + let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; + let depth = if tx_select { + let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh); + dec.symbol(&mut cdfs.tx_size_cat2[ctx]) + } else { + 0 + }; + if depth != 0 { + return Err(unsupported( + "a HORZ/VERT intra strip with a split transform (per-unit rect \ + prediction is not ported)", + )); + } + if !skip { + return Err(unsupported( + "a coded (non-skip) HORZ/VERT rect strip below 16x16 (this decoder ports only \ + the skip case at this size)", + )); + } + let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); + let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); + let (cpx, cpy) = (px / 2, py / 2); + let (chroma_w, chroma_h) = (bw / 2, bh / 2); + y.reconstruct_rect( + px, + py, + bw, + bh, + mode, + angle_delta_y, + reach, + &vec![0i32; bw * bh], + None, + filter_intra, + smooth_neighbor, + ); + let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); + u.reconstruct_rect( + cpx, + cpy, + chroma_w, + chroma_h, + uv_predict_mode, + angle_delta_uv, + reach, + &vec![0i32; chroma_w * chroma_h], + alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), + None, + false, + ); + v.reconstruct_rect( + cpx, + cpy, + chroma_w, + chroma_h, + uv_predict_mode, + angle_delta_uv, + reach, + &vec![0i32; chroma_w * chroma_h], + alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), + None, + false, + ); + neighbours.record_mi_rect( + leaf_mi, + bw, + bh, + &[ + vec![0i32; bw * bh], + vec![0i32; chroma_w * chroma_h], + vec![0i32; chroma_w * chroma_h], + ], + ); + neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip); + neighbours.fill_lf_grid_rect(leaf_mi, mi_w, mi_h, bw as u8, bh as u8, 0); + Ok(mode) +} + /// Decodes one true `bw`x`bh` superblock-level `PARTITION_HORZ`/ /// `PARTITION_VERT` strip (lane-sbpart r2, `bw, bh` one of `(64, 32)` / /// `(32, 64)` -- [`decode_block_rect`]'s own sibling one level up). Unlike @@ -6616,9 +6815,189 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( )?; continue; } + if part16 == PARTITION_VERT_B { + VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1)); + // Left rect: 8x16, real + // `decode_block_rect`, sat at the + // 16x16 parent's own origin (no + // fractional-SUB-grid pixel + // offset needed -- the plain + // HORZ/VERT arms this lane's + // charter named DO need one, + // since their second half is + // offset by half the parent; + // unported, see decode_block_rect's + // own doc comment). + decode_block_rect( + &mut dec, + &mut cdfs, + &mut neighbours, + at16, + 8, + 16, + &mut y, + &mut u, + &mut v, + enable_filter_intra, + allow_screen_content_tools, + base_q_idx, + tx_select, + )?; + // Two 8x8 squares stacked on the + // right, chained through + // `prev_leaf` exactly like the + // real (non-straddle) SPLIT path + // below: the bottom leaf's ABOVE + // context is the top leaf, not + // the coarse SUB-grid array (a + // real block never sat there). + let (mi_row0, mi_col0) = + (sr as u32 * SUB_MI, sc as u32 * SUB_MI); + let top_right = + (mi_row0 as usize, mi_col0 as usize + 2); + let bot_right = + (mi_row0 as usize + 2, mi_col0 as usize + 2); + let mode_tr = decode_leaf8( + &mut dec, + &mut cdfs, + &mut neighbours, + at16, + top_right, + (&scan8, &scan4), + None, + &mut y, + &mut u, + &mut v, + base_q_idx, + enable_filter_intra, + allow_screen_content_tools, + allow_intrabc, + tx_select, + reduced_tx_set, + )?; + let mode_br = decode_leaf8( + &mut dec, + &mut cdfs, + &mut neighbours, + at16, + bot_right, + (&scan8, &scan4), + Some((top_right, mode_tr)), + &mut y, + &mut u, + &mut v, + base_q_idx, + enable_filter_intra, + allow_screen_content_tools, + allow_intrabc, + tx_select, + reduced_tx_set, + )?; + // `record()`'s above_mode/left_mode + // write is a no-op at an 8x8 + // leaf's own side (same gap the + // real-SPLIT path above patches): + // force it from the last-decoded + // (bottom-right) leaf. + neighbours.above_mode[sc] = mode_br; + neighbours.left_mode[sr] = mode_br; + continue; + } + if part16 == PARTITION_HORZ { + HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); + let (mi_row0, mi_col0) = ( + sr as u32 * SUB_MI, + sc as u32 * SUB_MI, + ); + let top = (mi_row0 as usize, mi_col0 as usize); + let bot = (mi_row0 as usize + 2, mi_col0 as usize); + let mode_top = decode_leaf_rect( + &mut dec, + &mut cdfs, + &mut neighbours, + at16, + top, + 16, + 8, + None, + &mut y, + &mut u, + &mut v, + enable_filter_intra, + allow_screen_content_tools, + base_q_idx, + tx_select, + )?; + let mode_bot = decode_leaf_rect( + &mut dec, + &mut cdfs, + &mut neighbours, + at16, + bot, + 16, + 8, + Some((top, mode_top)), + &mut y, + &mut u, + &mut v, + enable_filter_intra, + allow_screen_content_tools, + base_q_idx, + tx_select, + )?; + neighbours.above_mode[sc] = mode_bot; + neighbours.left_mode[sr] = mode_bot; + continue; + } + if part16 == PARTITION_VERT { + HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); + let (mi_row0, mi_col0) = ( + sr as u32 * SUB_MI, + sc as u32 * SUB_MI, + ); + let left = (mi_row0 as usize, mi_col0 as usize); + let right = (mi_row0 as usize, mi_col0 as usize + 2); + let mode_left = decode_leaf_rect( + &mut dec, + &mut cdfs, + &mut neighbours, + at16, + left, + 8, + 16, + None, + &mut y, + &mut u, + &mut v, + enable_filter_intra, + allow_screen_content_tools, + base_q_idx, + tx_select, + )?; + let mode_right = decode_leaf_rect( + &mut dec, + &mut cdfs, + &mut neighbours, + at16, + right, + 8, + 16, + Some((left, mode_left)), + &mut y, + &mut u, + &mut v, + enable_filter_intra, + allow_screen_content_tools, + base_q_idx, + tx_select, + )?; + neighbours.above_mode[sc] = mode_right; + neighbours.left_mode[sr] = mode_right; + continue; + } if part16 != PARTITION_SPLIT { return Err(unsupported( - "a partition below 16x16 other than a clean split (this decoder codes only the square arms below 16x16)", + "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)", )); } // A real (non-straddle) SPLIT of a diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 15b3cb0e..fb771602 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -28,7 +28,6 @@ const CAPABILITY_CLAIMS: &[&str] = &[ "a non-2D tx class on a rectangular transform (never expected at this size)", "a non-DC chroma mode on an 8x8 inter-frame leaf (this encoder never writes one)", "a nonzero angle delta (this encoder never writes one)", - "a partition below 16x16 other than a clean split (this decoder codes only the square arms below 16x16)", "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", "a tx_type symbol on a rectangular transform (never expected at this size)", ]; @@ -36,6 +35,9 @@ const CAPABILITY_CLAIMS: &[&str] = &[ #[cfg(test)] const REFUSALS: &[&str] = &[ "GLOBALMV (round 3)", + "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)", + "a coded (non-skip) HORZ/VERT rect strip below 16x16 (this decoder ports only the skip case at this size)", + "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)", "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", "a 32x32 partition type this decoder does not code (value={part32})", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index f17369cf..2e100638 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -5207,6 +5207,127 @@ mod tests { crate::decode::wii_hits() ); } + + /// lane-rect16 r1/r2: a plain default-settings aomenc run over lavfi + /// `mandelbrot` (`--cpu-used=4 --end-usage=q --cq-level=32`, no + /// `--enable-*` flags) used to refuse frame 0 outright with "a partition + /// below 16x16 other than a clean split". r1 root-caused the FIRST hit to + /// a `PARTITION_VERT_B` `partition_w16` symbol at mi=(3,2) and wired it + /// (left 8x16 real `decode_block_rect` strip + two stacked 8x8 + /// `decode_leaf8` leaves on the right). r2 re-measured after that fix + /// (`decision-before-quantiser`-shaped: don't trust a stale premise) and + /// found this stream's REAL first-hit blocker in z-order is earlier, at + /// mi=(0,7): a plain `PARTITION_HORZ`. That arm is now wired too + /// (`decode_leaf_rect`, sibling to `decode_leaf8` but real-mi-addressed + /// for a non-square strip) -- `horz_vert_intra_hits` proves it fires. + /// This exact stream's own HORZ block at mi=(0,7) is *coded* (real + /// coefficients), which is NOT ported (same ceiling as VERT_B's own + /// non-skip refusal -- no rectangular-transform coefficient tables at + /// this size), so decode still stops there and `vert_b_intra_hits` + /// never gets a chance to increment on this particular stream. This gate + /// proves the HORZ arm fires and the OLD (now-false) two-clause refusal + /// never reappears, not a pixel-exact decode of this stream. + #[test] + fn a_real_aomenc_stream_with_mandelbrot_fires_the_vert_b_partition_arm() { + const NAME: &str = "a_real_aomenc_stream_with_mandelbrot_fires_the_vert_b_partition_arm"; + 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 (width, height) = (192usize, 128usize); + let y4m = Command::new("ffmpeg") + .args([ + "-v", + "error", + "-f", + "lavfi", + "-i", + &format!("mandelbrot=size={width}x{height}"), + "-pix_fmt", + "yuv420p", + "-t", + "1", + "-f", + "yuv4mpegpipe", + "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let mut child = Command::new(aomenc_path()) + .args([ + "--threads=1", + "--row-mt=0", + "--sb-size=64", + "--cpu-used=4", + "--end-usage=q", + "--cq-level=32", + "--passes=1", + "--obu", + "-o", + "-", + "-", + ]) + .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; + // lane-rect16 r2: the recipe above was missing `--passes=1` -- + // without it aomenc silently ran 2-pass and wrote nothing to stdout + // on pass 1 (still exit 0), so this gate always decoded an EMPTY + // stream and never actually exercised the arm it claims to gate. + assert!( + !stream.is_empty(), + "{NAME}: aomenc wrote an empty stream (missing --passes=1?)" + ); + let result = decode_stream(&stream); + // The now-lifted false claim ("codes only the square arms below + // 16x16") must never appear again. + if let Err(e) = &result { + let msg = e.to_string(); + assert!( + !msg.contains("this decoder codes only the square arms below 16x16"), + "{NAME}: the OLD (disproved) refusal reappeared: {msg}" + ); + } + assert!( + crate::decode::horz_vert_intra_hits() > 0, + "{NAME}: the plain PARTITION_HORZ/VERT arm never fired on this stream (regression -- \ + it fired deterministically at mi=(0,7) when this gate was written)" + ); + eprintln!( + "{NAME}: horz_vert_intra_hits={}, vert_b_intra_hits={}, decode result: {:?}", + crate::decode::horz_vert_intra_hits(), + crate::decode::vert_b_intra_hits(), + result.as_ref().map(|f| f.len()).map_err(|e| e.to_string()) + ); + } /// lane-rectgate r1: every prior gate pins `--enable-rect-partitions=0 /// --enable-ab-partitions=0 --min/max-partition-size=32` so aomenc never /// gets to choose a real rect/ab split. This charter's premise ("rect diff --git a/lanes/rect16-r1.charter.md b/lanes/rect16-r1.charter.md new file mode 100644 index 00000000..a572b871 --- /dev/null +++ b/lanes/rect16-r1.charter.md @@ -0,0 +1,54 @@ +# lane-rect16 r1 — rectangular partitions below 16x16 + +Fresh lane off main (170a5a3). + +## Why this lane exists — measured +Plain default-settings aomenc over lavfi `mandelbrot` +(`--cpu-used=4 --end-usage=q --cq-level=32`, no `--enable-*` flags, 192x128) +refuses on frame 0 with **"a partition below 16x16 other than a clean split"**. +That refusal used to end "(this encoder never writes one)"; I reworded it on +main at e067e32 when this probe disproved it. Reproduce it yourself first — +`cargo run -p ec-av1 --example decode_probe -- `, extracting with +`ffmpeg -i -c:v copy -f obu` — so you are looking at a live failure, not +my sentence about one. + +## Scope +The HORZ/VERT arms at 8x8 and below: `PARTITION_HORZ`/`PARTITION_VERT` under a +16x16 parent, and whatever `decode_block` needs to code an 8x4/4x8 leaf. A +sibling lane (lane-sbpart) owns the same shape at 64x64 and is mid-bisect on a +luma mismatch there — **do not touch its worktree**, but do read +`git log`/`git show` for `decode_block_rect` and `decode_block_rect64` first: +the rectangular transform, scan and context machinery already exists, and this +may be a wiring job rather than a new primitive. If so, say that plainly instead +of building a second copy ([[square-only-transform-ceiling]]). + +Two classes to keep in view, both paid for by this repo: +- A rectangular scan's weight or step can use the CROSS axis; square candidates + hide every axis swap, so sweep the transposed copy in the SAME round + ([[scan-weights-cross-axis]]). +- A neighbour context read from ONE cell is right only under uniform block size; + strips need a gathered span ([[context-read-from-one-cell]]). + +## Order +1. Reproduce the refusal, and identify the exact failing BLOCK — size, position, + partition symbol — not just the frame's configuration. A refusal written from + a mismatching frame's header names a correlate, not the defect + ([[refusal-names-a-correlate]]). +2. Gate first, below `decode_stream`, hard-asserting the new partition arm fires. +3. Implement, bisecting any pixel mismatch with a range ladder against the + oracle (compare msac RANGE, never `tell()`). +4. Lift the refusal and update `refusal_inventory.rs` in the same commit, only + once the gate is pixel-exact. + +## Budget discipline +75 turns, and they do NOT reset if you are resumed. At about turn 55, stop +starting new work: commit what is green and write your report. + +Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-rect16`; foreground +`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms; fixtures +through `gradients_source(seed, w, h, tail)` where synthetic will do; every +ffmpeg generate bounded with `-t`; `EC_AV1_REQUIRE_AOMENC=1`; aomenc +`--threads=1 --row-mt=0 --sb-size=64`. Oracle rungs 6, 7, 8, 8b are taken — take +10 (9 is spoken for); the oracle is SHARED, env-gated rungs only. Sibling +worktrees have live agents — never build in or edit them. Never push, never merge +into main. End with `lanes/rect16-r1.report.md`, VERDICT on line 1. diff --git a/lanes/rect16-r2.report.md b/lanes/rect16-r2.report.md new file mode 100644 index 00000000..b62be329 --- /dev/null +++ b/lanes/rect16-r2.report.md @@ -0,0 +1,69 @@ +# lane-rect16 r2 report + +## What 34827e1 (builder's in-flight commit) actually contained +- Discovered mandelbrot's real first refusal was `PARTITION_VERT_B` at mi=(3,2), not plain HORZ/VERT + (the lane's original charter premise). Wired VERT_B: left 8x16 strip via existing `decode_block_rect` + (skip-only, at its natural SUB-grid position) + two 8x8 leaves via existing `decode_leaf8`. +- Added a gate test `a_real_aomenc_stream_with_mandelbrot_fires_the_vert_b_partition_arm` asserting + `vert_b_intra_hits() > 0`. +- BUG: that gate's aomenc invocation was missing `--passes=1` (every one of the other 42 aomenc + recipes in stream.rs has it) -- aomenc silently ran 2-pass and pass 1 wrote an EMPTY stream to + stdout, still exit 0. So the gate always decoded zero bytes and never actually fired anything; + it was vacuous, and it is the 1 failing test in the pre-merge suite (266 passed/1 failed). + +## Premise re-check +Confirmed still-live with `decode_probe` against a real aomenc stream (`--cpu-used=4 --end-usage=q +--cq-level=32 --passes=1`, sb-size=64, threads=1): before my fix, mandelbrot still stopped at +`REFUSED: ... (a partition below 16x16 other than a clean split or a VERT_B ...)`. Added a +`EC_RECT16_DEBUG` temporary eprintln (removed) to find WHICH part16 value: **`part16=1` +(`PARTITION_HORZ`) at mi=(0,7)`** -- the mandelbrot blocker is a plain HORZ, decode-order-earlier +than VERT_B's mi=(3,2), even though VERT_B's own doc claimed "frame 0's very first non-NONE/SPLIT +symbol" (that claim was about z-order recursion, and was simply wrong once traced against real +decode order). So the ORIGINAL lane charter target (plain HORZ/VERT below 16x16) was correct all +along; the r1 VERT_B work was real and worth keeping, just not the frontmost blocker. + +## What I built +New `decode_leaf_rect` (crates/ec-av1/src/decode.rs), sibling to `decode_leaf8` the way +`decode_block_rect` is sibling to `decode_block`: takes REAL mi coordinates (not derived from an +SUB-grid `outer_at`), so it can address a HORZ/VERT split's offset second strip, which +`decode_block_rect`'s `px = c * SUB` formula cannot name (that was VERT_B's r1 doc-noted gap). +Uses `read_intra_mode_rect` for mode/skip/tx-depth, `record_mi_rect`/`fill_skip_grid_rect`/ +`fill_lf_grid_rect` for fine-grained neighbour bookkeeping (never the coarse `record_rect`), and +`prev_leaf` chaining exactly like `decode_leaf8` for the second strip's above/left context. +Wired into `decode_key_frame_tile_with_cdfs` next to the VERT_B arm: `PARTITION_HORZ` -> two 16x8 +strips (top/bottom, mi row step 2); `PARTITION_VERT` -> two 8x16 strips (left/right, mi col step 2). +New hit counter `horz_vert_intra_hits()` (thread-local `Cell`, same pattern as +`vert_b_intra_hits`). + +## Ceiling hit +Only the SKIP case is ported (matches `decode_block_rect`'s own precedent at this size range and +VERT_B's own left-strip precedent): a coded (non-skip) HORZ/VERT strip below 16x16 has no +rectangular-transform coefficient tables here yet (same square-only-transform ceiling as the +sibling `lane-sub8`/`decode_block_rect` non-skip refusal at (16,8)/(8,16)), refused by name: +`"a coded (non-skip) HORZ/VERT rect strip below 16x16 (this decoder ports only the skip case at +this size)"`. Filter-intra on this strip is also refused by name (mirrors the existing +`decode_block_rect` refusal). Both added to `refusal_inventory.rs`'s pinned `REFUSALS` list. +Generic multi-way refusal string updated to `"a HORZ_A/HORZ_B/VERT_A partition below 16x16 ..."` +(HORZ_A/HORZ_B/VERT_A remain out of scope this round) and repinned. + +## Live mandelbrot re-probe after the fix +Decode now gets PAST mi=(0,7)'s HORZ arm entirely (structurally proven -- reads real symbols, +reconstructs) and stops at the coded-strip ceiling: `REFUSED: ... (a coded (non-skip) HORZ/VERT +rect strip below 16x16 ...)`. Tried cq=20/40/50/63 too: 20 hits the same coded-strip ceiling, +40 hits an unrelated pre-existing "partition below 8x8" refusal, 50/63 hit the filter-intra-on-strip +refusal (also newly wired, proving it reads real symbols too). No recipe reached a pixel-exact full +decode of this stream -- consistent with VERT_B's own r1 finding, not a regression I introduced. + +## Gate +`stream::tests::a_real_aomenc_stream_with_mandelbrot_fires_the_vert_b_partition_arm` (kept its old +name to avoid extra churn; doc comment rewritten to explain r1 vs r2 findings): fixed the missing +`--passes=1` (now asserts `!stream.is_empty()` as a guard against the same vacuous-gate class +recurring), swapped its hard assertion from `vert_b_intra_hits() > 0` (never true on this stream +post-fix, since HORZ blocks decode first) to `horz_vert_intra_hits() > 0`. +`EVIDENCE: cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_mandelbrot_fires_the_vert_b_partition_arm --nocapture | horz_vert_intra_hits=1, vert_b_intra_hits=0, decode result: Err("... coded (non-skip) HORZ/VERT ...")` + +## Suite / check +`cargo test -p ec-av1 --lib -j4 -- --test-threads=4`: 267 passed, 0 failed, 20 ignored (was 266/1 +pre-fix, the 1 failure being the vacuous gate above). +`cargo check --workspace --all-targets -j4`: clean, no errors, only pre-existing warnings. +HEAD: 7a49307 (branch lane-rect16).