forge
Explore
Log in

Don't you dare go Hollow

CDEF filtered 8x8 units libaom skips, and searched direction on clamped edge pixels

Browse files at this commit

e7460a02f64339f1ed0335e3c126827074f82ddbAhmet Kaan GümüşParent: a8d25d4
  • fix
    • CDEF filtered 8x8 units libaom skips, and searched direction on clamped edge pixels
Show full message
fix(av1): CDEF filtered 8x8 units libaom skips, and searched direction on clamped edge pixels

decode_inter_block8 (the leaf path --min-partition-size=4 picks for a 16x16
group) wrote the mi map and the loop-filter grid at both exits but never the
per-8x8 CDEF skip band, so an all-skip 8x8 group was judged by the PREVIOUS
frame's flags and got filtered where libaom's is_8x8_block_skip
(cdef.c:29-38) excludes it from av1_cdef_compute_sb_list's dlist: 3 luma
samples |d|=1 on decode-order frames 3 and 4 of a 192x128 6-frame inter
stream at cq 8 and cq 10, all in the frame's last 8x8 column.

apply_cdef's direction search also clamped to the last real sample instead of
reading the CDEF_VERY_LARGE padding libaom's cdef_prepare_fb writes past the
mi-rounded extent (cdef.c:249-256), so every 8x8 straddling an odd-mi crop
edge picked a different var, hence a different adjust_strength: a 68x192
stream goes 145 luma samples wrong on frame 1 to 0 on all five frames
(its chroma residue is a separate, still-open defect).

Gate: a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact,
real aomenc with --min-partition-size=4 --enable-cdef=1, every decode-order
frame on all three planes, hard-asserting both new counters (an 8x8 unit
excluded by the all-skip rule, and the leaf that now writes the band).
Also: dump_stage/dump_stage16 indexed per frame (they overwrote .f0 every
frame, which is why filter-stage bisection kept reading the LAST frame).
crates/ec-av1/src/decode.rsmodified+70 -6
@@ -2543,6 +2543,28 @@ thread_local! {
2543 static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };2543 static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2544 }2544 }
2545 2545
2546+// lane-cdef r1: (a) how many 8x8 CDEF units `apply_cdef` EXCLUDED because all
2547+// four of their mi cells are `skip_txfm` (libaom `cdef.c:29-38`
2548+// `is_8x8_block_skip` / `av1_cdef_compute_sb_list`'s dlist test), and (b) how
2549+// many 8x8 inter leaves (`decode_inter_block8`) wrote that skip band at all.
2550+// (b) was 0 for every stream before this round -- the leaf path never touched
2551+// the band, so an all-skip 8x8 group kept the PREVIOUS frame's flags and got
2552+// filtered where libaom skips it. A gate asserts both are non-zero.
2553+thread_local! {
2554+ static CDEF_SKIPPED_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2555+ static INTER8_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2556+}
2557+
2558+/// Current value of `CDEF_SKIPPED_UNITS`.
2559+pub(crate) fn cdef_skipped_units() -> usize {
2560+ CDEF_SKIPPED_UNITS.with(|c| c.get())
2561+}
2562+
2563+/// Current value of `INTER8_SKIP_BAND_HITS`.
2564+pub(crate) fn inter8_skip_band_hits() -> usize {
2565+ INTER8_SKIP_BAND_HITS.with(|c| c.get())
2566+}
2567+
2546 /// Current value of [`SUB8_SPLIT_HITS`].2568 /// Current value of [`SUB8_SPLIT_HITS`].
2547 pub(crate) fn sub8_split_hits() -> usize {2569 pub(crate) fn sub8_split_hits() -> usize {
2548 SUB8_SPLIT_HITS.with(|c| c.get())2570 SUB8_SPLIT_HITS.with(|c| c.get())
@@ -8822,7 +8844,7 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 {
8822 fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) {8844 fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) {
8823 use std::io::Write;8845 use std::io::Write;
8824 if let Ok(path) = std::env::var(var)8846 if let Ok(path) = std::env::var(var)
8825- && let Ok(mut f) = std::fs::File::create(format!("{path}.f0"))8847+ && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var)))
8826 {8848 {
8827 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))] {8849 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))] {
8828 for row in 0..h {8850 for row in 0..h {
@@ -8836,10 +8858,25 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize,
8836 }8858 }
8837 }8859 }
8838 8860
8861+/// Decode-order index of the next [`dump_stage`]/[`dump_stage16`] file for a
8862+/// given env var -- lane-cdef r1: both used to write `.f0` unconditionally, so
8863+/// every frame overwrote the previous one and only the LAST frame survived,
8864+/// which silently defeats any per-frame filter-stage bisection.
8865+fn dump_stage_idx(var: &str) -> usize {
8866+ use std::collections::HashMap;
8867+ use std::sync::{Mutex, OnceLock};
8868+ static IDX: OnceLock<Mutex<HashMap<String, usize>>> = OnceLock::new();
8869+ let mut m = IDX.get_or_init(|| Mutex::new(HashMap::new())).lock().unwrap();
8870+ let e = m.entry(var.to_string()).or_insert(0);
8871+ let i = *e;
8872+ *e += 1;
8873+ i
8874+}
8875+
8839 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {8876 fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) {
8840 use std::io::Write;8877 use std::io::Write;
8841 if let Ok(path) = std::env::var(var)8878 if let Ok(path) = std::env::var(var)
8842- && let Ok(mut f) = std::fs::File::create(format!("{path}.f0"))8879+ && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var)))
8843 {8880 {
8844 for p in [y, u, v] {8881 for p in [y, u, v] {
8845 let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect();8882 let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect();
@@ -10352,6 +10389,7 @@ fn decode_leaf8(
10352 neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]);10389 neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]);
10353 neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]);10390 neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]);
10354 }10391 }
10392+ INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1));
10355 neighbours.fill_skip_grid(leaf_mi, 2, skip);10393 neighbours.fill_skip_grid(leaf_mi, 2, skip);
10356 neighbours.fill_lf_grid(leaf_mi, 2, 8, 0);10394 neighbours.fill_lf_grid(leaf_mi, 2, 8, 0);
10357 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);10395 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);
@@ -12664,6 +12702,9 @@ fn apply_cdef(
12664 while mi_r < skip_grid.mi_rows {12702 while mi_r < skip_grid.mi_rows {
12665 let mut mi_c = 0usize;12703 let mut mi_c = 0usize;
12666 while mi_c < skip_grid.mi_cols {12704 while mi_c < skip_grid.mi_cols {
12705+ if skip_grid.is_skip_txfm(mi_r, mi_c) {
12706+ CDEF_SKIPPED_UNITS.with(|c| c.set(c.get() + 1));
12707+ }
12667 if !skip_grid.is_skip_txfm(mi_r, mi_c) {12708 if !skip_grid.is_skip_txfm(mi_r, mi_c) {
12668 let sidx = strength_idx(mi_r, mi_c);12709 let sidx = strength_idx(mi_r, mi_c);
12669 let (ox, oy) = (mi_c * 4, mi_r * 4);12710 let (ox, oy) = (mi_c * 4, mi_r * 4);
@@ -12676,10 +12717,15 @@ fn apply_cdef(
12676 i32::from(src_y[ny as usize * y_stride + nx as usize])12717 i32::from(src_y[ny as usize * y_stride + nx as usize])
12677 }12718 }
12678 };12719 };
12679- let (dir, var) = cdef_find_dir(coeff_shift, |r, c| {12720+ // lane-cdef r1: the direction search reads the SAME padded
12680- let (ny, nx) = ((oy + r).min(y_true_h - 1), (ox + c).min(y_true_w - 1));12721+ // block the taps do -- libaom runs `cdef_find_dir` on the
12681- i32::from(src_y[ny * y_stride + nx])12722+ // prepared filter block (`cdef_block.c:296-320` over
12682- });12723+ // `cdef_prepare_fb`'s buffer, `cdef.c:249-256`), whose columns
12724+ // and rows past the mi-rounded frame extent are CDEF_VERY_LARGE.
12725+ // Clamping to the last real sample instead made every straddling
12726+ // edge 8x8 (odd `mi_cols`/`mi_rows`) pick a different var, hence
12727+ // a different `adjust_strength`, hence a +-1 band at the crop edge.
12728+ let (dir, var) = cdef_find_dir(coeff_shift, |r, c| sample_y(r as i32, c as i32));
12683 12729
12684 // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0`12730 // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0`
12685 // -- each plane zeroes the shared direction when *its own*12731 // -- each plane zeroes the shared direction when *its own*
@@ -12689,6 +12735,12 @@ fn apply_cdef(
12689 let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift;12735 let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift;
12690 let y_dir = if y_pri_strength != 0 { dir } else { 0 };12736 let y_dir = if y_pri_strength != 0 { dir } else { 0 };
12691 let t = cdef_adjust_strength(y_pri_strength, var);12737 let t = cdef_adjust_strength(y_pri_strength, var);
12738+ // lane-cdef r1 rung: one line per filtered 8x8 luma CDEF unit.
12739+ if std::env::var_os("EC_AV1_CDEF_DBG").is_some() {
12740+ eprintln!(
12741+ "EC_CDEF mi_r={mi_r} mi_c={mi_c} x={ox} y={oy} sidx={sidx} dir={dir} var={var} t={t} pri={y_pri_strength} sec={y_sec_strength} damp={damping}"
12742+ );
12743+ }
12692 let enable_primary = t != 0;12744 let enable_primary = t != 0;
12693 let enable_secondary = y_sec_strength != 0;12745 let enable_secondary = y_sec_strength != 0;
12694 if enable_primary || enable_secondary {12746 if enable_primary || enable_secondary {
@@ -19668,6 +19720,14 @@ fn decode_inter_block8(
19668 // so the 16x16 below a split block read partition ctx 019720 // so the 16x16 below a split block read partition ctx 0
19669 // instead of 1 and mis-read PARTITION_SPLIT as NONE.19721 // instead of 1 and mis-read PARTITION_SPLIT as NONE.
19670 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);19722 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
19723+ // lane-cdef r1: ... and the CDEF skip band too. `apply_cdef`'s
19724+ // `is_8x8_block_skip` (libaom `cdef.c:29-38`) reads all four mi
19725+ // cells of the 8x8; this leaf wrote none of them, so a 64x64
19726+ // whose bottom-right 16x16 is an all-skip 8x8-leaf group kept
19727+ // the PREVIOUS frame's flags and got filtered where libaom's
19728+ // dlist excludes it (3 luma samples on a 192x128 inter frame).
19729+ INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1));
19730+ neighbours.fill_skip_grid(leaf_mi, 2, skip);
19671 neighbours.fill_lf_grid(19731 neighbours.fill_lf_grid(
19672 leaf_mi,19732 leaf_mi,
19673 2,19733 2,
@@ -20473,6 +20533,10 @@ fn decode_inter_block8(
20473 // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference20533 // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference
20474 // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every20534 // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every
20475 // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test).20535 // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test).
20536+ // lane-cdef r1: the fall-through twin of the compound arm's skip-band
20537+ // write above -- `skip` is one flag for the whole 8x8 leaf (read at
20538+ // `decode.rs`'s `skip_ctx` site), `split8` only splits its transform.
20539+ neighbours.fill_skip_grid(leaf_mi, 2, skip);
20476 neighbours.fill_lf_grid(20540 neighbours.fill_lf_grid(
20477 leaf_mi,20541 leaf_mi,
20478 2,20542 2,
crates/ec-av1/src/stream.rsmodified+145 -0
@@ -15223,6 +15223,151 @@ mod tests {
15223 );15223 );
15224 }15224 }
15225 15225
15226+ /// lane-cdef r1: CDEF's per-8x8 skip band under sub-16x16 inter leaves.
15227+ ///
15228+ /// `apply_cdef` excludes an 8x8 luma unit whose four mi cells are all
15229+ /// `skip_txfm` (libaom `cdef.c:29-38 is_8x8_block_skip`, called from
15230+ /// `av1_cdef_compute_sb_list`'s dlist loop). `decode_inter_block8` -- the
15231+ /// leaf path `--min-partition-size=4` makes aomenc pick for a 16x16 group
15232+ /// -- wrote the loop-filter grid but never that skip band, so an all-skip
15233+ /// group kept the PREVIOUS frame's flags and got filtered where libaom
15234+ /// skips it (3 luma samples, decode-order frames 3 and 4 of the 192x128
15235+ /// cq-8 stream below, at the frame's last 8x8 column).
15236+ ///
15237+ /// Both counters are hard asserts per compared attempt: `cdef_skipped_units`
15238+ /// proves the all-skip dlist exclusion was actually reached, and
15239+ /// `inter8_skip_band_hits` proves the 8x8 leaf path (the writer that used
15240+ /// to be missing) ran on the same stream.
15241+ #[test]
15242+ fn a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact() {
15243+ if !have_aomenc() {
15244+ return;
15245+ }
15246+ let (width, height, frames) = (192usize, 128usize, 6usize);
15247+ let mut refusals: Vec<String> = Vec::new();
15248+ let mut fired = 0u32;
15249+ for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] {
15250+ let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
15251+ let src = format!(
15252+ "color=c=gray:s={width}x{height}:d=0.24:r=25,format=gray,\
15253+ geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p"
15254+ );
15255+ let y4m = Command::new("ffmpeg")
15256+ .args([
15257+ "-v", "error", "-f", "lavfi", "-i", &src, "-t", "0.24", "-pix_fmt", pix,
15258+ "-strict", "-1", "-f", "yuv4mpegpipe", "-",
15259+ ])
15260+ .stdin(Stdio::null())
15261+ .stdout(Stdio::piped())
15262+ .stderr(Stdio::piped())
15263+ .output()
15264+ .expect("ffmpeg failed to run");
15265+ assert!(
15266+ y4m.status.success(),
15267+ "ffmpeg fixture: {}",
15268+ String::from_utf8_lossy(&y4m.stderr)
15269+ );
15270+ let mut child = Command::new(aomenc_path())
15271+ .args([
15272+ "--codec=av1",
15273+ "--passes=1",
15274+ "--end-usage=q",
15275+ &format!("--cq-level={cq}"),
15276+ "--cpu-used=0",
15277+ "--threads=1",
15278+ "--row-mt=0",
15279+ "--sb-size=64",
15280+ &format!("--bit-depth={depth}"),
15281+ &format!("--input-bit-depth={depth}"),
15282+ "--enable-restoration=0",
15283+ "--enable-palette=0",
15284+ "--deltaq-mode=0",
15285+ "--enable-filter-intra=0",
15286+ "--enable-cfl-intra=0",
15287+ "--enable-intrabc=0",
15288+ "--lag-in-frames=0",
15289+ "--enable-obmc=0",
15290+ "--enable-tx-size-search=1",
15291+ "--enable-rect-partitions=0",
15292+ "--enable-ab-partitions=0",
15293+ "--enable-1to4-partitions=0",
15294+ "--min-partition-size=4",
15295+ "--max-partition-size=16",
15296+ // Last occurrence of a repeated --enable-* flag wins
15297+ // (aomenc-last-flag-wins): CDEF stays ON, and the two
15298+ // counters below prove the filter really ran.
15299+ "--enable-cdef=1",
15300+ "--obu",
15301+ "-o",
15302+ "-",
15303+ "-",
15304+ ])
15305+ .stdin(Stdio::piped())
15306+ .stdout(Stdio::piped())
15307+ .stderr(Stdio::piped())
15308+ .spawn()
15309+ .expect("aomenc failed to start");
15310+ child
15311+ .stdin
15312+ .take()
15313+ .expect("aomenc stdin")
15314+ .write_all(&y4m.stdout)
15315+ .expect("writing y4m to aomenc");
15316+ let out = child.wait_with_output().expect("aomenc failed to run");
15317+ assert!(
15318+ out.status.success(),
15319+ "aomenc refused the fixture (depth={depth} cq={cq})"
15320+ );
15321+ let stream = out.stdout;
15322+ let skipped_before = decode::cdef_skipped_units();
15323+ let leaves_before = decode::inter8_skip_band_hits();
15324+ let decoded = match decode_stream(&stream) {
15325+ Ok(f) => f,
15326+ Err(e) => {
15327+ let msg = e.to_string();
15328+ assert!(
15329+ msg.starts_with("unsupported: "),
15330+ "decode error that is not a named refusal \
15331+ (depth={depth} cq={cq}): {msg}"
15332+ );
15333+ refusals.push(format!("depth={depth} cq={cq}: {msg}"));
15334+ continue;
15335+ }
15336+ };
15337+ assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})");
15338+ assert!(
15339+ decode::cdef_skipped_units() > skipped_before,
15340+ "no 8x8 CDEF unit was excluded by the all-skip rule \
15341+ (depth={depth} cq={cq})"
15342+ );
15343+ assert!(
15344+ decode::inter8_skip_band_hits() > leaves_before,
15345+ "no sub-16x16 inter leaf wrote the CDEF skip band \
15346+ (depth={depth} cq={cq})"
15347+ );
15348+ let reference = if depth == 10 {
15349+ ffmpeg_decode_sequence_10bit(&stream, width, height, frames)
15350+ } else {
15351+ ffmpeg_decode_sequence(&stream, width, height, frames)
15352+ };
15353+ for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() {
15354+ assert_eq!(ours.y, theirs.y, "luma frame {i} (depth={depth} cq={cq})");
15355+ assert_eq!(ours.u, theirs.u, "U frame {i} (depth={depth} cq={cq})");
15356+ assert_eq!(ours.v, theirs.v, "V frame {i} (depth={depth} cq={cq})");
15357+ }
15358+ fired += 1;
15359+ }
15360+ // Three of the five arms land on OTHER open refusals (a non-DC chroma
15361+ // mode on an 8x8 inter leaf; inter partitions below 8x8) -- the two
15362+ // 8-bit cq 8/10 arms ARE the streams the defect was found on, and each
15363+ // hard-asserts both counters plus all six frames on all three planes.
15364+ assert!(
15365+ fired >= 2,
15366+ "fewer than 2 firing+pixel-exact attempts:\n{}",
15367+ refusals.join("\n")
15368+ );
15369+ }
15370+
15226 /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients15371 /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients
15227 /// at low cq reliably makes aomenc split an 8x8 block all the way to15372 /// at low cq reliably makes aomenc split an 8x8 block all the way to
15228 /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec15373 /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec
lanes/cdef-r1.handoff.mdadded+66 -0
@@ -0,0 +1,66 @@
1+# lane-cdef r1 -- HANDOFF (2 CDEF defects rooted, both fixed, gate GREEN; one residue open)
2+
3+Base: main 48b35ab. Suite unit `cdef-suite-1788330834.service` -> `$HOME/.cache/cdef-suite-r1.log`
4+(started at the turn cap; FIRST THING NEXT ROUND: `grep -E "^test result|FAILED" $HOME/.cache/cdef-suite-r1.log`).
5+
6+## Defect A -- per-8x8 CDEF skip band never written by the 8x8 inter leaf (charter hypothesis (a), variant)
7+
8+* Stream: `~/.cache/cdef-tmp/a0_8.obu`, sha256 `aa40f17f6e49eca2bb8c9d9ab99a175312134bdcf45c39b8a76b6757d8536751`
9+ (hashed twice, identical), `~/.cache/cdef-tmp/gen.sh 8 3 8 a0_8.obu` = lane-intersub8's recipe,
10+ 192x128, 6 frames, `--min-partition-size=4`, cq 8, 8-bit.
11+* Stage attribution: reconstruction and post-deblock are EXACT (`EC_AV1_POSTDEBLOCK_DUMP` ours vs
12+ the instrumented aomdec: 0/24576 luma on decode-order frame 3); the 3 samples enter at CDEF.
13+ NOTE: aomdec's `EC_AV1_PREFILT_DUMP` is ALREADY POST-DEBLOCK on this build (r_pre.fN == r_pd.fN
14+ for 5 of 6 frames) -- ours is genuinely pre-deblock, so the two rungs are NOT the same stage.
15+* Root cause: `decode_inter_block8` (decode.rs, the leaf path `--min-partition-size=4` picks for a
16+ 16x16 group) wrote `record_mi` + `fill_lf_grid` at both exits but NEVER `fill_skip_grid`. The
17+ bottom-right 16x16 of decode-order frame 3 was therefore judged by the PREVIOUS frame's flags:
18+ our 8x8 units at mi(28,46)/(30,46) read skip=false and were filtered, while libaom's
19+ `is_8x8_block_skip` (cdef.c:29-38, called from `av1_cdef_compute_sb_list` cdef.c:40-71) excludes
20+ an all-skip 8x8 from the dlist. Proof: a python model of `cdef_block.c` reproduces the reference
21+ for all 16 units of the last column at (sec=1,damp=3) EXCEPT those two, where only "unfiltered"
22+ matches; frame-3 fill log showed 0 of 95 skip fills covering mi(28,44)+16x16.
23+* Fix: `neighbours.fill_skip_grid(leaf_mi, 2, skip)` at both `decode_inter_block8` exits (compound
24+ early return + fall-through), each bumping `INTER8_SKIP_BAND_HITS`.
25+* Before/after on the pinned stream: frames 3 and 4 had 3 luma samples |d|=1 each
26+ ((189,116/120/124) and (186,116/120/124)); after, all 6 frames pixel-exact on Y/U/V.
27+
28+## Defect B -- CDEF direction search clamped at the crop edge instead of reading CDEF_VERY_LARGE
29+
30+* Stream: `~/.cache/golomb-tmp/s68.obu` (68x192, 5 frames, 8-bit, cq 35) -- lane-golomb r9's
31+ deferred "straddle band".
32+* Root cause: `apply_cdef`'s `cdef_find_dir` closure clamped to `true_w-1`/`true_h-1`, but libaom
33+ runs `cdef_find_dir` over `cdef_prepare_fb`'s buffer (cdef.c:249-256 `frame_boundary[RIGHT]`
34+ fill, cdef_block.c:296-320), whose columns/rows past the mi-rounded extent are CDEF_VERY_LARGE.
35+ With odd `mi_cols` (68 px -> 17 mi) the last 8x8 straddles, so var/`adjust_strength` differed.
36+* Fix: the direction search now reads the SAME padded `sample_y` the taps use (one line).
37+* Before/after: frame 1 luma 145 diffs -> **0**; all 5 frames luma exact.
38+* RESIDUE (open, NOT fixed): the same stream still differs in CHROMA from frame 1 on
39+ (U/V 194/401/466/551 samples, |d| up to 6, spread over ~37 chroma 4x4 units, frame 0 exact).
40+ Not attributable yet: `EC_AV1_DEBUG_SKIP_CDEF=1` cannot bisect inter frames (it also breaks the
41+ reference frames), so the postdeblock rung is only valid for frame 0 here. Next step: dump
42+ per-4x4 chroma CDEF params (uv pri/sec, damping-1, shared luma dir) for frame 1's first
43+ differing unit and model it against `cdef_block.c` the way defect A was modelled
44+ (`~/.cache/cdef-tmp/model.py` is a complete python port of cdef_block.c + find_dir + adjust).
45+
46+## Gate
47+`stream.rs::a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact` -- real
48+aomenc, `--min-partition-size=4 --enable-cdef=1` (last flag wins), 5 arms (8-bit cq 8/10/12,
49+10-bit cq 8/12), every decode-order frame compared on Y/U/V, hard asserts
50+`decode::cdef_skipped_units()` (an 8x8 unit really excluded by the all-skip rule) and
51+`decode::inter8_skip_band_hits()` (the leaf that used to write nothing) both grew per compared
52+attempt. 2 of 5 arms fire; the other 3 hit UNRELATED open refusals (non-DC chroma mode on an 8x8
53+inter leaf; inter partition below 8x8) -- widening to 10-bit needs those lifted first.
54+`cargo test -p ec-av1 --lib cdef_and_sub16` -> ok, 1 passed / 0 failed.
55+
56+## Other
57+* `dump_stage`/`dump_stage16` wrote `.f0` for EVERY frame (each overwrote the last), so
58+ `EC_AV1_POSTDEBLOCK_DUMP`/`POSTCDEF_DUMP` were unusable for per-frame bisection. Now indexed
59+ per env var (`dump_stage_idx`), matching aomdec's own `.fN`.
60+* New rung `EC_AV1_CDEF_DBG=1`: one line per filtered 8x8 luma unit
61+ (`EC_CDEF mi_r= mi_c= x= y= sidx= dir= var= t= pri= sec= damp=`).
62+* Class sweep for "per-8x8 map read at the top-left mi only under sub-8x8 partitions": the skip
63+ grid is written by every OTHER leaf path (grep `fill_skip_grid`), `decode_inter_block8` was the
64+ only writer missing; `is_skip_txfm` already gathers all four cells; the deblock/tx grid has a
65+ `fill_lf_grid` at every one of those sites including both `decode_inter_block8` exits.
66+* Not done: `--tile-columns=1` arm on the new gate (COMMON neighbour-map rule) -- deferred.