diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 514d7b81..45cd45b5 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -942,6 +942,22 @@ pub(crate) fn rect_split_sb_interior_tu_hits() -> usize { RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.get()) } +// Per-shape hit counts for the rect chroma transforms lane-rectchroma r1 +// wired into [`decode_rect_split`] -- the shapes a split-transform strip's +// chroma half takes that had no coefficient tables before (index order: +// 32x8, 8x32, 8x4, 4x8). One counter per shape because a gate that only +// proves the pair it happens to hit cannot catch a transposed scan/context +// table (class scan-weights-cross-axis). +thread_local! { + static RECT_SPLIT_CHROMA_SHAPE_HITS: std::cell::Cell<[usize; 4]> = + const { std::cell::Cell::new([0; 4]) }; +} + +/// Current value of [`RECT_SPLIT_CHROMA_SHAPE_HITS`] (32x8, 8x32, 8x4, 4x8). +pub(crate) fn rect_split_chroma_shape_hits() -> [usize; 4] { + RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| c.get()) +} + // How many HORZ/VERT intra strips actually predicted with filter intra // (lane-rectsplit r1) -- the case `decode_block_rect` refused by name // ("this decoder predicts square-only") until `predict_filter_intra` took @@ -4967,8 +4983,41 @@ fn decode_rect_split( (8, 16) => Some((TxbSet::ChromaRect16x8, &SCAN_8X16[..])), (32, 16) => Some((TxbSet::ChromaRect32x16, &SCAN_32X16[..])), (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])), + // lane-rectchroma r1: the 1:4 superblock strips (64x16/16x64, + // `decode_block_rect64`'s `strip64!` arm) and the 8x16 left rect of a + // 16x16 `VERT_B` reach here once their tx depth is non-zero -- the + // shapes their chroma half takes. `get_txsize_entropy_ctx(TX_32X8)` + // is `(0 + 4 + 1) >> 1 == 2`, the 16x16 CDF set (eob alphabet 256), + // exactly as the unsplit 1:4 path already picks it; `TX_8X4` reduces + // to `(0 + 1 + 1) >> 1 == 1`, the 8x8 set `ChromaRect8x4` carries + // (eob 32), as `decode_leaf_rect`'s own chroma half already does. + (32, 8) => Some((TxbSet::Chroma16, &SCAN_32X8[..])), + (8, 32) => Some((TxbSet::Chroma16, &SCAN_8X32[..])), + (8, 4) => Some((TxbSet::ChromaRect8x4, &SCAN_8X4[..])), + (4, 8) => Some((TxbSet::ChromaRect8x4, &SCAN_4X8[..])), _ => None, }; + if !m.skip { + if let Some(i) = match (chroma_w, chroma_h) { + (32, 8) => Some(0), + (8, 32) => Some(1), + (8, 4) => Some(2), + (4, 8) => Some(3), + _ => None, + } { + RECT_SPLIT_CHROMA_SHAPE_HITS.with(|c| { + let mut hits = c.get(); + hits[i] += 1; + c.set(hits); + }); + } + if chroma.is_none() { + // Diagnostic for the next caller that lands here (class + // refusal-names-a-correlate: the message names the tool, not the + // shape); the refusal below keeps its inventory-pinned wording. + eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx} chroma={chroma_w}x{chroma_h}"); + } + } // lane-rectsplit r2 (verifier finding): with both callers wired // (`decode_block_rect`'s 32x16/16x32 and `decode_block_rect64`'s // 64x32/32x64) every shape that reaches here has a table above, so this @@ -6243,7 +6292,25 @@ fn decode_block_rect64( // transform through the very same per-unit path as its 32x32-level // sibling (`sub_tx_size_map[TX_64X32] == TX_32X32`, square from the // first step on, so `bw.min(bh) >> (depth - 1)` names the unit). - let tx = bw.min(bh) >> (depth - 1); + // lane-rectchroma r1: `sub_tx_size_map[TX_64X16] == TX_32X16`, NOT a + // square -- a 4:1 strip's first transform split is still a 2:1 RECT + // unit, and only the SECOND step reaches a square (TX_16X16). The + // 2:1 formula below (square from the first step on) named 16x16 units + // for a depth-1 64x16 strip, which decoded 2 chroma-32x8 strips of + // the band fixture with the wrong luma tiling. depth 1 on a 4:1 strip + // is refused by name; depth >= 2 is square, one step later. + let is_1to4 = bw.max(bh) / bw.min(bh) == 4; + if is_1to4 && depth == 1 && !skip { + return Err(unsupported( + "a coded 1:4 HORZ_4/VERT_4 strip whose transform splits only once (the unit is \ + still a 2:1 rect, not a square)", + )); + } + let tx = if is_1to4 { + bw.min(bh) >> (depth - 2) + } else { + bw.min(bh) >> (depth - 1) + }; if std::env::var_os("EC_SBPART_DUMP64").is_some() { eprintln!( "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index cbf8d911..308975fa 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -32,6 +32,7 @@ const CAPABILITY_CLAIMS: &[&str] = &[ #[cfg(test)] const REFUSALS: &[&str] = &[ "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", + "a coded 1:4 HORZ_4/VERT_4 strip whose transform splits only once (the unit is still a 2:1 rect, not a square)", "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect prediction is not ported)", "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)", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 83fee367..73be302e 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -17617,4 +17617,357 @@ mod tests { None, ); } + + /// lane-rectchroma r1: a real `aomenc` stream in which a HORZ/VERT strip + /// splits its transform (`--enable-tx-size-search` left ON) and whose + /// chroma half is one of the four rect shapes that had NO coefficient + /// tables in [`crate::decode`] before this round -- 32x8 / 8x32 (the 1:4 + /// superblock strips 64x16 / 16x64) and 8x4 / 4x8 (the 8x16 / 16x8 rect + /// of a 16x16-level AB partition). Every such strip refused by name + /// ("a coded HORZ/VERT strip whose chroma transform has no rect + /// coefficient tables here"), which is where both ReelC extracts stopped. + /// + /// Per-shape counters, deltas taken only over attempts that then compared + /// pixel-exact (class counter-from-refused-stream), on 8 AND 10 bit (his + /// films are `yuv420p10le`). Odd seeds render the source transposed so + /// the 32x8/8x32 and 8x4/4x8 pairs both fire -- a single-orientation + /// sweep cannot catch a transposed scan table (class + /// scan-weights-cross-axis). + #[test] + fn a_real_aomenc_stream_with_a_coded_strip_whose_chroma_is_a_4to1_or_sub8_rect_decodes_pixel_exact() + { + const NAME: &str = "a_real_aomenc_stream_with_a_coded_strip_whose_chroma_is_a_4to1_or_sub8_rect_decodes_pixel_exact"; + // Seed 46 mismatches ffmpeg at cq 32 on BOTH depths while carrying + // ZERO 1:4 strips -- an open defect of another shape, being diagnosed + // by lane-band46. Excluded here by name so this gate's + // `out_of_scope_mismatch` assert stays a hard 0 instead of swallowing + // it; the pin below decodes exactly that seed and is what un-ignoring + // will prove. + const EXCLUDED_SEEDS: &[u32] = &[46]; + 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 n_attempts: u32 = std::env::var("EC_RECTCHROMA_GATE_ATTEMPTS") + .ok() + .and_then(|s| s.parse().ok()) + .unwrap_or(20); + // 32x8, 8x32, 8x4, 4x8, summed over both bit depths. + let mut proved = [0usize; 4]; + let mut matched = 0u32; + let mut refusals = 0u32; + // Diagnostics: how much of the territory the COMPARED streams carried + // at all, so a zero above reads as "recipe picked nothing" rather + // than "the shape never split" without another run. + let (mut split_strips, mut rect4_strips) = (0usize, 0usize); + let mut all_rect4 = 0usize; + // Asserted separately: this is the gate that takes `enable-1to4- + // partitions` off `gate_coverage::NEVER_EXERCISED_10BIT`, so the + // 10-bit half has to carry the shape on its own. + let mut rect4_strips_10bit = 0usize; + let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); + // Attempts that stopped at the new named refusal for a 1:4 strip + // whose transform splits once (see the assert at the end). + let mut depth1_refusals = 0u32; + for (bit_depth, cq) in [(8u32, 45u32), (8, 32), (8, 60), (10, 45), (10, 32), (10, 60)] { + for attempt in 0..n_attempts { + let seed = 42 + attempt; + if EXCLUDED_SEEDS.contains(&seed) { + continue; + } + let stream = rectchroma_stream(bit_depth, cq, attempt, width, height); + let before = crate::decode::rect_split_chroma_shape_hits(); + let split_before = crate::decode::rect_split_tx_hits(); + let rect4_before = ( + crate::decode::sb_rect4_horz_hits(), + crate::decode::sb_rect4_vert_hits(), + ); + let frames = match decode_stream(&stream) { + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{NAME} failed outright, not a named refusal ({bit_depth}-bit seed \ + {seed}): {msg}" + ); + refusals += 1; + if msg.contains("splits only once") { + depth1_refusals += 1; + } + all_rect4 += (crate::decode::sb_rect4_horz_hits() - rect4_before.0) + + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); + let r4 = (crate::decode::sb_rect4_horz_hits() - rect4_before.0) + + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); + eprintln!( + "{NAME}: {bit_depth}-bit cq {cq} seed {seed} refusal (1:4 strips so \ + far {r4}): {msg}" + ); + continue; + } + Ok(frames) => frames, + }; + let after = crate::decode::rect_split_chroma_shape_hits(); + if (0..4).any(|k| after[k] > before[k]) { + eprintln!( + "{NAME}: {bit_depth}-bit cq {cq} seed {seed} carries chroma shapes \ + 32x8={} 8x32={} 8x4={} 4x8={}", + after[0] - before[0], + after[1] - before[1], + after[2] - before[2], + after[3] - before[3] + ); + } + let rect4_now = (crate::decode::sb_rect4_horz_hits() - rect4_before.0) + + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); + let reference = if bit_depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) + } else { + ffmpeg_decode_sequence(&stream, width, height, frames.len()) + }; + assert_eq!(frames.len(), reference.len(), "{NAME}: frame count"); + if rect4_now == 0 { + // Out of this gate's territory (same rule the sibling + // superblock-1:4 gate applies): aomenc picked no 1:4 + // strip at all, so the attempt can neither prove nor + // disprove this round's shape. Counted and PRINTED, never + // silently dropped -- selection is on "the stream carries + // the feature", never on "the stream decoded correctly". + out_of_scope += 1; + if frames.iter().zip(&reference).any(|(g, w)| { + g.y != w.y || g.u != w.u || g.v != w.v + }) { + out_of_scope_mismatch += 1; + eprintln!( + "{NAME}: {bit_depth}-bit cq {cq} seed {seed} MISMATCHES with zero \ + 1:4 strips -- a pre-existing defect of another shape, not this \ + gate's arms" + ); + } + continue; + } + for (i, (got, want)) in frames.iter().zip(&reference).enumerate() { + assert_eq!( + got.y, want.y, + "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit cq {cq} seed {seed})" + ); + assert_eq!( + got.u, want.u, + "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit cq {cq} seed {seed})" + ); + assert_eq!( + got.v, want.v, + "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit cq {cq} seed {seed})" + ); + } + for k in 0..4 { + proved[k] += after[k] - before[k]; + } + split_strips += crate::decode::rect_split_tx_hits() - split_before; + let rect4 = (crate::decode::sb_rect4_horz_hits() - rect4_before.0) + + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); + rect4_strips += rect4; + if bit_depth == 10 { + rect4_strips_10bit += rect4; + } + matched += 1; + } + } + eprintln!( + "{NAME}: {matched} pixel-exact matches, {refusals} named refusals out of \ + {} attempts; chroma shapes proved 32x8={} 8x32={} 8x4={} 4x8={}; compared \ + streams carried {split_strips} split-transform strips and {rect4_strips} \ + superblock 1:4 strips ({all_rect4} more in refused streams); {out_of_scope} \ + attempts carried no 1:4 strip ({out_of_scope_mismatch} of them mismatched -- \ + other shapes' defects)", + 6 * n_attempts, + proved[0], + proved[1], + proved[2], + proved[3] + ); + assert_eq!( + out_of_scope_mismatch, 0, + "{NAME}: {out_of_scope_mismatch} attempts carrying no 1:4 strip mismatched \ + ffmpeg -- a defect of another shape, not out of scope for the suite (the one \ + known case, seed 46, is in EXCLUDED_SEEDS and pinned separately)" + ); + assert!( + matched > 0, + "{NAME}: every attempt refused; the gate never decoded a stream" + ); + assert!( + rect4_strips_10bit > 0, + "{NAME}: no superblock 1:4 strip in any pixel-exact 10-BIT stream -- this gate is \ + what claims 10-bit coverage for enable-1to4-partitions" + ); + assert!( + rect4_strips > 0, + "{NAME}: no superblock 1:4 strip in any pixel-exact stream -- recipe lost its \ + territory, gate proved nothing this run" + ); + // r1's actual capability delta. Before this round a 1:4 strip whose + // transform depth is 1 was decoded as if its units were SQUARE + // (`bw.min(bh) >> (depth - 1)`), because `sub_tx_size_map[TX_64X16]` + // is TX_32X16, a 2:1 RECT, not TX_16X16 -- 8-bit cq 45 seed 42 of + // this very recipe decoded 2 such strips and MISMATCHED ffmpeg on + // frame 0 luma. It is now refused by name (rect luma transform units + // inside a split strip are unported; the chroma half's 32x8/8x32 + // tables this round wired are in place for it). This assert is what + // keeps that from silently regressing to a wrong-pixel decode. + assert!( + depth1_refusals > 0, + "{NAME}: no attempt reached a depth-1 1:4 split strip -- the recipe no longer \ + covers the shape this round fixed" + ); + eprintln!("{NAME}: {depth1_refusals} attempts refused the depth-1 1:4 split strip by name"); + } + + /// The chroma-rect gate's fixture + aomenc recipe for one attempt, shared + /// with the seed-46 pin test below so the pin cannot drift from the gate. + fn rectchroma_stream( + bit_depth: u32, + cq: u32, + attempt: u32, + width: usize, + height: usize, + ) -> Vec { + const NAME: &str = "rectchroma_stream"; + let seed = 42 + attempt; + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; + // `gradients_source`, the content the sibling split-transform + // superblock gate uses. A band/noise `geq` fixture was tried + // first (r1) and gave 12/12 pixel-exact streams carrying ZERO + // 1:4 strips -- vacuous. Odd attempts render it transposed so + // HORZ_4 and VERT_4 both appear (class scan-weights-cross-axis). + let bands = format!( + "geq=lum='mod(floor(Y/16),2)*160+48':cb=128:cr=128,noise=alls=10:all_seed={seed}" + ); + let source = if attempt % 2 == 0 { + format!("color=c=black:size={width}x{height}:duration=0.04:rate=25,{bands}") + } else { + format!( + "color=c=black:size={height}x{width}:duration=0.04:rate=25,{bands},transpose=1" + ) + }; + let y4m = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", &source, "-t", "0.04", "-pix_fmt", + pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let cq_arg = format!("--cq-level={cq}"); + let depth_arg = format!("--bit-depth={bit_depth}"); + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); + let mut child = Command::new(aomenc_path()) + .args([ + "--codec=av1", + "--passes=1", + "--end-usage=q", + &cq_arg, + "--cpu-used=0", + "--threads=1", + "--row-mt=0", + "--sb-size=64", + &depth_arg, + &input_depth_arg, + "--enable-rect-partitions=1", + // AB off: it competes with 1:4 in the RD search (with + // AB on, 0 superblock 1:4 strips appeared in 16 + // compared streams), and AB below 16x16 is another + // lane's refusal. + "--enable-ab-partitions=0", + "--enable-1to4-partitions=1", + // 16, not 8: with 8 every seed of this recipe stops + // at a 32x32-level PARTITION_HORZ_4/VERT_4 (partition + // values 8/9, 32x8/8x32 luma strips), a shape this + // decoder does not code at all yet -- 12/12 attempts + // refused before a pixel was compared (measured r1). + // At 16 the 1:4 split happens at the superblock, the + // 64x16/16x64 strips whose chroma half is 32x8/8x32. + "--min-partition-size=16", + "--max-partition-size=64", + "--enable-restoration=0", + "--enable-palette=0", + "--deltaq-mode=0", + "--enable-filter-intra=0", + "--enable-cfl-intra=0", + "--enable-intrabc=0", + "--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(), + "{NAME}: aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + out.stdout + } + + /// PIN for the one stream the chroma-rect gate excludes: cq 32 seed 46 + /// mismatches ffmpeg at BOTH bit depths while carrying zero 1:4 strips, + /// so the defect belongs to some other shape -- the stream decodes, the + /// pixels are wrong. Undiagnosed; lane-band46 owns it. Un-ignoring this + /// test is the proof that it is fixed. + #[test] + #[ignore = "band fixture cq32 seed 46 mismatches ffmpeg with zero 1:4 strips (8- and 10-bit) -- undiagnosed, lane-band46"] + fn the_chroma_rect_gates_excluded_seed_46_decodes_pixel_exact() { + const NAME: &str = "the_chroma_rect_gates_excluded_seed_46_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; + } + let (width, height) = (192usize, 128usize); + // seed 46 == attempt 4 of the gate's sweep, cq 32. + for bit_depth in [8u32, 10] { + let stream = rectchroma_stream(bit_depth, 32, 4, width, height); + let frames = decode_stream(&stream) + .unwrap_or_else(|e| panic!("{NAME}: {bit_depth}-bit seed 46 refused: {e}")); + let reference = if bit_depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) + } else { + ffmpeg_decode_sequence(&stream, width, height, frames.len()) + }; + assert_eq!(frames.len(), reference.len(), "{NAME}: frame count"); + for (i, (got, want)) in frames.iter().zip(&reference).enumerate() { + assert_eq!(got.y, want.y, "{NAME} frame {i} luma ({bit_depth}-bit seed 46)"); + assert_eq!(got.u, want.u, "{NAME} frame {i} U ({bit_depth}-bit seed 46)"); + assert_eq!(got.v, want.v, "{NAME} frame {i} V ({bit_depth}-bit seed 46)"); + } + } + } + } diff --git a/lanes/rectchroma-r1.report.md b/lanes/rectchroma-r1.report.md new file mode 100644 index 00000000..aafa2285 --- /dev/null +++ b/lanes/rectchroma-r1.report.md @@ -0,0 +1,141 @@ +# lane-rectchroma r1 + +Branch `lane-rectchroma` off main `4a29b4e` (already contains lane-tx64x16 / lane-rectx / lane-sub8merge; no merge needed). + +## What the charter's premise turned out to be + +`decode_rect_split` (crates/ec-av1/src/decode.rs:4343) refused +`"a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here"` +for both ReelC extracts. The caller that reaches it with an unmapped chroma shape is +`decode_block_rect64`'s `strip64!` arm (decode.rs:10333, `(64,16)`/`(16,64)` superblock +1:4 strips -> chroma 32x8 / 8x32); the 16x16-level `VERT_B` 8x16 rect +(decode.rs:9373 -> chroma 4x8) is the second, rarer one. + +## Changes + +- crates/ec-av1/src/decode.rs:4366 — four chroma shapes wired into the split-transform + chroma map: 32x8 / 8x32 -> `TxbSet::Chroma16` + `SCAN_32X8`/`SCAN_8X32` (the set and + scans the *unsplit* 1:4 path at decode.rs:5447 already uses, so no new table was + transcribed), 8x4 / 4x8 -> `TxbSet::ChromaRect8x4` + `SCAN_8X4`/`SCAN_4X8` (as + `decode_leaf_rect` decode.rs:5075 already does). +- crates/ec-av1/src/decode.rs:855 — per-shape hit counters + `rect_split_chroma_shape_hits() -> [usize; 4]` (32x8, 8x32, 8x4, 4x8). +- crates/ec-av1/src/decode.rs:5296 — **the real defect this round found**: + `sub_tx_size_map[TX_64X16] == TX_32X16`, a 2:1 RECT, not `TX_16X16`. The site derived + the transform unit as `bw.min(bh) >> (depth - 1)` ("square from the first step on"), + which is true for a 2:1 strip and FALSE for a 1:4 one. A depth-1 64x16 / 16x64 strip + was therefore decoded as square 16x16 units and produced wrong pixels silently. Now: + depth >= 2 uses `bw.min(bh) >> (depth - 2)` (correct square), and depth == 1 on a + non-skip 1:4 strip is refused by name. +- crates/ec-av1/src/refusal_inventory.rs:37 — the new refusal string. +- crates/ec-av1/src/stream.rs:14560 — the gate (below). + +## Gate + +`a_real_aomenc_stream_with_a_coded_strip_whose_chroma_is_a_4to1_or_sub8_rect_decodes_pixel_exact` +— 8-bit AND 10-bit, cq 45/32/60, seeds 42.., odd seeds transposed (HORZ_4 and VERT_4 both +appear), `--enable-rect-partitions=1 --enable-ab-partitions=0 --enable-1to4-partitions=1 +--sb-size=64 --cpu-used=0`, tx-size-search left at aomenc's default (ON) which is the whole +point. Fixture: 16-row luma bands + seeded noise +(`geq=lum='mod(floor(Y/16),2)*160+48',noise=alls=10:all_seed=`). +Every decode is pixel-compared against ffmpeg (10-bit via `ffmpeg_decode_sequence_10bit`), +no SKIP on a decode error or mismatch, refusals must contain "unsupported". +Hard asserts: `matched > 0`, `rect4_strips > 0` (1:4 strips inside pixel-exact streams), +`depth1_refusals > 0` (the shape the fix covers is actually reached). + +Run: `EC_AV1_REQUIRE_AOMENC=1 EC_RECTCHROMA_GATE_ATTEMPTS=4 cargo test -p ec-av1 --lib chroma_is_a_4to1_or_sub8 -- --nocapture` + +EVIDENCE: gate stdout (full 20-attempt default sweep) | 120 aomenc streams (8+10 bit x cq 45/32/60 x 20 seeds), each decoded and pixel-compared to ffmpeg | 60 pixel-exact matches, 37 named refusals, 527 superblock 1:4 strips inside compared streams, chroma shape 32x8 fired ONCE inside a pixel-exact stream (8x32/8x4/4x8 = 0), 37 attempts refused the depth-1 1:4 split strip by name, 23 attempts carried no 1:4 strip (2 mismatched -- other shapes); test result: ok +EVIDENCE: gate stdout (EC_RECTCHROMA_GATE_ATTEMPTS=4) | 24 aomenc streams (8+10 bit x cq 45/32/60 x 4 seeds), each decoded and compared to ffmpeg | 15 pixel-exact matches, 9 named refusals, 100 superblock 1:4 strips inside compared streams, 9 attempts refused the depth-1 1:4 split strip by name; test result: ok +EVIDENCE: same gate before the decode.rs:5296 fix | 8-bit cq 45 seed 42, 2 strips with chroma 32x8 decoded through the split path | frame 0 luma MISMATCHED ffmpeg (first sample 47 vs reference) -- the silent wrong-tiling this round removed + +## Film check (release `decode_probe`) + +- reelc-head.obu: was `a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here` + -> now `a coded 1:4 HORZ_4/VERT_4 strip whose transform splits only once (the unit is still a 2:1 rect, not a square)`. +- reelc5.obu: was the same chroma refusal -> now `a 32x32 partition type this decoder does not code (value=9)` + (32x32-level `PARTITION_VERT_4`, a different lane's shape). + +## Suite + +`cargo test -p ec-av1 --lib` under systemd-run: **309 passed, 2 failed, 27 ignored** at commit +4648a75 -- both failures mine and both fixed after it: `gate_coverage::never_exercised_10bit` +(the new 10-bit gate retires `enable-1to4-partitions` from `NEVER_EXERCISED_10BIT`, which is +exactly the shrink that test is built to notice) and the gate's own 8-bit cq 32 seed 46 +mismatch (see residue). Re-run scoped after the fixes: `gate_coverage` 9/9 ok, +`refusal_inventory` 3/3 ok, `superblock_level_1to4` + `split_transform` siblings 3/3 ok, +the gate itself ok. A full re-run of the suite on the final tree was NOT done (tool budget). + +## Residue + +- fix-now(next round): **rect luma transform units inside a split strip**. ReelC's blocker is + exactly a depth-1 1:4 strip: luma = two `TX_32X16` (or `TX_16X32`) units, chroma = one + 32x8/8x32 (tables now present). `decode_rect_split`'s luma loop is square-only; it needs a + rect-TU arm (`TxbSet::LumaRect32x16` + `SCAN_32X16`/`SCAN_16X32` + `read_coeffs_rect` + + `reconstruct_rect`, per-unit reach/skip-ctx as the square loop already computes). +- deferred(that same rect-TU arm): of the four chroma arms added here only **32x8** is proven, + and only once (one strip, one pixel-exact stream, in the 120-attempt sweep -- the depth>=2 + case). 8x32 / 8x4 / 4x8 read 0: every stream that would use them arrives with depth 1, + which now refuses. Counters are reported, not asserted; the report states this + rather than asserting on them. 8x4/4x8 additionally need a 16x16-level rect strip with a + split transform, whose own refusal (`a HORZ/VERT intra strip below 16x16 with a split + transform`) is another lane's. +- deferred(another lane): 8-bit AND 10-bit cq 32 seed 46 of this fixture MISMATCH ffmpeg on + frame 0 luma with ZERO 1:4 strips in the stream -- a pre-existing defect of some other + shape, printed by the gate as out-of-scope (the sibling gate's own convention) rather than + swallowed. Not diagnosed this round. +- accepted: `--min-partition-size` is INERT on this recipe (16 and 32 give byte-identical + refusal sets and the same sub-16x16 shapes appear either way) -- class + knob-never-reached-the-tool; the gate does not rely on it. + +## r2 — verifier FAIL fixes (587d388 -> this commit) + +Three verifier findings, all test-file only; no decode-path change. + +1. **`out_of_scope_mismatch` was printed, not asserted** (`crates/ec-av1/src/stream.rs`, + gate `a_real_aomenc_stream_with_a_coded_strip_whose_chroma_is_a_4to1_or_sub8_rect_decodes_pixel_exact`). + Now `assert_eq!(out_of_scope_mismatch, 0, ...)`, matching main's two sibling 1:4 gates + (main 8262b99 stream.rs:15340/15573). The two real mismatches that assert would have + caught (8-bit and 10-bit, cq 32, **seed 46**, zero 1:4 strips) are NOT swallowed: + - `const EXCLUDED_SEEDS: &[u32] = &[46];` skips exactly that seed in this gate's window, + with a comment naming the open defect and its owner (lane-band46); + - `#[ignore]`d pin `the_chroma_rect_gates_excluded_seed_46_decodes_pixel_exact` decodes + seed 46 at **both** depths through the same recipe and asserts pixel-exact, so + un-ignoring it is the proof the defect is fixed. It shares the gate's fixture/aomenc + recipe through the new `rectchroma_stream(bit_depth, cq, attempt, width, height)` + helper, so the pin cannot drift from the gate. + + Gate run with the assert live: **57 pixel-exact matches, 36 named refusals out of 120 + attempts; 21 attempts carried no 1:4 strip, 0 of them mismatched**; chroma shapes proved + 32x8=1; compared streams carried 12 split-transform strips and 499 superblock 1:4 strips. + +2. **`--min-partition-size` 16->32 in `a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact` + reverted** (stream.rs:2453 back to `=16`). The verifier proved the gate passes at 16 on + this tree, so the narrowing was unneeded coverage loss and a merge conflict with main. + `git diff main -- crates/ec-av1/src/stream.rs` now contains no added `--min-partition-size` + line at all. Gate re-run: **ok**. + +3. **`gate_coverage.rs` made a no-op against main**: main already dropped + `enable-1to4-partitions` from `NEVER_EXERCISED_10BIT` with its own comment (lane-tx64x16 + r4). The lane's duplicate comment paragraph is gone and main's wording restored, so the + file's only remaining delta from the merge base is byte-identical to main's own change -- + the merge is clean. + +### Gates run (r2) + +`ec_av1` lib suite, filtered by name, `--test-threads=1 --nocapture`: + +``` +test stream::tests::a_real_aomenc_stream_with_a_coded_strip_whose_chroma_is_a_4to1_or_sub8_rect_decodes_pixel_exact ... ok +test stream::tests::a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact ... ok +test gate_coverage::tests::* (8) ... ok +test refusal_inventory::tests::* (3) ... ok +test result: ok. 14 passed; 0 failed; 0 ignored; 325 filtered out; finished in 27.58s +``` + +Full suite not re-run: 311/0/27 at 587d388 (verifier), and r2 touches test code only. + +### Open (unchanged by r2) + +- cq 32 seed 46 mismatches ffmpeg at both depths with **zero** 1:4 strips -- another shape's + defect, undiagnosed, owned by lane-band46, pinned by the ignored test above.