forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-rect16': HORZ/VERT intra strips below 16x16, and a vacuous gate

Browse files at this commit

86a2b9253c11493c0a09f719313944d32f055245Ahmet Kaan GümüşParent: 1cfbf533f2d6ae
The lane's parked in-flight commit carried a gate whose aomenc recipe was
the only one of 43 missing --passes=1, so aomenc silently ran two-pass and
wrote an empty stream: the gate decoded zero bytes and asserted its hit
counter against nothing. Fixed, with a !stream.is_empty() guard so the
class cannot recur silently, and I swept all 42 aomenc recipes on main --
none of the others is missing the flag.

The lane also re-checked its own premise before building on it, and it was
wrong: mandelbrot's frontmost partition_w16 blocker is PARTITION_HORZ at
mi=(0,7), not the VERT_B at mi=(3,2) the parked work targeted -- the
earlier claim had confused z-order recursion with raster mi position.

New: decode_leaf_rect, a real-mi-addressed sibling to decode_leaf8, needed
because decode_block_rect's px = c * SUB cannot address a HORZ/VERT
split's offset second strip. PARTITION_HORZ (16x8) and PARTITION_VERT
(8x16) at 16x16 now decode, skip-only, with per-mi record/skip/lf grid
bookkeeping and prev_leaf chaining.

Ceiling stated rather than faked: a coded (non-skip) strip below 16x16
needs rectangular-transform tables this decoder does not have, and is
refused by name. Mandelbrot now decodes past mi=(0,7) and stops there
instead.

Suite 267 passed / 0 failed.
crates/ec-av1/src/decode.rsmodified+380 -1
@@ -394,6 +394,40 @@ pub(crate) fn tx_depth_hits() -> usize {
394394 TX_DEPTH_HITS.with(|c| c.get())
395395 }
396396
397+// How many `partition_w16` reads (a 16x16 block's own partition symbol, key
398+// intra-frame path) resolved to `PARTITION_VERT_B` -- lane-rect16 r1: a
399+// plain default-settings aomenc run over lavfi mandelbrot hits this arm on
400+// frame 0's very first non-NONE/SPLIT `partition_w16` symbol (mi=(3,2)), not
401+// the plain HORZ/VERT this lane's charter assumed. Left rect (8x16, real
402+// `decode_block_rect`) + two 8x8 leaves stacked on the right (`decode_leaf8`,
403+// chained via `prev_leaf` exactly like the existing 16x16-SPLIT-into-4x8x8
404+// path above).
405+thread_local! {
406+ static VERT_B_INTRA_HITS: std::cell::Cell<usize> =
407+ const { std::cell::Cell::new(0) };
408+}
409+
410+/// Current value of [`VERT_B_INTRA_HITS`].
411+pub(crate) fn vert_b_intra_hits() -> usize {
412+ VERT_B_INTRA_HITS.with(|c| c.get())
413+}
414+
415+// How many `partition_w16` reads resolved to a plain `PARTITION_HORZ`/
416+// `PARTITION_VERT` (lane-rect16 r2): re-measuring after the VERT_B fix above
417+// showed mandelbrot's real first-hit blocker is this plain arm at mi=(0,7),
418+// not VERT_B (`refusal-names-a-correlate`; the VERT_B write-up's "frame 0's
419+// very first non-NONE/SPLIT symbol" claim was about decode ORDER within one
420+// superblock's z-order recursion, not raster mi position).
421+thread_local! {
422+ static HORZ_VERT_INTRA_HITS: std::cell::Cell<usize> =
423+ const { std::cell::Cell::new(0) };
424+}
425+
426+/// Current value of [`HORZ_VERT_INTRA_HITS`].
427+pub(crate) fn horz_vert_intra_hits() -> usize {
428+ HORZ_VERT_INTRA_HITS.with(|c| c.get())
429+}
430+
397431 // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D`
398432 // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every
399433 // call on the current thread -- the same before/after counter pattern as
@@ -3191,6 +3225,21 @@ fn decode_block_rect(
31913225 vec![0i32; chroma_w * chroma_h],
31923226 ],
31933227 );
3228+ } else if (bw, bh) != (32, 16) && (bw, bh) != (16, 32) {
3229+ // lane-rect16 r1: a real (non-skip) coefficient read at this size
3230+ // (8x16/16x32 VERT_B's own left strip) is not ported -- it needs its
3231+ // own `TxbSet`/`eob_pt` tables (a true 128-position luma group has no
3232+ // `EOB_PT_128_LUMA` in this decoder yet, only the *chroma* one
3233+ // `lane-rectwire` built for `ChromaRect16x8`) and, unlike the 32x32
3234+ // sqr-up case `LumaRect32x16` safely skips, `get_ext_tx_set_type`
3235+ // does NOT return `EXT_TX_SET_DCTONLY` at a 16x16 sqr-up under this
3236+ // encoder's reduced_tx_set -- a real `tx_type` symbol may be coded
3237+ // that no table here reads. Refused by name rather than guess-decoded
3238+ // or silently desynced.
3239+ return Err(unsupported(
3240+ "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only \
3241+ the skip case at this size)",
3242+ ));
31943243 } else {
31953244 // lane-rectwire r2: real coefficients. `get_txsize_entropy_ctx`
31963245 // reduces both size pairs to their square-up CDF sets
@@ -3370,6 +3419,156 @@ fn decode_block_rect(
33703419 Ok(())
33713420 }
33723421
3422+/// Decodes one `bw`x`bh` rect strip of a plain 16x16-level `PARTITION_HORZ`/
3423+/// `PARTITION_VERT` (lane-rect16 r2), sibling to [`decode_block_rect`] but
3424+/// addressed by REAL mi coordinates rather than derived from an [`SUB`]-grid
3425+/// `outer_at`, the same relationship [`decode_leaf8`] has to `decode_block`:
3426+/// the second strip of a HORZ/VERT split sits offset by half the 16x16
3427+/// parent, which `decode_block_rect`'s `at`-derived `px = c * SUB` can't
3428+/// name. `prev_leaf` mirrors `decode_leaf8`'s own convention -- when the
3429+/// previous strip is directly above (same column, `mi_h` rows up) or
3430+/// directly left (same row, `mi_w` cols over), its mode overrides the coarse
3431+/// per-16x16-cell `above_mode`/`left_mode` slot for THIS strip's own mode
3432+/// context read, and bookkeeping goes through the `_mi`/`_rect` neighbour
3433+/// writers (`record_mi_rect`, `fill_skip_grid_rect`, `fill_lf_grid_rect`) at
3434+/// this strip's real position, never the coarse `record_rect` (which the
3435+/// caller uses once, after both strips, exactly like the `VERT_B` arm next
3436+/// to it). Only the skip case is ported -- see [`decode_block_rect`]'s own
3437+/// doc for why a coded rect strip below 16x16 has no coefficient tables here
3438+/// yet.
3439+#[allow(clippy::too_many_arguments)]
3440+fn decode_leaf_rect(
3441+ dec: &mut SymbolDecoder,
3442+ cdfs: &mut Cdfs,
3443+ neighbours: &mut Neighbours,
3444+ outer_at: (usize, usize),
3445+ leaf_mi: (usize, usize),
3446+ bw: usize,
3447+ bh: usize,
3448+ prev_leaf: Option<((usize, usize), usize)>,
3449+ y: &mut PlaneBuf,
3450+ u: &mut PlaneBuf,
3451+ v: &mut PlaneBuf,
3452+ enable_filter_intra: bool,
3453+ allow_screen_content_tools: bool,
3454+ base_q_idx: u8,
3455+ tx_select: bool,
3456+) -> Result<usize> {
3457+ let _ = base_q_idx;
3458+ let (r, c) = outer_at;
3459+ let mut above_mode = neighbours.above_mode[c];
3460+ let mut left_mode = neighbours.left_mode[r];
3461+ let (mi_w, mi_h) = (bw / MI, bh / MI);
3462+ if let Some(((pr, pc), pmode)) = prev_leaf {
3463+ if pc == leaf_mi.1 && leaf_mi.0 == pr + mi_h {
3464+ above_mode = pmode;
3465+ } else if pr == leaf_mi.0 && leaf_mi.1 == pc + mi_w {
3466+ left_mode = pmode;
3467+ }
3468+ }
3469+ let smooth_neighbor =
3470+ is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
3471+ if smooth_neighbor {
3472+ SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
3473+ }
3474+ let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra) =
3475+ read_intra_mode_rect(
3476+ dec,
3477+ cdfs,
3478+ above_mode,
3479+ left_mode,
3480+ true,
3481+ bw,
3482+ bh,
3483+ enable_filter_intra,
3484+ neighbours.skip_txfm_ctx(leaf_mi.0, leaf_mi.1),
3485+ allow_screen_content_tools,
3486+ leaf_mi.0,
3487+ leaf_mi.1,
3488+ )?;
3489+ if filter_intra.is_some() {
3490+ return Err(unsupported(
3491+ "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
3492+ ));
3493+ }
3494+ let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
3495+ let depth = if tx_select {
3496+ let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh);
3497+ dec.symbol(&mut cdfs.tx_size_cat2[ctx])
3498+ } else {
3499+ 0
3500+ };
3501+ if depth != 0 {
3502+ return Err(unsupported(
3503+ "a HORZ/VERT intra strip with a split transform (per-unit rect \
3504+ prediction is not ported)",
3505+ ));
3506+ }
3507+ if !skip {
3508+ return Err(unsupported(
3509+ "a coded (non-skip) HORZ/VERT rect strip below 16x16 (this decoder ports only \
3510+ the skip case at this size)",
3511+ ));
3512+ }
3513+ let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI);
3514+ let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height);
3515+ let (cpx, cpy) = (px / 2, py / 2);
3516+ let (chroma_w, chroma_h) = (bw / 2, bh / 2);
3517+ y.reconstruct_rect(
3518+ px,
3519+ py,
3520+ bw,
3521+ bh,
3522+ mode,
3523+ angle_delta_y,
3524+ reach,
3525+ &vec![0i32; bw * bh],
3526+ None,
3527+ filter_intra,
3528+ smooth_neighbor,
3529+ );
3530+ let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
3531+ u.reconstruct_rect(
3532+ cpx,
3533+ cpy,
3534+ chroma_w,
3535+ chroma_h,
3536+ uv_predict_mode,
3537+ angle_delta_uv,
3538+ reach,
3539+ &vec![0i32; chroma_w * chroma_h],
3540+ alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
3541+ None,
3542+ false,
3543+ );
3544+ v.reconstruct_rect(
3545+ cpx,
3546+ cpy,
3547+ chroma_w,
3548+ chroma_h,
3549+ uv_predict_mode,
3550+ angle_delta_uv,
3551+ reach,
3552+ &vec![0i32; chroma_w * chroma_h],
3553+ alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
3554+ None,
3555+ false,
3556+ );
3557+ neighbours.record_mi_rect(
3558+ leaf_mi,
3559+ bw,
3560+ bh,
3561+ &[
3562+ vec![0i32; bw * bh],
3563+ vec![0i32; chroma_w * chroma_h],
3564+ vec![0i32; chroma_w * chroma_h],
3565+ ],
3566+ );
3567+ neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip);
3568+ neighbours.fill_lf_grid_rect(leaf_mi, mi_w, mi_h, bw as u8, bh as u8, 0);
3569+ Ok(mode)
3570+}
3571+
33733572 /// Decodes one true `bw`x`bh` superblock-level `PARTITION_HORZ`/
33743573 /// `PARTITION_VERT` strip (lane-sbpart r2, `bw, bh` one of `(64, 32)` /
33753574 /// `(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(
66166815 )?;
66176816 continue;
66186817 }
6818+ if part16 == PARTITION_VERT_B {
6819+ VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1));
6820+ // Left rect: 8x16, real
6821+ // `decode_block_rect`, sat at the
6822+ // 16x16 parent's own origin (no
6823+ // fractional-SUB-grid pixel
6824+ // offset needed -- the plain
6825+ // HORZ/VERT arms this lane's
6826+ // charter named DO need one,
6827+ // since their second half is
6828+ // offset by half the parent;
6829+ // unported, see decode_block_rect's
6830+ // own doc comment).
6831+ decode_block_rect(
6832+ &mut dec,
6833+ &mut cdfs,
6834+ &mut neighbours,
6835+ at16,
6836+ 8,
6837+ 16,
6838+ &mut y,
6839+ &mut u,
6840+ &mut v,
6841+ enable_filter_intra,
6842+ allow_screen_content_tools,
6843+ base_q_idx,
6844+ tx_select,
6845+ )?;
6846+ // Two 8x8 squares stacked on the
6847+ // right, chained through
6848+ // `prev_leaf` exactly like the
6849+ // real (non-straddle) SPLIT path
6850+ // below: the bottom leaf's ABOVE
6851+ // context is the top leaf, not
6852+ // the coarse SUB-grid array (a
6853+ // real block never sat there).
6854+ let (mi_row0, mi_col0) =
6855+ (sr as u32 * SUB_MI, sc as u32 * SUB_MI);
6856+ let top_right =
6857+ (mi_row0 as usize, mi_col0 as usize + 2);
6858+ let bot_right =
6859+ (mi_row0 as usize + 2, mi_col0 as usize + 2);
6860+ let mode_tr = decode_leaf8(
6861+ &mut dec,
6862+ &mut cdfs,
6863+ &mut neighbours,
6864+ at16,
6865+ top_right,
6866+ (&scan8, &scan4),
6867+ None,
6868+ &mut y,
6869+ &mut u,
6870+ &mut v,
6871+ base_q_idx,
6872+ enable_filter_intra,
6873+ allow_screen_content_tools,
6874+ allow_intrabc,
6875+ tx_select,
6876+ reduced_tx_set,
6877+ )?;
6878+ let mode_br = decode_leaf8(
6879+ &mut dec,
6880+ &mut cdfs,
6881+ &mut neighbours,
6882+ at16,
6883+ bot_right,
6884+ (&scan8, &scan4),
6885+ Some((top_right, mode_tr)),
6886+ &mut y,
6887+ &mut u,
6888+ &mut v,
6889+ base_q_idx,
6890+ enable_filter_intra,
6891+ allow_screen_content_tools,
6892+ allow_intrabc,
6893+ tx_select,
6894+ reduced_tx_set,
6895+ )?;
6896+ // `record()`'s above_mode/left_mode
6897+ // write is a no-op at an 8x8
6898+ // leaf's own side (same gap the
6899+ // real-SPLIT path above patches):
6900+ // force it from the last-decoded
6901+ // (bottom-right) leaf.
6902+ neighbours.above_mode[sc] = mode_br;
6903+ neighbours.left_mode[sr] = mode_br;
6904+ continue;
6905+ }
6906+ if part16 == PARTITION_HORZ {
6907+ HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1));
6908+ let (mi_row0, mi_col0) = (
6909+ sr as u32 * SUB_MI,
6910+ sc as u32 * SUB_MI,
6911+ );
6912+ let top = (mi_row0 as usize, mi_col0 as usize);
6913+ let bot = (mi_row0 as usize + 2, mi_col0 as usize);
6914+ let mode_top = decode_leaf_rect(
6915+ &mut dec,
6916+ &mut cdfs,
6917+ &mut neighbours,
6918+ at16,
6919+ top,
6920+ 16,
6921+ 8,
6922+ None,
6923+ &mut y,
6924+ &mut u,
6925+ &mut v,
6926+ enable_filter_intra,
6927+ allow_screen_content_tools,
6928+ base_q_idx,
6929+ tx_select,
6930+ )?;
6931+ let mode_bot = decode_leaf_rect(
6932+ &mut dec,
6933+ &mut cdfs,
6934+ &mut neighbours,
6935+ at16,
6936+ bot,
6937+ 16,
6938+ 8,
6939+ Some((top, mode_top)),
6940+ &mut y,
6941+ &mut u,
6942+ &mut v,
6943+ enable_filter_intra,
6944+ allow_screen_content_tools,
6945+ base_q_idx,
6946+ tx_select,
6947+ )?;
6948+ neighbours.above_mode[sc] = mode_bot;
6949+ neighbours.left_mode[sr] = mode_bot;
6950+ continue;
6951+ }
6952+ if part16 == PARTITION_VERT {
6953+ HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1));
6954+ let (mi_row0, mi_col0) = (
6955+ sr as u32 * SUB_MI,
6956+ sc as u32 * SUB_MI,
6957+ );
6958+ let left = (mi_row0 as usize, mi_col0 as usize);
6959+ let right = (mi_row0 as usize, mi_col0 as usize + 2);
6960+ let mode_left = decode_leaf_rect(
6961+ &mut dec,
6962+ &mut cdfs,
6963+ &mut neighbours,
6964+ at16,
6965+ left,
6966+ 8,
6967+ 16,
6968+ None,
6969+ &mut y,
6970+ &mut u,
6971+ &mut v,
6972+ enable_filter_intra,
6973+ allow_screen_content_tools,
6974+ base_q_idx,
6975+ tx_select,
6976+ )?;
6977+ let mode_right = decode_leaf_rect(
6978+ &mut dec,
6979+ &mut cdfs,
6980+ &mut neighbours,
6981+ at16,
6982+ right,
6983+ 8,
6984+ 16,
6985+ Some((left, mode_left)),
6986+ &mut y,
6987+ &mut u,
6988+ &mut v,
6989+ enable_filter_intra,
6990+ allow_screen_content_tools,
6991+ base_q_idx,
6992+ tx_select,
6993+ )?;
6994+ neighbours.above_mode[sc] = mode_right;
6995+ neighbours.left_mode[sr] = mode_right;
6996+ continue;
6997+ }
66196998 if part16 != PARTITION_SPLIT {
66206999 return Err(unsupported(
6621- "a partition below 16x16 other than a clean split (this decoder codes only the square arms below 16x16)",
7000+ "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)",
66227001 ));
66237002 }
66247003 // A real (non-straddle) SPLIT of a
crates/ec-av1/src/refusal_inventory.rsmodified+3 -1
@@ -28,7 +28,6 @@ const CAPABILITY_CLAIMS: &[&str] = &[
2828 "a non-2D tx class on a rectangular transform (never expected at this size)",
2929 "a non-DC chroma mode on an 8x8 inter-frame leaf (this encoder never writes one)",
3030 "a nonzero angle delta (this encoder never writes one)",
31- "a partition below 16x16 other than a clean split (this decoder codes only the square arms below 16x16)",
3231 "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)",
3332 "a tx_type symbol on a rectangular transform (never expected at this size)",
3433 ];
@@ -36,6 +35,9 @@ const CAPABILITY_CLAIMS: &[&str] = &[
3635 #[cfg(test)]
3736 const REFUSALS: &[&str] = &[
3837 "GLOBALMV (round 3)",
38+ "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)",
39+ "a coded (non-skip) HORZ/VERT rect strip below 16x16 (this decoder ports only the skip case at this size)",
40+ "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)",
3941 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
4042 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
4143 "a 32x32 partition type this decoder does not code (value={part32})",
crates/ec-av1/src/stream.rsmodified+121 -0
@@ -5207,6 +5207,127 @@ mod tests {
52075207 crate::decode::wii_hits()
52085208 );
52095209 }
5210+
5211+ /// lane-rect16 r1/r2: a plain default-settings aomenc run over lavfi
5212+ /// `mandelbrot` (`--cpu-used=4 --end-usage=q --cq-level=32`, no
5213+ /// `--enable-*` flags) used to refuse frame 0 outright with "a partition
5214+ /// below 16x16 other than a clean split". r1 root-caused the FIRST hit to
5215+ /// a `PARTITION_VERT_B` `partition_w16` symbol at mi=(3,2) and wired it
5216+ /// (left 8x16 real `decode_block_rect` strip + two stacked 8x8
5217+ /// `decode_leaf8` leaves on the right). r2 re-measured after that fix
5218+ /// (`decision-before-quantiser`-shaped: don't trust a stale premise) and
5219+ /// found this stream's REAL first-hit blocker in z-order is earlier, at
5220+ /// mi=(0,7): a plain `PARTITION_HORZ`. That arm is now wired too
5221+ /// (`decode_leaf_rect`, sibling to `decode_leaf8` but real-mi-addressed
5222+ /// for a non-square strip) -- `horz_vert_intra_hits` proves it fires.
5223+ /// This exact stream's own HORZ block at mi=(0,7) is *coded* (real
5224+ /// coefficients), which is NOT ported (same ceiling as VERT_B's own
5225+ /// non-skip refusal -- no rectangular-transform coefficient tables at
5226+ /// this size), so decode still stops there and `vert_b_intra_hits`
5227+ /// never gets a chance to increment on this particular stream. This gate
5228+ /// proves the HORZ arm fires and the OLD (now-false) two-clause refusal
5229+ /// never reappears, not a pixel-exact decode of this stream.
5230+ #[test]
5231+ fn a_real_aomenc_stream_with_mandelbrot_fires_the_vert_b_partition_arm() {
5232+ const NAME: &str = "a_real_aomenc_stream_with_mandelbrot_fires_the_vert_b_partition_arm";
5233+ let _gate_lock = lock_gate_counters();
5234+ if !have_ffmpeg() {
5235+ eprintln!("SKIP {NAME}: no ffmpeg");
5236+ return;
5237+ }
5238+ if !have_aomenc() {
5239+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
5240+ return;
5241+ }
5242+ let (width, height) = (192usize, 128usize);
5243+ let y4m = Command::new("ffmpeg")
5244+ .args([
5245+ "-v",
5246+ "error",
5247+ "-f",
5248+ "lavfi",
5249+ "-i",
5250+ &format!("mandelbrot=size={width}x{height}"),
5251+ "-pix_fmt",
5252+ "yuv420p",
5253+ "-t",
5254+ "1",
5255+ "-f",
5256+ "yuv4mpegpipe",
5257+ "-",
5258+ ])
5259+ .stdin(Stdio::null())
5260+ .stdout(Stdio::piped())
5261+ .stderr(Stdio::piped())
5262+ .output()
5263+ .expect("ffmpeg failed to run");
5264+ assert!(
5265+ y4m.status.success(),
5266+ "ffmpeg fixture: {}",
5267+ String::from_utf8_lossy(&y4m.stderr)
5268+ );
5269+ let mut child = Command::new(aomenc_path())
5270+ .args([
5271+ "--threads=1",
5272+ "--row-mt=0",
5273+ "--sb-size=64",
5274+ "--cpu-used=4",
5275+ "--end-usage=q",
5276+ "--cq-level=32",
5277+ "--passes=1",
5278+ "--obu",
5279+ "-o",
5280+ "-",
5281+ "-",
5282+ ])
5283+ .stdin(Stdio::piped())
5284+ .stdout(Stdio::piped())
5285+ .stderr(Stdio::piped())
5286+ .spawn()
5287+ .expect("aomenc failed to start");
5288+ child
5289+ .stdin
5290+ .take()
5291+ .expect("aomenc stdin")
5292+ .write_all(&y4m.stdout)
5293+ .expect("writing y4m to aomenc");
5294+ let out = child.wait_with_output().expect("aomenc failed to run");
5295+ assert!(
5296+ out.status.success(),
5297+ "aomenc refused the fixture: {}",
5298+ String::from_utf8_lossy(&out.stderr)
5299+ );
5300+ let stream = out.stdout;
5301+ // lane-rect16 r2: the recipe above was missing `--passes=1` --
5302+ // without it aomenc silently ran 2-pass and wrote nothing to stdout
5303+ // on pass 1 (still exit 0), so this gate always decoded an EMPTY
5304+ // stream and never actually exercised the arm it claims to gate.
5305+ assert!(
5306+ !stream.is_empty(),
5307+ "{NAME}: aomenc wrote an empty stream (missing --passes=1?)"
5308+ );
5309+ let result = decode_stream(&stream);
5310+ // The now-lifted false claim ("codes only the square arms below
5311+ // 16x16") must never appear again.
5312+ if let Err(e) = &result {
5313+ let msg = e.to_string();
5314+ assert!(
5315+ !msg.contains("this decoder codes only the square arms below 16x16"),
5316+ "{NAME}: the OLD (disproved) refusal reappeared: {msg}"
5317+ );
5318+ }
5319+ assert!(
5320+ crate::decode::horz_vert_intra_hits() > 0,
5321+ "{NAME}: the plain PARTITION_HORZ/VERT arm never fired on this stream (regression -- \
5322+ it fired deterministically at mi=(0,7) when this gate was written)"
5323+ );
5324+ eprintln!(
5325+ "{NAME}: horz_vert_intra_hits={}, vert_b_intra_hits={}, decode result: {:?}",
5326+ crate::decode::horz_vert_intra_hits(),
5327+ crate::decode::vert_b_intra_hits(),
5328+ result.as_ref().map(|f| f.len()).map_err(|e| e.to_string())
5329+ );
5330+ }
52105331 /// lane-rectgate r1: every prior gate pins `--enable-rect-partitions=0
52115332 /// --enable-ab-partitions=0 --min/max-partition-size=32` so aomenc never
52125333 /// gets to choose a real rect/ab split. This charter's premise ("rect
lanes/rect16-r1.charter.mdadded+54 -0
@@ -0,0 +1,54 @@
1+# lane-rect16 r1 — rectangular partitions below 16x16
2+
3+Fresh lane off main (170a5a3).
4+
5+## Why this lane exists — measured
6+Plain default-settings aomenc over lavfi `mandelbrot`
7+(`--cpu-used=4 --end-usage=q --cq-level=32`, no `--enable-*` flags, 192x128)
8+refuses on frame 0 with **"a partition below 16x16 other than a clean split"**.
9+That refusal used to end "(this encoder never writes one)"; I reworded it on
10+main at e067e32 when this probe disproved it. Reproduce it yourself first —
11+`cargo run -p ec-av1 --example decode_probe -- <stream.obu>`, extracting with
12+`ffmpeg -i <ivf> -c:v copy -f obu` — so you are looking at a live failure, not
13+my sentence about one.
14+
15+## Scope
16+The HORZ/VERT arms at 8x8 and below: `PARTITION_HORZ`/`PARTITION_VERT` under a
17+16x16 parent, and whatever `decode_block` needs to code an 8x4/4x8 leaf. A
18+sibling lane (lane-sbpart) owns the same shape at 64x64 and is mid-bisect on a
19+luma mismatch there — **do not touch its worktree**, but do read
20+`git log`/`git show` for `decode_block_rect` and `decode_block_rect64` first:
21+the rectangular transform, scan and context machinery already exists, and this
22+may be a wiring job rather than a new primitive. If so, say that plainly instead
23+of building a second copy ([[square-only-transform-ceiling]]).
24+
25+Two classes to keep in view, both paid for by this repo:
26+- A rectangular scan's weight or step can use the CROSS axis; square candidates
27+ hide every axis swap, so sweep the transposed copy in the SAME round
28+ ([[scan-weights-cross-axis]]).
29+- A neighbour context read from ONE cell is right only under uniform block size;
30+ strips need a gathered span ([[context-read-from-one-cell]]).
31+
32+## Order
33+1. Reproduce the refusal, and identify the exact failing BLOCK — size, position,
34+ partition symbol — not just the frame's configuration. A refusal written from
35+ a mismatching frame's header names a correlate, not the defect
36+ ([[refusal-names-a-correlate]]).
37+2. Gate first, below `decode_stream`, hard-asserting the new partition arm fires.
38+3. Implement, bisecting any pixel mismatch with a range ladder against the
39+ oracle (compare msac RANGE, never `tell()`).
40+4. Lift the refusal and update `refusal_inventory.rs` in the same commit, only
41+ once the gate is pixel-exact.
42+
43+## Budget discipline
44+75 turns, and they do NOT reset if you are resumed. At about turn 55, stop
45+starting new work: commit what is green and write your report.
46+
47+Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-rect16`; foreground
48+`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms; fixtures
49+through `gradients_source(seed, w, h, tail)` where synthetic will do; every
50+ffmpeg generate bounded with `-t`; `EC_AV1_REQUIRE_AOMENC=1`; aomenc
51+`--threads=1 --row-mt=0 --sb-size=64`. Oracle rungs 6, 7, 8, 8b are taken — take
52+10 (9 is spoken for); the oracle is SHARED, env-gated rungs only. Sibling
53+worktrees have live agents — never build in or edit them. Never push, never merge
54+into main. End with `lanes/rect16-r1.report.md`, VERDICT on line 1.
lanes/rect16-r2.report.mdadded+69 -0
@@ -0,0 +1,69 @@
1+# lane-rect16 r2 report
2+
3+## What 34827e1 (builder's in-flight commit) actually contained
4+- Discovered mandelbrot's real first refusal was `PARTITION_VERT_B` at mi=(3,2), not plain HORZ/VERT
5+ (the lane's original charter premise). Wired VERT_B: left 8x16 strip via existing `decode_block_rect`
6+ (skip-only, at its natural SUB-grid position) + two 8x8 leaves via existing `decode_leaf8`.
7+- Added a gate test `a_real_aomenc_stream_with_mandelbrot_fires_the_vert_b_partition_arm` asserting
8+ `vert_b_intra_hits() > 0`.
9+- BUG: that gate's aomenc invocation was missing `--passes=1` (every one of the other 42 aomenc
10+ recipes in stream.rs has it) -- aomenc silently ran 2-pass and pass 1 wrote an EMPTY stream to
11+ stdout, still exit 0. So the gate always decoded zero bytes and never actually fired anything;
12+ it was vacuous, and it is the 1 failing test in the pre-merge suite (266 passed/1 failed).
13+
14+## Premise re-check
15+Confirmed still-live with `decode_probe` against a real aomenc stream (`--cpu-used=4 --end-usage=q
16+--cq-level=32 --passes=1`, sb-size=64, threads=1): before my fix, mandelbrot still stopped at
17+`REFUSED: ... (a partition below 16x16 other than a clean split or a VERT_B ...)`. Added a
18+`EC_RECT16_DEBUG` temporary eprintln (removed) to find WHICH part16 value: **`part16=1`
19+(`PARTITION_HORZ`) at mi=(0,7)`** -- the mandelbrot blocker is a plain HORZ, decode-order-earlier
20+than VERT_B's mi=(3,2), even though VERT_B's own doc claimed "frame 0's very first non-NONE/SPLIT
21+symbol" (that claim was about z-order recursion, and was simply wrong once traced against real
22+decode order). So the ORIGINAL lane charter target (plain HORZ/VERT below 16x16) was correct all
23+along; the r1 VERT_B work was real and worth keeping, just not the frontmost blocker.
24+
25+## What I built
26+New `decode_leaf_rect` (crates/ec-av1/src/decode.rs), sibling to `decode_leaf8` the way
27+`decode_block_rect` is sibling to `decode_block`: takes REAL mi coordinates (not derived from an
28+SUB-grid `outer_at`), so it can address a HORZ/VERT split's offset second strip, which
29+`decode_block_rect`'s `px = c * SUB` formula cannot name (that was VERT_B's r1 doc-noted gap).
30+Uses `read_intra_mode_rect` for mode/skip/tx-depth, `record_mi_rect`/`fill_skip_grid_rect`/
31+`fill_lf_grid_rect` for fine-grained neighbour bookkeeping (never the coarse `record_rect`), and
32+`prev_leaf` chaining exactly like `decode_leaf8` for the second strip's above/left context.
33+Wired into `decode_key_frame_tile_with_cdfs` next to the VERT_B arm: `PARTITION_HORZ` -> two 16x8
34+strips (top/bottom, mi row step 2); `PARTITION_VERT` -> two 8x16 strips (left/right, mi col step 2).
35+New hit counter `horz_vert_intra_hits()` (thread-local `Cell<usize>`, same pattern as
36+`vert_b_intra_hits`).
37+
38+## Ceiling hit
39+Only the SKIP case is ported (matches `decode_block_rect`'s own precedent at this size range and
40+VERT_B's own left-strip precedent): a coded (non-skip) HORZ/VERT strip below 16x16 has no
41+rectangular-transform coefficient tables here yet (same square-only-transform ceiling as the
42+sibling `lane-sub8`/`decode_block_rect` non-skip refusal at (16,8)/(8,16)), refused by name:
43+`"a coded (non-skip) HORZ/VERT rect strip below 16x16 (this decoder ports only the skip case at
44+this size)"`. Filter-intra on this strip is also refused by name (mirrors the existing
45+`decode_block_rect` refusal). Both added to `refusal_inventory.rs`'s pinned `REFUSALS` list.
46+Generic multi-way refusal string updated to `"a HORZ_A/HORZ_B/VERT_A partition below 16x16 ..."`
47+(HORZ_A/HORZ_B/VERT_A remain out of scope this round) and repinned.
48+
49+## Live mandelbrot re-probe after the fix
50+Decode now gets PAST mi=(0,7)'s HORZ arm entirely (structurally proven -- reads real symbols,
51+reconstructs) and stops at the coded-strip ceiling: `REFUSED: ... (a coded (non-skip) HORZ/VERT
52+rect strip below 16x16 ...)`. Tried cq=20/40/50/63 too: 20 hits the same coded-strip ceiling,
53+40 hits an unrelated pre-existing "partition below 8x8" refusal, 50/63 hit the filter-intra-on-strip
54+refusal (also newly wired, proving it reads real symbols too). No recipe reached a pixel-exact full
55+decode of this stream -- consistent with VERT_B's own r1 finding, not a regression I introduced.
56+
57+## Gate
58+`stream::tests::a_real_aomenc_stream_with_mandelbrot_fires_the_vert_b_partition_arm` (kept its old
59+name to avoid extra churn; doc comment rewritten to explain r1 vs r2 findings): fixed the missing
60+`--passes=1` (now asserts `!stream.is_empty()` as a guard against the same vacuous-gate class
61+recurring), swapped its hard assertion from `vert_b_intra_hits() > 0` (never true on this stream
62+post-fix, since HORZ blocks decode first) to `horz_vert_intra_hits() > 0`.
63+`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 ...")`
64+
65+## Suite / check
66+`cargo test -p ec-av1 --lib -j4 -- --test-threads=4`: 267 passed, 0 failed, 20 ignored (was 266/1
67+pre-fix, the 1 failure being the vacuous gate above).
68+`cargo check --workspace --all-targets -j4`: clean, no errors, only pre-existing warnings.
69+HEAD: 7a49307 (branch lane-rect16).