forge
Explore
Log in

Don't you dare go Hollow

merge: lane-sqdrift 7d498c0 (carries lane-sbrect10 9f1f108) into lane-intra14

Browse files at this commit

2c0dd84521bed6afd0e60a235e7448381ffd79e3Ahmet Kaan GümüşParent: c3a622f3891c64
The 64-axis intra block inside an inter frame read uv_mode from the 14-symbol
CFL alphabet although is_cfl_allowed caps CFL at 32x32 -- the silent inter-frame
pixel drift that blocked this lane's gate at r2. read_intra_mode_rect conflict
resolved keeping BOTH: sbrect10's is_cfl_allowed funnel first, then this lane's
intra-in-inter skip passthrough.
crates/ec-av1/src/decode.rsmodified+67 -6
@@ -1849,6 +1849,20 @@ pub(crate) fn wii_hits() -> usize {
1849 WII_HITS.with(|c| c.get())1849 WII_HITS.with(|c| c.get())
1850 }1850 }
1851 1851
1852+// lane-sbrect10 r1: how many INTRA blocks read `uv_mode` off the 13-symbol
1853+// NO-CFL alphabet *because their size excludes CFL* (libaom `is_cfl_allowed`:
1854+// wide <= 32 && high <= 32). The witness that a gate stream really carries a
1855+// 64-axis intra block -- the shape whose 14-symbol read desynced every inter
1856+// frame carrying one.
1857+thread_local! {
1858+ static NOCFL_UV_MODE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1859+}
1860+
1861+/// Current value of [`NOCFL_UV_MODE_HITS`].
1862+pub(crate) fn nocfl_uv_mode_hits() -> usize {
1863+ NOCFL_UV_MODE_HITS.with(|c| c.get())
1864+}
1865+
1852 // lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC1866 // lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC
1853 // blend -- the gate's proof that `--enable-obmc=1` reached this shape (the1867 // blend -- the gate's proof that `--enable-obmc=1` reached this shape (the
1854 // r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented1868 // r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented
@@ -5541,6 +5555,19 @@ fn read_intra_mode_rect(
5541 }5555 }
5542 };5556 };
5543 }5557 }
5558+ // lane-sbrect10 r1: libaom `is_cfl_allowed` (blockd.h) is
5559+ // `block_size_wide <= 32 && block_size_high <= 32` -- enforce it HERE, at
5560+ // the one point every rect caller routes through, so no call site can
5561+ // offer the 14-symbol CFL alphabet on a 64-axis block (class
5562+ // wrong-alphabet-same-value: same value, wrong interval, silent desync).
5563+ // This funnel covers the lane-intra14 intra-1:4-in-inter callers too: they
5564+ // reach their chroma through this same reader, never a private CFL read.
5565+ let cfl = if cfl && bw.max(bh) > 32 {
5566+ NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1));
5567+ false
5568+ } else {
5569+ cfl
5570+ };
5544 // lane-intra14 r1: on the INTER block path everything up to and including5571 // lane-intra14 r1: on the INTER block path everything up to and including
5545 // `is_inter` was already read by [`decode_inter_block`], so this reader5572 // `is_inter` was already read by [`decode_inter_block`], so this reader
5546 // starts at the mode syntax with the `skip` that caller read.5573 // starts at the mode syntax with the `skip` that caller read.
@@ -8594,6 +8621,14 @@ fn read_intra_mode(
8594 }8621 }
8595 };8622 };
8596 }8623 }
8624+ // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single
8625+ // point every square caller routes through (see `read_intra_mode_rect`).
8626+ let cfl = if cfl && side > 32 {
8627+ NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1));
8628+ false
8629+ } else {
8630+ cfl
8631+ };
8597 // spec 5.11.6 `intra_frame_mode_info`: `intra_segment_id` is read BEFORE8632 // spec 5.11.6 `intra_frame_mode_info`: `intra_segment_id` is read BEFORE
8598 // `skip` when `SegIdPreSkip`, and after it otherwise.8633 // `skip` when `SegIdPreSkip`, and after it otherwise.
8599 let (seg_w_mi, seg_h_mi) = (side / 4, side / 4);8634 let (seg_w_mi, seg_h_mi) = (side / 4, side / 4);
@@ -8937,8 +8972,13 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 {
8937 /// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE).8972 /// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE).
8938 fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) {8973 fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) {
8939 use std::io::Write;8974 use std::io::Write;
8975+ // lane-sbrect10 r2: index the dump by decode-order picture like
8976+ // EC_AV1_PREFILT_DUMP already does -- a fixed `.f0` name kept only the
8977+ // LAST frame, so a mid-sequence divergence could not be read out at all.
8978+ static STAGE16_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
8940 if let Ok(path) = std::env::var(var)8979 if let Ok(path) = std::env::var(var)
8941- && let Ok(mut f) = std::fs::File::create(format!("{path}.f0"))8980+ && let idx = STAGE16_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst)
8981+ && let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}"))
8942 {8982 {
8943 for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] {8983 for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] {
8944 for row in 0..h {8984 for row in 0..h {
@@ -18673,6 +18713,12 @@ fn decode_inter_block(
18673 return Ok(());18713 return Ok(());
18674 }18714 }
18675 let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]);18715 let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]);
18716+ if std::env::var_os("EC_IIS").is_some() {
18717+ eprintln!(
18718+ "TRACE iis px={px} py={py} side={side} w={write_w} h={write_h} sg={} mode={mode} skip={skip}",
18719+ size_group_wh(write_w, write_h)
18720+ );
18721+ }
18676 if mode >= 13 {18722 if mode >= 13 {
18677 return Err(unsupported(18723 return Err(unsupported(
18678 "an intra mode this decoder does not code (round 2)",18724 "an intra mode this decoder does not code (round 2)",
@@ -18701,13 +18747,27 @@ fn decode_inter_block(
18701 // directional intra-in-inter block was refused above.18747 // directional intra-in-inter block was refused above.
18702 let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c);18748 let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c);
18703 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);18749 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
18704- let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]);18750+ // lane-sbrect10 r1 (class wrong-alphabet-same-value, second instance
18751+ // after lane-sbpart r3's rect strips): `is_cfl_allowed` (libaom
18752+ // `blockd.h` -- `block_size_wide[bsize] <= 32 && block_size_high[bsize]
18753+ // <= 32`, spec 5.11.5) caps CFL at 32x32, so a 64x64 intra block inside
18754+ // an INTER frame reads the 13-symbol `uv_mode_no_cfl` alphabet. Reading
18755+ // the 14-symbol CFL one gave the same DC_PRED VALUE but narrowed the
18756+ // arithmetic coder by the wrong interval, desyncing the tile from this
18757+ // block on.
18758+ let cfl_allowed = write_w.max(write_h) <= 32;
18759+ if !cfl_allowed {
18760+ NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1));
18761+ }
18762+ let uv_mode = if cfl_allowed {
18763+ dec.symbol(&mut cdfs.uv_mode_cfl[mode])
18764+ } else {
18765+ dec.symbol(&mut cdfs.uv_mode_no_cfl[mode])
18766+ };
18705 if (9..=12).contains(&uv_mode) {18767 if (9..=12).contains(&uv_mode) {
18706 SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));18768 SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
18707 }18769 }
18708- let alpha = if uv_mode == DC_PRED {18770+ let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED {
18709- None
18710- } else if uv_mode == UV_CFL_PRED {
18711 Some(read_cfl_alphas(dec, cdfs))18771 Some(read_cfl_alphas(dec, cdfs))
18712 } else {18772 } else {
18713 None18773 None
@@ -21138,10 +21198,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
21138 // instead of silently decoding as SPLIT and desyncing.21198 // instead of silently decoding as SPLIT and desyncing.
21139 let part64 = match (has_cols, has_rows) {21199 let part64 = match (has_cols, has_rows) {
21140 (true, true) => {21200 (true, true) => {
21201+ let pre_rng = dec.debug_state().0;
21141 let p = dec.symbol(&mut cdfs.partition_w64[sb_ctx]);21202 let p = dec.symbol(&mut cdfs.partition_w64[sb_ctx]);
21142 if std::env::var_os("EC_AV1_TRACE").is_some() {21203 if std::env::var_os("EC_AV1_TRACE").is_some() {
21143 eprintln!(21204 eprintln!(
21144- "TRACE partition_w64 mi=({},{}) ctx={sb_ctx} value={p}",21205+ "TRACE partition_w64 mi=({},{}) ctx={sb_ctx} value={p} pre_rng={pre_rng}",
21145 sb_r * SB_MI,21206 sb_r * SB_MI,
21146 sb_c * SB_MI21207 sb_c * SB_MI
21147 );21208 );
crates/ec-av1/src/motion_field.rsmodified+9 -0
@@ -442,6 +442,15 @@ pub fn setup_motion_field(
442 );442 );
443 }443 }
444 444
445+ if std::env::var_os("EC_TRACE_TPL").is_some() {
446+ eprintln!("EC_TPL_FIELD oh={cur_order_hint} rows={rows} cols={cols}");
447+ for r in 0..rows {
448+ let row: String = (0..cols)
449+ .map(|c| if cells[r * cols + c].is_some() { '#' } else { '.' })
450+ .collect();
451+ eprintln!("EC_TPL_FIELD r{r} {row}");
452+ }
453+ }
445 TplField { cols, rows, cells }454 TplField { cols, rows, cells }
446 }455 }
447 456
crates/ec-av1/src/stream.rsmodified+341 -7
@@ -6988,13 +6988,16 @@ mod tests {
6988 // refusal it names is GONE (this round codes a 64-px transform axis as6988 // refusal it names is GONE (this round codes a 64-px transform axis as
6989 // its truncated low-32 corner), and a 10-bit sweep of this exact6989 // its truncated low-32 corner), and a 10-bit sweep of this exact
6990 // recipe now reaches the arm -- 2 pixel-exact attempts, 2 64x32 and 26990 // recipe now reaches the arm -- 2 pixel-exact attempts, 2 64x32 and 2
6991- // 32x64 strips, 2 of them carrying a coded 64-axis residual. It stays6991+ // 32x64 strips, 2 of them carrying a coded 64-axis residual.
6992- // 8-bit here for a DIFFERENT, newly exposed reason: 10-bit attempt 146992+ // lane-sbrect10 r1 closed the newly exposed 10-bit defect r14 r2
6993- // (cq 61, horizontal split, motion step 12) mismatches ffmpeg while6993+ // parked this arm on (10-bit attempt 14, cq 61, horizontal split,
6994- // decoding ZERO superblock-level rect strips and zero 64-axis6994+ // motion step 12 -- it mismatched ffmpeg while decoding ZERO rect
6995- // residual units, i.e. a defect of some other shape that this gate6995+ // strips): a 64x64 INTRA block inside an inter frame read `uv_mode`
6996- // must not absorb. See lanes/r14-r2.report.md.6996+ // off the 14-symbol CFL-allowed alphabet, which libaom's
6997- for bit_depth in [8u32] {6997+ // `is_cfl_allowed` caps at 32x32 -- same DC_PRED value, wrong
6998+ // interval narrowing, tile desynced from that block on. Both depths
6999+ // run now.
7000+ for bit_depth in [8u32, 10u32] {
6998 let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =7001 let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =
6999 (0u32, 0u32, 0u32, 0u32);7002 (0u32, 0u32, 0u32, 0u32);
7000 let (mut horz_proved, mut vert_proved) = (0usize, 0usize);7003 let (mut horz_proved, mut vert_proved) = (0usize, 0usize);
@@ -7149,6 +7152,337 @@ mod tests {
7149 }7152 }
7150 }7153 }
7151 7154
7155+ /// lane-sbrect10 r1: a 64x64 INTRA block inside an INTER frame, whose
7156+ /// `uv_mode` alphabet libaom's `is_cfl_allowed` (`blockd.h`: `wide <= 32
7157+ /// && high <= 32`) narrows to the 13-symbol NO-CFL table. Reading the
7158+ /// 14-symbol CFL one produced the same `DC_PRED` value with the wrong
7159+ /// interval narrowing, so the tile desynced from that block on and the
7160+ /// frame decoded silently wrong (class `wrong-alphabet-same-value`; found
7161+ /// as the "another shape" mismatch the superblock rect gate above had to
7162+ /// park its 10-bit arm on).
7163+ ///
7164+ /// The counter `nocfl_uv_mode_hits` proves the shape fired in EVERY
7165+ /// compared attempt, and every decode-order frame is compared against
7166+ /// ffmpeg -- an attempt that mismatches fails, it never SKIPs.
7167+ ///
7168+ /// lane-sbrect10 r2: with the half-random source below this gate also
7169+ /// covers a SECOND defect it exposed at 10-bit cq 58/61 -- the compound
7170+ /// MV stack's extension pass zero-filled the `comp_list` tail slots
7171+ /// libaom fills with each side's GLOBAL MOTION vector
7172+ /// (`combine_compound_candidates`, mvref_common.c:723-729). A compound
7173+ /// block with no usable neighbour pair (frame top row, intra block to
7174+ /// its left, empty temporal field) then took a `(0, 0)` predictor
7175+ /// instead of the frame's translation: 32890/39907 wrong luma samples
7176+ /// on decode-order frame 2 with the entropy stream still in sync.
7177+ #[test]
7178+ fn a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet() {
7179+ const NAME: &str =
7180+ "a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet";
7181+ let _gate_lock = lock_gate_counters();
7182+ if !have_ffmpeg() {
7183+ eprintln!("SKIP {NAME}: no ffmpeg");
7184+ return;
7185+ }
7186+ if !have_aomenc() {
7187+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
7188+ return;
7189+ }
7190+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
7191+ for bit_depth in [8u32, 10u32] {
7192+ let (mut named_refusals, mut matched, mut carried_none) = (0u32, 0u32, 0u32);
7193+ let mut total_hits = 0usize;
7194+ for attempt in 0..16u32 {
7195+ // The sibling superblock-rect gate's own grid (its 10-bit
7196+ // attempt 14 -- cq 61, horizontal split, motion step 12 -- is
7197+ // the stream that exposed the defect); which superblock the RD
7198+ // hands an intra 64x64 block moves with the quantiser and the
7199+ // depth, so both orientations x four quantisers x two motion
7200+ // steps run here too.
7201+ let vertical_split = attempt % 2 == 1;
7202+ let cq = [58, 52, 45, 61][(attempt / 2 % 4) as usize];
7203+ let sp = 8 + (attempt / 8) * 4;
7204+ // Half ramp, half deterministic pseudo-noise: the flat "200"
7205+ // half of r1's source made aomenc code the right-hand
7206+ // superblocks skip, so at 8 bit no >32 intra block ever
7207+ // appeared (probed cq 45/52/58/61/63 = 0 hits). The textured
7208+ // half forces intra above 32x32 in an inter frame at BOTH
7209+ // depths, so both arms carry the shape.
7210+ let geq = if vertical_split {
7211+ format!(
7212+ "if(lt(Y,64), 40+mod(floor((X+N*{sp})/32)*90,200), mod((X*7+Y*13+N*97)*31,256))"
7213+ )
7214+ } else {
7215+ format!(
7216+ "if(lt(X,128), 40+mod(floor((Y+N*{sp})/32)*90,200), mod((X*7+Y*13+N*97)*31,256))"
7217+ )
7218+ };
7219+ let duration = frame_count as f64 / 25.0;
7220+ let source = format!(
7221+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
7222+ geq=lum='{geq}',format=yuv420p"
7223+ );
7224+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
7225+ let y4m = Command::new("ffmpeg")
7226+ .args([
7227+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
7228+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
7229+ ])
7230+ .stdin(Stdio::null())
7231+ .stdout(Stdio::piped())
7232+ .stderr(Stdio::piped())
7233+ .output()
7234+ .expect("ffmpeg failed to run");
7235+ assert!(
7236+ y4m.status.success(),
7237+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
7238+ String::from_utf8_lossy(&y4m.stderr)
7239+ );
7240+ let cq_arg = format!("--cq-level={cq}");
7241+ let depth_arg = format!("--bit-depth={bit_depth}");
7242+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
7243+ let args: Vec<&str> = vec![
7244+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
7245+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
7246+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
7247+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
7248+ "--enable-tx-size-search=0", "--lag-in-frames=0",
7249+ "--enable-rect-partitions=1", "--enable-ab-partitions=0",
7250+ "--enable-1to4-partitions=1", "--min-partition-size=32",
7251+ "--max-partition-size=64",
7252+ "--obu", "-o", "-", "-",
7253+ ];
7254+ let mut child = Command::new(aomenc_path())
7255+ .args(&args)
7256+ .stdin(Stdio::piped())
7257+ .stdout(Stdio::piped())
7258+ .stderr(Stdio::piped())
7259+ .spawn()
7260+ .expect("aomenc failed to start");
7261+ child
7262+ .stdin
7263+ .take()
7264+ .expect("aomenc stdin")
7265+ .write_all(&y4m.stdout)
7266+ .expect("writing y4m to aomenc");
7267+ let out = child.wait_with_output().expect("aomenc failed to run");
7268+ assert!(
7269+ out.status.success(),
7270+ "aomenc refused the fixture: {}",
7271+ String::from_utf8_lossy(&out.stderr)
7272+ );
7273+ let stream = out.stdout;
7274+ let before = crate::decode::nocfl_uv_mode_hits();
7275+ let frames = match decode_stream(&stream) {
7276+ Err(e) => {
7277+ let msg = e.to_string();
7278+ assert!(
7279+ msg.contains("unsupported"),
7280+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
7281+ attempt {attempt}): {msg}"
7282+ );
7283+ named_refusals += 1;
7284+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
7285+ continue;
7286+ }
7287+ Ok(frames) => frames,
7288+ };
7289+ let hits = crate::decode::nocfl_uv_mode_hits() - before;
7290+ let ffmpeg_frames = if bit_depth == 10 {
7291+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7292+ } else {
7293+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7294+ };
7295+ assert_eq!(frames.len(), frame_count);
7296+ if hits == 0 {
7297+ // No 64-axis intra block in this stream: still compared
7298+ // (a mismatch here is a defect, never a pass), just not
7299+ // proof of this gate's shape.
7300+ carried_none += 1;
7301+ }
7302+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7303+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})");
7304+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})");
7305+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})");
7306+ }
7307+ if hits > 0 {
7308+ matched += 1;
7309+ total_hits += hits;
7310+ }
7311+ }
7312+ eprintln!(
7313+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
7314+ attempts carrying a >32 intra block ({total_hits} no-CFL uv_mode reads), \
7315+ {carried_none} attempts carried none"
7316+ );
7317+ assert!(
7318+ matched > 0 && total_hits > 0,
7319+ "{NAME} ({bit_depth}-bit): no attempt decoded an intra block above 32x32, so the \
7320+ no-CFL uv_mode alphabet was never exercised -- gate proved nothing \
7321+ ({named_refusals} refusals, {carried_none} attempts carried none)"
7322+ );
7323+ }
7324+ }
7325+ /// lane-sqdrift r2: the SQUARE-ONLY twin of the no-CFL `uv_mode` gate
7326+ /// above. With `--enable-rect-partitions=0` the encoder codes only
7327+ /// `PARTITION_NONE` and `PARTITION_SPLIT`, and on detailed content the RD
7328+ /// eventually hands one whole 64x64 superblock of an INTER frame to an
7329+ /// INTRA block -- `bsize == sb_size`, the one shape whose `uv_mode` must
7330+ /// come off the 13-symbol `uv_mode_no_cfl` alphabet because libaom's
7331+ /// `is_cfl_allowed` (`blockd.h`: `wide <= 32 && high <= 32`) excludes it.
7332+ ///
7333+ /// Before the fix this decoder read the 14-symbol CFL alphabet there: the
7334+ /// same `DC_PRED` value, a different interval, and the tile desynced from
7335+ /// that block on. r1 measured the damage on the pinned 192x128 stream
7336+ /// (sha256 `c6af4fb4...`): decode-order frames 0-3 pre-filter byte-exact,
7337+ /// frame 4 luma 3540 samples wrong over exactly the last superblock
7338+ /// (x 128..191, y 64..127), then 24k wrong by frame 7 -- and the decoder
7339+ /// did not even report a mismatch, it reported an intra-rect-strip refusal
7340+ /// read out of the already-desynced stream (class `refusal-from-own-desync`;
7341+ /// aomdec's own partition histogram over that stream is rect-free).
7342+ /// After the fix the same stream is byte-exact on all 8 frames.
7343+ ///
7344+ /// Distinct from the sibling gate: rect partitions OFF (so the 64x64 NONE
7345+ /// really is a whole superblock), `--min-partition-size=16`, natural
7346+ /// mandelbrot detail instead of a synthetic half-noise ramp, and 8 frames
7347+ /// of drift so a desync that survives one frame still fails here. Every
7348+ /// decode-order frame of every attempt is compared against ffmpeg, so a
7349+ /// mismatch of ANY shape fails; the gate never turns one into a SKIP.
7350+ #[test]
7351+ fn a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact()
7352+ {
7353+ const NAME: &str = "a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact";
7354+ let _gate_lock = lock_gate_counters();
7355+ if !have_ffmpeg() {
7356+ eprintln!("SKIP {NAME}: no ffmpeg");
7357+ return;
7358+ }
7359+ if !have_aomenc() {
7360+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
7361+ return;
7362+ }
7363+ let (width, height, frame_count) = (192usize, 128usize, 8usize);
7364+ for bit_depth in [8u32, 10u32] {
7365+ let (mut named_refusals, mut matched, mut carried_none) = (0u32, 0u32, 0u32);
7366+ let mut total_hits = 0usize;
7367+ for attempt in 0..4u32 {
7368+ // r1's pinned recipe is (start_scale 4.76, cq 55); the other
7369+ // three points move the detail level and the quantiser, which
7370+ // is what moves WHICH superblock the RD codes intra.
7371+ let start_scale = ["4.76", "3.20"][(attempt % 2) as usize];
7372+ let cq = [55, 45][(attempt / 2) as usize];
7373+ let duration = frame_count as f64 / 25.0;
7374+ let source = format!(
7375+ "mandelbrot=size={width}x{height}:start_scale={start_scale}:\
7376+ end_scale=0.004:end_pts=8:rate=25"
7377+ );
7378+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
7379+ let y4m = Command::new("ffmpeg")
7380+ .args([
7381+ "-v", "error", "-f", "lavfi", "-i", &source, "-vf", "hue=s=0",
7382+ "-t", &duration.to_string(), "-pix_fmt", pix_fmt, "-strict", "-1",
7383+ "-f", "yuv4mpegpipe", "-strict", "-1", "-",
7384+ ])
7385+ .stdin(Stdio::null())
7386+ .stdout(Stdio::piped())
7387+ .stderr(Stdio::piped())
7388+ .output()
7389+ .expect("ffmpeg failed to run");
7390+ assert!(
7391+ y4m.status.success(),
7392+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
7393+ String::from_utf8_lossy(&y4m.stderr)
7394+ );
7395+ let cq_arg = format!("--cq-level={cq}");
7396+ let depth_arg = format!("--bit-depth={bit_depth}");
7397+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
7398+ let args: Vec<&str> = vec![
7399+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=1",
7400+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
7401+ "--lag-in-frames=0", "--auto-alt-ref=0",
7402+ "--kf-min-dist=1000", "--kf-max-dist=1000",
7403+ "--enable-rect-partitions=0", "--enable-ab-partitions=0",
7404+ "--enable-1to4-partitions=0", "--min-partition-size=16",
7405+ "--max-partition-size=64", "--enable-tx-size-search=0",
7406+ "--enable-order-hint=0", "--enable-warped-motion=0", "--enable-obmc=0",
7407+ "--enable-masked-comp=0", "--enable-interintra-comp=0",
7408+ "--enable-dist-wtd-comp=0", "--enable-diff-wtd-comp=0",
7409+ "--enable-onesided-comp=0", "--enable-interintra-wedge=0",
7410+ "--enable-smooth-interintra=0", "--enable-filter-intra=0",
7411+ "--enable-smooth-intra=0", "--enable-paeth-intra=0",
7412+ "--enable-directional-intra=0", "--enable-angle-delta=0",
7413+ "--enable-cdef=0", "--enable-restoration=0", "--enable-palette=0",
7414+ "--enable-intrabc=0", "--enable-cfl-intra=0", "--enable-ref-frame-mvs=0",
7415+ "--obu", "-o", "-", "-",
7416+ ];
7417+ let mut child = Command::new(aomenc_path())
7418+ .args(&args)
7419+ .stdin(Stdio::piped())
7420+ .stdout(Stdio::piped())
7421+ .stderr(Stdio::piped())
7422+ .spawn()
7423+ .expect("aomenc failed to start");
7424+ child
7425+ .stdin
7426+ .take()
7427+ .expect("aomenc stdin")
7428+ .write_all(&y4m.stdout)
7429+ .expect("writing y4m to aomenc");
7430+ let out = child.wait_with_output().expect("aomenc failed to run");
7431+ assert!(
7432+ out.status.success(),
7433+ "aomenc refused the fixture: {}",
7434+ String::from_utf8_lossy(&out.stderr)
7435+ );
7436+ let stream = out.stdout;
7437+ let before = crate::decode::nocfl_uv_mode_hits();
7438+ let frames = match decode_stream(&stream) {
7439+ Err(e) => {
7440+ let msg = e.to_string();
7441+ assert!(
7442+ msg.contains("unsupported"),
7443+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
7444+ attempt {attempt}): {msg}"
7445+ );
7446+ named_refusals += 1;
7447+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
7448+ continue;
7449+ }
7450+ Ok(frames) => frames,
7451+ };
7452+ let hits = crate::decode::nocfl_uv_mode_hits() - before;
7453+ let ffmpeg_frames = if bit_depth == 10 {
7454+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7455+ } else {
7456+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7457+ };
7458+ assert_eq!(frames.len(), frame_count);
7459+ if hits == 0 {
7460+ carried_none += 1;
7461+ }
7462+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7463+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})");
7464+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})");
7465+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})");
7466+ }
7467+ if hits > 0 {
7468+ matched += 1;
7469+ total_hits += hits;
7470+ }
7471+ }
7472+ eprintln!(
7473+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
7474+ attempts carrying a 64x64 intra superblock ({total_hits} no-CFL uv_mode reads), \
7475+ {carried_none} attempts carried none"
7476+ );
7477+ assert!(
7478+ matched > 0 && total_hits > 0,
7479+ "{NAME} ({bit_depth}-bit): no square-only attempt decoded a 64x64 intra block \
7480+ inside an inter frame, so the no-CFL uv_mode alphabet was never exercised -- \
7481+ gate proved nothing ({named_refusals} refusals, {carried_none} carried none)"
7482+ );
7483+ }
7484+ }
7485+
7152 /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT`7486 /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT`
7153 /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r17487 /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r1
7154 /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs7488 /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs
lanes/sbrect10-r1.handoff.mdadded+81 -0
@@ -0,0 +1,81 @@
1+# lane-sbrect10 r1 handoff (turn cap)
2+
3+Branch `lane-sbrect10` (worktree `/home/user/Documents/Code/Rust/edith_codecs-sbrect10`),
4+based on lane-r14 a2e2e29 with `main` (7a47fc1) merged in cleanly (merge commit in history).
5+
6+## STATUS: root cause FOUND and FIXED; sibling gate GREEN both depths; the new dedicated gate
7+## still needs an 8-bit fixture (its 8-bit arm currently FAILS "gate proved nothing").
8+
9+## Pinned stream
10+`$HOME/.cache/sbrect10/a14.obu`, sha256 (hashed twice, identical)
11+`e85d3b84180de05cd7af769daa7b4f0662389fe0cbf5f0dc8119e4a036b6cf44`.
12+Regenerate: `bash $HOME/.cache/sbrect10/gen.sh <out>` (192x128, 6 frames, cq 61, 10-bit,
13+horizontal split geq, motion step 12 = the sibling gate's 10-bit attempt 14).
14+
15+## First mismatch (before the fix)
16+decode-order frame 2 (display == decode order, `--lag-in-frames=0`), plane Y, 15973/24576 luma
17+samples + 874 V; frames 0 and 1 exact. Per-64x64-SB wrong-pixel map row0 = [128, 332, 3931],
18+row1 = [3912, 3728, 3942]; SB(0,0)'s 128 are rows 62-63 only (deblock bleed from below).
19+
20+## Range ladder (EC_TRACE_MODE / EC_TRACE_MODE_STEP / EC_TRACE_COEFF / EC_AV1_TELL vs
21+## instrumented aomdec `~/.cache/aom-oracle/build/aomdec`)
22+- Partition symbols: 40/40 identical (values + positions) -> no rect strips anywhere, every
23+ inter SB is PARTITION_NONE 64x64. Confirms the sibling gate's "zero rect strips" note.
24+- Our `TELL label=post_interp_filter range=` equals aomdec's `EC_MODE_VAL ... rng=` for every
25+ inter block up to the divergence (frame 2 block mi(0,16): both 61730). Mode info in sync.
26+- First diverging element: frame 2, block mi_row=0 mi_col=32 (SB(0,2), x=128..191), which BOTH
27+ decoders read as INTRA inside an inter frame (`is_inter=false`, our TELL post_is_inter
28+ range=42400). aomdec then reads its luma TU with entry rng=38192 and all_zero=1; ours reached
29+ all_zero=0 at rng=63221 with eob=56 -> desync inside that block's intra mode syntax.
30+- Root cause: `uv_mode` was read off the 14-symbol CFL-allowed CDF (`cdfs.uv_mode_cfl`) on a
31+ 64x64 block. libaom `is_cfl_allowed` (blockd.h, spec 5.11.5) = `block_size_wide <= 32 &&
32+ block_size_high <= 32`, so the real alphabet is the 13-symbol `uv_mode_no_cfl`. Same DC_PRED
33+ VALUE, wrong interval narrowing -> silent desync (class `wrong-alphabet-same-value`, second
34+ instance after lane-sbpart r3).
35+
36+## Fix (committed)
37+- `crates/ec-av1/src/decode.rs` intra-in-inter block path: `cfl_allowed = write_w.max(write_h)
38+ <= 32`, picks `uv_mode_no_cfl`, and gates the `cfl_alphas` read.
39+- Same rule enforced ONCE at the head of `read_intra_mode_rect` and `read_intra_mode`
40+ (`let cfl = cfl && bw.max(bh) <= 32` / `side <= 32`), so no caller can offer CFL above 32.
41+- New counter `NOCFL_UV_MODE_HITS` / `decode::nocfl_uv_mode_hits()` fires exactly when the
42+ size rule removed CFL.
43+- Result on the pinned stream: all 6 frames byte-identical to `ffmpeg -pix_fmt yuv420p10le`
44+ (was [0,0,16847,23688,19028,17491] wrong samples).
45+
46+## Gates
47+- `a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact`
48+ flipped to `[8u32, 10u32]` and is GREEN: 8-bit 2 refusals / 4 pixel-exact carrying the arm /
49+ 64x32=4 / 32x64=4 / 64-axis TUs=2 / 10 out-of-scope with 0 mismatches; 10-bit 2 refusals /
50+ 2 carrying / 64x32=2 / 32x64=2 / 64-axis TUs=2 / 12 out-of-scope with 0 mismatches.
51+- NEW dedicated gate `a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet`
52+ (stream.rs, just above the lane-inter4 32x32 rect gate): 16-attempt grid, both depths, every
53+ decode-order frame compared, asserts `nocfl_uv_mode_hits` moved. 10-bit arm passes; the
54+ **8-bit arm FAILS** ("no attempt decoded an intra block above 32x32") -- with the smooth
55+ translating source aomenc never picks a >32 intra block in an inter frame at 8 bit
56+ (probed cq 45/52/58/61/63, with and without `noise=all_seed=7:alls=30`: 0 hits every time).
57+
58+## Exact next step (measured, ready to paste)
59+Replace the gate's source with the half-random fixture, which DOES produce the shape at 8 bit:
60+`geq=lum='if(lt(X,128), 40+mod(floor((Y+N*12)/32)*90,200), mod((X*7+Y*13+N*97)*31,256))'`
61+Probe results (`$HOME/.cache/sbrect10/probe.sh <geq> <cq> <depth> <extra>`, counts >32
62+intra-in-inter blocks and pixel diffs vs ffmpeg):
63+ 8-bit cq52: 4 hits but DECODE-ERR (named refusal) | cq58: 2 hits, 0 pixel diffs |
64+ cq61: 3 hits, 0 pixel diffs
65+ 10-bit cq52: 6 hits, 0 diffs | cq58: 7 hits, **32890 diffs** | cq61: 7 hits, **39907 diffs**
66+So: use cq 58/61 for the 8-bit arm, cq 52 for the 10-bit arm, OR (better) treat the 10-bit
67+cq58/cq61 half-random mismatch as the NEXT defect of this lane -- it is a real, reproducible
68+10-bit failure on a stream this decoder does not refuse, and it is NOT the CFL bug (that one is
69+fixed). Triage it with the same ladder (EC_AV1_TELL post_interp_filter vs aomdec EC_MODE_VAL,
70+then EC_TRACE_COEFF entry ranges).
71+Then: full suite via
72+`systemd-run --user --unit=sbrect10-suite-$(date +%s) -p MemoryMax=10G --same-dir bash -lc 'EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sbrect10 nice -n 10 cargo test -p ec-av1 --lib -j3 > $HOME/.cache/sbrect10-suite-r1.log 2>&1'`
73+(NOT run yet this round), then `lanes/sbrect10-r1.report.md`.
74+
75+## Ruled out
76+- Rect partitions / 64-axis residual: zero of both in the failing stream (partition trace 40/40
77+ identical), so the sibling gate's "another shape" note was correct.
78+- MV stack, motion_mode alphabet, interp filter, interintra: all exonerated by the
79+ post_motion_mode / post_interp_filter range equality with aomdec on every block up to the
80+ diverging one.
81+- Encoder-recipe doubt: stream hashes identical across two generations.
lanes/sbrect10-r2.handoff.mdadded+175 -0
@@ -0,0 +1,175 @@
1+# lane-sbrect10 r2 handoff
2+
3+Branch `lane-sbrect10`, tip `2b9709c` (worktree
4+`/home/user/Documents/Code/Rust/edith_codecs-sbrect10`).
5+Commits this round: `3a9e83e` (merge main 18bf7dc) + `2b9709c` (the fix + gate + instrumentation).
6+
7+## STATUS: root cause FOUND and FIXED; pinned stream now byte-exact on all 6 probe arms.
8+## Only thing outstanding: the full suite result (armed, was at 340 tests / 0 failures).
9+
10+## 1. Merge state (done, clean)
11+`git merge --no-commit main` (main = 18bf7dc: r14 a2e2e29 + sb128 5ea5ec8) auto-merged
12+decode.rs + stream.rs with no conflicts. Verified before committing:
13+- `git diff main -- crates/ec-av1/src/cdf.rs` EMPTY and `... refusal_inventory.rs` EMPTY, so the
14+ NZ_MAP / FILTER_INTRA rows and the refusal list are byte-identical to main.
15+- The only lines the merged tree removes vs main are the lane's own r1 hunks (4 `uv_mode_cfl`
16+ lines in decode.rs, the `[8u32]` arm + its comment in stream.rs). Main's deletions all kept.
17+
18+## 2. Gate fixture state (done)
19+`a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet` (stream.rs)
20+now uses the half-random source in BOTH orientations:
21+
22+ horizontal: if(lt(X,128), 40+mod(floor((Y+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256))
23+ vertical: if(lt(Y,64), 40+mod(floor((X+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256))
24+
25+r1's flat `200` half made aomenc code the right-hand superblocks skip, so the 8-bit arm saw 0
26+intra-above-32x32 blocks (probed cq 45/52/58/61/63). Grid `[58, 52, 45, 61]` x 2 orientations x
27+2 motion steps x 2 depths unchanged; counters are read on decoded+compared attempts only, every
28+decode-order frame is compared on Y/U/V, a mismatch fails and never SKIPs.
29+
30+## 3. The 10-bit defect: root cause, libaom line, fix
31+Pinned stream `$HOME/.cache/sbrect10/b58.obu`, sha256 hashed TWICE identical
32+`00b9253b308201118e27f348c67932a0006e3077ba7a9a401854c2ee7eb1dcd2`
33+(192x128, 6 frames, 10-bit cq58, `--sb-size=64 --min-partition-size=32 --max-partition-size=64
34+--enable-rect-partitions=1 --enable-1to4-partitions=1 --lag-in-frames=0 --cpu-used=0`;
35+regenerate with `bash $HOME/.cache/sbrect10/probe.sh "<geq>" 58 10`).
36+
37+How it was localised (each step ruled a layer out):
38+- First mismatch DECODE-ORDER frame 2, plane Y only (U/V exact), 8252 samples; per-64x64-SB map
39+ row0 `[0,0,4092]`, row1 `[0,64,4096]` = the whole RIGHT superblock column + deblock bleed.
40+- NOT an entropy desync: our `EC_TRACE_COEFF` all_zero ladder vs instrumented aomdec's is
41+ identical for all 180 TUs of the whole stream (`diff` empty), and blocks decoded AFTER the
42+ wrong ones (mi(16,0)) are pixel-exact.
43+- NOT a clamp: an `EC_DBG_CLAMP` probe on the dequant clamp `+-(1 << (7 + bd))` and on every
44+ `clamp_range` in transform.rs fired ZERO times on this stream.
45+- `EC_TRACE_MODE` mv diff, decode-order frame 2: aomdec mi(0,32) mode=24 ref0=1 ref1=4
46+ mv0=(128,-16) / ours (-1,2); mi(0,40), mi(8,32), mi(8,40), mi(16,40) all (128,-16) vs (-1,2);
47+ mi(16,32) (-176,256) vs (-241,264); mi(24,32) (-128,56) vs (-193,64). The
48+ NEAREST_NEARESTMV blocks take stack[0] directly, so libaom's stack[0].this_mv is (128,-16)
49+ where ours is (0,0), and the NEWMV blocks are off by the same predictor delta.
50+- Our stack for mi(0,32) = two entries `this=(0,0) comp=(0,0) w=2` -- the signature of the
51+ compound EXTENSION pass appending comp_list[0] and comp_list[1] into an empty stack.
52+- Frame 2's temporal field really is empty and that is CORRECT (new `EC_TPL_FIELD` occupancy
53+ dump under EC_TRACE_TPL: oh=1,2 all `.`, oh=3,4,5 all `#`; frame 2's LAST projection is
54+ suppressed by `is_lst_overlay` and its LAST2 is the key frame). So the candidate is spatial.
55+
56+ROOT CAUSE: `combine_compound_candidates` (crates/ec-av1/src/mvstack.rs:1482) filled the
57+`comp_list` tail slots -- the ones left after `ref_id` then `ref_diff` -- with `(0, 0)`.
58+libaom fills them with that side's GLOBAL MOTION vector, `setup_ref_mv_list`,
59+`av1/common/mvref_common.c:729`:
60+
61+ for (; comp_idx < MAX_MV_REF_CANDIDATES; ++comp_idx)
62+ comp_list[comp_idx][idx] = gm_mv_candidates[idx];
63+
64+Zero-filling was right only under IDENTITY global motion (the module doc's original reduction);
65+aomenc has `--enable-global-motion` ON by default. A compound block with no usable neighbour
66+pair (frame top row -> no above, 64x64 INTRA block to its left, empty temporal field) therefore
67+took a `(0,0)` predictor where libaom took the frame's translation.
68+
69+FIX: `combine_compound_candidates` takes `gm_mv_candidates: [(i32,i32); 2]` and uses it as the
70+per-side fill; the call site passes `[gm_mv(gm, ref_frame.0), gm_mv(gm, ref_frame.1)]`.
71+
72+SIBLING SWEEP (same shape): every `gm_mv_candidates` use in mvref_common.c was walked. The
73+single-ref tail fill (`:787-788`) is already ported as `gm_fallback` at mvstack.rs:1099-1100;
74+the `is_gm_block` substitutions (`:92`, `:117`) already take `gm` through `scan_*_compound`; the
75+add_tpl_ref_mv GLOBALMV_OFFSET compares (`:379-410`) already use `gm_mv(gm, ...)` on both sides.
76+This was the only zero-filled site in the crate.
77+
78+## 4. Is the pinned stream exact now? YES
79+`probe.sh "<half-random geq>" <cq> <depth>` after the fix, pixel diffs vs
80+`ffmpeg -pix_fmt yuv420p10le` / `yuv420p`, and `>32` intra-in-inter hit counts:
81+
82+| depth | cq 52 | cq 58 | cq 61 |
83+|---|---|---|---|
84+| 8-bit | 5 hits, 0 diffs | 2 hits, 0 diffs | 3 hits, 0 diffs |
85+| 10-bit | 6 hits, 0 diffs | 7 hits, 0 diffs | 7 hits, 0 diffs |
86+
87+Before the fix the 10-bit arms were 32890 (cq58) and 39907 (cq61) wrong samples.
88+
89+## 5. NEXT STEP (the only thing left)
90+Read `$HOME/.cache/sbrect10-suite-r2.log` -- the suite is armed as a user systemd unit
91+(`sbrect10-suite-r2-1788325070.service`, MemoryMax=10G, `cargo test -p ec-av1 --lib -j3`,
92+EC_AV1_REQUIRE_AOMENC=1, CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sbrect10). At handoff it had
93+reached 340 tests with no FAILED line. Check with a single
94+`grep -E "^test result|FAILED" $HOME/.cache/sbrect10-suite-r2.log`; if a gate is red, re-run that
95+gate alone before touching code (another lane rebuilding the shared aomdec shows up as
96+"Os code 13 PermissionDenied"). Then fill the N/0 totals into `lanes/sbrect10-r2.report.md`
97+(section 4 is otherwise complete) and the lane is done.
98+
99+Nothing else is in flight; the worktree is clean at 2b9709c.
100+
101+## 5b. CORRECTION at handoff time -- THE SUITE IS RED (3 gates), details not yet printed
102+The suite unit was still running when this handoff was written; at 343 tests it had THREE
103+FAILED lines (cargo buffers the panic bodies to the end of the run, so no message text yet):
104+
105+ stream::tests::a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet ... FAILED
106+ stream::tests::a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact ... FAILED
107+ stream::tests::a_real_aomenc_stream_with_film_grain_decodes_pixel_exact ... FAILED
108+
109+So the lane is RED, not green. Do NOT treat section 4's probe table as a suite result: it proves
110+only the 6 probed (geq, cq, depth) points, not the gates' own 16-attempt grids.
111+
112+Triage order for the next round:
113+1. `grep -A 30 "^failures:" $HOME/.cache/sbrect10-suite-r2.log` for the three panic bodies.
114+2. `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` is the loudest signal: it touches
115+ NEITHER the CFL alphabet nor the compound stack's fixture, so if it is a pixel mismatch it is
116+ most likely a REGRESSION from this round's `combine_compound_candidates` gm-fill (a compound
117+ block that previously got (0,0) and now gets a global-motion vector). Check it first, alone:
118+ `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sbrect10 cargo test -p ec-av1 --lib
119+ a_real_aomenc_stream_with_film_grain_decodes_pixel_exact -- --nocapture`
120+ and if it is red, re-run it at `3a9e83e` (the merge commit, fix not yet in) in a DETACHED
121+ worktree to separate "regression from the gm-fill" from "already red after the merge".
122+ Note the merge itself was never suite-tested -- r1 never ran a suite either (its handoff says
123+ so), so an inherited red from main's sb128/r14 merge is equally possible.
124+3. The other two are this lane's own gates; the rect-partition sibling gate shares the compound
125+ stack path, so it is the expected place for a gm-fill regression to show.
126+4. Only after the three are green: fill the N/0 totals into `lanes/sbrect10-r2.report.md`.
127+
128+## 5c. SUITE FINISHED -- final result and per-failure triage (supersedes 5b)
129+`test result: FAILED. 368 passed; 3 failed; 32 ignored; finished in 1049.95s`
130+(`$HOME/.cache/sbrect10-suite-r2.log`).
131+
132+### (a) `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` -- FLAKE, not a defect. CLOSED.
133+Panic was `Result::unwrap()` on `Err(Os { code: 2, NotFound })` at stream.rs:15680, i.e. the
134+`concat!(CARGO_MANIFEST_DIR, "/../../fixtures/golden6-mismatch.obu")` READ failed -- the shared
135+`fixtures` symlink (`-> /home/user/Documents/Code/Rust/edith_codecs/fixtures`) was transiently
136+gone mid-run, the known concurrent-lane merge hazard. The file is present now and the gate passes
137+on its own:
138+`cargo test -p ec-av1 --lib a_real_aomenc_stream_with_film_grain_decodes_pixel_exact`
139+-> `test result: ok. 1 passed; 0 failed`. Nothing to fix here; it is NOT a gm-fill regression.
140+
141+### (b) `a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet` -- REAL, MINE, OPEN.
142+ 8-bit: 2 named refusals, 0 pixel-exact attempts carrying a >32 intra block
143+ (0 no-CFL uv_mode reads), 14 attempts carried none
144+ (the two refusals are "an inter SB-level AB partition" and "a split intra strip whose
145+ transform unit is 32x64" -- both other lanes' gaps, correctly named, not mismatches)
146+10-bit arm passes. **My step-2 claim that the half-random fixture makes the 8-bit arm carry the
147+shape is DISPROVEN by the gate itself.** The probe (`probe.sh`) counted a DIFFERENT quantity than
148+the gate: it greps `EC_AV1_TELL` for `post_is_inter is_inter=false` with `side>32`, whereas the
149+gate asserts `crate::decode::nocfl_uv_mode_hits()` moved. On the very same stream (8-bit cq58,
150+horizontal, sp=12 == gate attempt 8) the probe reports 2 and the counter reports 0, so those
151+8-bit >32 intra-in-inter blocks reach a decode path that never touches the counter.
152+NEXT: the three `NOCFL_UV_MODE_HITS` increment sites are `decode.rs:5499`, `decode.rs:8442`,
153+`decode.rs:18544`; instrument which intra-in-inter path an 8-bit 64x64 block actually takes
154+(the 10-bit ones clearly hit one of the three), then either fix the missing counter site or, if
155+the 8-bit path genuinely never offers CFL, narrow the gate's 8-bit assertion and say so.
156+No pixel mismatch is involved -- every decoded attempt compared exact.
157+
158+### (c) `a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact` -- REAL, OPEN, UNATTRIBUTED.
159+ 8-bit: 4 named refusals, 3 carrying, 64x32=8, 32x64=2, 64-axis residual TUs=1, 9 none (0 mismatched)
160+ 10-bit: 0 named refusals, 1 carrying, 64x32=2, 32x64=0, 64-axis residual TUs=0, 15 none (0 mismatched)
161+ panic at stream.rs:6725: "(10-bit): no superblock-level rect strip carried a coded 64-axis
162+ residual transform unit inside a pixel-exact attempt (horz=2, vert=0)"
163+This is a VACUOUS-ARM assert, NOT a pixel mismatch (`0 of them mismatched` on both depths). r1
164+recorded this same gate GREEN with 10-bit `64-axis TUs=2` and `2 carrying`; it is now `0` and `1`.
165+Two candidate causes, NOT separated this round: (i) the `main` 18bf7dc merge (sb128 + r14 changed
166+partition/var-tx handling and neither r1 nor this lane ever suite-tested the merge), or (ii) this
167+round's gm-fill changing which attempts come out pixel-exact (only pixel-exact attempts count
168+toward the arm). Separate them by running this gate alone at `3a9e83e` (merge, pre-fix) in a
169+DETACHED worktree with its own CARGO_TARGET_DIR, then at `2b9709c`.
170+
171+### Corrected disposition
172+- fix-now next round: (b) the 8-bit no-CFL counter, (c) the 10-bit 64-axis vacuous arm.
173+- accepted/closed: (a) film_grain fixture flake.
174+- The gm-fill fix itself is NOT contradicted by anything in this suite: no gate reported a pixel
175+ mismatch, and the pinned stream `b58.obu` plus all 6 probe arms are byte-exact vs ffmpeg.
lanes/sbrect10-r2.report.mdadded+124 -0
@@ -0,0 +1,124 @@
1+# lane-sbrect10 r2 report
2+
3+Branch `lane-sbrect10`, worktree `/home/user/Documents/Code/Rust/edith_codecs-sbrect10`.
4+Base: r1 tip 6fba6a6 + `main` 18bf7dc (sb128 5ea5ec8 + r14 a2e2e29) merged.
5+
6+## 1. Merge (step 1)
7+`git merge --no-commit main` -> clean auto-merge (decode.rs, stream.rs), commit `3a9e83e`.
8+- Diffstat 12 files, +1392/-147 (all of it main's; the lane contributed nothing to those files
9+ beyond its own r1 hunks).
10+- `git diff main -- crates/ec-av1/src/cdf.rs` and `... refusal_inventory.rs` are BOTH EMPTY, so
11+ the NZ_MAP / FILTER_INTRA tables and the refusal list are byte-identical to main -- nothing to
12+ reconcile.
13+- The only lines the merged tree removes relative to main are the lane's own 4 r1 CFL lines in
14+ `decode.rs` (`cdfs.uv_mode_cfl[mode]` + its `cfl_alphas` arm) and the r1 comment/`[8u32]` arm in
15+ `stream.rs`. Main's deletions are all kept.
16+
17+## 2. Gate source swapped to the half-random fixture (step 2)
18+`crates/ec-av1/src/stream.rs` (gate
19+`a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet`): the flat
20+`200` half of r1's source made aomenc code the right-hand superblocks skip, so at 8 bit no
21+`>32` intra-in-inter block ever appeared. Both orientations now carry a deterministic
22+pseudo-noise half:
23+
24+ horizontal: if(lt(X,128), 40+mod(floor((Y+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256))
25+ vertical: if(lt(Y,64), 40+mod(floor((X+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256))
26+
27+Probe grid, `$HOME/.cache/sbrect10/probe.sh` (counts `>32` intra-in-inter blocks via
28+`EC_AV1_TELL`, and pixel diffs vs `ffmpeg -pix_fmt yuv420p10le`/`yuv420p`), AFTER the r2 fix:
29+
30+| depth | cq 52 | cq 58 | cq 61 |
31+|---|---|---|---|
32+| 8-bit | 5 hits, 0 diffs | 2 hits, 0 diffs | 3 hits, 0 diffs |
33+| 10-bit | 6 hits, 0 diffs | 7 hits, 0 diffs | 7 hits, 0 diffs |
34+
35+Both depth arms therefore carry >=1 no-CFL intra hit per compared attempt; per-attempt counters
36+are read on decoded+compared attempts only, every decode-order frame is compared on Y/U/V, and a
37+mismatch fails (never SKIPs).
38+
39+## 3. The SECOND defect this fixture exposed -- root cause and fix (step 3)
40+
41+### Pinned stream
42+`$HOME/.cache/sbrect10/b58.obu` (192x128, 6 frames, 10-bit, cq 58, `--sb-size=64
43+--min-partition-size=32 --max-partition-size=64 --enable-rect-partitions=1
44+--enable-1to4-partitions=1 --lag-in-frames=0 --cpu-used=0`), sha256 hashed twice, identical:
45+`00b9253b308201118e27f348c67932a0006e3077ba7a9a401854c2ee7eb1dcd2`.
46+
47+### Localisation
48+- First mismatching frame: DECODE-ORDER 2 (display == decode order), plane Y only, 8252 samples;
49+ U and V exact; frames 0 and 1 exact. Per-64x64-SB wrong-pixel map: row0 `[0, 0, 4092]`,
50+ row1 `[0, 64, 4096]` -- i.e. the whole right superblock column, plus 64 deblock-bleed pixels.
51+- NOT an entropy desync: the 180-TU `all_zero` range ladder is IDENTICAL between our
52+ `EC_TRACE_COEFF` and instrumented `aomdec`'s (`diff a.az o.az` empty over the WHOLE stream),
53+ and blocks decoded AFTER the wrong ones (mi(16,0)) are pixel-exact.
54+- NOT a clamp: an `EC_DBG_CLAMP` probe on both the dequant clamp
55+ (`+-(1 << (7 + bd))`) and every `clamp_range` in `transform.rs` fired ZERO times on this stream.
56+- The divergence is in the MV VALUES. `EC_TRACE_MODE` diff, decode-order frame 2:
57+
58+ aomdec mi(0,32) mode=24 ref0=1 ref1=4 mv0=(128,-16) ours mv0=(-1,2)
59+ aomdec mi(0,40) mode=17 ref0=1 ref1=4 mv0=(128,-16) ours mv0=(-1,2)
60+ aomdec mi(8,32) / mi(8,40) / mi(16,40): same (128,-16) vs (-1,2)
61+ aomdec mi(16,32) mode=24 mv0=(-176,256) ours (-241,264)
62+ aomdec mi(24,32) mode=16 mv0=(-128,56) ours (-193,64)
63+
64+ The NEAREST_NEARESTMV blocks take stack[0] directly, so libaom's stack[0].this_mv is
65+ `(128,-16)` where ours is `(0,0)`; the NEWMV/NEW_NEWMV blocks are off by exactly the same
66+ predictor delta.
67+- Our stack for mi(0,32): two entries, `this=(0,0) comp=(0,0) w=2` -- the signature of libaom's
68+ compound EXTENSION pass appending `comp_list[0]` and `comp_list[1]` into an empty stack.
69+- The temporal field is genuinely empty for that frame and this is CORRECT: a new
70+ `EC_TRACE_TPL` field dump (`EC_TPL_FIELD`) shows oh=1 and oh=2 all-`.` and oh=3 onward all-`#`;
71+ frame 2's LAST projection is suppressed by `is_lst_overlay` and its LAST2 is the key frame.
72+
73+### Root cause
74+`crates/ec-av1/src/mvstack.rs:1482` `combine_compound_candidates` filled the `comp_list` tail
75+slots (the ones left over after `ref_id` then `ref_diff`) with `(0, 0)`. libaom fills them with
76+that side's GLOBAL MOTION vector -- `setup_ref_mv_list`, `av1/common/mvref_common.c:729`:
77+
78+ for (; comp_idx < MAX_MV_REF_CANDIDATES; ++comp_idx)
79+ comp_list[comp_idx][idx] = gm_mv_candidates[idx];
80+
81+The zero fill was only right under IDENTITY global motion, which the module's original reduction
82+assumed; aomenc has `--enable-global-motion` ON by default. A compound block with no usable
83+neighbour pair (frame top row -> no above, 64x64 INTRA block to its left, empty temporal field)
84+therefore took a `(0, 0)` predictor where libaom took the frame's translation.
85+
86+Class: `parsed then discarded` / reduction-assumption -- global motion is parsed and used by the
87+single-ref path (`gm_fallback`, mvstack.rs:1099-1100) but was dropped on the compound tail.
88+
89+### Fix
90+`crates/ec-av1/src/mvstack.rs`: `combine_compound_candidates` now takes
91+`gm_mv_candidates: [(i32,i32); 2]` and uses it as the per-side fill; the call site passes
92+`[gm_mv(gm, ref_frame.0), gm_mv(gm, ref_frame.1)]`.
93+
94+### Sibling sweep (same shape, whole crate)
95+Every `gm_mv_candidates` use in `mvref_common.c` was walked. The single-reference tail fill
96+(`mvref_common.c:787-788`, `mv_ref_list[idx] = gm_mv_candidates[0]`) is already ported
97+(`mvstack.rs:1099-1100` `gm_fallback`); the scan-row/col/corner `is_gm_block` substitutions
98+(`:92`, `:117`) already take `gm` through `scan_*_compound`; the `add_tpl_ref_mv`
99+`GLOBALMV_OFFSET` compares (`:379-410`) already use `gm_mv(gm, ...)` on both sides. This was the
100+only zero-filled site.
101+
102+## 4. Other change
103+`crates/ec-av1/src/decode.rs` `dump_stage16`: the `EC_AV1_PREFILT_DUMP16` dump wrote a fixed
104+`<prefix>.f0` every frame, so only the LAST frame survived and a mid-sequence divergence could
105+not be read out at all. It is now indexed by decode-order picture like `EC_AV1_PREFILT_DUMP`.
106+`crates/ec-av1/src/motion_field.rs`: `setup_motion_field` prints an `EC_TPL_FIELD` occupancy map
107+under the existing `EC_TRACE_TPL` rung (this is what proved frame 2's empty temporal field).
108+
109+## 5. Refusals
110+None lifted this round (r1 lifted none either; this lane's work is two silent-miscode fixes).
111+`refusal_inventory.rs` is byte-identical to main.
112+
113+## Suite (step 4) -- RED
114+`test result: FAILED. 368 passed; 3 failed; 32 ignored; finished in 1049.95s`
115+(`$HOME/.cache/sbrect10-suite-r2.log`). film_grain is a shared-`fixtures`-symlink flake and
116+passes alone; the other two are open and triaged in `lanes/sbrect10-r2.handoff.md` section 5c.
117+Section 2's probe table proves only the 6 probed points -- it does NOT prove the gate's own
118+counter, which still reads 0 on the 8-bit arm.
119+
120+## EVIDENCE
121+EVIDENCE: $HOME/.cache/sbrect10/b58.obu (sha256 00b9253b...dcd2, hashed twice) | probe.sh half-random geq, 6 arms (8/10-bit x cq 52/58/61), decode + compare vs ffmpeg | pixel diffs 0/0/0/0/0/0 (was 0/32890/39907 on the 10-bit arms), >32 intra-in-inter hits 5/2/3 (8-bit) and 6/7/7 (10-bit)
122+EVIDENCE: $HOME/.cache/sbrect10/{a.az,o.az} | EC_TRACE_COEFF all_zero ladder, instrumented aomdec vs ours, whole stream | 180 TUs, `diff` empty -> entropy in sync, defect is reconstruction-side
123+EVIDENCE: $HOME/.cache/sbrect10/{a.mode,o.mode} | EC_TRACE_MODE mv0 diff, decode-order frame 2 | aomdec mi(0,32) mv0=(128,-16), ours (-1,2); 6 blocks diverge, all in the right superblock column
124+EVIDENCE: $HOME/.cache/sbrect10/o.tplf | EC_TPL_FIELD occupancy dump, all 5 inter frames | oh=1,2 empty / oh=3,4,5 full -> the empty temporal field at oh=2 is correct, not the defect
lanes/sbrect10-r3.report.mdadded+98 -0
@@ -0,0 +1,98 @@
1+# lane-sbrect10 r3 report
2+
3+Branch `lane-sbrect10`. Round input: r2 tip `1866bd5`, suite RED with 3 failed gates.
4+Round output: all three root-caused and green; merged main `85887c7` (which now carries
5+lane-mvtwin `2e2a225`), mvstack.rs resolved to main's copy byte-for-byte.
6+
7+## 1. `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` -- ENVIRONMENT, not code
8+
9+Panic body (r2 log had none: the unit was still running when the handoff was written, my first
10+`systemctl --user is-active sbrect10-suite-r2` used the un-timestamped unit name and read back
11+`inactive` wrongly). Run alone off the r2 binary:
12+
13+ stream.rs:15680: called `Result::unwrap()` on an `Err` value:
14+ Os { code: 2, kind: NotFound, message: "No such file or directory" }
15+
16+The worktree had **no top-level `fixtures` symlink** (`fixtures` is gitignored and per-worktree).
17+`fixtures/golden6-mismatch.obu` was simply absent. Not a temp-path collision: this gate writes no
18+temp file at all -- `ffmpeg_decode_sequence` (stream.rs:1316) pipes the stream through ffmpeg's
19+stdin/stdout, and the two helpers that DO make scratch dirs already key them on
20+`{test name}-{std::process::id()}` (stream.rs:2000, 15735), which is unique per process and per test.
21+Same failure at the same wall-clock in lane-sb128c's suite = the same missing symlink there, not a
22+race. Fixed with `ln -s .../edith_codecs/fixtures fixtures`.
23+
24+SWEEP: all three `../../fixtures/*.obu` reads in `crates/ec-av1/src` (golden6-mismatch.obu,
25+golden7-forwarding-mismatch.obu, lr-sgr-r7.obu) now resolve.
26+
27+EVIDENCE: $HOME/.cache/sbrect10-suite-r2.log + rerun | ln -s fixtures; ec_av1 binary --exact
28+a_real_aomenc_stream_with_film_grain_decodes_pixel_exact | FAILED (NotFound) -> ok, 0.31s
29+
30+## 2. The other two reds: ONE cause -- r2's fixture swap landed in the sibling gate
31+
32+Neither red was a pixel mismatch; both were vacuity asserts, and both counters read 0 for the
33+same reason. r2's half-random lavfi source
34+
35+ horizontal: if(lt(X,128), 40+mod(floor((Y+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256))
36+ vertical: if(lt(Y,64), 40+mod(floor((X+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256))
37+
38+was written into `a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact`
39+(stream.rs:6592) instead of `a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet`
40+(stream.rs:6791) -- the rationale comment travelled with it, so the code read consistent. Effect:
41+
42+- CFL gate kept r1's flat `200` source, whose right-hand superblocks aomenc codes skip ->
43+ 8-bit arm decoded 0 intra blocks above 32x32: *"no attempt decoded an intra block above 32x32
44+ ... gate proved nothing (2 refusals, 14 attempts carried none)"*.
45+- rect gate got the textured source, which changed the RD's residual decisions -> its 10-bit arm
46+ lost the coded 64-axis transform unit lane-r14 r2 had measured on the flat source
47+ (8-bit residual TUs=1, 10-bit=0): *"no superblock-level rect strip carried a coded 64-axis
48+ residual transform unit ... (horz=2, vert=0)"*.
49+
50+FIX (`e2d9e9e`): sources swapped back so each gate runs the source it was measured on. No assert
51+weakened, no grid changed, no decoder code touched.
52+
53+Result of the two gates alone at the merged tree (`--test-threads=1 --exact`):
54+
55+| gate | 8-bit | 10-bit |
56+|---|---|---|
57+| no_cfl_uv_alphabet | 4 refusals, 4 exact attempts, **15** no-CFL uv_mode reads | 0 refusals, 8 exact attempts, **43** reads |
58+| superblock_level_rect_partition | 2 refusals, 4 exact, 64x32=4 32x64=4, **64-axis residual TUs=2** | 2 refusals, 2 exact, 64x32=2 32x64=2, **residual TUs=2** |
59+
60+0 out-of-scope mismatches in either depth of either gate, so r2's `combine_compound_candidates`
61+global-motion tail fill is NOT a regression source -- every attempt that decoded compared exact.
62+
63+EVIDENCE: $HOME/.cache/sbrect10-g2-a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet.log,
64+$HOME/.cache/sbrect10-g2-a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact.log |
65+swap the two gates' geq sources, rebuild, run each gate alone under systemd-run MemoryMax=6G |
66+both `test result: ok`, counters 15/43 no-CFL reads and 2/2 64-axis residual TUs
67+
68+## 3. Merge
69+
70+`git merge --no-commit main` twice: first main `4eff3a1` (`de045b7`, clean auto-merge), then main
71+`85887c7` after it took lane-mvtwin mid-round. Only conflict: `crates/ec-av1/src/mvstack.rs`,
72+resolved to MAIN's copy byte-for-byte (`git diff main -- crates/ec-av1/src/mvstack.rs` EMPTY) --
73+main carries this lane's own comp_list global-motion tail fill plus mvtwin's insertion-time
74+candidate cap and tile-origin clamp. `cdf.rs`, `cdf_state.rs`, `refusal_inventory.rs` all
75+byte-identical to main. Lines this branch drops vs main are only its own hunks (uv_mode_cfl
76+narrowing, indexed `dump_stage16` prefix, gate fixtures). The merge commit was recorded by the
77+coordinator as `10e25e3` (parents `e2d9e9e` + `85887c7`) while this round was mid-flight.
78+
79+## 4. Suite
80+
81+`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` under user unit
82+`sbrect10-suite-r3-1788326330.service`, log `$HOME/.cache/sbrect10-suite-r3.log`.
83+r2 for comparison: 368 passed / 3 failed / 32 ignored (the three above).
84+
85+**GREEN: 378 passed / 0 failed / 33 ignored / 0 measured, 1229.56s.**
86+
87+EVIDENCE: $HOME/.cache/sbrect10-suite-r3.log | systemd-run --user --unit=sbrect10-suite-r3-1788326330
88+-p MemoryMax=10G cargo test -p ec-av1 --lib -j3, EC_AV1_REQUIRE_AOMENC=1 |
89+`test result: ok. 378 passed; 0 failed; 33 ignored` (r2 was 368/3/32)
90+
91+## 5. Residue
92+
93+- accepted: the no-CFL gate's 8-bit arm still takes named refusals on other shapes
94+ (SB-level AB partition, 32x64/64x32 split intra strips) -- other lanes' scope, and 4 attempts
95+ decode + prove the shape regardless.
96+- accepted: r2's `probe.sh` counted intra-in-inter blocks through an `EC_AV1_TELL` trace grep,
97+ not through `nocfl_uv_mode_hits`; the gate itself asserts the real counter, so the proxy is only
98+ a probe convenience. Not worth a rewrite.
lanes/sqdrift-r1.handoff.mdadded+40 -0
@@ -0,0 +1,40 @@
1+# lane-sqdrift r1 -> r2 handoff
2+
3+Branch `lane-sqdrift` @ 6edd5af (off main 85887c7). Worktree
4+`/home/user/Documents/Code/Rust/edith_codecs-sqdrift`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sqdrift`.
5+
6+## Do NOT redo any of this (all measured, see lanes/sqdrift-r1.report.md for the EVIDENCE lines)
7+* Stream: `/home/user/.cache/sqdrift/gen.sh` -> `s.obu`, sha256
8+ `c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55`, hashed twice.
9+* Frames 0-3 byte-exact pre-filter AND post-filter (both dumps). No poisoned reference.
10+* Frame 4 damage = exactly the last SB, mi(16,32), PARTITION_NONE at 64x64, INTRA in an
11+ inter frame (aomdec prints neither EC_MODE nor EC_IMODE for it).
12+* We enter that block IN SYNC: our `pre_rng=33730` == aomdec `EC_PART ... rng=33730`.
13+* TX_64X64 dequant + inverse transform EXONERATED against real libaom (0/4096).
14+* The stream contains no rect/AB/1:4 partition at all; main's 1:4-strip refusal on it is
15+ a phantom of this desync.
16+* aomdec's prediction there is none of DC/SMOOTH/SMOOTH_V/SMOOTH_H/PAETH computed from
17+ the true neighbours, so its coefficients differ too -> a SYMBOL diverges, not a predictor.
18+
19+## The one open question
20+Which symbol between `partition_w64` and the end of that block. Ordered suspects:
21+1. `read_delta_q_params` -- delta_q IS present (base_q_idx 80/110/168) and this is the
22+ only block in the stream with `bsize == sb_size`, libaom's own special case
23+ (`decodemv.c`: `if (bsize != cm->seq_params->sb_size || !mbmi->skip_txfm)`), incl. the
24+ `delta_lf` sub-read.
25+2. `skip` / `is_inter` ctx at a 64x64 block.
26+3. `y_mode[size_group_lookup[BLOCK_64X64]=3]` CDF content (adaptation drift; frames 0-3
27+ never crossed a decision boundary).
28+4. `tx_depth`: `--enable-tx-size-search=0`, so TX_64X64 must code no depth symbol.
29+5. The 64x64 luma coefficient read (eob_pt alphabet at TX_64X64, `all_zero` ctx).
30+
31+## Instruments already in the tree
32+* `EC_AV1_TRACE=1` -> `TRACE partition_w64 ... pre_rng=<range before the symbol>`.
33+* `EC_IIS=1` -> `TRACE iis px= py= side= w= h= sg= mode= skip=` at the square
34+ intra-in-inter `y_mode` read (decode.rs, right after `cdfs.y_mode[size_group_wh(..)]`).
35+* `/home/user/.cache/sqdrift/h.c` -- libaom inverse-transform harness. Build:
36+ `gcc -O1 -o h h.c -I$SRC -I$BUILD -I$SRC/apps $BUILD/libaom.a -lm -lpthread`.
37+ MUST call `av1_rtcd(); aom_dsp_rtcd();` first or `av1_idct64` is a NULL fn ptr (segfault).
38+* The oracle has NO range print inside `read_intra_block_mode_info` /
39+ `read_delta_q_params`. Add one via `scripts/instrument-aom-oracle.sh` into a PRIVATE
40+ build dir; never rebuild the shared `~/.cache/aom-oracle/build/aomdec` in place.
lanes/sqdrift-r1.report.mdadded+100 -0
@@ -0,0 +1,100 @@
1+# lane-sqdrift r1 -- the square-only silent pixel drift, localised to ONE block
2+
3+## Verdict: RED (defect localised and bounded, not yet fixed). No refusal lifted.
4+
5+## The stream (pinned, reproducible)
6+
7+`/home/user/.cache/sqdrift/gen.sh` (kept; recipe = lane-intra14's gate recipe with
8+`--enable-rect-partitions=0`): 192x128 8-bit `mandelbrot start_scale=4.76 end_scale=0.004
9+end_pts=8 rate=25`, hue=s=0, `-t 0.32`, real `~/.cache/aom-oracle/build/aomenc`
10+`--cpu-used=1 --cq-level=55 --min-partition-size=16 --max-partition-size=64
11+--enable-tx-size-search=0 --kf-min/max-dist=1000 --threads=1 --row-mt=0`, order-hint /
12+warped / obmc / masked / interintra / dist-wtd / diff-wtd / onesided / ab / 1to4 /
13+filter-intra / smooth-intra / paeth-intra / directional-intra / angle-delta / cdef /
14+restoration / palette / intrabc / cfl / ref-frame-mvs ALL `=0`.
15+sha256 `c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55`, hashed twice
16+from two independent encodes -- reproducible.
17+
18+## What is actually wrong (measured, not reasoned)
19+
20+1. `aomdec EC_TRACE=1` partition histogram over the whole stream: only
21+ `value=0 (NONE)` and `value=3 (SPLIT)` at bsize 12/9/6. **No rect, no AB, no 1:4
22+ partition exists in this stream at all** -- so main's refusal
23+ "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", which this
24+ stream stops at on `main@85887c7`, is a PHANTOM read out of an already-diverged
25+ bitstream (class `refusal-from-own-desync`).
26+2. Pre-loop-filter dumps, our `EC_AV1_PREFILT_DUMP` vs aomdec's, per decode-order frame:
27+ f0..f3 **byte-exact (luma AND chroma)**; f4 luma 3540 samples wrong, max |d| = 6,
28+ **chroma exact**. Post-filter reference dumps (`EC_AV1_FINAL_DUMP`) f0..f3 exact too,
29+ so no reference frame is poisoned going into f4.
30+3. The f4 damage is EXACTLY one superblock: bbox x 128..191, y 64..127 -- the last SB,
31+ mi (16,32), which frame 4 codes as `PARTITION_NONE` at 64x64. It is the ONLY
32+ 64x64 PARTITION_NONE block in any inter frame of this stream.
33+4. Range ladder at that block's entry: our pre-read msac range for its `partition_w64`
34+ symbol is **33730**, identical to aomdec's `EC_PART mi_row=16 mi_col=32 bsize=12
35+ ctx=15 tell=25598 rng=33730`, and the ctx matches too (aomdec prints `bsl*4+ctx`
36+ = 12+3, ours `ctx=3`). **We enter that block bit-exactly in sync.**
37+5. The divergence is INSIDE that block. aomdec prints neither `EC_MODE` (=
38+ `read_inter_block_mode_info`) nor `EC_IMODE`, i.e. libaom takes
39+ `read_intra_block_mode_info` -- an INTRA block inside an inter frame. Our decoder
40+ takes the same arm and reads `y_mode[size_group=3] = 0 (DC_PRED)`
41+ (new `EC_IIS=1` rung: `TRACE iis px=128 py=64 side=64 w=64 h=64 sg=3 mode=0 skip=false`).
42+ Our reconstruction there is a FLAT 93, which is exactly
43+ `(sum(above 64) + sum(left 64) + 64) >> 7` -- textbook DC_PRED. aomdec's
44+ reconstruction is not flat.
45+6. The luma residual is NOT the defect. The block's 5 non-zero levels were pushed
46+ through libaom itself (`av1_inv_txfm2d_add_64x64_c`, real `libaom.a`, dequant
47+ replicated from `decodetxb.c:361-374` with `av1_dc/ac_quant_QTX(80,0,8)` = 74/87 and
48+ `av1_get_tx_scale` shift 2): **0 mismatches** against our own `residual` for those
49+ levels (and 2171 with the axes swapped, so the layout is right too). Our TX_64X64
50+ dequant + inverse transform is exact.
51+7. Everything after that block drifts: frame 5's SB0 `partition_w64` still reads 3, SB1
52+ reads 8 where aomdec reads 3 -- a CDF-state divergence carried across the frame
53+ boundary (frame 5 restarts its own msac, so only the adapted CDFs can carry the
54+ damage). f5..f7 then drift to ~24k samples / max |d| ~220 as they predict from f4.
55+
56+So: **the first divergent symbol is in the mode-info or coefficient read of a 64x64
57+PARTITION_NONE intra-in-inter block, after `partition_w64` and at/after `y_mode`.**
58+The candidate set is now tiny: `skip`, `read_delta_q_params` (this is the ONE block in
59+the stream where `bsize == sb_size`, the exact case libaom's
60+`read_delta_q_params` special-cases), `is_inter`, `y_mode[3]`, `uv_mode_cfl[0]`,
61+`tx_depth` (`--enable-tx-size-search=0`, so a TX_64X64 must code no depth symbol), or the
62+64x64 coefficient read itself. `base_q_idx` in our trace takes three values (80/110/168)
63+across the stream, i.e. **delta_q IS present in this stream** -- that makes the
64+`bsize == sb_size` delta-q exception a first-class suspect.
65+
66+## What changed (all env-gated instrumentation, no decode behaviour)
67+
68+* `crates/ec-av1/src/decode.rs` (`decode_inter_frame_tile_with_cdfs`'s `partition_w64`
69+ read) -- the `EC_AV1_TRACE` line now carries `pre_rng=`, the msac range BEFORE the
70+ symbol, which is what makes it directly comparable to aomdec's `EC_PART ... rng=`
71+ (class `compare-range-not-tell`). This is the measurement that proved fact 4.
72+* `crates/ec-av1/src/decode.rs` (square intra-in-inter `y_mode` read) -- new `EC_IIS=1`
73+ rung printing `px/py/side/w/h/size_group/mode/skip` for every intra block in an inter
74+ frame. That is fact 5.
75+
76+## Gate
77+
78+None added -- there is no fix to gate yet. Adding a gate now would pin the defect, not a
79+capability; the reproducing recipe is `scripts`-free and lives in this report plus
80+`/home/user/.cache/sqdrift/gen.sh`.
81+
82+## EVIDENCE
83+
84+EVIDENCE: /home/user/.cache/sqdrift/{op,aom}.f0..f4 | our EC_AV1_PREFILT_DUMP vs aomdec EC_AV1_PREFILT_DUMP on the pinned stream, every decode-order frame compared Y/U/V | f0-f3 0 bad samples; f4 luma 3540 bad, max |d| 6, chroma 0 bad, bbox exactly x128-191 y64-127
85+EVIDENCE: /home/user/.cache/sqdrift/{of,af}.f0..f4 | EC_AV1_FINAL_DUMP (post-filter reference buffers) both decoders | f0-f3 0 bad; f4 first bad (145,58), 3848 bad, max 6 -- deblocking only spreads the f4 damage, no reference is poisoned earlier
86+EVIDENCE: /home/user/.cache/sqdrift/aom.trace | aomdec EC_TRACE=1 partition histogram, whole stream | bsize12 {0:2, 3:46}, bsize9 {0:58, 3:126}, bsize6 {0:504} -- zero rect/AB/1:4 partitions, so main's 1:4-strip refusal on this stream is a phantom
87+EVIDENCE: our EC_AV1_TRACE pre_rng vs /home/user/.cache/sqdrift/aom.both | range ladder at frame 4 SB (16,32) | ours pre_rng=33730 ctx=3, aomdec rng=33730 ctx=15(=12+3) -- in sync at block entry, so the defect is inside the block
88+EVIDENCE: /home/user/.cache/sqdrift/{h.c,aomres1.txt,ourres.txt} | the block's 5 non-zero levels through real libaom av1_inv_txfm2d_add_64x64_c vs our residual | 0/4096 mismatches (swapped-axis control: 2171) -- TX_64X64 dequant+inverse is exact
89+EVIDENCE: EC_IIS=1 rung on the pinned stream | our intra-in-inter mode read at the failing block | `TRACE iis px=128 py=64 side=64 w=64 h=64 sg=3 mode=0 skip=false`, reconstruction flat 93 = DC_PRED of the true neighbours; aomdec's is not flat (SMOOTH/SMOOTH_V/SMOOTH_H/PAETH all rejected numerically too, so aomdec's coefficients differ as well -- the divergence is a SYMBOL, not a predictor)
90+
91+## Residue
92+
93+* fix-now (next round, r2): bisect the ~6 remaining symbols of that one block. The
94+ cheapest decisive instrument is a `pre_rng` print on every symbol of
95+ `read_inter_frame_mode_info`'s square intra arm plus an aomdec-side `rng` print at the
96+ same points in `read_intra_block_mode_info` / `read_delta_q_params` (the oracle has no
97+ print there today -- add one to `scripts/instrument-aom-oracle.sh`, do NOT rebuild the
98+ shared aomdec in place). Start with `read_delta_q_params`' `bsize == sb_size` exception.
99+* deferred: 10-bit arm -- unblocked by the fix; there is nothing to gate yet.
100+* accepted: the two `EC_*` trace rungs ship as permanent debug instrumentation.
lanes/sqdrift-r2.report.mdadded+93 -0
@@ -0,0 +1,93 @@
1+# lane-sqdrift r2 -- the square-only silent drift is the no-CFL `uv_mode` alphabet
2+
3+## Verdict: GREEN. Root cause confirmed by ablation, gated with a new real-aomenc gate.
4+
5+Tip `2b750e6` on `lane-sqdrift` (base main `85887c7`).
6+
7+## 1. What the divergence was
8+
9+r1 had localised it to one 64x64 `PARTITION_NONE` INTRA block inside an INTER frame
10+(frame 4, mi(16,32) = the last superblock), entered bit-exactly in sync (`pre_rng=33730`
11+== aomdec's `rng=33730`), with TX_64X64 dequant+inverse already exonerated against real
12+libaom. The open question was "which symbol inside that block".
13+
14+Answer: `uv_mode`. libaom's `is_cfl_allowed` (`blockd.h`: `block_size_wide[bsize] <= 32 &&
15+block_size_high[bsize] <= 32`, spec 5.11.5) excludes a 64-axis block from CFL, so its
16+`uv_mode` comes off the **13-symbol `uv_mode_no_cfl`** alphabet. We read the 14-symbol
17+`uv_mode_cfl` one: the same `DC_PRED` VALUE, a different interval narrowing, and the tile
18+desynced from that block on (class `wrong-alphabet-same-value`).
19+
20+The fix was found independently by lane-sbrect10 (`9f1f108`) and is merged here, not
21+rewritten: commit `cbcbf13` merges `lane-sbrect10` into this branch. `decode.rs` gets the
22+`cfl_allowed = write_w.max(write_h) <= 32` test at the intra-in-inter square arm plus the
23+same `is_cfl_allowed` bound enforced at the two funnels `read_intra_mode` /
24+`read_intra_mode_rect`, and the `nocfl_uv_mode_hits()` witness counter. No decoder line in
25+this round is mine; my round's contributions are the confirmation, the ablation, and the
26+square-only gate.
27+
28+## 2. The decisive before/after, same stream, same tree
29+
30+Pinned stream `/home/user/.cache/sqdrift/keep-s.obu`, sha256
31+`c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55` (r1's `gen.sh`,
32+hashed twice from two independent encodes), compared PRE-LOOP-FILTER, per decode-order
33+frame, byte for byte against instrumented aomdec's own `EC_AV1_PREFILT_DUMP`:
34+
35+| | f0 | f1 | f2 | f3 | f4 | f5 | f6 | f7 | outcome |
36+|---|---|---|---|---|---|---|---|---|---|
37+| before (`cfl_allowed = true` ablation on THIS tree) | 0 | 0 | 0 | 0 | **3540** | - | - | - | REFUSED after f4: "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path" |
38+| after (merged fix) | 0 | 0 | 0 | 0 | **0** | 0 | 0 | 0 | 8 frames decoded, all byte-exact |
39+
40+The "before" row is not r1's memory: it is the one-line ablation
41+`decode.rs:18548 let cfl_allowed = true;` rebuilt and re-run in this round, then reverted
42+(`git diff --stat` after revert shows stream.rs only). It also re-confirms r1's finding
43+that the refusal main stops at on this stream is a PHANTOM of the desync -- aomdec's
44+partition histogram over the stream contains no rect partition at all (class
45+`refusal-from-own-desync`).
46+
47+## 3. The gate (new)
48+
49+`crates/ec-av1/src/stream.rs:6900`
50+`a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact`
51+
52+The SQUARE-ONLY twin of lane-sbrect10's gate, pinning r1's recipe: real aomenc,
53+192x128 mandelbrot (`start_scale` 4.76/3.20), cq 55/45, `--cpu-used=1 --sb-size=64
54+--enable-rect-partitions=0 --enable-ab-partitions=0 --enable-1to4-partitions=0
55+--min-partition-size=16 --max-partition-size=64 --enable-tx-size-search=0`, 8 decode-order
56+frames, **both bit depths**. Rect OFF is what makes the 64x64 `PARTITION_NONE` a WHOLE
57+superblock (`bsize == sb_size`), a shape the sibling gate's rect-on recipe does not pin;
58+8 frames of drift means a desync that survives one frame still fails here.
59+
60+Asserts: every decode-order frame's Y/U/V compared against ffmpeg (a mismatch of ANY shape
61+is a failure, never a SKIP -- so out-of-scope mismatches are structurally 0); a decode
62+error must be a named `unsupported` refusal; and `nocfl_uv_mode_hits` delta per attempt
63+must be > 0 on at least one pixel-exact attempt per depth.
64+
65+Result (`--exact --nocapture --test-threads=1`), 10.4 s:
66+
67+* 8-bit: 0 named refusals, **4/4 pixel-exact attempts**, 6 no-CFL `uv_mode` reads, 0 carried none
68+* 10-bit: 0 named refusals, **4/4 pixel-exact attempts**, 6 no-CFL `uv_mode` reads, 0 carried none
69+
70+No refusal string is removed in this round: the refusal this stream used to hit was never
71+about this shape.
72+
73+## 4. Suite
74+
75+`cargo test -p ec-av1 --lib` under `systemd-run --user --unit=sqdrift-suite-r2-...`,
76+log `$HOME/.cache/sqdrift-suite-r2.log`: **379 passed, 0 failed, 33 ignored** in 958.68 s (r1 baseline on the unfixed tree never completed).
77+
78+## EVIDENCE
79+
80+EVIDENCE: /home/user/.cache/sqdrift/np.f0..f7 vs aom.f0..f7 | decode_probe with EC_AV1_PREFILT_DUMP on the pinned stream (sha256 c6af4fb4...) after merging lane-sbrect10, cmp -l per decode-order frame Y+U+V | 0 differing bytes on all 8 frames (r1: f4 3540 wrong luma samples, then refusal)
81+EVIDENCE: /home/user/.cache/sqdrift/ab.f0..f4 | same binary with decode.rs:18548 ablated to `cfl_allowed = true`, rebuilt, re-run, then reverted | f0-f3 0, f4 3540 differing bytes, decode then REFUSES "an intra-coded 1:4 ... rect strip on the inter block path" -- the phantom refusal is produced by this desync alone
82+EVIDENCE: cargo test -p ec-av1 --lib -- --exact --nocapture a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact | 4 attempts x 2 bit depths of real aomenc, rect partitions off, every decode-order frame vs ffmpeg | ok in 10.38s; 8-bit 4 exact/6 hits, 10-bit 4 exact/6 hits, 0 refusals, 0 attempts carried none
83+
84+## Residue
85+
86+* deferred(lane-intra14 re-runs its own gate): `lanes/intra14-r2.report.md` records its
87+ blocker as "decode-order frame 3/4 luma ~3.7-4.5k samples at max |d| 6..17, first diff
88+ around x=128..141, y=58..59, then frames 5-7 drift to ~24k at max |d| ~220" on the same
89+ 192x128 mandelbrot source -- the identical signature to this lane's, at the identical
90+ coordinates. Very likely the same defect, so its two `#[ignore]`d 1:4-strip arms should
91+ be re-measured on a tree carrying this fix. Not measured here: its recipe (1:4 on) is
92+ another lane's surface.
93+* accepted: r1's `EC_AV1_TRACE pre_rng` and `EC_IIS` rungs stay as debug instrumentation.