forge
Explore
Log in

Don't you dare go Hollow

The frame-edge straddling-band gate is green -- un-ignored, with a straddling-CDEF-unit counter and multi-tile arms

Browse files at this commit

827ee1d7243c945805a2ba704ea28b6b094ae3e8Ahmet Kaan GümüşParent: 6f7bda6
  • test
    • the frame-edge straddling-band gate is green -- un-ignored, with a straddling-CDEF-unit counter and multi-tile arms
Show full message
test(av1): the frame-edge straddling-band gate is green -- un-ignored, with a straddling-CDEF-unit counter and multi-tile arms

The 68x192 / 192x68 straddling band (a frame axis that is not a multiple of
8) now decodes pixel-exact on Y, U and V for all 5 frames, 8- and 10-bit:
the luma half was this lane's r1 CDEF direction-search fix (libaom searches
over cdef_prepare_fb's padded buffer, CDEF_VERY_LARGE past the MI-ROUNDED
extent -- cdef.c:164-167 hsize/vsize and the frame_boundary[RIGHT] fill at
cdef.c:249-256 -- not the last real sample at the crop), the chroma half was
lane-golomb r8's crop-sized loop-restoration planes and reference-size test,
merged in this round.

* decode.rs: new CDEF_STRADDLE_UNITS counter -- a FILTERED 8x8 CDEF unit whose
  extent crosses the cropped frame edge, i.e. exactly the units for which
  clamping and CDEF_VERY_LARGE padding differ. apply_cdef takes the header's
  cropped size for it.
* stream.rs: a_frame_edge_straddling_band_decodes_pixel_exact un-ignored,
  hard-asserts that counter grew (337 units over 14 compared attempts), and
  gains a --tile-columns=1 twin of each arm. All 32 multi-tile attempts refuse
  by name today (census in the doc comment) -- that half compares nothing yet.
crates/ec-av1/src/decode.rsmodified+40 -2
@@ -2608,6 +2608,14 @@ thread_local! {
26082608 thread_local! {
26092609 static CDEF_SKIPPED_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
26102610 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) };
26112619 }
26122620
26132621 /// Current value of `CDEF_SKIPPED_UNITS`.
@@ -2620,6 +2628,11 @@ pub(crate) fn inter8_skip_band_hits() -> usize {
26202628 INTER8_SKIP_BAND_HITS.with(|c| c.get())
26212629 }
26222630
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+
26232636 /// Current value of [`SUB8_SPLIT_HITS`].
26242637 pub(crate) fn sub8_split_hits() -> usize {
26252638 SUB8_SPLIT_HITS.with(|c| c.get())
@@ -12844,6 +12857,9 @@ fn apply_cdef(
1284412857 v: &mut PlaneBuf,
1284512858 cdef: &CdefParams,
1284612859 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),
1284712863 ) {
1284812864 // lane-part32 r2 debug rung, env-gated: see `apply_deblock`'s sibling.
1284912865 if std::env::var_os("EC_AV1_DEBUG_SKIP_CDEF").is_some() {
@@ -12928,6 +12944,14 @@ fn apply_cdef(
1292812944 }
1292912945 let enable_primary = t != 0;
1293012946 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+ }
1293112955 if enable_primary || enable_secondary {
1293212956 cdef_filter_block(
1293312957 sample_y,
@@ -15060,7 +15084,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1506015084 // dump above these bisect WHICH filter stage introduced a mismatch.
1506115085 dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v);
1506215086 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+ );
1506415095 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);
1506515096 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
1506615097 apply_loop_restoration(
@@ -22991,7 +23022,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2299123022 // dump above these bisect WHICH filter stage introduced a mismatch.
2299223023 dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v);
2299323024 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+ );
2299523033 dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v);
2299623034 dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize);
2299723035 apply_loop_restoration(
crates/ec-av1/src/stream.rsmodified+60 -15
@@ -19532,10 +19532,36 @@ mod tests {
1953219532 /// `frame_width` clip, is correct.
1953319533 /// * The divergence therefore enters in CDEF, at the last 8x8 CDEF block
1953419534 /// column/row, which is the one that straddles the crop edge.
19535- /// `#[ignore]` so the suite stays green; run it with
19536- /// `cargo test -p ec-av1 --lib -- --ignored a_frame_edge_straddling_band`.
19535+ /// lane-cdef r2: CLOSED, and un-ignored. r1 rooted the luma half in
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.
1953719564 #[test]
19538- #[ignore = "open r9 defect: CDEF at the last straddling 8x8 block column/row"]
1953919565 fn a_frame_edge_straddling_band_decodes_pixel_exact() {
1954019566 edge32_gate(
1954119567 "a_frame_edge_straddling_band_decodes_pixel_exact",
@@ -19554,15 +19580,15 @@ mod tests {
1955419580 eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
1955519581 return;
1955619582 }
19557- // (width, height, frames, ten_bit)
19558- let mut arms: Vec<(usize, usize, usize, bool)> = Vec::new();
19583+ // (width, height, frames, ten_bit, tile_columns_log2)
19584+ let mut arms: Vec<(usize, usize, usize, bool, u32)> = Vec::new();
1955919585 for &(w, h) in &[(192usize, 80usize), (80usize, 192usize)] {
19560- arms.push((w, h, 1, false));
19561- arms.push((w, h, 1, true));
19586+ arms.push((w, h, 1, false, 0));
19587+ arms.push((w, h, 1, true, 0));
1956219588 }
1956319589 // The inter arm: >= 4 frames so the 32-level edge path in the INTER
1956419590 // tile walk is exercised too.
19565- arms.push((192, 80, 5, false));
19591+ arms.push((192, 80, 5, false, 0));
1956619592 // lane-golomb r9: the straddling-band arms, only under the ignored
1956719593 // `a_frame_edge_straddling_band_decodes_pixel_exact` name (they are
1956819594 // RED -- see that test's own comment for the stage bisection). Naming
@@ -19570,10 +19596,12 @@ mod tests {
1957019596 // recipe, the counters and the refusal handling identical.
1957119597 if name == "a_frame_edge_straddling_band_decodes_pixel_exact" {
1957219598 arms.clear();
19573- arms.push((192, 68, 5, false));
19574- arms.push((192, 68, 5, true));
19575- arms.push((68, 192, 5, false));
19576- arms.push((68, 192, 5, true));
19599+ for &tile_cols in &[0u32, 1] {
19600+ arms.push((192, 68, 5, false, tile_cols));
19601+ arms.push((192, 68, 5, true, tile_cols));
19602+ arms.push((68, 192, 5, false, tile_cols));
19603+ arms.push((68, 192, 5, true, tile_cols));
19604+ }
1957719605 }
1957819606 // lane-golomb r8 MEASURED, arm STILL NOT added (every cq level is
1957919607 // vacuous, panicking or red -- each measured this round with
@@ -19614,7 +19642,9 @@ mod tests {
1961419642 let mut totals = [0usize; 8];
1961519643 let mut compared = 0usize;
1961619644 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 {
1961819648 for &cq in &cqs {
1961919649 let duration = frame_count as f64 / 25.0;
1962019650 // `noise` (explicit seed) both defeats aomenc's
@@ -19689,6 +19719,10 @@ mod tests {
1968919719 if ten_bit {
1969019720 args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);
1969119721 }
19722+ let tile_arg = format!("--tile-columns={tile_cols}");
19723+ if tile_cols > 0 {
19724+ args.push(&tile_arg);
19725+ }
1969219726 args.extend_from_slice(&["--obu", "-o", "-", "-"]);
1969319727 let mut child = Command::new(aomenc_path())
1969419728 .args(&args)
@@ -19717,8 +19751,12 @@ mod tests {
1971719751 "{NAME}: aomenc did not write a 10-bit sequence header"
1971819752 );
1971919753 }
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+ );
1972119758 let before = crate::decode::edge32_hits();
19759+ let straddle_before = crate::decode::cdef_straddle_units();
1972219760 // lane-golomb r8: name the attempt BEFORE decoding it -- a
1972319761 // desync surfaces as a panic deep in mc.rs with no arm in the
1972419762 // message, and r8 spent a run bisecting arms by hand.
@@ -19780,6 +19818,7 @@ mod tests {
1978019818 }
1978119819 }
1978219820 compared += 1;
19821+ straddle_units += crate::decode::cdef_straddle_units() - straddle_before;
1978319822 for i in 0..8 {
1978419823 totals[i] += delta[i];
1978519824 }
@@ -19790,6 +19829,11 @@ mod tests {
1979019829 "{NAME}: every attempt hit a named refusal:\n{}",
1979119830 refusals.join("\n")
1979219831 );
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+ );
1979319837 assert!(
1979419838 totals[0] + totals[1] + totals[4] + totals[5] > 0,
1979519839 "{NAME}: no frame-edge partition bit was read at all over \
@@ -19815,7 +19859,8 @@ mod tests {
1981519859 eprintln!(
1981619860 "{NAME}: {compared} pixel-exact attempts, 32-level edge bits \
1981719861 [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",
1981919864 totals[0],
1982019865 totals[1],
1982119866 totals[2],