Merge branch 'lane-cdefstrip' (092b124): the CDEF skip band on skipped rect inter strips
Browse files at this commit4 changed files +359 -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 +84 -0
crates/ec-av1/examples/decode_probe.rsmodified+12 -0
| @@ -84,6 +84,18 @@ fn main() { | ||
| 84 | 84 | "intra_rect4_in_inter: 64x16={} 16x64={} 32x8={} 8x32={}", |
| 85 | 85 | i4.0, i4.1, i4.2, i4.3 |
| 86 | 86 | ); |
| 87 | + // lane-cdefstrip r1: 8x8 CDEF units whose skip band no coded block | |
| 88 | + // wrote this frame -- non-zero means a decode arm forgot | |
| 89 | + // `fill_skip_grid_rect`, and CDEF filtered a unit libaom may skip. | |
| 90 | + println!( | |
| 91 | + "cdef_unwritten_skip_units: {}", | |
| 92 | + ec_av1::decode::cdef_unwritten_skip_units() | |
| 93 | + ); | |
| 94 | + println!( | |
| 95 | + "cdef_band: rect_skip_writes={} mixed_skip_units={}", | |
| 96 | + ec_av1::decode::rect_skip_band_hits(), | |
| 97 | + ec_av1::decode::cdef_mixed_skip_units() | |
| 98 | + ); | |
| 87 | 99 | let ir = ec_av1::stream::inter_rect_counters(); |
| 88 | 100 | println!( |
| 89 | 101 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", |
crates/ec-av1/src/decode.rsmodified+85 -4
| @@ -3058,6 +3058,26 @@ thread_local! { | ||
| 3058 | 3058 | // whose width or height is not a multiple of 8 is the only shape that |
| 3059 | 3059 | // produces one; the straddling-band gate arms assert it grew. |
| 3060 | 3060 | static CDEF_STRADDLE_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 3061 | + // lane-cdefstrip r1: 8x8 CDEF units visited with an UNWRITTEN skip band | |
| 3062 | + // (see `Neighbours::skip_written`). | |
| 3063 | + static CDEF_UNWRITTEN_SKIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 3064 | + // lane-cdefstrip r1: (d) skip RECTANGULAR blocks (every strip arm: 32x8, | |
| 3065 | + // 8x32, 16x8, 32x16, 64x16, AB/1:4 pieces...) that wrote the CDEF skip | |
| 3066 | + // band, and (e) 8x8 CDEF units whose four mi cells do NOT agree on skip -- | |
| 3067 | + // the shape libaom's `is_8x8_block_skip` (`cdef.c:29-38`) exists for: an | |
| 3068 | + // 8-tall strip pair where only one half is skip must still be FILTERED. | |
| 3069 | + static RECT_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 3070 | + static CDEF_MIXED_SKIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 3071 | +} | |
| 3072 | + | |
| 3073 | +/// Current value of `RECT_SKIP_BAND_HITS`. | |
| 3074 | +pub fn rect_skip_band_hits() -> usize { | |
| 3075 | + RECT_SKIP_BAND_HITS.with(|c| c.get()) | |
| 3076 | +} | |
| 3077 | + | |
| 3078 | +/// Current value of `CDEF_MIXED_SKIP_UNITS`. | |
| 3079 | +pub fn cdef_mixed_skip_units() -> usize { | |
| 3080 | + CDEF_MIXED_SKIP_UNITS.with(|c| c.get()) | |
| 3061 | 3081 | } |
| 3062 | 3082 | |
| 3063 | 3083 | /// Current value of `CDEF_SKIPPED_UNITS`. |
| @@ -3065,6 +3085,12 @@ pub(crate) fn cdef_skipped_units() -> usize { | ||
| 3065 | 3085 | CDEF_SKIPPED_UNITS.with(|c| c.get()) |
| 3066 | 3086 | } |
| 3067 | 3087 | |
| 3088 | +/// How many 8x8 CDEF units [`apply_cdef`] visited whose skip band no coded | |
| 3089 | +/// block wrote this frame -- a writer gap, always a defect (lane-cdefstrip r1). | |
| 3090 | +pub fn cdef_unwritten_skip_units() -> usize { | |
| 3091 | + CDEF_UNWRITTEN_SKIP_UNITS.with(|c| c.get()) | |
| 3092 | +} | |
| 3093 | + | |
| 3068 | 3094 | /// Current value of `INTER8_SKIP_BAND_HITS`. |
| 3069 | 3095 | pub(crate) fn inter8_skip_band_hits() -> usize { |
| 3070 | 3096 | INTER8_SKIP_BAND_HITS.with(|c| c.get()) |
| @@ -4331,6 +4357,15 @@ struct Neighbours { | ||
| 4331 | 4357 | /// granularity by [`apply_cdef`] since `skip` is constant across every |
| 4332 | 4358 | /// mi cell one coded block covers. |
| 4333 | 4359 | skip_grid: Vec<bool>, |
| 4360 | + /// lane-cdefstrip r1 instrument: whether any coded block actually WROTE | |
| 4361 | + /// [`Self::skip_grid`] at this mi cell during this frame. A fresh | |
| 4362 | + /// `Neighbours` seeds `skip_grid` all-`false` ("not skip"), so a decode | |
| 4363 | + /// arm that forgets [`Self::fill_skip_grid_rect`] silently makes | |
| 4364 | + /// [`apply_cdef`] filter an 8x8 unit libaom's `is_8x8_block_skip` | |
| 4365 | + /// (`cdef.c:29-38`) excludes -- exactly the lane-cdef defect, and | |
| 4366 | + /// unobservable from the pixels alone. Counted by | |
| 4367 | + /// [`cdef_unwritten_skip_units`]. | |
| 4368 | + skip_written: Vec<bool>, | |
| 4334 | 4369 | skip_grid_cols_mi: usize, |
| 4335 | 4370 | /// Per-4x4-mi luma transform width in pixels (8/16/32/64) -- this decoder |
| 4336 | 4371 | /// never splits a coded block's transform below its own size (round 2: |
| @@ -4450,6 +4485,7 @@ impl Neighbours { | ||
| 4450 | 4485 | mi_cols, |
| 4451 | 4486 | mi_rows, |
| 4452 | 4487 | skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], |
| 4488 | + skip_written: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], | |
| 4453 | 4489 | skip_grid_cols_mi: cols * (SUB / MI), |
| 4454 | 4490 | tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 4455 | 4491 | tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| @@ -4864,14 +4900,18 @@ impl Neighbours { | ||
| 4864 | 4900 | /// [`Self::fill_skip_grid`] with independent row/col extents (lane-partitions r1). |
| 4865 | 4901 | fn fill_skip_grid_rect(&mut self, at_mi: (usize, usize), w_mi: usize, h_mi: usize, skip: bool) { |
| 4866 | 4902 | let (mi_r, mi_c) = at_mi; |
| 4903 | + if skip && w_mi != h_mi { | |
| 4904 | + RECT_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | |
| 4905 | + } | |
| 4867 | 4906 | for rr in 0..h_mi { |
| 4868 | 4907 | for cc in 0..w_mi { |
| 4869 | - if let Some(cell) = self | |
| 4870 | - .skip_grid | |
| 4871 | - .get_mut((mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc)) | |
| 4872 | - { | |
| 4908 | + let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc); | |
| 4909 | + if let Some(cell) = self.skip_grid.get_mut(idx) { | |
| 4873 | 4910 | *cell = skip; |
| 4874 | 4911 | } |
| 4912 | + if let Some(cell) = self.skip_written.get_mut(idx) { | |
| 4913 | + *cell = true; | |
| 4914 | + } | |
| 4875 | 4915 | } |
| 4876 | 4916 | } |
| 4877 | 4917 | } |
| @@ -14425,6 +14465,47 @@ fn apply_cdef( | ||
| 14425 | 14465 | if std::env::var_os("EC_AV1_DEBUG_SKIP_CDEF").is_some() { |
| 14426 | 14466 | return; |
| 14427 | 14467 | } |
| 14468 | + // lane-cdefstrip r1 instrument, BEFORE either early return so it is valid | |
| 14469 | + // for every frame: an 8x8 CDEF unit none of whose four mi cells a coded | |
| 14470 | + // block wrote this frame. `Neighbours` seeds `skip_grid` all-false, so a | |
| 14471 | + // decode arm that forgets `fill_skip_grid_rect` reads "not skip" and CDEF | |
| 14472 | + // filters a unit libaom's `is_8x8_block_skip` (`cdef.c:29-38`) may exclude. | |
| 14473 | + // Always 0 on every stream measured; a gate asserts it stays 0. | |
| 14474 | + { | |
| 14475 | + let mut r = 0usize; | |
| 14476 | + while r < skip_grid.mi_rows { | |
| 14477 | + let mut c = 0usize; | |
| 14478 | + while c < skip_grid.mi_cols { | |
| 14479 | + if (0..2).any(|rr| { | |
| 14480 | + (0..2).any(|cc| { | |
| 14481 | + !skip_grid | |
| 14482 | + .skip_written | |
| 14483 | + .get((r + rr) * skip_grid.skip_grid_cols_mi + (c + cc)) | |
| 14484 | + .copied() | |
| 14485 | + .unwrap_or(true) | |
| 14486 | + }) | |
| 14487 | + }) { | |
| 14488 | + CDEF_UNWRITTEN_SKIP_UNITS.with(|c2| c2.set(c2.get() + 1)); | |
| 14489 | + if std::env::var_os("EC_AV1_DEBUG_CDEF_BAND").is_some() { | |
| 14490 | + eprintln!("cdef band unwritten at mi ({r},{c}) px ({},{})", r * 4, c * 4); | |
| 14491 | + } | |
| 14492 | + } | |
| 14493 | + let cell = |rr: usize, cc: usize| { | |
| 14494 | + skip_grid | |
| 14495 | + .skip_grid | |
| 14496 | + .get((r + rr) * skip_grid.skip_grid_cols_mi + (c + cc)) | |
| 14497 | + .copied() | |
| 14498 | + .unwrap_or(false) | |
| 14499 | + }; | |
| 14500 | + let first = cell(0, 0); | |
| 14501 | + if (0..2).any(|rr| (0..2).any(|cc| cell(rr, cc) != first)) { | |
| 14502 | + CDEF_MIXED_SKIP_UNITS.with(|c2| c2.set(c2.get() + 1)); | |
| 14503 | + } | |
| 14504 | + c += 2; | |
| 14505 | + } | |
| 14506 | + r += 2; | |
| 14507 | + } | |
| 14508 | + } | |
| 14428 | 14509 | // `cdef.bits == 0` still means "no filtering at all" whenever the single |
| 14429 | 14510 | // (index 0) strength pair is all-zero -- the fast path every existing |
| 14430 | 14511 | // gate stream takes. A `bits > 0` frame can still be all-zero-strength |
crates/ec-av1/src/stream.rsmodified+178 -0
| @@ -18712,6 +18712,184 @@ mod tests { | ||
| 18712 | 18712 | ); |
| 18713 | 18713 | } |
| 18714 | 18714 | |
| 18715 | + /// lane-cdefstrip r1: the CDEF skip band under SKIPPED rectangular inter | |
| 18716 | + /// strips (32x8 / 8x32 / 64x16 / 16x64 / 32x64 / 64x32, the rect and 1:4 | |
| 18717 | + /// arms), the sibling of the 8x8-leaf case lane-cdef fixed. | |
| 18718 | + /// | |
| 18719 | + /// A fresh `Neighbours` seeds `skip_grid` all-`false` ("not skip"), so any | |
| 18720 | + /// decode arm that resolves `skip` and forgets `fill_skip_grid_rect` makes | |
| 18721 | + /// `apply_cdef` FILTER an 8x8 unit libaom's `is_8x8_block_skip` | |
| 18722 | + /// (`cdef.c:29-38`, `av1_cdef_compute_sb_list`'s dlist test) excludes -- | |
| 18723 | + /// a +-1 band that no entropy or prediction check can see. | |
| 18724 | + /// `decode::cdef_unwritten_skip_units` is the direct instrument for that | |
| 18725 | + /// class: it counts 8x8 CDEF units none of whose four mi cells any coded | |
| 18726 | + /// block wrote this frame, and this gate hard-asserts it stays 0 while | |
| 18727 | + /// `decode::rect_skip_band_hits` proves skipped rect strips really ran. | |
| 18728 | + /// | |
| 18729 | + /// MEASURED (lane-cdefstrip r1, 177 real aomenc streams incl. every arm | |
| 18730 | + /// below): the count is already 0 everywhere -- the charter's premise that | |
| 18731 | + /// the rect strip arms never write the band is FALSE. This gate is the | |
| 18732 | + /// regression fence for it, not a fix. | |
| 18733 | + #[test] | |
| 18734 | + fn a_real_aomenc_stream_with_skipped_rect_inter_strips_keeps_the_cdef_skip_band() { | |
| 18735 | + if !have_aomenc() { | |
| 18736 | + return; | |
| 18737 | + } | |
| 18738 | + let (width, height, frames) = (192usize, 128usize, 6usize); | |
| 18739 | + let mut refusals: Vec<String> = Vec::new(); | |
| 18740 | + let mut fired = 0u32; | |
| 18741 | + // (depth, cq, source): the arms measured pixel-exact end to end in the | |
| 18742 | + // r1 sweep (~/.cache/cdefstrip-tmp/sw.sh). Source `b` is the two-axis | |
| 18743 | + // moving sinusoid that makes aomenc pick 16x64/32x64/8x32 strips at | |
| 18744 | + // low cq and 32x8/64x16 at high cq; `a` is lane-inter16ab's source. | |
| 18745 | + let src_b = "120+55*sin((X+N*4)/7)+40*sin((Y-N*2)/11)"; | |
| 18746 | + let src_a = "128+60*sin((Y+N*3)/5)+30*sin(X/23)"; | |
| 18747 | + for (depth, cq, lum) in [ | |
| 18748 | + (8u32, 18u32, src_b), | |
| 18749 | + (8, 45, src_b), | |
| 18750 | + (10, 18, src_b), | |
| 18751 | + (10, 24, src_b), | |
| 18752 | + (10, 24, src_a), | |
| 18753 | + (8, 24, src_a), | |
| 18754 | + ] { | |
| 18755 | + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 18756 | + let src = format!( | |
| 18757 | + "color=c=gray:s={width}x{height}:d=0.24:r=25,format=gray,\ | |
| 18758 | + geq=lum='{lum}',format=yuv420p" | |
| 18759 | + ); | |
| 18760 | + let y4m = Command::new("ffmpeg") | |
| 18761 | + .args([ | |
| 18762 | + "-v", "error", "-f", "lavfi", "-i", &src, "-t", "0.24", "-pix_fmt", pix, | |
| 18763 | + "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 18764 | + ]) | |
| 18765 | + .stdin(Stdio::null()) | |
| 18766 | + .stdout(Stdio::piped()) | |
| 18767 | + .stderr(Stdio::piped()) | |
| 18768 | + .output() | |
| 18769 | + .expect("ffmpeg failed to run"); | |
| 18770 | + assert!( | |
| 18771 | + y4m.status.success(), | |
| 18772 | + "ffmpeg fixture: {}", | |
| 18773 | + String::from_utf8_lossy(&y4m.stderr) | |
| 18774 | + ); | |
| 18775 | + let mut child = Command::new(aomenc_path()) | |
| 18776 | + .args([ | |
| 18777 | + "--codec=av1", | |
| 18778 | + "--passes=1", | |
| 18779 | + "--end-usage=q", | |
| 18780 | + &format!("--cq-level={cq}"), | |
| 18781 | + "--cpu-used=0", | |
| 18782 | + "--threads=1", | |
| 18783 | + "--row-mt=0", | |
| 18784 | + "--sb-size=64", | |
| 18785 | + &format!("--bit-depth={depth}"), | |
| 18786 | + &format!("--input-bit-depth={depth}"), | |
| 18787 | + "--enable-restoration=0", | |
| 18788 | + "--enable-palette=0", | |
| 18789 | + "--deltaq-mode=0", | |
| 18790 | + "--enable-filter-intra=0", | |
| 18791 | + "--enable-cfl-intra=0", | |
| 18792 | + "--enable-intrabc=0", | |
| 18793 | + "--lag-in-frames=0", | |
| 18794 | + "--kf-max-dist=9999", | |
| 18795 | + "--tile-columns=0", | |
| 18796 | + "--enable-tx-size-search=0", | |
| 18797 | + "--enable-ab-partitions=0", | |
| 18798 | + "--min-partition-size=8", | |
| 18799 | + "--max-partition-size=64", | |
| 18800 | + // Last occurrence wins (aomenc-last-flag-wins): the three | |
| 18801 | + // flags this gate is about stay last. | |
| 18802 | + "--enable-rect-partitions=1", | |
| 18803 | + "--enable-1to4-partitions=1", | |
| 18804 | + "--enable-cdef=1", | |
| 18805 | + "--obu", | |
| 18806 | + "-o", | |
| 18807 | + "-", | |
| 18808 | + "-", | |
| 18809 | + ]) | |
| 18810 | + .stdin(Stdio::piped()) | |
| 18811 | + .stdout(Stdio::piped()) | |
| 18812 | + .stderr(Stdio::piped()) | |
| 18813 | + .spawn() | |
| 18814 | + .expect("aomenc failed to start"); | |
| 18815 | + child | |
| 18816 | + .stdin | |
| 18817 | + .take() | |
| 18818 | + .expect("aomenc stdin") | |
| 18819 | + .write_all(&y4m.stdout) | |
| 18820 | + .expect("writing y4m to aomenc"); | |
| 18821 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 18822 | + assert!( | |
| 18823 | + out.status.success(), | |
| 18824 | + "aomenc refused the fixture (depth={depth} cq={cq})" | |
| 18825 | + ); | |
| 18826 | + let stream = out.stdout; | |
| 18827 | + let unwritten_before = decode::cdef_unwritten_skip_units(); | |
| 18828 | + let rect_skip_before = decode::rect_skip_band_hits(); | |
| 18829 | + let skipped_before = decode::cdef_skipped_units(); | |
| 18830 | + let decoded = match decode_stream(&stream) { | |
| 18831 | + Ok(f) => f, | |
| 18832 | + Err(e) => { | |
| 18833 | + let msg = e.to_string(); | |
| 18834 | + assert!( | |
| 18835 | + msg.starts_with("unsupported: "), | |
| 18836 | + "decode error that is not a named refusal \ | |
| 18837 | + (depth={depth} cq={cq}): {msg}" | |
| 18838 | + ); | |
| 18839 | + refusals.push(format!("depth={depth} cq={cq}: {msg}")); | |
| 18840 | + continue; | |
| 18841 | + } | |
| 18842 | + }; | |
| 18843 | + assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})"); | |
| 18844 | + assert_eq!( | |
| 18845 | + decode::cdef_unwritten_skip_units(), | |
| 18846 | + unwritten_before, | |
| 18847 | + "an 8x8 CDEF unit was judged from an UNWRITTEN skip band \ | |
| 18848 | + (a decode arm resolved `skip` without `fill_skip_grid_rect`) \ | |
| 18849 | + (depth={depth} cq={cq})" | |
| 18850 | + ); | |
| 18851 | + let reference = if depth == 10 { | |
| 18852 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | |
| 18853 | + } else { | |
| 18854 | + ffmpeg_decode_sequence(&stream, width, height, frames) | |
| 18855 | + }; | |
| 18856 | + for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() { | |
| 18857 | + assert_eq!(ours.y, theirs.y, "luma frame {i} (depth={depth} cq={cq})"); | |
| 18858 | + assert_eq!(ours.u, theirs.u, "U frame {i} (depth={depth} cq={cq})"); | |
| 18859 | + assert_eq!(ours.v, theirs.v, "V frame {i} (depth={depth} cq={cq})"); | |
| 18860 | + } | |
| 18861 | + // Pixels are asserted for EVERY decoded attempt above; an attempt | |
| 18862 | + // counts as FIRING only if this stream really exercised the class | |
| 18863 | + // (a skipped rect strip wrote the band AND CDEF consulted it via | |
| 18864 | + // the all-skip exclusion). aomenc picking no skipped strip at a | |
| 18865 | + // given cq is a non-firing attempt, never a weakened assert. | |
| 18866 | + let rect_skips = decode::rect_skip_band_hits() - rect_skip_before; | |
| 18867 | + let excluded = decode::cdef_skipped_units() - skipped_before; | |
| 18868 | + if rect_skips == 0 || excluded == 0 { | |
| 18869 | + refusals.push(format!( | |
| 18870 | + "depth={depth} cq={cq}: exact but did not fire \ | |
| 18871 | + (skipped rect strips {rect_skips}, excluded 8x8 units {excluded})" | |
| 18872 | + )); | |
| 18873 | + continue; | |
| 18874 | + } | |
| 18875 | + fired += 1; | |
| 18876 | + } | |
| 18877 | + eprintln!( | |
| 18878 | + "a_real_aomenc_stream_with_skipped_rect_inter_strips_keeps_the_cdef_skip_band: \ | |
| 18879 | + {fired} firing+exact attempts, unwritten skip-band units {}, \ | |
| 18880 | + skipped rect strips {}, 8x8 units excluded {}\n{}", | |
| 18881 | + decode::cdef_unwritten_skip_units(), | |
| 18882 | + decode::rect_skip_band_hits(), | |
| 18883 | + decode::cdef_skipped_units(), | |
| 18884 | + refusals.join("\n") | |
| 18885 | + ); | |
| 18886 | + assert!( | |
| 18887 | + fired >= 3, | |
| 18888 | + "fewer than 3 firing+pixel-exact attempts:\n{}", | |
| 18889 | + refusals.join("\n") | |
| 18890 | + ); | |
| 18891 | + } | |
| 18892 | + | |
| 18715 | 18893 | /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients |
| 18716 | 18894 | /// at low cq reliably makes aomenc split an 8x8 block all the way to |
| 18717 | 18895 | /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec |
lanes/cdefstrip-r1.report.mdadded+84 -0
| @@ -0,0 +1,84 @@ | ||
| 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. | |
| 82 | + | |
| 83 | +`cargo test -p ec-av1 --lib` (unit `cdefstrip-suite-1788349014.service`, log | |
| 84 | +$HOME/.cache/cdefstrip-suite-r1.log): **401 passed, 0 failed, 33 ignored**, 1396.72s. |