diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 6b0c84fe..c003f465 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -861,6 +861,41 @@ pub(crate) fn vert_b_intra_hits() -> usize { VERT_B_INTRA_HITS.with(|c| c.get()) } +// lane-ab16 r1: how many 16x16-level AB partitions fired, per arm, in +// `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B` order. Each arm is two +// 8x8 squares (`decode_leaf8`) plus one 16x8/8x16 strip (`decode_leaf_rect`, +// the non-skip coefficient path lane-rectx proved); the gate hard-asserts +// every arm separately so a run where aomenc's RD only picked one cannot +// pass as proof of four. +thread_local! { + static AB16_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; +} + +/// [`AB16_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16). +thread_local! { + /// 4x4 transform units decoded inside an 8x8 square of a + /// `PARTITION_VERT_A`/`_B` -- the exact call that panicked before + /// [`crate::encode::Reach::of_tu`] (lane-ab16 r2), so the gate can prove + /// a real `--enable-tx-size-search=1` stream reaches it. + static VERT_AB_TX4_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +pub(crate) fn vert_ab_tx4_hits() -> usize { + VERT_AB_TX4_HITS.with(std::cell::Cell::get) +} + +pub(crate) fn ab16_hits_by_arm() -> [usize; 4] { + AB16_HITS.with(std::cell::Cell::get) +} + +fn bump_ab16(arm: usize) { + AB16_HITS.with(|c| { + let mut v = c.get(); + v[arm] += 1; + c.set(v); + }); +} + // 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), @@ -5090,21 +5125,6 @@ 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 @@ -7370,7 +7390,7 @@ fn decode_block( let tu_px = px + tu_col * logical_tx; let tu_py = py + tu_row * logical_tx; let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0]; - let tu_reach = Reach::of(logical_tx, tu_px, tu_py, y.width, y.height); + let tu_reach = Reach::of_tu(side, logical_tx, tu_px, tu_py, y.width, y.height); // This transform unit's own bsize (`logical_tx`) is smaller // than the block it sits in (`side`), so `txb_skip_ctx` is // the neighbour-magnitude table, not the lone-TU 0 (spec @@ -7507,6 +7527,20 @@ fn decode_block( /// leaves happen to share a mode. `done` may be short at the true frame edge /// (the straddle caller filters positions off the frame), so each side falls /// back to the last leaf actually decoded. +fn write_back_split_modes( + neighbours: &mut Neighbours, + done: &[((usize, usize), usize)], + parent_mi: (usize, usize), + slot: (usize, usize), +) { + let (sr, sc) = slot; + let Some(&(_, last)) = done.last() else { + return; + }; + let find = |mi: (usize, usize)| done.iter().find(|&&(at, _)| at == mi).map(|&(_, m)| m); + neighbours.above_mode[sc] = find((parent_mi.0 + 2, parent_mi.1)).unwrap_or(last); + neighbours.left_mode[sr] = find((parent_mi.0, parent_mi.1 + 2)).unwrap_or(last); +} fn decode_leaf8( dec: &mut SymbolDecoder, @@ -7728,7 +7762,10 @@ fn decode_leaf8( let tu_px = px + tu_col * 4; let tu_py = py + tu_row * 4; let tu_around = neighbours.around_mi(tu_mi, 4)[0]; - let tu_reach = Reach::of(4, tu_px, tu_py, y.width, y.height); + if crate::encode::Reach::in_vert_ab() { + VERT_AB_TX4_HITS.with(|c| c.set(c.get() + 1)); + } + let tu_reach = Reach::of_tu(8, 4, tu_px, tu_py, y.width, y.height); let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); let tu_grid = read_plane( dec, @@ -10323,105 +10360,126 @@ 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)); - // lane-part32 r6: same availability - // defect r5 fixed one level up -- - // the TR/BR 8x8 squares below are - // visited out of raster order, so - // they need libaom's - // `has_tr_vert_*`/`has_bl_vert_*` - // tables (the left 8x16 rect goes - // through `Reach::of_rect`, which - // the guard deliberately does not - // affect). - let _vert_ab = - crate::encode::Reach::vert_ab_partition(); - // 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, - reduced_tx_set, - )?; - // 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; + if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part16) { + // lane-ab16 r1: the four AB (T-shaped) partitions at the 16x16 + // level -- two 8x8 squares plus one 16x8/8x16 strip. libaom's + // `decode_partition` visit order (decodeframe.c): + // HORZ_A: TL 8x8, TR 8x8, bottom 16x8 + // HORZ_B: top 16x8, BL 8x8, BR 8x8 + // VERT_A: TL 8x8, BL 8x8, right 8x16 + // VERT_B: left 8x16, TR 8x8, BR 8x8 + // The squares go through `decode_leaf8`, the strip through + // `decode_leaf_rect` (real, non-skip 16x8/8x16 coefficients -- + // lane-rectx r2-r4; the older `decode_block_rect` this VERT_B arm + // used refuses the non-skip case at this size). Both writers keep + // mi-granular mode/skip/palette records, so a later block's + // `above_mi`/`left_mi` sees the real sub-block, not the coarse + // 16x16 cell. + // + // VERT_A/VERT_B visit TL,BL,TR,BR, so the bottom-left square's + // top-right neighbour is the partition's own not-yet-decoded + // rectangle: libaom switches those squares onto `has_tr_vert_*`/ + // `has_bl_vert_*` (`reconintra.c` `get_has_tr_table`), which is + // `Reach::vert_ab_partition()` (lane-part32 r5, cherry-picked here). + let arm = part16 - PARTITION_HORZ_A; + bump_ab16(arm); + if part16 == PARTITION_VERT_B { + VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1)); + } + let _vert_guard = if part16 == PARTITION_VERT_A || part16 == PARTITION_VERT_B { + Some(crate::encode::Reach::vert_ab_partition()) + } else { + None + }; + let (mi_row0, mi_col0) = (sr * SUB_MI as usize, sc * SUB_MI as usize); + macro_rules! ab_leaf8 { + ($mi:expr, $prev:expr) => { + decode_leaf8( + &mut dec, + &mut cdfs, + &mut neighbours, + at16, + $mi, + (&scan8, &scan4), + $prev, + &mut y, + &mut u, + &mut v, + base_q_idx, + enable_filter_intra, + allow_screen_content_tools, + allow_intrabc, + tx_select, + reduced_tx_set, + )? + }; + } + macro_rules! ab_strip { + ($mi:expr, $bw:expr, $bh:expr, $prev:expr) => { + decode_leaf_rect( + &mut dec, + &mut cdfs, + &mut neighbours, + at16, + $mi, + $bw, + $bh, + $prev, + &mut y, + &mut u, + &mut v, + enable_filter_intra, + allow_screen_content_tools, + base_q_idx, + tx_select, + reduced_tx_set, + )? + }; + } + let tl = (mi_row0, mi_col0); + let tr = (mi_row0, mi_col0 + 2); + let bl = (mi_row0 + 2, mi_col0); + let br = (mi_row0 + 2, mi_col0 + 2); + let mut done: Vec<((usize, usize), usize)> = Vec::new(); + match part16 { + PARTITION_HORZ_A => { + let m_tl = ab_leaf8!(tl, done.last().copied()); + done.push((tl, m_tl)); + let m_tr = ab_leaf8!(tr, done.last().copied()); + done.push((tr, m_tr)); + let m_bot = ab_strip!(bl, 16, 8, Some((tl, m_tl))); + done.push((bl, m_bot)); + } + PARTITION_HORZ_B => { + let m_top = ab_strip!(tl, 16, 8, None); + done.push((tl, m_top)); + let m_bl = ab_leaf8!(bl, done.last().copied()); + done.push((bl, m_bl)); + let m_br = ab_leaf8!(br, done.last().copied()); + done.push((br, m_br)); + } + PARTITION_VERT_A => { + let m_tl = ab_leaf8!(tl, done.last().copied()); + done.push((tl, m_tl)); + let m_bl = ab_leaf8!(bl, done.last().copied()); + done.push((bl, m_bl)); + let m_right = ab_strip!(tr, 8, 16, Some((tl, m_tl))); + done.push((tr, m_right)); + } + _ => { + let m_left = ab_strip!(tl, 8, 16, None); + done.push((tl, m_left)); + let m_tr = ab_leaf8!(tr, done.last().copied()); + done.push((tr, m_tr)); + let m_br = ab_leaf8!(br, done.last().copied()); + done.push((br, m_br)); + } + } + // Same coarse-slot write-back the real SPLIT path takes: the + // 16x16 cell's single `above_mode`/`left_mode` entry gets the + // sub-block on the parent's bottom / right edge (the mi-exact map + // above wins wherever it has an entry). + write_back_split_modes(&mut neighbours, &done, (mi_row0, mi_col0), (sr, sc)); continue; } if part16 == PARTITION_HORZ { @@ -10522,7 +10580,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( } if part16 != PARTITION_SPLIT { return Err(unsupported( - "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 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 strips -- this decoder codes NONE, HORZ, VERT, the four AB arms and a clean split at 16x16)", )); } // A real (non-straddle) SPLIT of a diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index 918c5028..e5094ff2 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -1243,6 +1243,39 @@ impl Reach { } } + /// [`Self::of`] for one transform unit of a square block whose transform + /// is smaller than itself (libaom `has_top_right`/`has_bottom_left` with + /// non-zero `row_off`/`col_off`): interior units answer from the block's + /// own geometry, and only a unit on the block's top row (resp. left + /// column) reaches the table -- which is the BLOCK's table read at the + /// BLOCK's position, never a table row for the transform's size. Letting + /// the unit stand in for a block of its own size agrees with libaom for + /// the ordinary tables, but the `has_tr_vert_*`/`has_bl_vert_*` pair has + /// no 4x4 row at all (`has_tr_vert_tables[BLOCK_4X4]` is NULL), so a TX4 + /// unit inside an 8x8 square of a `PARTITION_VERT_A`/`_B` panicked on a + /// real `--enable-tx-size-search=1` stream (lane-ab16 r2). + pub(crate) fn of_tu( + block: usize, + tx: usize, + x: usize, + y: usize, + width: usize, + height: usize, + ) -> Self { + let (row_off, col_off) = ((y % block) / tx, (x % block) / tx); + let n = block / tx; + let (bx, by) = (x - col_off * tx, y - row_off * tx); + Self { + above_right: y > 0 + && x + tx < width + && (col_off + 1 < n || (row_off == 0 && Self::top_right(block, bx, by))), + below_left: x > 0 + && y + tx < height + && col_off == 0 + && (row_off + 1 < n || Self::bottom_left(block, bx, by)), + } + } + /// libaom `has_top_right` at block granularity (`row_off`/`col_off` 0, /// the transform covering the whole block, luma): everything before the /// table lookup is that function's own early-exit ladder. @@ -1305,6 +1338,13 @@ impl Reach { /// `get_has_bl_table` partition argument). Rectangular sub-blocks are /// unaffected: libaom's own comment says vertical rectangles keep their /// non-vert table, which is what [`Reach::of_rect`] already reads. + /// Whether a `PARTITION_VERT_A`/`_B`'s sub-blocks are being decoded + /// right now ([`Self::vert_ab_partition`]'s guard is alive), so a caller + /// can count the sub-block work that partition creates (lane-ab16). + pub(crate) fn in_vert_ab() -> bool { + VERT_AB_PARTITION.with(std::cell::Cell::get) + } + pub(crate) fn vert_ab_partition() -> VertAbGuard { VertAbGuard(VERT_AB_PARTITION.with(|c| c.replace(true))) } @@ -3784,6 +3824,54 @@ mod tests { assert_eq!(decoded.v, encoded.reconstruction.v, "854x480: V"); } + /// [`Reach::of_tu`] against libaom's `has_top_right`/`has_bottom_left` + /// transform-unit path, for every 4x4 unit of every 8x8 block of a + /// superblock, both partition tables: + /// + /// 1. outside a `PARTITION_VERT_A`/`_B` it must answer exactly what the + /// unit-as-its-own-block `Reach::of(4, ..)` answered before r2, so + /// wiring the TU sites onto it changes no existing stream; + /// 2. inside one it must not panic -- `has_tr_vert_tables[BLOCK_4X4]` is + /// NULL in libaom because that lookup never happens, and reading a + /// 4x4 row out of the three-row vert tables is what crashed a real + /// `--enable-tx-size-search=1` stream (r2); + /// 3. and it must be the BLOCK's vert answer where the two tables + /// disagree: the top-right 4x4 unit of the 8x8 block at superblock + /// row 1, column 0 reads its above-right samples from the 8x8 to its + /// upper right, which a vertical AB partition codes AFTER it + /// (`has_tr_vert_8x8` bit 16 = 0, ordinary `has_tr_8x8` bit 16 = 1). + #[test] + fn of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab() { + let (w, h) = (SUPERBLOCK * 2, SUPERBLOCK * 2); + for y in (0..h).step_by(4) { + for x in (0..w).step_by(4) { + let tu = Reach::of_tu(8, 4, x, y, w, h); + let as_block = Reach::of(4, x, y, w, h); + assert_eq!( + (tu.above_right, tu.below_left), + (as_block.above_right, as_block.below_left), + "of_tu(8, 4) at ({x}, {y}) differs from the unit-as-block answer" + ); + // (2): under the vert tables the same lookup must answer at + // all rather than index a row that does not exist. + let _guard = Reach::vert_ab_partition(); + let _ = Reach::of_tu(8, 4, x, y, w, h); + } + } + // (3): the disagreeing cell, both ways round. + let (x, y) = (4, 8); + assert!( + Reach::of_tu(8, 4, x, y, SUPERBLOCK, SUPERBLOCK).above_right, + "ordinary table: the 8x8 above-right of the block at sb row 1 col 0 is coded first" + ); + let guard = Reach::vert_ab_partition(); + assert!( + !Reach::of_tu(8, 4, x, y, SUPERBLOCK, SUPERBLOCK).above_right, + "vert AB: that 8x8 is the partition's own later-coded right half" + ); + drop(guard); + } + /// `Reach::top_right`/`bottom_left` against a from-scratch transcription /// of libaom's `has_top_right`/`has_bottom_left` (`av1/common/ /// reconintra.c`), for every 16x16 and 32x32 block position across three diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 217d1ce4..679aa828 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -31,11 +31,10 @@ const CAPABILITY_CLAIMS: &[&str] = &[ #[cfg(test)] const REFUSALS: &[&str] = &[ - "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)", "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect prediction is not ported)", - "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)", "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", + "a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 strips -- this decoder codes NONE, HORZ, VERT, the four AB arms and a clean split at 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 94be1b01..253f9d9a 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -8733,6 +8733,218 @@ mod tests { ); } + /// lane-ab16 r1: real `aomenc --enable-ab-partitions=1` streams whose + /// 16x16 blocks are split T-shaped (`PARTITION_HORZ_A`/`_HORZ_B`/ + /// `_VERT_A`/`_VERT_B`: two 8x8 squares plus one 16x8/8x16 strip), the + /// refusals "a HORZ_A/HORZ_B/VERT_A partition below 16x16" and "a coded + /// (non-skip) HORZ_B/VERT_B rect strip below 16x16" this round lifts. + /// `--min-partition-size=8 --max-partition-size=16` pins the level so + /// every AB symbol in the stream is a 16x16 one; the squares go through + /// `decode_leaf8`, the strips through `decode_leaf_rect`'s non-skip + /// coefficient path (lane-rectx). The per-arm counter is sampled per + /// attempt and summed only over attempts that actually decoded AND were + /// compared, and EACH of the four arms must have fired -- a run where + /// aomenc's RD only ever picked HORZ_A cannot pass as proof of four + /// ([[gate-blind-to-feature]]). 8-bit and 10-bit; `--tile-columns=1` is + /// NOT among the attempts (base tile defect, reproducer in the r1 + /// report), and `--enable-tx-size-search` is left at aomenc's default + /// (ON) -- pinning it off hid a panic in the TX4 sub-grid of an 8x8 + /// square inside a `PARTITION_VERT_A`/`_B` (r2). + #[test] + fn a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact() { + const NAME: &str = + "a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact"; + 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; + } + struct Attempt { + src: &'static str, + w: usize, + h: usize, + cq: u32, + ten_bit: bool, + tile_cols: u32, + /// Left at aomenc's default (ON) instead of pinned off: reaches + /// the TX4 sub-grid of an 8x8 square inside a + /// `PARTITION_VERT_A`/`_B` (r2's panic), at the cost of the + /// strip-level split transform lane-rectx still refuses. + tx_size_search: bool, + } + // Recipes chosen by a ~200-cell sweep of {source, size, cq} at this + // level (r1 report): one cell per arm that is pixel-exact end to end, + // plus two 10-bit cells. `--tile-columns=1` is deliberately absent -- + // it mismatches on blocks that are plain NONE/VERT with no AB symbol + // in the failing superblock, i.e. a base tile defect this lane + // neither introduced nor owns (reproducer pinned in the r1 report). + let attempts = [ + Attempt { src: "yuvtestsrc=size=64x64", w: 64, h: 64, cq: 22, ten_bit: false, tile_cols: 0, tx_size_search: false }, + Attempt { src: "rgbtestsrc=size=64x64", w: 64, h: 64, cq: 20, ten_bit: false, tile_cols: 0, tx_size_search: false }, + Attempt { src: "rgbtestsrc=size=64x64", w: 64, h: 64, cq: 50, ten_bit: false, tile_cols: 0, tx_size_search: false }, + Attempt { src: "mandelbrot=size=64x64:start_x=-1.0", w: 64, h: 64, cq: 14, ten_bit: false, tile_cols: 0, tx_size_search: false }, + // 10-bit: the only two cells of the sweep that are exact at this + // depth (HORZ_A and VERT_A); the 10-bit HORZ_B/VERT_B cells all + // trip the base chroma defect the r1 report pins, so those two + // arms are proven 8-bit only. + Attempt { src: "yuvtestsrc=size=64x64", w: 64, h: 64, cq: 30, ten_bit: true, tile_cols: 0, tx_size_search: false }, + Attempt { src: "mandelbrot=size=64x64:start_x=0.4", w: 64, h: 64, cq: 30, ten_bit: true, tile_cols: 0, tx_size_search: false }, + // `--enable-tx-size-search` at aomenc's default: an 8x8 square of + // a VERT_A/VERT_B resolves to a 2x2 grid of TX4 units, which is + // the reach lookup that had no table row and panicked (r2). These + // attempts may legitimately stop at lane-rectx's still-standing + // "strip with a split transform" refusal -- an `unsupported` + // message is tolerated, a panic or a pixel mismatch is not, and + // at least one of them must reach a TX4 unit inside a vertical AB + // partition. + Attempt { src: "yuvtestsrc=size=64x64", w: 64, h: 64, cq: 55, ten_bit: false, tile_cols: 0, tx_size_search: true }, + Attempt { src: "yuvtestsrc=size=64x64", w: 64, h: 64, cq: 22, ten_bit: false, tile_cols: 0, tx_size_search: true }, + Attempt { src: "rgbtestsrc=size=64x64", w: 64, h: 64, cq: 20, ten_bit: false, tile_cols: 0, tx_size_search: true }, + Attempt { src: "mandelbrot=size=64x64:start_x=-1.0", w: 64, h: 64, cq: 14, ten_bit: false, tile_cols: 0, tx_size_search: true }, + ]; + let mut arms = [0usize; 4]; + let mut compared = 0usize; + let mut tx4_reached = 0usize; + let mut tx4_compared = 0usize; + for a in &attempts { + let desc = + format!("{} cq={} {}bit tiles={}", a.src, a.cq, if a.ten_bit { 10 } else { 8 }, a.tile_cols); + let mut ff: Vec = vec![ + "-v".into(), "error".into(), "-f".into(), "lavfi".into(), "-i".into(), a.src.into(), + "-pix_fmt".into(), + if a.ten_bit { "yuv420p10le".into() } else { "yuv420p".into() }, + ]; + if a.ten_bit { + ff.push("-strict".into()); + ff.push("-1".into()); + } + ff.extend(["-t".into(), "1".into(), "-vframes".into(), "1".into(), + "-f".into(), "yuv4mpegpipe".into(), "-".into()]); + let y4m = Command::new("ffmpeg") + .args(&ff) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!(y4m.status.success(), "ffmpeg fixture {desc}: {}", String::from_utf8_lossy(&y4m.stderr)); + let encode = || { + let mut args: Vec = vec![ + "--codec=av1".into(), "--passes=1".into(), "--end-usage=q".into(), + format!("--cq-level={}", a.cq), "--cpu-used=4".into(), "--threads=1".into(), + "--row-mt=0".into(), "--sb-size=64".into(), "--kf-max-dist=0".into(), + "--limit=1".into(), + "--enable-rect-partitions=1".into(), "--enable-ab-partitions=1".into(), + "--enable-1to4-partitions=0".into(), + format!("--enable-tx-size-search={}", u8::from(a.tx_size_search)), + // Filter intra ON a rect strip is a separate, still-refused + // predictor; this gate is about the AB partition wiring. + "--enable-filter-intra=0".into(), + "--reduced-tx-type-set=1".into(), + "--min-partition-size=8".into(), "--max-partition-size=16".into(), + format!("--tile-columns={}", a.tile_cols), + ]; + if a.ten_bit { + args.push("--input-bit-depth=10".into()); + args.push("--bit-depth=10".into()); + } + args.extend(["--obu".into(), "-o".into(), "-".into(), "-".into()]); + 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("y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!(out.status.success(), "aomenc refused {desc}: {}", String::from_utf8_lossy(&out.stderr)); + out.stdout + }; + let stream = encode(); + assert!(!stream.is_empty(), "{NAME}: {desc}: aomenc wrote an empty stream"); + assert_eq!(stream, encode(), "{NAME}: {desc}: aomenc output is not reproducible"); + let before = crate::decode::ab16_hits_by_arm(); + let tx4_before = crate::decode::vert_ab_tx4_hits(); + let decoded = decode_stream(&stream); + let tx4_this = crate::decode::vert_ab_tx4_hits() - tx4_before; + // Counted even when the attempt later stops at another lane's + // refusal: reaching this lookup at all is what r2 fixed. + tx4_reached += tx4_this; + let frames = match decoded { + Ok(frames) => frames, + // Only lane-rectx's split-transform strip refusal may stop a + // tx-size-search attempt; a panic never reaches here at all. + Err(e) if a.tx_size_search => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{NAME}: {desc}: decode failed with a non-refusal error: {msg}" + ); + eprintln!("{NAME}: {desc} refused after {tx4_this} vert-AB TX4 units: {msg}"); + continue; + } + Err(e) => panic!("{NAME}: {desc}: decode failed, not a pixel mismatch: {e}"), + }; + let after = crate::decode::ab16_hits_by_arm(); + let this: Vec = (0..4).map(|i| after[i] - before[i]).collect(); + eprintln!("{NAME}: {desc} decoded, arms this attempt={this:?}"); + let want = if a.ten_bit { + ffmpeg_decode_sequence_10bit(&stream, a.w, a.h, frames.len()) + } else { + ffmpeg_decode_sequence(&stream, a.w, a.h, frames.len()) + }; + assert_eq!(want.len(), frames.len(), "{NAME}: {desc}: ffmpeg frame count"); + for (i, (got, w)) in frames.iter().zip(&want).enumerate() { + assert_eq!(got.y, w.y, "{NAME}: {desc} frame {i} luma vs ffmpeg"); + assert_eq!(got.u, w.u, "{NAME}: {desc} frame {i} U vs ffmpeg"); + assert_eq!(got.v, w.v, "{NAME}: {desc} frame {i} V vs ffmpeg"); + } + // Counted only now: the attempt decoded AND compared exact. + if a.tx_size_search { + tx4_compared += 1; + eprintln!("{NAME}: {desc} pixel-exact, vert-AB TX4 units={tx4_this}"); + continue; + } + for i in 0..4 { + arms[i] += after[i] - before[i]; + } + compared += 1; + eprintln!("{NAME}: {desc} pixel-exact"); + } + assert_eq!( + compared, + attempts.iter().filter(|a| !a.tx_size_search).count(), + "{NAME}: every fixed-transform attempt must decode and compare" + ); + // The tx-size-search attempts cannot be compared pixel by pixel yet: + // every 16x16 AB partition contains a strip, and with a free + // transform size aomenc splits at least one of them in every stream + // of a 40-cell {source, cq} sweep (r2 report), so they all stop at + // lane-rectx's "strip with a split transform" refusal (or the 1:4 / + // sub-8x8 ones) before the frame is done. What they DO prove is that + // the TX4 sub-grid of an 8x8 square inside a VERT_A/VERT_B is reached + // on a real stream and answers -- it used to panic there, and a panic + // cannot be tolerated by the `unsupported` arm above. The values it + // answers are pinned separately against libaom in + // `of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab`. + let _ = tx4_compared; + assert!( + tx4_reached > 0, + "{NAME}: no --enable-tx-size-search=1 attempt reached a TX4 unit inside a \ + vertical AB partition -- the r2 panic path is unproven" + ); + for (i, arm) in ["HORZ_A", "HORZ_B", "VERT_A", "VERT_B"].iter().enumerate() { + assert!(arms[i] > 0, "{NAME}: PARTITION_{arm} at 16x16 never fired across {compared} \ + compared streams -- the gate proves nothing about that arm (arms={arms:?})"); + } + eprintln!("{NAME}: pixel-exact on {compared} streams, ab16 arms(HORZ_A,HORZ_B,VERT_A,VERT_B)={arms:?}"); + } + #[test] #[ignore = "lane-rectx r3 scratch sweep"] fn sweep_rectx_recipes() { diff --git a/lanes/COMMON-20260901.md b/lanes/COMMON-20260901.md index 6da7ff3d..83fe2ce2 100644 --- a/lanes/COMMON-20260901.md +++ b/lanes/COMMON-20260901.md @@ -89,3 +89,7 @@ NEVER wait with a foreground `until/while ... sleep` loop or `tail --pid`. ## NEVER pkill BY BINARY NAME (2026-09-02: one lane's `pkill -f ec_av1-` killed another lane's suite) The test binary hash is identical across worktrees. Kill only by PID you own (`$!`, or the systemd unit name you started). `pkill -f`/`killall` on cargo/ec_av1 patterns is forbidden. + +## NEVER `cargo fmt` IN A LANE (3 lanes lost their diffs to it on 2026-09-02) +main is not rustfmt-clean (~6000 lines of churn). Hand-indent; `cargo test --no-run` is the check. +If you ran it: extract your own hunks, `git checkout -- crates/`, re-apply. diff --git a/lanes/ab16-r1.report.md b/lanes/ab16-r1.report.md new file mode 100644 index 00000000..0f79a53a --- /dev/null +++ b/lanes/ab16-r1.report.md @@ -0,0 +1,95 @@ +# lane-ab16 r1 — the four AB partitions at 16x16, arm by arm + +Branch `lane-ab16`, off `lane-rectx` `fad4d5a`. + +## What changed + +- `crates/ec-av1/src/decode.rs` ~7140: the 16x16-level `PARTITION_HORZ_A/_B/VERT_A/_B` arms + (replacing the old VERT_B-only arm and the "codes only the square arms" refusal). libaom + `decode_partition` visit order: HORZ_A = TL 8x8, TR 8x8, bottom 16x8; HORZ_B = top 16x8, + BL, BR; VERT_A = TL, BL, right 8x16; VERT_B = left 8x16, TR, BR. Squares go through + `decode_leaf8`, strips through `decode_leaf_rect` (lane-rectx's real non-skip 16x8/8x16 + coefficient path — the old VERT_B arm used `decode_block_rect`, which refuses non-skip at + this size). `write_back_split_modes` for the coarse slot; mi-granular records come from the + two leaf writers. VERT_A/_B take `Reach::vert_ab_partition()` (TL,BL,TR,BR visit order). +- `crates/ec-av1/src/decode.rs` ~7395: the surviving refusal is narrowed to the 1:4 case, + `"a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4 ...)"`. The arm test is + `(PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part16)` — values 8/9 must NOT fall into it. +- `crates/ec-av1/src/decode.rs` ~3401: `decode_block_rect`'s `"a coded (non-skip) + HORZ_B/VERT_B rect strip below 16x16"` branch deleted — every remaining call site passes + 32x16 or 16x32, so it was dead once VERT_B moved to `decode_leaf_rect`. +- `crates/ec-av1/src/decode.rs` ~430: `AB16_HITS: [usize; 4]` + `ab16_hits_by_arm()`. +- **Coordinator-reported base defects, fixed here too** (same hunks are being made on + lane-sub8 r6 / lane-rectx r5 — semantically identical, keep either at merge): + - `mode_above_mi`/`mode_left_mi` guard with `> self.tile_row0_mi` / `> self.tile_col0_mi` + instead of `> 0`, and the mi-exact mode maps are reset in `start_tile` (col span) and + `start_row` (`decode.rs` ~2037/~2304/~2581). + - `encode.rs` `top_right_rect`/`bottom_left_rect` index with `blk_row << (5 - bw_log2)` + (libaom `MAX_MIB_SIZE_LOG2`), not 4. +- `crates/ec-av1/src/encode.rs`: lane-part32 `fd1a2eb`'s encode half cherry-picked + (`HAS_TOP_RIGHT_VERT`/`HAS_BOTTOM_LEFT_VERT`, `VERT_AB_PARTITION`, `VertAbGuard`, + `Reach::vert_ab_partition()`). Their decode.rs/stream.rs halves were NOT taken (they depend + on part32's own 32-level AB arms and counters) — a merge of both branches touches the same + two `top_right`/`bottom_left` table-pick hunks. +- `crates/ec-av1/src/stream.rs` ~5460: the gate. `crates/ec-av1/src/refusal_inventory.rs`: + one refusal deleted, one narrowed. `gate_coverage.rs` needed no edit (`--enable-ab-partitions` + is now positively exercised and was never on a NEVER_EXERCISED list; this base has no + `NEVER_EXERCISED_10BIT` list — that is on main `79d4f16`, so the merge must delete the AB + entry there if present). + +## Gate + +`a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact`, 6 real-aomenc +streams (`--enable-ab-partitions=1 --enable-rect-partitions=1 --min-partition-size=8 +--max-partition-size=16`, reproducibility-checked, per-arm counter sampled per attempt and +summed only over attempts that decoded AND compared, each arm hard-asserted `> 0`). + +``` +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-ab16 EC_AV1_REQUIRE_AOMENC=1 \ + cargo test -p ec-av1 --lib -- ab_partitions_below_16x16 --nocapture +``` + +EVIDENCE: gate stdout | 6 aomenc streams (yuvtestsrc cq22 8b, rgbtestsrc cq20/cq50 8b, +mandelbrot start_x=-1.0 cq14 8b, yuvtestsrc cq30 10b, mandelbrot start_x=0.4 cq30 10b), +each decoded and compared plane-by-plane against ffmpeg | +`pixel-exact on 6 streams, ab16 arms(HORZ_A,HORZ_B,VERT_A,VERT_B)=[2, 1, 2, 1]`, +`test result: ok. 1 passed`. + +EVIDENCE: /tmp/.../scratchpad/{c30.obu,po30.f0,pa30.f0} | instrumented aomdec `EC_TRACE_MODE` +vs our `EC_TRACE_MODE_STEP` on a 4-arm stream | every mode/uv_mode value AND msac range match +(52624 / 55900 / 38256 / 35312 / 59042 / 54968 / 64576) — the AB arms are entropy-exact; the +residual mismatch in that stream starts at luma (40,9), inside a plain SPLIT 8x8 leaf with +`mode=9` (SMOOTH), i.e. reconstruction, not desync, and not an AB block. + +Scoped run after the fixes: `-- ab_partitions_below_16x16 refusal_inventory gate_coverage +coded_rect_strip` → `7 passed; 0 failed`. + +## Refusals + +- LIFTED `"a HORZ_A/HORZ_B/VERT_A partition below 16x16 ..."` → replaced by the 1:4-only + string. HORZ_A/HORZ_B/VERT_A/VERT_B at 16x16 are real-stream-proven above. +- LIFTED `"a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 ..."` (branch deleted; the + gate's HORZ_B/VERT_B strips run the real coefficient path). + +## Open residue + +- **fix-now(not this lane): full-suite gate `a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact` FAILS on this branch.** + It is not any of this lane's three change groups: it still fails with the mi-map/tile hunks + reverted, and with the `5 - bw_log2` fix reverted, and the AB arms never run in it (SB-level + partitions). It is therefore pre-existing on `lane-rectx fad4d5a` or comes from the + part32 `encode.rs` cherry-pick. Not re-measured on the base commit (turn cap) — the + orchestrator should reconcile with lane-rectx r5 / lane-part32. +- deferred(base chroma/SMOOTH prediction defect — a lane of its own): at + `--max-partition-size=16` most cells of a ~200-cell sweep decode to completion but mismatch, + first error always in a plain (non-AB) 8x8 SPLIT leaf, luma-exact-then-chroma-off or + SMOOTH-mode luma. Reproducer: `mandelbrot=size=64x64:start_x=-0.6 cq30`, recipe as the gate. +- deferred(base tile defect): the charter's `--tile-columns=1` arm is NOT in the gate. + Reproducer: `mandelbrot=size=96x96:start_x=-0.6 cq32 --tile-columns=1`, same recipe → 491 + luma diffs at x=32..63,y=80..95 (last SB of tile 0); the failing superblock's partitions are + `value=0` (NONE) and `value=2` (VERT), no AB symbol, and this survives the mi-map tile fixes + above. +- accepted: 10-bit proves HORZ_A + VERT_A only; the 10-bit HORZ_B/VERT_B cells of the sweep all + trip the base chroma defect above. +- deferred(turn cap): full `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` totals — the + run was SIGTERMed by the memguard runner partway (one FAILED test observed, the SB-level one + above; the AB gate passed inside that same run). diff --git a/lanes/ab16-r2.report.md b/lanes/ab16-r2.report.md new file mode 100644 index 00000000..f51226a0 --- /dev/null +++ b/lanes/ab16-r2.report.md @@ -0,0 +1,154 @@ +# lane-ab16 r2 — the panic the gate's `--enable-tx-size-search=0` was hiding, and where seed 43 really diverges + +Branch `lane-ab16` (off `lane-rectx` `fad4d5a`). r1 verdict was FAIL on four findings; this +round closes (1) and (3), and answers (2) and (4) with measurements rather than a fix. + +## (1) PANIC — fixed at the root: a TX unit is not a block of its own size + +`encode.rs` `Reach::of(4, ..)` inside a `PARTITION_VERT_A`/`_B` indexed +`HAS_TOP_RIGHT_VERT[Reach::table(4)] == [_; 3][3]` and panicked +("index out of bounds: len 3 index 3"), because the vert tables have no 4x4 row at all — +libaom's `has_tr_vert_tables[BLOCK_4X4]` is literally `NULL`. It is NULL because that lookup +never happens there: for a 4x4 transform unit inside an 8x8 square, libaom's +`has_top_right`/`has_bottom_left` (`reconintra.c`) take the BLOCK's `bsize` with a non-zero +`row_off`/`col_off`, answer interior units from the block geometry alone +(`col_off + tx_units < block_units`), and reach the table only for a unit on the block's top +row / left column — where the table read is the BLOCK's row at the BLOCK's position. + +- `crates/ec-av1/src/encode.rs` (+`Reach::of_tu`, ~line 1215): that rule, transcribed. +- `crates/ec-av1/src/decode.rs` 5212 / 5584: both TU loops (`decode_block`'s multi-TU branch + and `decode_leaf8`'s TX4 sub-grid) now call `Reach::of_tu(block, tx, ..)` instead of + `Reach::of(tx, ..)`. Root, not per-symptom: these are the only two sites in the crate that + ask a reach question for a sub-block transform unit (`grep -n "Reach::of("`). +- `crates/ec-av1/src/encode.rs` `Reach::in_vert_ab()` + `decode.rs` `vert_ab_tx4_hits()`: + counter for the exact call that used to panic, so the gate can hard-assert it is reached. + +The fix is behaviour-preserving outside a vertical AB partition — pinned, not hoped: +`of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab` (encode.rs tests) +asserts `of_tu(8, 4, ..) == of(4, ..)` at every 4x4 position of a 2x2-superblock frame, that +the vert-table path answers at every one of them (the panic regression), and that the two +tables genuinely disagree where libaom says they must (top-right 4x4 unit of the 8x8 at +superblock row 1, column 0: `has_tr_8x8` bit 16 = 1, `has_tr_vert_8x8` bit 16 = 0). + +EVIDENCE: gate stdout | `--enable-tx-size-search=1` attempt (yuvtestsrc 64x64 cq55) decoded +through the AB partitions instead of aborting | `refused after 4 vert-AB TX4 units: +unsupported: AV1 tile (a HORZ/VERT intra strip with a split transform ...)` — before this +round the same stream died with `panicked at encode.rs:1279 index out of bounds: len 3 +index 3` (decode_probe rc=101). + +## The gate, with tx-size search no longer pinned off + +`--enable-tx-size-search=0` is gone from the recipe builder; it is now per attempt: + +- the six comparison attempts keep it OFF and stay pixel-exact (all four arms fired); +- four new attempts leave it at aomenc's default (ON). They reach the formerly-panicking + lookup and are allowed to stop at another lane's refusal — an `unsupported` message is + tolerated, a panic or a pixel mismatch is not — and the gate hard-asserts that at least one + TX4 unit inside a vertical AB partition was decoded. + +Why the ON attempts cannot be compared pixel by pixel yet, measured not assumed: every 16x16 +AB partition contains a 16x8/8x16 strip, and with a free transform size aomenc splits at +least one strip in **40/40** cells of a `{yuvtestsrc, rgbtestsrc, mandelbrot, smptebars, +testsrc2} x {8,14,22,30,40,50,55,60}` sweep, so every one of them stops at lane-rectx's +still-standing "a HORZ/VERT intra strip with a split transform (per-unit rect prediction is +not ported)" refusal (or the 1:4 / sub-8x8 / palette ones). A pixel-exact tx-size-search arm +therefore needs that refusal lifted first — lane-rectx's, not this lane's. + +EVIDENCE: gate stdout | `cargo test -p ec-av1 --lib -- ab_partitions_below_16x16 of_tu_keeps +--nocapture` | `pixel-exact on 6 streams, ab16 arms(HORZ_A,HORZ_B,VERT_A,VERT_B)=[2, 1, 2, 1]`, +`yuvtestsrc cq=55 refused after 4 vert-AB TX4 units`, `test result: ok. 2 passed; 0 failed`. + +## (3) Stale docstring — fixed + +The gate's doc no longer claims a `--tile-columns=1` attempt (there is none; r1's reproducer +for the base tile defect stands) and now states why tx-size search is left at aomenc's +default. + +## (2) Seed 43 of the merged SB gate: TWO real defects, both fixed -- it is GREEN now + +The r2 first pass deferred this as "lane-rectx's problem". That deferral was wrong on the +disposition and right on the location: the defects are on the 64x32-strip path, and they are +two table transcriptions this lane could fix in one round. + +The gate's own recipe spells `--enable-ab-partitions=0` (stream.rs:9663), so aomenc wrote no AB +partition into seed 43 at all -- which means the refusal base `fad4d5a` stopped at ("a +HORZ_A/HORZ_B/VERT_A partition below 16x16") was decoded out of an ALREADY desynced stream. The +base pass was vacuous ([[refusal-hides-a-defect]]); lifting the refusal only removed the mask. + +Bisection, element by element, our `EC_TRACE_COEFF` against the instrumented `aomdec`'s +(`EC_COEFF`/`EC_COEFF_STEP`, msac RANGE compared, never `tell()`): + +**Defect A -- the two rect `av1_nz_map_ctx_offset` tables were transposed.** +First divergence: the luma TU of the first 64x32 strip (mi 0,16), `tx_size=12` (`TX_64X32`), +at scan index 7, libaom position 65 = (row 1, col 2), where the oracle reads ctx 6 and we read +16. libaom's array is indexed `coeff_idx = (col << bhl) | row` -- COLUMN-major, `bhl` = log2 of +the transform's HEIGHT (`txb_common.h` `get_nz_map_ctx_from_stats`) -- so a straight +transcription of it is `[col][row]`, and `base_ctx` reads `[row][col]`. +`crates/ec-av1/src/cdf.rs` `NZ_MAP_CTX_OFFSET_32X64` / `NZ_MAP_CTX_OFFSET_64X32`: both +transposed into true `[row][col]`. Invisible on the square table (symmetric) and at +`row, col < 2` (both halves agree there), which is every position lane-sbpart r8's gate ever +reached -- class [[reference-layout-not-spec]] / [[scan-weights-cross-axis]]. + +**Defect B -- the 512-position CHROMA end-of-block CDF was the flat 1D row.** +With A fixed the stream ran on to the same strip's chroma TU (`tx_size=10`, `TX_32X16`), where +the oracle reads `eob=3` and we read `eob=103` off `EOB_PT_512_CHROMA`. +`av1_default_eob_multi512_cdfs` is `[q][plane][eob_multi_ctx][10]` (`token_cdfs.h:874`); the +constant carried the SECOND inner index (`eob_multi_ctx == 1`, the 1D `TX_CLASS_HORIZ`/`VERT` +row, which is the flat 3277/6554/... distribution for BOTH planes) instead of the chroma +plane's 2D row -- and its doc comment had rationalised the flatness as "libaom's default is the +same at all four q-contexts". `crates/ec-av1/src/cdf.rs`: the real chroma rows, all four +q-contexts (`EOB_PT_512_CHROMA{,_Q0,_Q1,_Q3}`); `crates/ec-av1/src/cdf_state.rs:1073`: `pick()` +by q-context like every sibling table. Class [[cdf-row-held-constant]]. + +Both are pinned by unit tests that do not need a stream (`decode.rs` tests): +`rect_nz_map_ctx_offset_tables_are_row_major` re-derives every entry of all three tables from +libaom's own generating rule AND asserts the table path (`base_ctx`) equals the spelled-out +rule path (`base_ctx_rect`) at every (row, col) for both shapes -- those two disagreed +silently before; `the_chroma_512_eob_cdf_is_not_the_flat_one_dimensional_row` pins the +mis-indexing itself. + +EVIDENCE: /ab16/{seed43.obu,ref.yuv,ours3.yuv,oc.raw,uc2.raw} | seed-43 stream +regenerated from the gate recipe (`gradients` seed 43, 192x128, cq45), decoded by +`~/.cache/aom-oracle/build/aomdec --rawvideo` and by `decode_probe`, coefficient traces +compared element by element | before: 20494/24576 luma bytes differ, first divergent element +`TX_64X32` luma scan idx 7 (rng 57584 vs ours); after defect A: first divergence moves to the +chroma `TX_32X16` eob (oracle 3, ours 103); after both: `cmp ours3.yuv ref.yuv` -> identical, +36864/36864 bytes. + +## (4) The chroma-only residue (mandelbrot 64x64 start_x=-0.6 cq30) -- re-measured, AB blocks ARE in it + +Unchanged by this round: 670 differing bytes, all of them chroma, first at offset 4246 (U +plane starts at 4096), luma bit-exact. And the stream does contain all four AB arms: the +16x16 partition symbols are `value=0 x2, 1 x2, 2, 3 x7, 4, 5, 6, 7` -- one HORZ_A, one HORZ_B, +one VERT_A, one VERT_B. Luma-exact with chroma-wrong means the entropy stream is fine through +the whole frame, so this is chroma PREDICTION/reconstruction, not a table or a desync +(a green entropy trace plus byte-exact luma exonerates the coefficient path -- the +`h265-chroma`/`gmaffine` class note in memory). +Disposition: **deferred(a chroma-prediction lane -- 4-wide/8-wide intra MC at these sizes; this +lane's tables are now proven exact by the seed-43 bisection)**. + +EVIDENCE: /ab16/{m30.obu,m_ref.yuv,m_ours.yuv} | aomenc gate recipe at cq30 on +`mandelbrot=size=64x64:start_x=-0.6`, decoded by aomdec and decode_probe, byte diff by plane; +`EC_AV1_TRACE=1 ... | grep partition_w16` for the arm census | 670 diffs, 0 of them luma, +first at 4246; AB arm values 4/5/6/7 each present once. + +## Test totals + +`EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-ab16 cargo test -p ec-av1 --lib` +(log `$HOME/.cache/ab16-suite.log`): **274 passed; 0 failed; 24 ignored**, 619 s. That run +includes both gates this lane owns and every sibling the fixes touch -- +`a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact` (seed 43 +included, 40 seeds) is GREEN, `a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact` +is green with `--enable-tx-size-search` at aomenc's default on four of its ten attempts, and the +rectx / tiny / rectwire / sbpart gates that share the two corrected tables all pass. + +EVIDENCE: $HOME/.cache/ab16-suite.log | `cargo test -p ec-av1 --lib` with the aomenc oracle +required | `test result: ok. 274 passed; 0 failed; 24 ignored`. + +## Residue + +- deferred(a chroma-prediction lane): the mandelbrot cq30 chroma-only 670-byte residue above. +- deferred(base tile defect, r1 reproducer stands): no `--tile-columns=1` arm in the AB gate. +- deferred(lane-rectx): the tx-size-search AB attempts still stop at the "HORZ/VERT intra strip + with a split transform" refusal, so they prove the reach lookup, not pixels. +- accepted: 10-bit proves HORZ_A + VERT_A only (r1).