Instrument the CDEF per-8x8 skip band, and gate skipped rect inter strips
Browse files at this commita81f6e395d063bcc786b899b6b9cb42e8accebc5Parent: c4478d5- test
- instrument the CDEF per-8x8 skip band, and gate skipped rect inter strips
4 changed files +356 -4
- crates/ec-av1/examples/decode_probe.rs +12 -0
- crates/ec-av1/src/decode.rs +85 -4
- crates/ec-av1/src/stream.rs +178 -0
- lanes/cdefstrip-r1.report.md +81 -0
crates/ec-av1/examples/decode_probe.rsmodified+12 -0
| @@ -54,6 +54,18 @@ fn main() { | ||
| 54 | 54 | "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}", |
| 55 | 55 | es[0], es[1], es[2], es[3], es[4], es[5] |
| 56 | 56 | ); |
| 57 | + // lane-cdefstrip r1: 8x8 CDEF units whose skip band no coded block | |
| 58 | + // wrote this frame -- non-zero means a decode arm forgot | |
| 59 | + // `fill_skip_grid_rect`, and CDEF filtered a unit libaom may skip. | |
| 60 | + println!( | |
| 61 | + "cdef_unwritten_skip_units: {}", | |
| 62 | + ec_av1::decode::cdef_unwritten_skip_units() | |
| 63 | + ); | |
| 64 | + println!( | |
| 65 | + "cdef_band: rect_skip_writes={} mixed_skip_units={}", | |
| 66 | + ec_av1::decode::rect_skip_band_hits(), | |
| 67 | + ec_av1::decode::cdef_mixed_skip_units() | |
| 68 | + ); | |
| 57 | 69 | let ir = ec_av1::stream::inter_rect_counters(); |
| 58 | 70 | println!( |
| 59 | 71 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", |
crates/ec-av1/src/decode.rsmodified+85 -4
| @@ -2761,6 +2761,26 @@ thread_local! { | ||
| 2761 | 2761 | // whose width or height is not a multiple of 8 is the only shape that |
| 2762 | 2762 | // produces one; the straddling-band gate arms assert it grew. |
| 2763 | 2763 | static CDEF_STRADDLE_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2764 | + // lane-cdefstrip r1: 8x8 CDEF units visited with an UNWRITTEN skip band | |
| 2765 | + // (see `Neighbours::skip_written`). | |
| 2766 | + static CDEF_UNWRITTEN_SKIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 2767 | + // lane-cdefstrip r1: (d) skip RECTANGULAR blocks (every strip arm: 32x8, | |
| 2768 | + // 8x32, 16x8, 32x16, 64x16, AB/1:4 pieces...) that wrote the CDEF skip | |
| 2769 | + // band, and (e) 8x8 CDEF units whose four mi cells do NOT agree on skip -- | |
| 2770 | + // the shape libaom's `is_8x8_block_skip` (`cdef.c:29-38`) exists for: an | |
| 2771 | + // 8-tall strip pair where only one half is skip must still be FILTERED. | |
| 2772 | + static RECT_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 2773 | + static CDEF_MIXED_SKIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 2774 | +} | |
| 2775 | + | |
| 2776 | +/// Current value of `RECT_SKIP_BAND_HITS`. | |
| 2777 | +pub fn rect_skip_band_hits() -> usize { | |
| 2778 | + RECT_SKIP_BAND_HITS.with(|c| c.get()) | |
| 2779 | +} | |
| 2780 | + | |
| 2781 | +/// Current value of `CDEF_MIXED_SKIP_UNITS`. | |
| 2782 | +pub fn cdef_mixed_skip_units() -> usize { | |
| 2783 | + CDEF_MIXED_SKIP_UNITS.with(|c| c.get()) | |
| 2764 | 2784 | } |
| 2765 | 2785 | |
| 2766 | 2786 | /// Current value of `CDEF_SKIPPED_UNITS`. |
| @@ -2768,6 +2788,12 @@ pub(crate) fn cdef_skipped_units() -> usize { | ||
| 2768 | 2788 | CDEF_SKIPPED_UNITS.with(|c| c.get()) |
| 2769 | 2789 | } |
| 2770 | 2790 | |
| 2791 | +/// How many 8x8 CDEF units [`apply_cdef`] visited whose skip band no coded | |
| 2792 | +/// block wrote this frame -- a writer gap, always a defect (lane-cdefstrip r1). | |
| 2793 | +pub fn cdef_unwritten_skip_units() -> usize { | |
| 2794 | + CDEF_UNWRITTEN_SKIP_UNITS.with(|c| c.get()) | |
| 2795 | +} | |
| 2796 | + | |
| 2771 | 2797 | /// Current value of `INTER8_SKIP_BAND_HITS`. |
| 2772 | 2798 | pub(crate) fn inter8_skip_band_hits() -> usize { |
| 2773 | 2799 | INTER8_SKIP_BAND_HITS.with(|c| c.get()) |
| @@ -4029,6 +4055,15 @@ struct Neighbours { | ||
| 4029 | 4055 | /// granularity by [`apply_cdef`] since `skip` is constant across every |
| 4030 | 4056 | /// mi cell one coded block covers. |
| 4031 | 4057 | skip_grid: Vec<bool>, |
| 4058 | + /// lane-cdefstrip r1 instrument: whether any coded block actually WROTE | |
| 4059 | + /// [`Self::skip_grid`] at this mi cell during this frame. A fresh | |
| 4060 | + /// `Neighbours` seeds `skip_grid` all-`false` ("not skip"), so a decode | |
| 4061 | + /// arm that forgets [`Self::fill_skip_grid_rect`] silently makes | |
| 4062 | + /// [`apply_cdef`] filter an 8x8 unit libaom's `is_8x8_block_skip` | |
| 4063 | + /// (`cdef.c:29-38`) excludes -- exactly the lane-cdef defect, and | |
| 4064 | + /// unobservable from the pixels alone. Counted by | |
| 4065 | + /// [`cdef_unwritten_skip_units`]. | |
| 4066 | + skip_written: Vec<bool>, | |
| 4032 | 4067 | skip_grid_cols_mi: usize, |
| 4033 | 4068 | /// Per-4x4-mi luma transform width in pixels (8/16/32/64) -- this decoder |
| 4034 | 4069 | /// never splits a coded block's transform below its own size (round 2: |
| @@ -4136,6 +4171,7 @@ impl Neighbours { | ||
| 4136 | 4171 | mi_cols, |
| 4137 | 4172 | mi_rows, |
| 4138 | 4173 | skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], |
| 4174 | + skip_written: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], | |
| 4139 | 4175 | skip_grid_cols_mi: cols * (SUB / MI), |
| 4140 | 4176 | tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 4141 | 4177 | tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| @@ -4514,14 +4550,18 @@ impl Neighbours { | ||
| 4514 | 4550 | /// [`Self::fill_skip_grid`] with independent row/col extents (lane-partitions r1). |
| 4515 | 4551 | fn fill_skip_grid_rect(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize, skip: bool) { |
| 4516 | 4552 | let (mi_r, mi_c) = at_mi; |
| 4553 | + if skip && w_mi != h_mi { | |
| 4554 | + RECT_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | |
| 4555 | + } | |
| 4517 | 4556 | for rr in 0..h_mi { |
| 4518 | 4557 | for cc in 0..w_mi { |
| 4519 | - if let Some(cell) = self | |
| 4520 | - .skip_grid | |
| 4521 | - .get_mut((mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc)) | |
| 4522 | - { | |
| 4558 | + let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc); | |
| 4559 | + if let Some(cell) = self.skip_grid.get_mut(idx) { | |
| 4523 | 4560 | *cell = skip; |
| 4524 | 4561 | } |
| 4562 | + if let Some(cell) = self.skip_written.get_mut(idx) { | |
| 4563 | + *cell = true; | |
| 4564 | + } | |
| 4525 | 4565 | } |
| 4526 | 4566 | } |
| 4527 | 4567 | } |
| @@ -13350,6 +13390,47 @@ fn apply_cdef( | ||
| 13350 | 13390 | if std::env::var_os("EC_AV1_DEBUG_SKIP_CDEF").is_some() { |
| 13351 | 13391 | return; |
| 13352 | 13392 | } |
| 13393 | + // lane-cdefstrip r1 instrument, BEFORE either early return so it is valid | |
| 13394 | + // for every frame: an 8x8 CDEF unit none of whose four mi cells a coded | |
| 13395 | + // block wrote this frame. `Neighbours` seeds `skip_grid` all-false, so a | |
| 13396 | + // decode arm that forgets `fill_skip_grid_rect` reads "not skip" and CDEF | |
| 13397 | + // filters a unit libaom's `is_8x8_block_skip` (`cdef.c:29-38`) may exclude. | |
| 13398 | + // Always 0 on every stream measured; a gate asserts it stays 0. | |
| 13399 | + { | |
| 13400 | + let mut r = 0usize; | |
| 13401 | + while r < skip_grid.mi_rows { | |
| 13402 | + let mut c = 0usize; | |
| 13403 | + while c < skip_grid.mi_cols { | |
| 13404 | + if (0..2).any(|rr| { | |
| 13405 | + (0..2).any(|cc| { | |
| 13406 | + !skip_grid | |
| 13407 | + .skip_written | |
| 13408 | + .get((r + rr) * skip_grid.skip_grid_cols_mi + (c + cc)) | |
| 13409 | + .copied() | |
| 13410 | + .unwrap_or(true) | |
| 13411 | + }) | |
| 13412 | + }) { | |
| 13413 | + CDEF_UNWRITTEN_SKIP_UNITS.with(|c2| c2.set(c2.get() + 1)); | |
| 13414 | + if std::env::var_os("EC_AV1_DEBUG_CDEF_BAND").is_some() { | |
| 13415 | + eprintln!("cdef band unwritten at mi ({r},{c}) px ({},{})", r * 4, c * 4); | |
| 13416 | + } | |
| 13417 | + } | |
| 13418 | + let cell = |rr: usize, cc: usize| { | |
| 13419 | + skip_grid | |
| 13420 | + .skip_grid | |
| 13421 | + .get((r + rr) * skip_grid.skip_grid_cols_mi + (c + cc)) | |
| 13422 | + .copied() | |
| 13423 | + .unwrap_or(false) | |
| 13424 | + }; | |
| 13425 | + let first = cell(0, 0); | |
| 13426 | + if (0..2).any(|rr| (0..2).any(|cc| cell(rr, cc) != first)) { | |
| 13427 | + CDEF_MIXED_SKIP_UNITS.with(|c2| c2.set(c2.get() + 1)); | |
| 13428 | + } | |
| 13429 | + c += 2; | |
| 13430 | + } | |
| 13431 | + r += 2; | |
| 13432 | + } | |
| 13433 | + } | |
| 13353 | 13434 | // `cdef.bits == 0` still means "no filtering at all" whenever the single |
| 13354 | 13435 | // (index 0) strength pair is all-zero -- the fast path every existing |
| 13355 | 13436 | // gate stream takes. A `bits > 0` frame can still be all-zero-strength |
crates/ec-av1/src/stream.rsmodified+178 -0
| @@ -16965,6 +16965,184 @@ mod tests { | ||
| 16965 | 16965 | ); |
| 16966 | 16966 | } |
| 16967 | 16967 | |
| 16968 | + /// lane-cdefstrip r1: the CDEF skip band under SKIPPED rectangular inter | |
| 16969 | + /// strips (32x8 / 8x32 / 64x16 / 16x64 / 32x64 / 64x32, the rect and 1:4 | |
| 16970 | + /// arms), the sibling of the 8x8-leaf case lane-cdef fixed. | |
| 16971 | + /// | |
| 16972 | + /// A fresh `Neighbours` seeds `skip_grid` all-`false` ("not skip"), so any | |
| 16973 | + /// decode arm that resolves `skip` and forgets `fill_skip_grid_rect` makes | |
| 16974 | + /// `apply_cdef` FILTER an 8x8 unit libaom's `is_8x8_block_skip` | |
| 16975 | + /// (`cdef.c:29-38`, `av1_cdef_compute_sb_list`'s dlist test) excludes -- | |
| 16976 | + /// a +-1 band that no entropy or prediction check can see. | |
| 16977 | + /// `decode::cdef_unwritten_skip_units` is the direct instrument for that | |
| 16978 | + /// class: it counts 8x8 CDEF units none of whose four mi cells any coded | |
| 16979 | + /// block wrote this frame, and this gate hard-asserts it stays 0 while | |
| 16980 | + /// `decode::rect_skip_band_hits` proves skipped rect strips really ran. | |
| 16981 | + /// | |
| 16982 | + /// MEASURED (lane-cdefstrip r1, 177 real aomenc streams incl. every arm | |
| 16983 | + /// below): the count is already 0 everywhere -- the charter's premise that | |
| 16984 | + /// the rect strip arms never write the band is FALSE. This gate is the | |
| 16985 | + /// regression fence for it, not a fix. | |
| 16986 | + #[test] | |
| 16987 | + fn a_real_aomenc_stream_with_skipped_rect_inter_strips_keeps_the_cdef_skip_band() { | |
| 16988 | + if !have_aomenc() { | |
| 16989 | + return; | |
| 16990 | + } | |
| 16991 | + let (width, height, frames) = (192usize, 128usize, 6usize); | |
| 16992 | + let mut refusals: Vec<String> = Vec::new(); | |
| 16993 | + let mut fired = 0u32; | |
| 16994 | + // (depth, cq, source): the arms measured pixel-exact end to end in the | |
| 16995 | + // r1 sweep (~/.cache/cdefstrip-tmp/sw.sh). Source `b` is the two-axis | |
| 16996 | + // moving sinusoid that makes aomenc pick 16x64/32x64/8x32 strips at | |
| 16997 | + // low cq and 32x8/64x16 at high cq; `a` is lane-inter16ab's source. | |
| 16998 | + let src_b = "120+55*sin((X+N*4)/7)+40*sin((Y-N*2)/11)"; | |
| 16999 | + let src_a = "128+60*sin((Y+N*3)/5)+30*sin(X/23)"; | |
| 17000 | + for (depth, cq, lum) in [ | |
| 17001 | + (8u32, 18u32, src_b), | |
| 17002 | + (8, 45, src_b), | |
| 17003 | + (10, 18, src_b), | |
| 17004 | + (10, 24, src_b), | |
| 17005 | + (10, 24, src_a), | |
| 17006 | + (8, 24, src_a), | |
| 17007 | + ] { | |
| 17008 | + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 17009 | + let src = format!( | |
| 17010 | + "color=c=gray:s={width}x{height}:d=0.24:r=25,format=gray,\ | |
| 17011 | + geq=lum='{lum}',format=yuv420p" | |
| 17012 | + ); | |
| 17013 | + let y4m = Command::new("ffmpeg") | |
| 17014 | + .args([ | |
| 17015 | + "-v", "error", "-f", "lavfi", "-i", &src, "-t", "0.24", "-pix_fmt", pix, | |
| 17016 | + "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 17017 | + ]) | |
| 17018 | + .stdin(Stdio::null()) | |
| 17019 | + .stdout(Stdio::piped()) | |
| 17020 | + .stderr(Stdio::piped()) | |
| 17021 | + .output() | |
| 17022 | + .expect("ffmpeg failed to run"); | |
| 17023 | + assert!( | |
| 17024 | + y4m.status.success(), | |
| 17025 | + "ffmpeg fixture: {}", | |
| 17026 | + String::from_utf8_lossy(&y4m.stderr) | |
| 17027 | + ); | |
| 17028 | + let mut child = Command::new(aomenc_path()) | |
| 17029 | + .args([ | |
| 17030 | + "--codec=av1", | |
| 17031 | + "--passes=1", | |
| 17032 | + "--end-usage=q", | |
| 17033 | + &format!("--cq-level={cq}"), | |
| 17034 | + "--cpu-used=0", | |
| 17035 | + "--threads=1", | |
| 17036 | + "--row-mt=0", | |
| 17037 | + "--sb-size=64", | |
| 17038 | + &format!("--bit-depth={depth}"), | |
| 17039 | + &format!("--input-bit-depth={depth}"), | |
| 17040 | + "--enable-restoration=0", | |
| 17041 | + "--enable-palette=0", | |
| 17042 | + "--deltaq-mode=0", | |
| 17043 | + "--enable-filter-intra=0", | |
| 17044 | + "--enable-cfl-intra=0", | |
| 17045 | + "--enable-intrabc=0", | |
| 17046 | + "--lag-in-frames=0", | |
| 17047 | + "--kf-max-dist=9999", | |
| 17048 | + "--tile-columns=0", | |
| 17049 | + "--enable-tx-size-search=0", | |
| 17050 | + "--enable-ab-partitions=0", | |
| 17051 | + "--min-partition-size=8", | |
| 17052 | + "--max-partition-size=64", | |
| 17053 | + // Last occurrence wins (aomenc-last-flag-wins): the three | |
| 17054 | + // flags this gate is about stay last. | |
| 17055 | + "--enable-rect-partitions=1", | |
| 17056 | + "--enable-1to4-partitions=1", | |
| 17057 | + "--enable-cdef=1", | |
| 17058 | + "--obu", | |
| 17059 | + "-o", | |
| 17060 | + "-", | |
| 17061 | + "-", | |
| 17062 | + ]) | |
| 17063 | + .stdin(Stdio::piped()) | |
| 17064 | + .stdout(Stdio::piped()) | |
| 17065 | + .stderr(Stdio::piped()) | |
| 17066 | + .spawn() | |
| 17067 | + .expect("aomenc failed to start"); | |
| 17068 | + child | |
| 17069 | + .stdin | |
| 17070 | + .take() | |
| 17071 | + .expect("aomenc stdin") | |
| 17072 | + .write_all(&y4m.stdout) | |
| 17073 | + .expect("writing y4m to aomenc"); | |
| 17074 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 17075 | + assert!( | |
| 17076 | + out.status.success(), | |
| 17077 | + "aomenc refused the fixture (depth={depth} cq={cq})" | |
| 17078 | + ); | |
| 17079 | + let stream = out.stdout; | |
| 17080 | + let unwritten_before = decode::cdef_unwritten_skip_units(); | |
| 17081 | + let rect_skip_before = decode::rect_skip_band_hits(); | |
| 17082 | + let skipped_before = decode::cdef_skipped_units(); | |
| 17083 | + let decoded = match decode_stream(&stream) { | |
| 17084 | + Ok(f) => f, | |
| 17085 | + Err(e) => { | |
| 17086 | + let msg = e.to_string(); | |
| 17087 | + assert!( | |
| 17088 | + msg.starts_with("unsupported: "), | |
| 17089 | + "decode error that is not a named refusal \ | |
| 17090 | + (depth={depth} cq={cq}): {msg}" | |
| 17091 | + ); | |
| 17092 | + refusals.push(format!("depth={depth} cq={cq}: {msg}")); | |
| 17093 | + continue; | |
| 17094 | + } | |
| 17095 | + }; | |
| 17096 | + assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})"); | |
| 17097 | + assert_eq!( | |
| 17098 | + decode::cdef_unwritten_skip_units(), | |
| 17099 | + unwritten_before, | |
| 17100 | + "an 8x8 CDEF unit was judged from an UNWRITTEN skip band \ | |
| 17101 | + (a decode arm resolved `skip` without `fill_skip_grid_rect`) \ | |
| 17102 | + (depth={depth} cq={cq})" | |
| 17103 | + ); | |
| 17104 | + let reference = if depth == 10 { | |
| 17105 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | |
| 17106 | + } else { | |
| 17107 | + ffmpeg_decode_sequence(&stream, width, height, frames) | |
| 17108 | + }; | |
| 17109 | + for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() { | |
| 17110 | + assert_eq!(ours.y, theirs.y, "luma frame {i} (depth={depth} cq={cq})"); | |
| 17111 | + assert_eq!(ours.u, theirs.u, "U frame {i} (depth={depth} cq={cq})"); | |
| 17112 | + assert_eq!(ours.v, theirs.v, "V frame {i} (depth={depth} cq={cq})"); | |
| 17113 | + } | |
| 17114 | + // Pixels are asserted for EVERY decoded attempt above; an attempt | |
| 17115 | + // counts as FIRING only if this stream really exercised the class | |
| 17116 | + // (a skipped rect strip wrote the band AND CDEF consulted it via | |
| 17117 | + // the all-skip exclusion). aomenc picking no skipped strip at a | |
| 17118 | + // given cq is a non-firing attempt, never a weakened assert. | |
| 17119 | + let rect_skips = decode::rect_skip_band_hits() - rect_skip_before; | |
| 17120 | + let excluded = decode::cdef_skipped_units() - skipped_before; | |
| 17121 | + if rect_skips == 0 || excluded == 0 { | |
| 17122 | + refusals.push(format!( | |
| 17123 | + "depth={depth} cq={cq}: exact but did not fire \ | |
| 17124 | + (skipped rect strips {rect_skips}, excluded 8x8 units {excluded})" | |
| 17125 | + )); | |
| 17126 | + continue; | |
| 17127 | + } | |
| 17128 | + fired += 1; | |
| 17129 | + } | |
| 17130 | + eprintln!( | |
| 17131 | + "a_real_aomenc_stream_with_skipped_rect_inter_strips_keeps_the_cdef_skip_band: \ | |
| 17132 | + {fired} firing+exact attempts, unwritten skip-band units {}, \ | |
| 17133 | + skipped rect strips {}, 8x8 units excluded {}\n{}", | |
| 17134 | + decode::cdef_unwritten_skip_units(), | |
| 17135 | + decode::rect_skip_band_hits(), | |
| 17136 | + decode::cdef_skipped_units(), | |
| 17137 | + refusals.join("\n") | |
| 17138 | + ); | |
| 17139 | + assert!( | |
| 17140 | + fired >= 3, | |
| 17141 | + "fewer than 3 firing+pixel-exact attempts:\n{}", | |
| 17142 | + refusals.join("\n") | |
| 17143 | + ); | |
| 17144 | + } | |
| 17145 | + | |
| 16968 | 17146 | /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients |
| 16969 | 17147 | /// at low cq reliably makes aomenc split an 8x8 block all the way to |
| 16970 | 17148 | /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec |
lanes/cdefstrip-r1.report.mdadded+81 -0
| @@ -0,0 +1,81 @@ | ||
| 1 | +# lane-cdefstrip r1 — report (GREEN gate, charter premise DISPROVED, no fix needed) | |
| 2 | + | |
| 3 | +Branch `lane-cdefstrip`, rebased onto main `3566501` (charter said "main >= dfe9ce8"; | |
| 4 | +main had moved two merges further, so the premise was re-measured on the current tree). | |
| 5 | + | |
| 6 | +## 1. The charter's defect no longer exists | |
| 7 | +Charter premise: "a real aomenc 8-bit stream is +-1 wrong on 4 luma px of decode-order | |
| 8 | +frame 1 (cols 48/54/55/59) inside a SKIPPED 32x8 inter strip's row" (lane-inter16ab r6, | |
| 9 | +`~/.cache/inter16ab-tmp/a8.sh`). | |
| 10 | + | |
| 11 | +Re-measured on main 3566501 (which contains lane-cdef 1176a16): that stream is now | |
| 12 | +pixel-exact on frames 0-4 including the named pixels. The +-1 band was the 8x8-leaf | |
| 13 | +skip-band gap lane-cdef fixed; the charter was written from the pre-merge measurement. | |
| 14 | + | |
| 15 | +EVIDENCE: ~/.cache/cdefstrip-tmp/{a8.obu,ours.yuv,ref.yuv} | `bash a8.sh` (sha256 | |
| 16 | +`6d8b29d903ef5f8deb8e0a6b79798b33291373be9ffc50f750ce3cbc6f38170a`, hashed twice, identical); | |
| 17 | +`EC_PROBE_OUT=ours.yuv decode_probe a8.obu` vs `ffmpeg -i a8.obu -f rawvideo` | | |
| 18 | +frames 0,1,2,3,4 luma diff = 0 px each (was 4 px on frame 1); frame 5 differs — see 4. | |
| 19 | + | |
| 20 | +## 2. "Rect strip arms never write the CDEF skip band" is FALSE — measured, not argued | |
| 21 | +Built the direct instrument instead of auditing arms one by one: `Neighbours::skip_written` | |
| 22 | +(decode.rs:4046, set in `fill_skip_grid_rect` decode.rs:4536-4541) records whether ANY coded | |
| 23 | +block wrote the per-mi skip band this frame; `apply_cdef` (decode.rs:13363-13405, a pass placed | |
| 24 | +BEFORE both early returns so it is valid for every frame) counts 8x8 CDEF units with an | |
| 25 | +unwritten band into `decode::cdef_unwritten_skip_units()`. A fresh `Neighbours` seeds | |
| 26 | +`skip_grid` all-`false`, so an arm that forgets the write is exactly an unwritten unit — | |
| 27 | +the defect class, observable without pixels. | |
| 28 | + | |
| 29 | +Result: **0 unwritten units on 177 real aomenc streams** — 145 pre-existing corpus streams | |
| 30 | +(`~/.cache/inter16ab-tmp/*.obu` + `crates/ec-av1/fixtures/*.obu`, incl. 32x8/8x32/64x32/32x64/ | |
| 31 | +64x16/16x64 strips, AB and 1:4 arms, 8- and 10-bit) plus 32 new sweep streams | |
| 32 | +(`~/.cache/cdefstrip-tmp/sw.sh`: 2 sources x cq 18/24/32/45 x min-partition-size 4/8 x 8+10 bit). | |
| 33 | + | |
| 34 | +EVIDENCE: ~/.cache/cdefstrip-tmp/sw.sh + corpus sweep | `decode_probe <stream>` per stream, | |
| 35 | +grep `cdef_unwritten_skip_units` | streams=145 with_unwritten=0, plus 32/32 sweep streams at 0; | |
| 36 | +a8.obu shows `rect_skip_writes=16` (skipped rect strips that DID write the band). | |
| 37 | + | |
| 38 | +Also checked by reading, not assumed: `is_8x8_block_skip`'s all-four-cells rule is already | |
| 39 | +`Neighbours::is_skip_txfm` (decode.rs, gathered over the 2x2 mi span, matching cdef.c:29-38), | |
| 40 | +and `maybe_read_cdef_idx` (decode.rs:412-416) returns before consuming the literal when the | |
| 41 | +block is `skip`, so a skipped 32x8 strip does not eat the 64x64's `cdef_idx` — the charter's | |
| 42 | +second suspicion. | |
| 43 | + | |
| 44 | +## 3. New gate (regression fence for the class) | |
| 45 | +`stream.rs: a_real_aomenc_stream_with_skipped_rect_inter_strips_keeps_the_cdef_skip_band` | |
| 46 | +— real aomenc, `--enable-cdef=1 --enable-rect-partitions=1 --enable-1to4-partitions=1 | |
| 47 | +--min-partition-size=8 --sb-size=64`, 6 arms (8+10 bit x cq 18/24/45 x two motion sources), | |
| 48 | +every decode-order frame compared on all three planes (stricter than out_of_scope_mismatch==0), | |
| 49 | +hard asserts: `cdef_unwritten_skip_units()` unchanged (==0 growth) per compared attempt; | |
| 50 | +per-attempt firing requires a skipped rect strip to have written the band AND an 8x8 unit to | |
| 51 | +have been excluded by the all-skip rule; >=3 firing+exact attempts. | |
| 52 | + | |
| 53 | +EVIDENCE: cargo test output | `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib | |
| 54 | +skipped_rect_inter_strips -- --nocapture` | ok, "4 firing+exact attempts, unwritten skip-band | |
| 55 | +units 0, skipped rect strips 49, 8x8 units excluded 1630"; 2 non-firing arms recorded | |
| 56 | +(one SB-level AB refusal, one 10-bit arm where aomenc picked no skipped strip). | |
| 57 | + | |
| 58 | +## 4. Residue found, NOT this lane's class | |
| 59 | +The LAST decode-order frame (frame 5) of 3 of the 32 sweep arms mismatches | |
| 60 | +(8-bit only: source-a cq18 945 px max|d|=42; source-b cq24 min-part 4 and 8, 8370 px | |
| 61 | +max|d|=87; a8.obu cq22 1349 px). It is NOT CDEF: re-encoding the identical source with | |
| 62 | +`--enable-cdef=0` (`a8n.sh`) still mismatches that frame (5479 px), while frames 0-4 are exact | |
| 63 | +in both. Every 10-bit twin of those arms is exact on all 6 frames. | |
| 64 | +Disposition: deferred(needs its own lane: last-frame-only 8-bit inter defect, prediction or | |
| 65 | +residual, unblocked by bisecting b10/a8 frame 5 with the pre-filter dump) — it is why the gate's | |
| 66 | +arm list is the measured-exact subset rather than the whole sweep. | |
| 67 | + | |
| 68 | +Second residue: `cdef_mixed_skip_units()` (an 8x8 CDEF unit whose four mi cells disagree on | |
| 69 | +skip — the HORZ_4 shape the charter names) is 0 on all 177 streams, because the only blocks | |
| 70 | +that can straddle an 8x8 unit are 16x4/4x16 and sub-8x8 inter, both still refused | |
| 71 | +("an inter 16x16-level 1:4 partition", "an inter partition below 8x8"). | |
| 72 | +Disposition: accepted — unreachable until those refusals lift; the counter is in place so the | |
| 73 | +day one lifts, this gate's arms report it. | |
| 74 | + | |
| 75 | +## 5. Refusals | |
| 76 | +None lifted (none of this lane's class exists). `refusal_inventory` / `gate_coverage` untouched | |
| 77 | +and green. | |
| 78 | + | |
| 79 | +## 6. Suite | |
| 80 | +`cargo test -p ec-av1 --lib` under a systemd unit -> $HOME/.cache/cdefstrip-suite-r1.log: see | |
| 81 | +the line appended below. |