The frame-edge straddling-band gate is green -- un-ignored, with a straddling-CDEF-unit counter and multi-tile arms
Browse files at this commit827ee1d7243c945805a2ba704ea28b6b094ae3e8Parent: 6f7bda6- test
- the frame-edge straddling-band gate is green -- un-ignored, with a straddling-CDEF-unit counter and multi-tile arms
2 changed files +100 -17
- crates/ec-av1/src/decode.rs +40 -2
- crates/ec-av1/src/stream.rs +60 -15
crates/ec-av1/src/decode.rsmodified+40 -2
| @@ -2608,6 +2608,14 @@ thread_local! { | |||
| 2608 | thread_local! { | 2608 | thread_local! { |
| 2609 | static CDEF_SKIPPED_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2609 | static CDEF_SKIPPED_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2610 | static INTER8_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2610 | static INTER8_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2611 | + // lane-cdef r2: (c) 8x8 CDEF units that are FILTERED and whose extent | ||
| 2612 | + // crosses the cropped frame edge -- the only units for which "clamp at | ||
| 2613 | + // the crop" and "pad past the mi-rounded extent with CDEF_VERY_LARGE" | ||
| 2614 | + // (libaom `cdef.c:249-256`, `cdef_prepare_fb`'s hsize/vsize are | ||
| 2615 | + // `nhb << mi_wide_l2` off the MI grid, not the crop) differ. A frame | ||
| 2616 | + // whose width or height is not a multiple of 8 is the only shape that | ||
| 2617 | + // produces one; the straddling-band gate arms assert it grew. | ||
| 2618 | + static CDEF_STRADDLE_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2611 | } | 2619 | } |
| 2612 | 2620 | ||
| 2613 | /// Current value of `CDEF_SKIPPED_UNITS`. | 2621 | /// Current value of `CDEF_SKIPPED_UNITS`. |
| @@ -2620,6 +2628,11 @@ pub(crate) fn inter8_skip_band_hits() -> usize { | |||
| 2620 | INTER8_SKIP_BAND_HITS.with(|c| c.get()) | 2628 | INTER8_SKIP_BAND_HITS.with(|c| c.get()) |
| 2621 | } | 2629 | } |
| 2622 | 2630 | ||
| 2631 | +/// Current value of `CDEF_STRADDLE_UNITS`. | ||
| 2632 | +pub(crate) fn cdef_straddle_units() -> usize { | ||
| 2633 | + CDEF_STRADDLE_UNITS.with(|c| c.get()) | ||
| 2634 | +} | ||
| 2635 | + | ||
| 2623 | /// Current value of [`SUB8_SPLIT_HITS`]. | 2636 | /// Current value of [`SUB8_SPLIT_HITS`]. |
| 2624 | pub(crate) fn sub8_split_hits() -> usize { | 2637 | pub(crate) fn sub8_split_hits() -> usize { |
| 2625 | SUB8_SPLIT_HITS.with(|c| c.get()) | 2638 | SUB8_SPLIT_HITS.with(|c| c.get()) |
| @@ -12844,6 +12857,9 @@ fn apply_cdef( | |||
| 12844 | v: &mut PlaneBuf, | 12857 | v: &mut PlaneBuf, |
| 12845 | cdef: &CdefParams, | 12858 | cdef: &CdefParams, |
| 12846 | skip_grid: &Neighbours, | 12859 | skip_grid: &Neighbours, |
| 12860 | + // This frame header's own CROPPED luma size, for the straddling-unit | ||
| 12861 | + // counter only -- CDEF itself walks the mi-rounded plane. | ||
| 12862 | + (frame_w, frame_h): (usize, usize), | ||
| 12847 | ) { | 12863 | ) { |
| 12848 | // lane-part32 r2 debug rung, env-gated: see `apply_deblock`'s sibling. | 12864 | // lane-part32 r2 debug rung, env-gated: see `apply_deblock`'s sibling. |
| 12849 | if std::env::var_os("EC_AV1_DEBUG_SKIP_CDEF").is_some() { | 12865 | if std::env::var_os("EC_AV1_DEBUG_SKIP_CDEF").is_some() { |
| @@ -12928,6 +12944,14 @@ fn apply_cdef( | |||
| 12928 | } | 12944 | } |
| 12929 | let enable_primary = t != 0; | 12945 | let enable_primary = t != 0; |
| 12930 | let enable_secondary = y_sec_strength != 0; | 12946 | let enable_secondary = y_sec_strength != 0; |
| 12947 | + if (ox + 8 > frame_w || oy + 8 > frame_h) | ||
| 12948 | + && (enable_primary | ||
| 12949 | + || enable_secondary | ||
| 12950 | + || cdef.uv_pri_strength[sidx] != 0 | ||
| 12951 | + || cdef.uv_sec_strength[sidx] != 0) | ||
| 12952 | + { | ||
| 12953 | + CDEF_STRADDLE_UNITS.with(|c| c.set(c.get() + 1)); | ||
| 12954 | + } | ||
| 12931 | if enable_primary || enable_secondary { | 12955 | if enable_primary || enable_secondary { |
| 12932 | cdef_filter_block( | 12956 | cdef_filter_block( |
| 12933 | sample_y, | 12957 | sample_y, |
| @@ -15060,7 +15084,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 15060 | // dump above these bisect WHICH filter stage introduced a mismatch. | 15084 | // dump above these bisect WHICH filter stage introduced a mismatch. |
| 15061 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); | 15085 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); |
| 15062 | dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | 15086 | dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 15063 | - apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 15087 | + apply_cdef( |
| 15088 | + &mut y, | ||
| 15089 | + &mut u, | ||
| 15090 | + &mut v, | ||
| 15091 | + cdef, | ||
| 15092 | + &neighbours, | ||
| 15093 | + (frame_width as usize, frame_height as usize), | ||
| 15094 | + ); | ||
| 15064 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); | 15095 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); |
| 15065 | dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | 15096 | dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 15066 | apply_loop_restoration( | 15097 | apply_loop_restoration( |
| @@ -22991,7 +23022,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 22991 | // dump above these bisect WHICH filter stage introduced a mismatch. | 23022 | // dump above these bisect WHICH filter stage introduced a mismatch. |
| 22992 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); | 23023 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); |
| 22993 | dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | 23024 | dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 22994 | - apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 23025 | + apply_cdef( |
| 23026 | + &mut y, | ||
| 23027 | + &mut u, | ||
| 23028 | + &mut v, | ||
| 23029 | + cdef, | ||
| 23030 | + &neighbours, | ||
| 23031 | + (frame_width as usize, frame_height as usize), | ||
| 23032 | + ); | ||
| 22995 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); | 23033 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); |
| 22996 | dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | 23034 | dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 22997 | apply_loop_restoration( | 23035 | apply_loop_restoration( |
crates/ec-av1/src/stream.rsmodified+60 -15
| @@ -19532,10 +19532,36 @@ mod tests { | |||
| 19532 | /// `frame_width` clip, is correct. | 19532 | /// `frame_width` clip, is correct. |
| 19533 | /// * The divergence therefore enters in CDEF, at the last 8x8 CDEF block | 19533 | /// * The divergence therefore enters in CDEF, at the last 8x8 CDEF block |
| 19534 | /// column/row, which is the one that straddles the crop edge. | 19534 | /// column/row, which is the one that straddles the crop edge. |
| 19535 | - /// `#[ignore]` so the suite stays green; run it with | 19535 | + /// lane-cdef r2: CLOSED, and un-ignored. r1 rooted the luma half in |
| 19536 | - /// `cargo test -p ec-av1 --lib -- --ignored a_frame_edge_straddling_band`. | 19536 | + /// `apply_cdef`'s direction search, which clamped at the CROPPED frame |
| 19537 | + /// edge while libaom runs `cdef_find_dir` over `cdef_prepare_fb`'s buffer | ||
| 19538 | + /// -- whose columns/rows past the MI-ROUNDED extent (`hsize = nhb << | ||
| 19539 | + /// mi_wide_l2`, `cdef.c:164-167`, and the `frame_boundary[RIGHT]` | ||
| 19540 | + /// CDEF_VERY_LARGE fill at `cdef.c:249-256`) are CDEF_VERY_LARGE, not the | ||
| 19541 | + /// last real sample. The chroma half was lane-golomb r8's loop-restoration | ||
| 19542 | + /// plane size (LR is the one post-decode filter sized by the CROP, not the | ||
| 19543 | + /// mi grid) plus its reference-size fix; merging both branches takes all | ||
| 19544 | + /// four arms to 0 differing pixels on Y, U and V. | ||
| 19545 | + /// | ||
| 19546 | + /// Arms: 192x68 and 68x192 (a 4-px straddling band on one axis), 5 frames, | ||
| 19547 | + /// 8-bit and 10-bit, plus a `--tile-columns=1` twin of each (COMMON's | ||
| 19548 | + /// neighbour-map rule -- the skip band CDEF reads is a per-mi side band). | ||
| 19549 | + /// MEASURED 2026-09-02: all 32 multi-tile attempts refuse BY NAME today, | ||
| 19550 | + /// so that half of the gate compares nothing yet (class | ||
| 19551 | + /// `counter-from-refused-stream`); the census is 10x "an inter SB-level AB | ||
| 19552 | + /// partition", 6x "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | ||
| 19553 | + /// rectangular residual coding", 6x "an 8x8 intra leaf in an inter frame | ||
| 19554 | + /// whose tx_depth splits it into 4x4 transform units", 5x "an inter | ||
| 19555 | + /// partition below 8x8", 3x "an inter 16x16-level AB or 1:4 partition", | ||
| 19556 | + /// 1x "a split intra strip whose transform unit is 32x64", 1x "an | ||
| 19557 | + /// intra-coded 1:4 (or other non-2:1) rect strip on the inter block path". | ||
| 19558 | + /// The arms stay so the coverage appears the day those lift; every assert | ||
| 19559 | + /// below is carried by the single-tile arms. | ||
| 19560 | + /// Hard-asserts `decode::cdef_straddle_units()` grew: a FILTERED 8x8 CDEF | ||
| 19561 | + /// unit whose extent crosses the crop edge is the only shape for which | ||
| 19562 | + /// clamping and padding differ, so a zero delta would make these arms | ||
| 19563 | + /// vacuous for this defect. | ||
| 19537 | #[test] | 19564 | #[test] |
| 19538 | - #[ignore = "open r9 defect: CDEF at the last straddling 8x8 block column/row"] | ||
| 19539 | fn a_frame_edge_straddling_band_decodes_pixel_exact() { | 19565 | fn a_frame_edge_straddling_band_decodes_pixel_exact() { |
| 19540 | edge32_gate( | 19566 | edge32_gate( |
| 19541 | "a_frame_edge_straddling_band_decodes_pixel_exact", | 19567 | "a_frame_edge_straddling_band_decodes_pixel_exact", |
| @@ -19554,15 +19580,15 @@ mod tests { | |||
| 19554 | eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | 19580 | eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); |
| 19555 | return; | 19581 | return; |
| 19556 | } | 19582 | } |
| 19557 | - // (width, height, frames, ten_bit) | 19583 | + // (width, height, frames, ten_bit, tile_columns_log2) |
| 19558 | - let mut arms: Vec<(usize, usize, usize, bool)> = Vec::new(); | 19584 | + let mut arms: Vec<(usize, usize, usize, bool, u32)> = Vec::new(); |
| 19559 | for &(w, h) in &[(192usize, 80usize), (80usize, 192usize)] { | 19585 | for &(w, h) in &[(192usize, 80usize), (80usize, 192usize)] { |
| 19560 | - arms.push((w, h, 1, false)); | 19586 | + arms.push((w, h, 1, false, 0)); |
| 19561 | - arms.push((w, h, 1, true)); | 19587 | + arms.push((w, h, 1, true, 0)); |
| 19562 | } | 19588 | } |
| 19563 | // The inter arm: >= 4 frames so the 32-level edge path in the INTER | 19589 | // The inter arm: >= 4 frames so the 32-level edge path in the INTER |
| 19564 | // tile walk is exercised too. | 19590 | // tile walk is exercised too. |
| 19565 | - arms.push((192, 80, 5, false)); | 19591 | + arms.push((192, 80, 5, false, 0)); |
| 19566 | // lane-golomb r9: the straddling-band arms, only under the ignored | 19592 | // lane-golomb r9: the straddling-band arms, only under the ignored |
| 19567 | // `a_frame_edge_straddling_band_decodes_pixel_exact` name (they are | 19593 | // `a_frame_edge_straddling_band_decodes_pixel_exact` name (they are |
| 19568 | // RED -- see that test's own comment for the stage bisection). Naming | 19594 | // RED -- see that test's own comment for the stage bisection). Naming |
| @@ -19570,10 +19596,12 @@ mod tests { | |||
| 19570 | // recipe, the counters and the refusal handling identical. | 19596 | // recipe, the counters and the refusal handling identical. |
| 19571 | if name == "a_frame_edge_straddling_band_decodes_pixel_exact" { | 19597 | if name == "a_frame_edge_straddling_band_decodes_pixel_exact" { |
| 19572 | arms.clear(); | 19598 | arms.clear(); |
| 19573 | - arms.push((192, 68, 5, false)); | 19599 | + for &tile_cols in &[0u32, 1] { |
| 19574 | - arms.push((192, 68, 5, true)); | 19600 | + arms.push((192, 68, 5, false, tile_cols)); |
| 19575 | - arms.push((68, 192, 5, false)); | 19601 | + arms.push((192, 68, 5, true, tile_cols)); |
| 19576 | - arms.push((68, 192, 5, true)); | 19602 | + arms.push((68, 192, 5, false, tile_cols)); |
| 19603 | + arms.push((68, 192, 5, true, tile_cols)); | ||
| 19604 | + } | ||
| 19577 | } | 19605 | } |
| 19578 | // lane-golomb r8 MEASURED, arm STILL NOT added (every cq level is | 19606 | // lane-golomb r8 MEASURED, arm STILL NOT added (every cq level is |
| 19579 | // vacuous, panicking or red -- each measured this round with | 19607 | // vacuous, panicking or red -- each measured this round with |
| @@ -19614,7 +19642,9 @@ mod tests { | |||
| 19614 | let mut totals = [0usize; 8]; | 19642 | let mut totals = [0usize; 8]; |
| 19615 | let mut compared = 0usize; | 19643 | let mut compared = 0usize; |
| 19616 | let mut refusals: Vec<String> = Vec::new(); | 19644 | let mut refusals: Vec<String> = Vec::new(); |
| 19617 | - for &(width, height, frame_count, ten_bit) in &arms { | 19645 | + let straddle = name == "a_frame_edge_straddling_band_decodes_pixel_exact"; |
| 19646 | + let mut straddle_units = 0usize; | ||
| 19647 | + for &(width, height, frame_count, ten_bit, tile_cols) in &arms { | ||
| 19618 | for &cq in &cqs { | 19648 | for &cq in &cqs { |
| 19619 | let duration = frame_count as f64 / 25.0; | 19649 | let duration = frame_count as f64 / 25.0; |
| 19620 | // `noise` (explicit seed) both defeats aomenc's | 19650 | // `noise` (explicit seed) both defeats aomenc's |
| @@ -19689,6 +19719,10 @@ mod tests { | |||
| 19689 | if ten_bit { | 19719 | if ten_bit { |
| 19690 | args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); | 19720 | args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); |
| 19691 | } | 19721 | } |
| 19722 | + let tile_arg = format!("--tile-columns={tile_cols}"); | ||
| 19723 | + if tile_cols > 0 { | ||
| 19724 | + args.push(&tile_arg); | ||
| 19725 | + } | ||
| 19692 | args.extend_from_slice(&["--obu", "-o", "-", "-"]); | 19726 | args.extend_from_slice(&["--obu", "-o", "-", "-"]); |
| 19693 | let mut child = Command::new(aomenc_path()) | 19727 | let mut child = Command::new(aomenc_path()) |
| 19694 | .args(&args) | 19728 | .args(&args) |
| @@ -19717,8 +19751,12 @@ mod tests { | |||
| 19717 | "{NAME}: aomenc did not write a 10-bit sequence header" | 19751 | "{NAME}: aomenc did not write a 10-bit sequence header" |
| 19718 | ); | 19752 | ); |
| 19719 | } | 19753 | } |
| 19720 | - let tag = format!("{width}x{height} cq{cq} frames={frame_count} 10bit={ten_bit}"); | 19754 | + let tag = format!( |
| 19755 | + "{width}x{height} cq{cq} frames={frame_count} 10bit={ten_bit} \ | ||
| 19756 | + tile_cols={tile_cols}" | ||
| 19757 | + ); | ||
| 19721 | let before = crate::decode::edge32_hits(); | 19758 | let before = crate::decode::edge32_hits(); |
| 19759 | + let straddle_before = crate::decode::cdef_straddle_units(); | ||
| 19722 | // lane-golomb r8: name the attempt BEFORE decoding it -- a | 19760 | // lane-golomb r8: name the attempt BEFORE decoding it -- a |
| 19723 | // desync surfaces as a panic deep in mc.rs with no arm in the | 19761 | // desync surfaces as a panic deep in mc.rs with no arm in the |
| 19724 | // message, and r8 spent a run bisecting arms by hand. | 19762 | // message, and r8 spent a run bisecting arms by hand. |
| @@ -19780,6 +19818,7 @@ mod tests { | |||
| 19780 | } | 19818 | } |
| 19781 | } | 19819 | } |
| 19782 | compared += 1; | 19820 | compared += 1; |
| 19821 | + straddle_units += crate::decode::cdef_straddle_units() - straddle_before; | ||
| 19783 | for i in 0..8 { | 19822 | for i in 0..8 { |
| 19784 | totals[i] += delta[i]; | 19823 | totals[i] += delta[i]; |
| 19785 | } | 19824 | } |
| @@ -19790,6 +19829,11 @@ mod tests { | |||
| 19790 | "{NAME}: every attempt hit a named refusal:\n{}", | 19829 | "{NAME}: every attempt hit a named refusal:\n{}", |
| 19791 | refusals.join("\n") | 19830 | refusals.join("\n") |
| 19792 | ); | 19831 | ); |
| 19832 | + assert!( | ||
| 19833 | + !straddle || straddle_units > 0, | ||
| 19834 | + "{NAME}: no FILTERED 8x8 CDEF unit crossed the cropped frame edge over \ | ||
| 19835 | + {compared} compared attempts -- the straddling arms proved nothing" | ||
| 19836 | + ); | ||
| 19793 | assert!( | 19837 | assert!( |
| 19794 | totals[0] + totals[1] + totals[4] + totals[5] > 0, | 19838 | totals[0] + totals[1] + totals[4] + totals[5] > 0, |
| 19795 | "{NAME}: no frame-edge partition bit was read at all over \ | 19839 | "{NAME}: no frame-edge partition bit was read at all over \ |
| @@ -19815,7 +19859,8 @@ mod tests { | |||
| 19815 | eprintln!( | 19859 | eprintln!( |
| 19816 | "{NAME}: {compared} pixel-exact attempts, 32-level edge bits \ | 19860 | "{NAME}: {compared} pixel-exact attempts, 32-level edge bits \ |
| 19817 | [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, 64-level edge bits \ | 19861 | [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, 64-level edge bits \ |
| 19818 | - [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, {} named refusals", | 19862 | + [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, \ |
| 19863 | + {straddle_units} straddling CDEF units, {} named refusals", | ||
| 19819 | totals[0], | 19864 | totals[0], |
| 19820 | totals[1], | 19865 | totals[1], |
| 19821 | totals[2], | 19866 | totals[2], |