Merge branch 'lane-cdef' (2d76270): CDEF skip band for 8x8 inter leaves, cdef_find_dir padding
Browse files at this commit4 changed files +468 -42
- crates/ec-av1/src/decode.rs +114 -27
- crates/ec-av1/src/stream.rs +205 -15
- lanes/cdef-r1.handoff.md +66 -0
- lanes/cdef-r2.report.md +83 -0
crates/ec-av1/src/decode.rsmodified+114 -27
| @@ -2673,6 +2673,41 @@ thread_local! { | |||
| 2673 | static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2673 | static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2674 | } | 2674 | } |
| 2675 | 2675 | ||
| 2676 | +// lane-cdef r1: (a) how many 8x8 CDEF units `apply_cdef` EXCLUDED because all | ||
| 2677 | +// four of their mi cells are `skip_txfm` (libaom `cdef.c:29-38` | ||
| 2678 | +// `is_8x8_block_skip` / `av1_cdef_compute_sb_list`'s dlist test), and (b) how | ||
| 2679 | +// many 8x8 inter leaves (`decode_inter_block8`) wrote that skip band at all. | ||
| 2680 | +// (b) was 0 for every stream before this round -- the leaf path never touched | ||
| 2681 | +// the band, so an all-skip 8x8 group kept the PREVIOUS frame's flags and got | ||
| 2682 | +// filtered where libaom skips it. A gate asserts both are non-zero. | ||
| 2683 | +thread_local! { | ||
| 2684 | + static CDEF_SKIPPED_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2685 | + static INTER8_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2686 | + // lane-cdef r2: (c) 8x8 CDEF units that are FILTERED and whose extent | ||
| 2687 | + // crosses the cropped frame edge -- the only units for which "clamp at | ||
| 2688 | + // the crop" and "pad past the mi-rounded extent with CDEF_VERY_LARGE" | ||
| 2689 | + // (libaom `cdef.c:249-256`, `cdef_prepare_fb`'s hsize/vsize are | ||
| 2690 | + // `nhb << mi_wide_l2` off the MI grid, not the crop) differ. A frame | ||
| 2691 | + // whose width or height is not a multiple of 8 is the only shape that | ||
| 2692 | + // produces one; the straddling-band gate arms assert it grew. | ||
| 2693 | + static CDEF_STRADDLE_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2694 | +} | ||
| 2695 | + | ||
| 2696 | +/// Current value of `CDEF_SKIPPED_UNITS`. | ||
| 2697 | +pub(crate) fn cdef_skipped_units() -> usize { | ||
| 2698 | + CDEF_SKIPPED_UNITS.with(|c| c.get()) | ||
| 2699 | +} | ||
| 2700 | + | ||
| 2701 | +/// Current value of `INTER8_SKIP_BAND_HITS`. | ||
| 2702 | +pub(crate) fn inter8_skip_band_hits() -> usize { | ||
| 2703 | + INTER8_SKIP_BAND_HITS.with(|c| c.get()) | ||
| 2704 | +} | ||
| 2705 | + | ||
| 2706 | +/// Current value of `CDEF_STRADDLE_UNITS`. | ||
| 2707 | +pub(crate) fn cdef_straddle_units() -> usize { | ||
| 2708 | + CDEF_STRADDLE_UNITS.with(|c| c.get()) | ||
| 2709 | +} | ||
| 2710 | + | ||
| 2676 | /// Current value of [`SUB8_SPLIT_HITS`]. | 2711 | /// Current value of [`SUB8_SPLIT_HITS`]. |
| 2677 | pub(crate) fn sub8_split_hits() -> usize { | 2712 | pub(crate) fn sub8_split_hits() -> usize { |
| 2678 | SUB8_SPLIT_HITS.with(|c| c.get()) | 2713 | SUB8_SPLIT_HITS.with(|c| c.get()) |
| @@ -9304,13 +9339,12 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 { | |||
| 9304 | /// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE). | 9339 | /// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE). |
| 9305 | fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { | 9340 | fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { |
| 9306 | use std::io::Write; | 9341 | use std::io::Write; |
| 9307 | - // lane-sbrect10 r2: index the dump by decode-order picture like | 9342 | + // lane-sbrect10 r2 / lane-cdef r1 (one shared helper): index the dump by |
| 9308 | - // EC_AV1_PREFILT_DUMP already does -- a fixed `.f0` name kept only the | 9343 | + // decode-order picture like EC_AV1_PREFILT_DUMP already does -- a fixed |
| 9309 | - // LAST frame, so a mid-sequence divergence could not be read out at all. | 9344 | + // `.f0` name kept only the LAST frame, so a mid-sequence divergence could |
| 9310 | - static STAGE16_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | 9345 | + // not be read out at all. |
| 9311 | if let Ok(path) = std::env::var(var) | 9346 | if let Ok(path) = std::env::var(var) |
| 9312 | - && let idx = STAGE16_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst) | 9347 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) |
| 9313 | - && let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) | ||
| 9314 | { | 9348 | { |
| 9315 | 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))] { | 9349 | 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))] { |
| 9316 | for row in 0..h { | 9350 | for row in 0..h { |
| @@ -9324,24 +9358,25 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, | |||
| 9324 | } | 9358 | } |
| 9325 | } | 9359 | } |
| 9326 | 9360 | ||
| 9361 | +/// Decode-order index of the next [`dump_stage`]/[`dump_stage16`] file for a | ||
| 9362 | +/// given env var -- lane-cdef r1: both used to write `.f0` unconditionally, so | ||
| 9363 | +/// every frame overwrote the previous one and only the LAST frame survived, | ||
| 9364 | +/// which silently defeats any per-frame filter-stage bisection. | ||
| 9365 | +fn dump_stage_idx(var: &str) -> usize { | ||
| 9366 | + use std::collections::HashMap; | ||
| 9367 | + use std::sync::{Mutex, OnceLock}; | ||
| 9368 | + static IDX: OnceLock<Mutex<HashMap<String, usize>>> = OnceLock::new(); | ||
| 9369 | + let mut m = IDX.get_or_init(|| Mutex::new(HashMap::new())).lock().unwrap(); | ||
| 9370 | + let e = m.entry(var.to_string()).or_insert(0); | ||
| 9371 | + let i = *e; | ||
| 9372 | + *e += 1; | ||
| 9373 | + i | ||
| 9374 | +} | ||
| 9375 | + | ||
| 9327 | fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { | 9376 | fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { |
| 9328 | use std::io::Write; | 9377 | use std::io::Write; |
| 9329 | - // lane-golomb r6: one file per DECODE-order picture, like aomdec's own | ||
| 9330 | - // `ec_dump16` static index -- a single `.f0` overwritten every frame made | ||
| 9331 | - // the post-deblock stage uncomparable across a sequence. | ||
| 9332 | - thread_local! { | ||
| 9333 | - static STAGE_IDX: std::cell::RefCell<std::collections::HashMap<String, usize>> = | ||
| 9334 | - std::cell::RefCell::new(std::collections::HashMap::new()); | ||
| 9335 | - } | ||
| 9336 | - let idx = STAGE_IDX.with(|m| { | ||
| 9337 | - let mut m = m.borrow_mut(); | ||
| 9338 | - let e = m.entry(var.to_string()).or_insert(0); | ||
| 9339 | - let i = *e; | ||
| 9340 | - *e += 1; | ||
| 9341 | - i | ||
| 9342 | - }); | ||
| 9343 | if let Ok(path) = std::env::var(var) | 9378 | if let Ok(path) = std::env::var(var) |
| 9344 | - && let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) | 9379 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) |
| 9345 | { | 9380 | { |
| 9346 | for p in [y, u, v] { | 9381 | for p in [y, u, v] { |
| 9347 | let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect(); | 9382 | let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect(); |
| @@ -10854,6 +10889,7 @@ fn decode_leaf8( | |||
| 10854 | neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]); | 10889 | neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]); |
| 10855 | neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]); | 10890 | neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]); |
| 10856 | } | 10891 | } |
| 10892 | + INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | ||
| 10857 | neighbours.fill_skip_grid(leaf_mi, 2, skip); | 10893 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 10858 | // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal | 10894 | // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal |
| 10859 | // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm && | 10895 | // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm && |
| @@ -13236,6 +13272,9 @@ fn apply_cdef( | |||
| 13236 | v: &mut PlaneBuf, | 13272 | v: &mut PlaneBuf, |
| 13237 | cdef: &CdefParams, | 13273 | cdef: &CdefParams, |
| 13238 | skip_grid: &Neighbours, | 13274 | skip_grid: &Neighbours, |
| 13275 | + // This frame header's own CROPPED luma size, for the straddling-unit | ||
| 13276 | + // counter only -- CDEF itself walks the mi-rounded plane. | ||
| 13277 | + (frame_w, frame_h): (usize, usize), | ||
| 13239 | ) { | 13278 | ) { |
| 13240 | // lane-part32 r2 debug rung, env-gated: see `apply_deblock`'s sibling. | 13279 | // lane-part32 r2 debug rung, env-gated: see `apply_deblock`'s sibling. |
| 13241 | if std::env::var_os("EC_AV1_DEBUG_SKIP_CDEF").is_some() { | 13280 | if std::env::var_os("EC_AV1_DEBUG_SKIP_CDEF").is_some() { |
| @@ -13279,6 +13318,9 @@ fn apply_cdef( | |||
| 13279 | while mi_r < skip_grid.mi_rows { | 13318 | while mi_r < skip_grid.mi_rows { |
| 13280 | let mut mi_c = 0usize; | 13319 | let mut mi_c = 0usize; |
| 13281 | while mi_c < skip_grid.mi_cols { | 13320 | while mi_c < skip_grid.mi_cols { |
| 13321 | + if skip_grid.is_skip_txfm(mi_r, mi_c) { | ||
| 13322 | + CDEF_SKIPPED_UNITS.with(|c| c.set(c.get() + 1)); | ||
| 13323 | + } | ||
| 13282 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { | 13324 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { |
| 13283 | let sidx = strength_idx(mi_r, mi_c); | 13325 | let sidx = strength_idx(mi_r, mi_c); |
| 13284 | let (ox, oy) = (mi_c * 4, mi_r * 4); | 13326 | let (ox, oy) = (mi_c * 4, mi_r * 4); |
| @@ -13291,10 +13333,15 @@ fn apply_cdef( | |||
| 13291 | i32::from(src_y[ny as usize * y_stride + nx as usize]) | 13333 | i32::from(src_y[ny as usize * y_stride + nx as usize]) |
| 13292 | } | 13334 | } |
| 13293 | }; | 13335 | }; |
| 13294 | - let (dir, var) = cdef_find_dir(coeff_shift, |r, c| { | 13336 | + // lane-cdef r1: the direction search reads the SAME padded |
| 13295 | - let (ny, nx) = ((oy + r).min(y_true_h - 1), (ox + c).min(y_true_w - 1)); | 13337 | + // block the taps do -- libaom runs `cdef_find_dir` on the |
| 13296 | - i32::from(src_y[ny * y_stride + nx]) | 13338 | + // prepared filter block (`cdef_block.c:296-320` over |
| 13297 | - }); | 13339 | + // `cdef_prepare_fb`'s buffer, `cdef.c:249-256`), whose columns |
| 13340 | + // and rows past the mi-rounded frame extent are CDEF_VERY_LARGE. | ||
| 13341 | + // Clamping to the last real sample instead made every straddling | ||
| 13342 | + // edge 8x8 (odd `mi_cols`/`mi_rows`) pick a different var, hence | ||
| 13343 | + // a different `adjust_strength`, hence a +-1 band at the crop edge. | ||
| 13344 | + let (dir, var) = cdef_find_dir(coeff_shift, |r, c| sample_y(r as i32, c as i32)); | ||
| 13298 | 13345 | ||
| 13299 | // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0` | 13346 | // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0` |
| 13300 | // -- each plane zeroes the shared direction when *its own* | 13347 | // -- each plane zeroes the shared direction when *its own* |
| @@ -13304,8 +13351,22 @@ fn apply_cdef( | |||
| 13304 | let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift; | 13351 | let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift; |
| 13305 | let y_dir = if y_pri_strength != 0 { dir } else { 0 }; | 13352 | let y_dir = if y_pri_strength != 0 { dir } else { 0 }; |
| 13306 | let t = cdef_adjust_strength(y_pri_strength, var); | 13353 | let t = cdef_adjust_strength(y_pri_strength, var); |
| 13354 | + // lane-cdef r1 rung: one line per filtered 8x8 luma CDEF unit. | ||
| 13355 | + if std::env::var_os("EC_AV1_CDEF_DBG").is_some() { | ||
| 13356 | + eprintln!( | ||
| 13357 | + "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}" | ||
| 13358 | + ); | ||
| 13359 | + } | ||
| 13307 | let enable_primary = t != 0; | 13360 | let enable_primary = t != 0; |
| 13308 | let enable_secondary = y_sec_strength != 0; | 13361 | let enable_secondary = y_sec_strength != 0; |
| 13362 | + if (ox + 8 > frame_w || oy + 8 > frame_h) | ||
| 13363 | + && (enable_primary | ||
| 13364 | + || enable_secondary | ||
| 13365 | + || cdef.uv_pri_strength[sidx] != 0 | ||
| 13366 | + || cdef.uv_sec_strength[sidx] != 0) | ||
| 13367 | + { | ||
| 13368 | + CDEF_STRADDLE_UNITS.with(|c| c.set(c.get() + 1)); | ||
| 13369 | + } | ||
| 13309 | if enable_primary || enable_secondary { | 13370 | if enable_primary || enable_secondary { |
| 13310 | cdef_filter_block( | 13371 | cdef_filter_block( |
| 13311 | sample_y, | 13372 | sample_y, |
| @@ -15444,7 +15505,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 15444 | // dump above these bisect WHICH filter stage introduced a mismatch. | 15505 | // dump above these bisect WHICH filter stage introduced a mismatch. |
| 15445 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); | 15506 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); |
| 15446 | dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | 15507 | dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 15447 | - apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 15508 | + apply_cdef( |
| 15509 | + &mut y, | ||
| 15510 | + &mut u, | ||
| 15511 | + &mut v, | ||
| 15512 | + cdef, | ||
| 15513 | + &neighbours, | ||
| 15514 | + (frame_width as usize, frame_height as usize), | ||
| 15515 | + ); | ||
| 15448 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); | 15516 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); |
| 15449 | dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | 15517 | dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 15450 | apply_loop_restoration( | 15518 | apply_loop_restoration( |
| @@ -20423,6 +20491,14 @@ fn decode_inter_block8( | |||
| 20423 | // so the 16x16 below a split block read partition ctx 0 | 20491 | // so the 16x16 below a split block read partition ctx 0 |
| 20424 | // instead of 1 and mis-read PARTITION_SPLIT as NONE. | 20492 | // instead of 1 and mis-read PARTITION_SPLIT as NONE. |
| 20425 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); | 20493 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); |
| 20494 | + // lane-cdef r1: ... and the CDEF skip band too. `apply_cdef`'s | ||
| 20495 | + // `is_8x8_block_skip` (libaom `cdef.c:29-38`) reads all four mi | ||
| 20496 | + // cells of the 8x8; this leaf wrote none of them, so a 64x64 | ||
| 20497 | + // whose bottom-right 16x16 is an all-skip 8x8-leaf group kept | ||
| 20498 | + // the PREVIOUS frame's flags and got filtered where libaom's | ||
| 20499 | + // dlist excludes it (3 luma samples on a 192x128 inter frame). | ||
| 20500 | + INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | ||
| 20501 | + neighbours.fill_skip_grid(leaf_mi, 2, skip); | ||
| 20426 | neighbours.fill_lf_grid( | 20502 | neighbours.fill_lf_grid( |
| 20427 | leaf_mi, | 20503 | leaf_mi, |
| 20428 | 2, | 20504 | 2, |
| @@ -21228,6 +21304,10 @@ fn decode_inter_block8( | |||
| 21228 | // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference | 21304 | // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference |
| 21229 | // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every | 21305 | // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every |
| 21230 | // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test). | 21306 | // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test). |
| 21307 | + // lane-cdef r1: the fall-through twin of the compound arm's skip-band | ||
| 21308 | + // write above -- `skip` is one flag for the whole 8x8 leaf (read at | ||
| 21309 | + // `decode.rs`'s `skip_ctx` site), `split8` only splits its transform. | ||
| 21310 | + neighbours.fill_skip_grid(leaf_mi, 2, skip); | ||
| 21231 | neighbours.fill_lf_grid( | 21311 | neighbours.fill_lf_grid( |
| 21232 | leaf_mi, | 21312 | leaf_mi, |
| 21233 | 2, | 21313 | 2, |
| @@ -23560,7 +23640,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 23560 | // dump above these bisect WHICH filter stage introduced a mismatch. | 23640 | // dump above these bisect WHICH filter stage introduced a mismatch. |
| 23561 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); | 23641 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); |
| 23562 | dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | 23642 | dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 23563 | - apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 23643 | + apply_cdef( |
| 23644 | + &mut y, | ||
| 23645 | + &mut u, | ||
| 23646 | + &mut v, | ||
| 23647 | + cdef, | ||
| 23648 | + &neighbours, | ||
| 23649 | + (frame_width as usize, frame_height as usize), | ||
| 23650 | + ); | ||
| 23564 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); | 23651 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); |
| 23565 | dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | 23652 | dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 23566 | apply_loop_restoration( | 23653 | apply_loop_restoration( |
crates/ec-av1/src/stream.rsmodified+205 -15
| @@ -16655,6 +16655,151 @@ mod tests { | |||
| 16655 | ); | 16655 | ); |
| 16656 | } | 16656 | } |
| 16657 | 16657 | ||
| 16658 | + /// lane-cdef r1: CDEF's per-8x8 skip band under sub-16x16 inter leaves. | ||
| 16659 | + /// | ||
| 16660 | + /// `apply_cdef` excludes an 8x8 luma unit whose four mi cells are all | ||
| 16661 | + /// `skip_txfm` (libaom `cdef.c:29-38 is_8x8_block_skip`, called from | ||
| 16662 | + /// `av1_cdef_compute_sb_list`'s dlist loop). `decode_inter_block8` -- the | ||
| 16663 | + /// leaf path `--min-partition-size=4` makes aomenc pick for a 16x16 group | ||
| 16664 | + /// -- wrote the loop-filter grid but never that skip band, so an all-skip | ||
| 16665 | + /// group kept the PREVIOUS frame's flags and got filtered where libaom | ||
| 16666 | + /// skips it (3 luma samples, decode-order frames 3 and 4 of the 192x128 | ||
| 16667 | + /// cq-8 stream below, at the frame's last 8x8 column). | ||
| 16668 | + /// | ||
| 16669 | + /// Both counters are hard asserts per compared attempt: `cdef_skipped_units` | ||
| 16670 | + /// proves the all-skip dlist exclusion was actually reached, and | ||
| 16671 | + /// `inter8_skip_band_hits` proves the 8x8 leaf path (the writer that used | ||
| 16672 | + /// to be missing) ran on the same stream. | ||
| 16673 | + #[test] | ||
| 16674 | + fn a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact() { | ||
| 16675 | + if !have_aomenc() { | ||
| 16676 | + return; | ||
| 16677 | + } | ||
| 16678 | + let (width, height, frames) = (192usize, 128usize, 6usize); | ||
| 16679 | + let mut refusals: Vec<String> = Vec::new(); | ||
| 16680 | + let mut fired = 0u32; | ||
| 16681 | + for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] { | ||
| 16682 | + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 16683 | + let src = format!( | ||
| 16684 | + "color=c=gray:s={width}x{height}:d=0.24:r=25,format=gray,\ | ||
| 16685 | + geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p" | ||
| 16686 | + ); | ||
| 16687 | + let y4m = Command::new("ffmpeg") | ||
| 16688 | + .args([ | ||
| 16689 | + "-v", "error", "-f", "lavfi", "-i", &src, "-t", "0.24", "-pix_fmt", pix, | ||
| 16690 | + "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 16691 | + ]) | ||
| 16692 | + .stdin(Stdio::null()) | ||
| 16693 | + .stdout(Stdio::piped()) | ||
| 16694 | + .stderr(Stdio::piped()) | ||
| 16695 | + .output() | ||
| 16696 | + .expect("ffmpeg failed to run"); | ||
| 16697 | + assert!( | ||
| 16698 | + y4m.status.success(), | ||
| 16699 | + "ffmpeg fixture: {}", | ||
| 16700 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 16701 | + ); | ||
| 16702 | + let mut child = Command::new(aomenc_path()) | ||
| 16703 | + .args([ | ||
| 16704 | + "--codec=av1", | ||
| 16705 | + "--passes=1", | ||
| 16706 | + "--end-usage=q", | ||
| 16707 | + &format!("--cq-level={cq}"), | ||
| 16708 | + "--cpu-used=0", | ||
| 16709 | + "--threads=1", | ||
| 16710 | + "--row-mt=0", | ||
| 16711 | + "--sb-size=64", | ||
| 16712 | + &format!("--bit-depth={depth}"), | ||
| 16713 | + &format!("--input-bit-depth={depth}"), | ||
| 16714 | + "--enable-restoration=0", | ||
| 16715 | + "--enable-palette=0", | ||
| 16716 | + "--deltaq-mode=0", | ||
| 16717 | + "--enable-filter-intra=0", | ||
| 16718 | + "--enable-cfl-intra=0", | ||
| 16719 | + "--enable-intrabc=0", | ||
| 16720 | + "--lag-in-frames=0", | ||
| 16721 | + "--enable-obmc=0", | ||
| 16722 | + "--enable-tx-size-search=1", | ||
| 16723 | + "--enable-rect-partitions=0", | ||
| 16724 | + "--enable-ab-partitions=0", | ||
| 16725 | + "--enable-1to4-partitions=0", | ||
| 16726 | + "--min-partition-size=4", | ||
| 16727 | + "--max-partition-size=16", | ||
| 16728 | + // Last occurrence of a repeated --enable-* flag wins | ||
| 16729 | + // (aomenc-last-flag-wins): CDEF stays ON, and the two | ||
| 16730 | + // counters below prove the filter really ran. | ||
| 16731 | + "--enable-cdef=1", | ||
| 16732 | + "--obu", | ||
| 16733 | + "-o", | ||
| 16734 | + "-", | ||
| 16735 | + "-", | ||
| 16736 | + ]) | ||
| 16737 | + .stdin(Stdio::piped()) | ||
| 16738 | + .stdout(Stdio::piped()) | ||
| 16739 | + .stderr(Stdio::piped()) | ||
| 16740 | + .spawn() | ||
| 16741 | + .expect("aomenc failed to start"); | ||
| 16742 | + child | ||
| 16743 | + .stdin | ||
| 16744 | + .take() | ||
| 16745 | + .expect("aomenc stdin") | ||
| 16746 | + .write_all(&y4m.stdout) | ||
| 16747 | + .expect("writing y4m to aomenc"); | ||
| 16748 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 16749 | + assert!( | ||
| 16750 | + out.status.success(), | ||
| 16751 | + "aomenc refused the fixture (depth={depth} cq={cq})" | ||
| 16752 | + ); | ||
| 16753 | + let stream = out.stdout; | ||
| 16754 | + let skipped_before = decode::cdef_skipped_units(); | ||
| 16755 | + let leaves_before = decode::inter8_skip_band_hits(); | ||
| 16756 | + let decoded = match decode_stream(&stream) { | ||
| 16757 | + Ok(f) => f, | ||
| 16758 | + Err(e) => { | ||
| 16759 | + let msg = e.to_string(); | ||
| 16760 | + assert!( | ||
| 16761 | + msg.starts_with("unsupported: "), | ||
| 16762 | + "decode error that is not a named refusal \ | ||
| 16763 | + (depth={depth} cq={cq}): {msg}" | ||
| 16764 | + ); | ||
| 16765 | + refusals.push(format!("depth={depth} cq={cq}: {msg}")); | ||
| 16766 | + continue; | ||
| 16767 | + } | ||
| 16768 | + }; | ||
| 16769 | + assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})"); | ||
| 16770 | + assert!( | ||
| 16771 | + decode::cdef_skipped_units() > skipped_before, | ||
| 16772 | + "no 8x8 CDEF unit was excluded by the all-skip rule \ | ||
| 16773 | + (depth={depth} cq={cq})" | ||
| 16774 | + ); | ||
| 16775 | + assert!( | ||
| 16776 | + decode::inter8_skip_band_hits() > leaves_before, | ||
| 16777 | + "no sub-16x16 inter leaf wrote the CDEF skip band \ | ||
| 16778 | + (depth={depth} cq={cq})" | ||
| 16779 | + ); | ||
| 16780 | + let reference = if depth == 10 { | ||
| 16781 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | ||
| 16782 | + } else { | ||
| 16783 | + ffmpeg_decode_sequence(&stream, width, height, frames) | ||
| 16784 | + }; | ||
| 16785 | + for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() { | ||
| 16786 | + assert_eq!(ours.y, theirs.y, "luma frame {i} (depth={depth} cq={cq})"); | ||
| 16787 | + assert_eq!(ours.u, theirs.u, "U frame {i} (depth={depth} cq={cq})"); | ||
| 16788 | + assert_eq!(ours.v, theirs.v, "V frame {i} (depth={depth} cq={cq})"); | ||
| 16789 | + } | ||
| 16790 | + fired += 1; | ||
| 16791 | + } | ||
| 16792 | + // Three of the five arms land on OTHER open refusals (a non-DC chroma | ||
| 16793 | + // mode on an 8x8 inter leaf; inter partitions below 8x8) -- the two | ||
| 16794 | + // 8-bit cq 8/10 arms ARE the streams the defect was found on, and each | ||
| 16795 | + // hard-asserts both counters plus all six frames on all three planes. | ||
| 16796 | + assert!( | ||
| 16797 | + fired >= 2, | ||
| 16798 | + "fewer than 2 firing+pixel-exact attempts:\n{}", | ||
| 16799 | + refusals.join("\n") | ||
| 16800 | + ); | ||
| 16801 | + } | ||
| 16802 | + | ||
| 16658 | /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients | 16803 | /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients |
| 16659 | /// at low cq reliably makes aomenc split an 8x8 block all the way to | 16804 | /// at low cq reliably makes aomenc split an 8x8 block all the way to |
| 16660 | /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec | 16805 | /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec |
| @@ -20578,10 +20723,36 @@ mod tests { | |||
| 20578 | /// `frame_width` clip, is correct. | 20723 | /// `frame_width` clip, is correct. |
| 20579 | /// * The divergence therefore enters in CDEF, at the last 8x8 CDEF block | 20724 | /// * The divergence therefore enters in CDEF, at the last 8x8 CDEF block |
| 20580 | /// column/row, which is the one that straddles the crop edge. | 20725 | /// column/row, which is the one that straddles the crop edge. |
| 20581 | - /// `#[ignore]` so the suite stays green; run it with | 20726 | + /// lane-cdef r2: CLOSED, and un-ignored. r1 rooted the luma half in |
| 20582 | - /// `cargo test -p ec-av1 --lib -- --ignored a_frame_edge_straddling_band`. | 20727 | + /// `apply_cdef`'s direction search, which clamped at the CROPPED frame |
| 20728 | + /// edge while libaom runs `cdef_find_dir` over `cdef_prepare_fb`'s buffer | ||
| 20729 | + /// -- whose columns/rows past the MI-ROUNDED extent (`hsize = nhb << | ||
| 20730 | + /// mi_wide_l2`, `cdef.c:164-167`, and the `frame_boundary[RIGHT]` | ||
| 20731 | + /// CDEF_VERY_LARGE fill at `cdef.c:249-256`) are CDEF_VERY_LARGE, not the | ||
| 20732 | + /// last real sample. The chroma half was lane-golomb r8's loop-restoration | ||
| 20733 | + /// plane size (LR is the one post-decode filter sized by the CROP, not the | ||
| 20734 | + /// mi grid) plus its reference-size fix; merging both branches takes all | ||
| 20735 | + /// four arms to 0 differing pixels on Y, U and V. | ||
| 20736 | + /// | ||
| 20737 | + /// Arms: 192x68 and 68x192 (a 4-px straddling band on one axis), 5 frames, | ||
| 20738 | + /// 8-bit and 10-bit, plus a `--tile-columns=1` twin of each (COMMON's | ||
| 20739 | + /// neighbour-map rule -- the skip band CDEF reads is a per-mi side band). | ||
| 20740 | + /// MEASURED 2026-09-02: all 32 multi-tile attempts refuse BY NAME today, | ||
| 20741 | + /// so that half of the gate compares nothing yet (class | ||
| 20742 | + /// `counter-from-refused-stream`); the census is 10x "an inter SB-level AB | ||
| 20743 | + /// partition", 6x "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | ||
| 20744 | + /// rectangular residual coding", 6x "an 8x8 intra leaf in an inter frame | ||
| 20745 | + /// whose tx_depth splits it into 4x4 transform units", 5x "an inter | ||
| 20746 | + /// partition below 8x8", 3x "an inter 16x16-level AB or 1:4 partition", | ||
| 20747 | + /// 1x "a split intra strip whose transform unit is 32x64", 1x "an | ||
| 20748 | + /// intra-coded 1:4 (or other non-2:1) rect strip on the inter block path". | ||
| 20749 | + /// The arms stay so the coverage appears the day those lift; every assert | ||
| 20750 | + /// below is carried by the single-tile arms. | ||
| 20751 | + /// Hard-asserts `decode::cdef_straddle_units()` grew: a FILTERED 8x8 CDEF | ||
| 20752 | + /// unit whose extent crosses the crop edge is the only shape for which | ||
| 20753 | + /// clamping and padding differ, so a zero delta would make these arms | ||
| 20754 | + /// vacuous for this defect. | ||
| 20583 | #[test] | 20755 | #[test] |
| 20584 | - #[ignore = "open r9 defect: CDEF at the last straddling 8x8 block column/row"] | ||
| 20585 | fn a_frame_edge_straddling_band_decodes_pixel_exact() { | 20756 | fn a_frame_edge_straddling_band_decodes_pixel_exact() { |
| 20586 | edge32_gate( | 20757 | edge32_gate( |
| 20587 | "a_frame_edge_straddling_band_decodes_pixel_exact", | 20758 | "a_frame_edge_straddling_band_decodes_pixel_exact", |
| @@ -20600,15 +20771,15 @@ mod tests { | |||
| 20600 | eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | 20771 | eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); |
| 20601 | return; | 20772 | return; |
| 20602 | } | 20773 | } |
| 20603 | - // (width, height, frames, ten_bit) | 20774 | + // (width, height, frames, ten_bit, tile_columns_log2) |
| 20604 | - let mut arms: Vec<(usize, usize, usize, bool)> = Vec::new(); | 20775 | + let mut arms: Vec<(usize, usize, usize, bool, u32)> = Vec::new(); |
| 20605 | for &(w, h) in &[(192usize, 80usize), (80usize, 192usize)] { | 20776 | for &(w, h) in &[(192usize, 80usize), (80usize, 192usize)] { |
| 20606 | - arms.push((w, h, 1, false)); | 20777 | + arms.push((w, h, 1, false, 0)); |
| 20607 | - arms.push((w, h, 1, true)); | 20778 | + arms.push((w, h, 1, true, 0)); |
| 20608 | } | 20779 | } |
| 20609 | // The inter arm: >= 4 frames so the 32-level edge path in the INTER | 20780 | // The inter arm: >= 4 frames so the 32-level edge path in the INTER |
| 20610 | // tile walk is exercised too. | 20781 | // tile walk is exercised too. |
| 20611 | - arms.push((192, 80, 5, false)); | 20782 | + arms.push((192, 80, 5, false, 0)); |
| 20612 | // lane-golomb r9: the straddling-band arms, only under the ignored | 20783 | // lane-golomb r9: the straddling-band arms, only under the ignored |
| 20613 | // `a_frame_edge_straddling_band_decodes_pixel_exact` name (they are | 20784 | // `a_frame_edge_straddling_band_decodes_pixel_exact` name (they are |
| 20614 | // RED -- see that test's own comment for the stage bisection). Naming | 20785 | // RED -- see that test's own comment for the stage bisection). Naming |
| @@ -20616,10 +20787,12 @@ mod tests { | |||
| 20616 | // recipe, the counters and the refusal handling identical. | 20787 | // recipe, the counters and the refusal handling identical. |
| 20617 | if name == "a_frame_edge_straddling_band_decodes_pixel_exact" { | 20788 | if name == "a_frame_edge_straddling_band_decodes_pixel_exact" { |
| 20618 | arms.clear(); | 20789 | arms.clear(); |
| 20619 | - arms.push((192, 68, 5, false)); | 20790 | + for &tile_cols in &[0u32, 1] { |
| 20620 | - arms.push((192, 68, 5, true)); | 20791 | + arms.push((192, 68, 5, false, tile_cols)); |
| 20621 | - arms.push((68, 192, 5, false)); | 20792 | + arms.push((192, 68, 5, true, tile_cols)); |
| 20622 | - arms.push((68, 192, 5, true)); | 20793 | + arms.push((68, 192, 5, false, tile_cols)); |
| 20794 | + arms.push((68, 192, 5, true, tile_cols)); | ||
| 20795 | + } | ||
| 20623 | } | 20796 | } |
| 20624 | // lane-golomb r8 MEASURED, arm STILL NOT added (every cq level is | 20797 | // lane-golomb r8 MEASURED, arm STILL NOT added (every cq level is |
| 20625 | // vacuous, panicking or red -- each measured this round with | 20798 | // vacuous, panicking or red -- each measured this round with |
| @@ -20660,7 +20833,9 @@ mod tests { | |||
| 20660 | let mut totals = [0usize; 8]; | 20833 | let mut totals = [0usize; 8]; |
| 20661 | let mut compared = 0usize; | 20834 | let mut compared = 0usize; |
| 20662 | let mut refusals: Vec<String> = Vec::new(); | 20835 | let mut refusals: Vec<String> = Vec::new(); |
| 20663 | - for &(width, height, frame_count, ten_bit) in &arms { | 20836 | + let straddle = name == "a_frame_edge_straddling_band_decodes_pixel_exact"; |
| 20837 | + let mut straddle_units = 0usize; | ||
| 20838 | + for &(width, height, frame_count, ten_bit, tile_cols) in &arms { | ||
| 20664 | for &cq in &cqs { | 20839 | for &cq in &cqs { |
| 20665 | let duration = frame_count as f64 / 25.0; | 20840 | let duration = frame_count as f64 / 25.0; |
| 20666 | // `noise` (explicit seed) both defeats aomenc's | 20841 | // `noise` (explicit seed) both defeats aomenc's |
| @@ -20735,6 +20910,10 @@ mod tests { | |||
| 20735 | if ten_bit { | 20910 | if ten_bit { |
| 20736 | args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); | 20911 | args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); |
| 20737 | } | 20912 | } |
| 20913 | + let tile_arg = format!("--tile-columns={tile_cols}"); | ||
| 20914 | + if tile_cols > 0 { | ||
| 20915 | + args.push(&tile_arg); | ||
| 20916 | + } | ||
| 20738 | args.extend_from_slice(&["--obu", "-o", "-", "-"]); | 20917 | args.extend_from_slice(&["--obu", "-o", "-", "-"]); |
| 20739 | let mut child = Command::new(aomenc_path()) | 20918 | let mut child = Command::new(aomenc_path()) |
| 20740 | .args(&args) | 20919 | .args(&args) |
| @@ -20763,8 +20942,12 @@ mod tests { | |||
| 20763 | "{NAME}: aomenc did not write a 10-bit sequence header" | 20942 | "{NAME}: aomenc did not write a 10-bit sequence header" |
| 20764 | ); | 20943 | ); |
| 20765 | } | 20944 | } |
| 20766 | - let tag = format!("{width}x{height} cq{cq} frames={frame_count} 10bit={ten_bit}"); | 20945 | + let tag = format!( |
| 20946 | + "{width}x{height} cq{cq} frames={frame_count} 10bit={ten_bit} \ | ||
| 20947 | + tile_cols={tile_cols}" | ||
| 20948 | + ); | ||
| 20767 | let before = crate::decode::edge32_hits(); | 20949 | let before = crate::decode::edge32_hits(); |
| 20950 | + let straddle_before = crate::decode::cdef_straddle_units(); | ||
| 20768 | // lane-golomb r8: name the attempt BEFORE decoding it -- a | 20951 | // lane-golomb r8: name the attempt BEFORE decoding it -- a |
| 20769 | // desync surfaces as a panic deep in mc.rs with no arm in the | 20952 | // desync surfaces as a panic deep in mc.rs with no arm in the |
| 20770 | // message, and r8 spent a run bisecting arms by hand. | 20953 | // message, and r8 spent a run bisecting arms by hand. |
| @@ -20826,6 +21009,7 @@ mod tests { | |||
| 20826 | } | 21009 | } |
| 20827 | } | 21010 | } |
| 20828 | compared += 1; | 21011 | compared += 1; |
| 21012 | + straddle_units += crate::decode::cdef_straddle_units() - straddle_before; | ||
| 20829 | for i in 0..8 { | 21013 | for i in 0..8 { |
| 20830 | totals[i] += delta[i]; | 21014 | totals[i] += delta[i]; |
| 20831 | } | 21015 | } |
| @@ -20836,6 +21020,11 @@ mod tests { | |||
| 20836 | "{NAME}: every attempt hit a named refusal:\n{}", | 21020 | "{NAME}: every attempt hit a named refusal:\n{}", |
| 20837 | refusals.join("\n") | 21021 | refusals.join("\n") |
| 20838 | ); | 21022 | ); |
| 21023 | + assert!( | ||
| 21024 | + !straddle || straddle_units > 0, | ||
| 21025 | + "{NAME}: no FILTERED 8x8 CDEF unit crossed the cropped frame edge over \ | ||
| 21026 | + {compared} compared attempts -- the straddling arms proved nothing" | ||
| 21027 | + ); | ||
| 20839 | assert!( | 21028 | assert!( |
| 20840 | totals[0] + totals[1] + totals[4] + totals[5] > 0, | 21029 | totals[0] + totals[1] + totals[4] + totals[5] > 0, |
| 20841 | "{NAME}: no frame-edge partition bit was read at all over \ | 21030 | "{NAME}: no frame-edge partition bit was read at all over \ |
| @@ -20861,7 +21050,8 @@ mod tests { | |||
| 20861 | eprintln!( | 21050 | eprintln!( |
| 20862 | "{NAME}: {compared} pixel-exact attempts, 32-level edge bits \ | 21051 | "{NAME}: {compared} pixel-exact attempts, 32-level edge bits \ |
| 20863 | [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, 64-level edge bits \ | 21052 | [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, 64-level edge bits \ |
| 20864 | - [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, {} named refusals", | 21053 | + [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, \ |
| 21054 | + {straddle_units} straddling CDEF units, {} named refusals", | ||
| 20865 | totals[0], | 21055 | totals[0], |
| 20866 | totals[1], | 21056 | totals[1], |
| 20867 | totals[2], | 21057 | totals[2], |
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. | ||
lanes/cdef-r2.report.mdadded+83 -0
| @@ -0,0 +1,83 @@ | |||
| 1 | +# lane-cdef r2 report -- merge, the 68x192 chroma residue CLOSED, gate un-ignored | ||
| 2 | + | ||
| 3 | +Branch `lane-cdef`, base main `727f29a`. Commits this round: | ||
| 4 | +* `32a467a` Merge main 727f29a (lane-r14, lane-kf1200, lane-reelckf) -- no conflicts. | ||
| 5 | +* `0e6c5c9` Merge lane-golomb 173b793 -- 2 conflicts in `decode.rs`, both resolved (below). | ||
| 6 | +* `26b971a` straddling-band gate un-ignored + `CDEF_STRADDLE_UNITS` counter + multi-tile arms. | ||
| 7 | + | ||
| 8 | +`cdf.rs` is byte-identical across `main`, `lane-golomb` and this tree | ||
| 9 | +(`sha256 655f9a45ccedf7e37adab8b46703cf7ec4c9cc395978a1e6179157741def5844`, all four). | ||
| 10 | + | ||
| 11 | +## r1's leftover suite unit | ||
| 12 | +`cdef-suite-1788330834.service` was still RUNNING at the start of this round; it had reached | ||
| 13 | +**184 tests ok, 0 FAILED / 0 panics** with no `test result` line yet. Stopped (its target dir is | ||
| 14 | +this lane's) and superseded by the r2 run below. | ||
| 15 | + | ||
| 16 | +## Merge conflicts (decode.rs), resolved | ||
| 17 | +1. `dump_stage`'s per-decode-order-frame index: both lanes added one. Kept this lane's shared | ||
| 18 | + `dump_stage_idx()` helper (`dump_stage16` uses it too), dropped lane-golomb's duplicate | ||
| 19 | + `thread_local` counter. | ||
| 20 | +2. The var-tx leaf loop (`decode.rs:19323`): took **main's** general `(row, col, tw, th)` rect | ||
| 21 | + leaves and **lane-golomb's** `fill_lf_grid_leaf_luma` writer. Routing a rect leaf through | ||
| 22 | + `fill_lf_grid_rect` would recompute the CHROMA tx dims from the leaf span; libaom's | ||
| 23 | + `get_transform_size` (`av1/common/av1_loopfilter.c:207`) applies the split override only for | ||
| 24 | + `plane == AOM_PLANE_Y`. Class `table-and-reader-move-together`: table (leaf tuple) from main, | ||
| 25 | + writer from golomb, both re-gated below. | ||
| 26 | + | ||
| 27 | +## Charter item (2) -- the 68x192 CHROMA residue: CLOSED, and it was NOT a chroma-CDEF defect | ||
| 28 | +The charter's hypotheses (chroma `hsize >> xdec` fill, `damping - 1`, `uv_pri/uv_sec`, shared luma | ||
| 29 | +`dir`, `coeff_shift`, the 8x8 skip band) were each checked against the oracle source and all six | ||
| 30 | +were **already correct** in `apply_cdef`: | ||
| 31 | +* right/bottom pad bound: `sample_uv` bounds at `plane.true_width/true_height`, which is | ||
| 32 | + `mi_cols * 4 / 2` (`decode.rs:13388`) = 36 for a 68-px axis -- exactly libaom's | ||
| 33 | + `hsize = nhb << mi_wide_l2` with `mi_wide_l2 = MI_SIZE_LOG2 - subsampling_x` | ||
| 34 | + (`cdef.c:164-167`), the fill starting there being `cdef.c:249-256`. | ||
| 35 | +* `damping += coeff_shift - (pli != AOM_PLANE_Y)` (`cdef_block.c:337`) == our `damping_uv`. | ||
| 36 | +* chroma `t = pri_strength`, NOT `adjust_strength` (`cdef_block.c:387`) == ours. | ||
| 37 | +* `pri_strength ? dir[by][bx] : 0` per plane (`cdef_block.c:392`) == ours; the `conv422/conv440` | ||
| 38 | + direction remap is `if (pli == 1 && xdec != ydec)` (`cdef_block.c:361-369`), i.e. never in 4:2:0. | ||
| 39 | +* `level`/`sec_strength` from `cdef_uv_strengths[mbmi_cdef_strength]` with the `== 3` bump | ||
| 40 | + (`cdef.c:325-333`) == ours; block size `8 >> xdec` by `8 >> ydec` == our 4x4. | ||
| 41 | + | ||
| 42 | +The residue was the **loop restoration plane size**, fixed on lane-golomb r8 and merged this | ||
| 43 | +round: LR is the one post-decode filter sized by the CROP (`av1_get_upsampled_plane_size`, | ||
| 44 | +`restoration.c:47`, asserted against the crop at `restoration.c:1106`), while deblock and CDEF walk | ||
| 45 | +the mi grid. With both branches' fixes in one tree all four straddling arms are exact on Y, U and V. | ||
| 46 | + | ||
| 47 | +EVIDENCE: /home/user/.cache/cdef-strad-r2.log | merged tree, `cargo test -p ec-av1 --lib -- --ignored --nocapture a_frame_edge_straddling_band` (192x68 + 68x192, 5 frames, 8+10-bit, cq 35..61) | 14 pixel-exact attempts (Y, U and V, every shown frame), 0 differing pixels, 18 named refusals, test result ok 1 passed / 0 failed | ||
| 48 | + | ||
| 49 | +## Charter item (3) -- `--tile-columns=1` arms: added, and VACUOUS today | ||
| 50 | +Each straddling arm gained a `--tile-columns=1` twin (8 arms x 8 cq = 64 attempts). All 32 | ||
| 51 | +multi-tile attempts refuse **by name**; census (in the test's doc comment): | ||
| 52 | +10x "an inter SB-level AB partition", 6x "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | ||
| 53 | +rectangular residual coding", 6x "an 8x8 intra leaf in an inter frame whose tx_depth splits it into | ||
| 54 | +4x4 transform units", 5x "an inter partition below 8x8", 3x "an inter 16x16-level AB or 1:4 | ||
| 55 | +partition", 1x "a split intra strip whose transform unit is 32x64", 1x "an intra-coded 1:4 rect | ||
| 56 | +strip on the inter block path". Class `counter-from-refused-stream`: that half of the gate compares | ||
| 57 | +nothing yet and every assert is carried by the single-tile arms. Arms kept so the coverage appears | ||
| 58 | +the day those refusals lift. | ||
| 59 | + | ||
| 60 | +## Gate | ||
| 61 | +`stream.rs::a_frame_edge_straddling_band_decodes_pixel_exact` -- **un-ignored** (was | ||
| 62 | +`#[ignore] "open r9 defect"`). Hard-asserts the new `decode::cdef_straddle_units()` grew: a FILTERED | ||
| 63 | +8x8 CDEF unit whose extent crosses the cropped frame edge is the only shape for which "clamp at the | ||
| 64 | +crop" and "pad with CDEF_VERY_LARGE past the mi-rounded extent" differ, so a zero delta would make | ||
| 65 | +these arms vacuous for this defect. | ||
| 66 | + | ||
| 67 | +EVIDENCE: /home/user/.cache/cdef-strad2-r2.log | `cargo test -p ec-av1 --lib -- --nocapture a_frame_edge_straddling_band` on the final tree | 14 pixel-exact attempts, **337 straddling CDEF units**, 50 named refusals, ok 1 passed / 0 failed in 33.99s | ||
| 68 | + | ||
| 69 | +Sibling gate (same tables/paths -- `apply_cdef`, the skip band, `fill_skip_grid`): | ||
| 70 | +EVIDENCE: /home/user/.cache/cdef-sib-r2.log | `cargo test -p ec-av1 --lib -- --nocapture cdef_and_sub16` | a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact ok, 1 passed / 0 failed | ||
| 71 | + | ||
| 72 | +## Suite | ||
| 73 | +EVIDENCE: /home/user/.cache/cdef-suite-r2.log | `systemd-run --user --unit=cdef-suite-r2-... -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3` on `646f2d3`'s tree | **386 passed, 0 failed, 34 ignored** in 1009.29s (r1's tree had 385/0/35 -- one test moved out of `ignored` and into `passed`: this round's un-ignored straddling gate) | ||
| 74 | + | ||
| 75 | +## Refusals | ||
| 76 | +None lifted this round, so `refusal_inventory.rs` is unchanged. `gate_coverage.rs` needs no entry | ||
| 77 | +either: its derivation deliberately excludes `--tile-columns` (see its header comment) and this | ||
| 78 | +round adds no `--enable-*` flag. | ||
| 79 | + | ||
| 80 | +## Residue | ||
| 81 | +* deferred(the 7 refusals in the census above) -- the multi-tile half of the straddling gate. | ||
| 82 | +* accepted -- the gate compares SHOWN frames (`ffmpeg_decode_sequence`); no-show alt-ref frames are | ||
| 83 | + not compared here, same as every sibling gate (class `gate-blind-to-hidden-frames`). | ||