forge
Explore
Log in

Don't you dare go Hollow

The warp-sample top-right probe needs libaom's rect shape refinements, not just the longer side

Browse files at this commit

00aa4498c0f89da2f4321bea1562572089789fc5Ahmet Kaan GümüşParent: 91fac5a
  • fix
    • the warp-sample top-right probe needs libaom's rect shape refinements, not just the longer side
Show full message
fix(av1): the warp-sample top-right probe needs libaom's rect shape refinements, not just the longer side

r9 changed `av1_findSamples`' top-right probe to libaom's
`AOMMAX(xd->width, xd->height)` (mvref_common.c:1235) but left our
`has_top_right` port without the two shape refinements libaom applies right
after the mask loop (`av1_common_int.h:1419-1428`):

  is_last_vertical_rect  = !((mi_col + width) & (height - 1))   [width < height]
  is_first_horizontal_rect = !(mi_row & (width - 1))            [width > height]

Both are derivable from mi_row/mi_col/bw4/bh4 alone -- no partition context --
and they only bite when bw4 != bh4, i.e. exactly the blocks whose probe size
r9 changed. Probing at the longer side WITHOUT them is half a port: it fixed
the 64x128 block (bs=32 > 16, early-out, no top-right sample, 2-symbol obmc
alphabet) and broke a 32-wide tall leaf in an earlier superblock, moving the
first divergence of the 10-bit 1920x792 264-frame cut EARLIER (decode frame 49,
mi(24,376) -> its successor mi(24,380) read a different rng).

With the refinements ported, on that cut:
* mode ladder vs the instrumented reference decoder over ALL 264 frames:
  915 equal runs, 914 inserts (our per-sub-block prints the reference does not
  emit), ZERO replace/delete -- every EC_MODE (mi_row, mi_col, rng) triple the
  reference emits matches ours, previously the first mismatch was frame 49.
* pixel compare vs the reference decoder: 231/267 frames bit-exact, 36 frames
  differ by 1-3 bytes each (the known chroma-MC bottom-row clamp residue,
  lane-t900 r8); was 218/267 frames differing, frame 49 alone by 2.26 MB.

`tr_reach_longer_side_hits()` now counts blocks where the full probe disagrees
with the old square-at-width probe (9936 on that cut).

corner-cut: libaom's third refinement (PARTITION_VERT_A bottom-left square)
still not ported -- it needs the parent partition type; ceiling and upgrade
path recorded on `mvstack::has_top_right`.
crates/ec-av1/src/decode.rsmodified+1 -1
@@ -18991,7 +18991,7 @@ fn find_samples(
1899118991 // `num_proj_ref >= 1` picked the 3-symbol `motion_mode_cdf` where
1899218992 // libaom reads the 2-symbol `obmc_cdf` (class
1899318993 // wrong-alphabet-same-value).
18994- let tr_reach = has_top_right(mi_row, mi_col, bw4.max(bh4));
18994+ let tr_reach = crate::mvstack::has_top_right(mi_row, mi_col, bw4, bh4);
1899518995 if do_tr && bw4 != bh4 && tr_reach != has_top_right(mi_row, mi_col, bw4) {
1899618996 TR_REACH_LONGER_SIDE_HITS.with(|c| c.set(c.get() + 1));
1899718997 }
crates/ec-av1/src/mvstack.rsmodified+25 -5
@@ -688,11 +688,13 @@ fn top_right_scan_allowed(bw4: usize, bh4: usize) -> bool {
688688 /// (what this module did before lane-sb128 r2) cannot see. It cost frame 6 of
689689 /// the 128 inter gate 380 wrong luma bytes with the entropy stream in sync.
690690 ///
691-/// corner-cut: libaom's three shape refinements (`is_last_vertical_rect`,
692-/// `is_first_horizontal_rect`, the `PARTITION_VERT_A` bottom-left square) are
693-/// not ported -- the ceiling is rectangular and AB-partitioned INTER leaves,
694-/// which this decoder refuses by name today; port them with the rect inter
695-/// leaf.
691+/// lane-t900 r10 ports `is_last_vertical_rect` and `is_first_horizontal_rect`
692+/// (both derivable from `mi_row`/`mi_col`/`bw4`/`bh4` alone).
693+/// corner-cut: libaom's third refinement (the `PARTITION_VERT_A` bottom-left
694+/// SQUARE, which needs the parent partition type this port does not thread
695+/// here) is still missing -- ceiling is a square INTER leaf inside a VERT_A
696+/// partition whose warp-sample top-right probe may answer 1 where libaom says
697+/// 0; upgrade path = thread `partition` into this call.
696698 pub(crate) fn has_top_right(mi_row: usize, mi_col: usize, bw4: usize, bh4: usize) -> bool {
697699 let sb_mi_size = crate::decode::sb_mi_cur() as usize;
698700 let bs0 = bw4.max(bh4);
@@ -713,6 +715,24 @@ pub(crate) fn has_top_right(mi_row: usize, mi_col: usize, bw4: usize, bh4: usize
713715 }
714716 bs <<= 1;
715717 }
718+ // lane-t900 r10: two of libaom's three shape refinements, computed from
719+ // the block's own position and side (`av1_common_int.h:1419-1428` sets
720+ // `is_last_vertical_rect` / `is_first_horizontal_rect` from exactly these
721+ // terms, no partition context). They only bite when `bw4 != bh4`, which is
722+ // also the only case where `bs0` differs from the block's width -- probing
723+ // at the longer side WITHOUT them is half a port and moved the first
724+ // divergence of the 10-bit 1080p cut EARLIER (r9).
725+ if bw4 < bh4 {
726+ let is_last_vertical_rect = (mi_col + bw4) & (bh4 - 1) == 0;
727+ if !is_last_vertical_rect {
728+ has_tr = true;
729+ }
730+ } else if bw4 > bh4 {
731+ let is_first_horizontal_rect = mi_row & (bw4 - 1) == 0;
732+ if !is_first_horizontal_rect {
733+ has_tr = false;
734+ }
735+ }
716736 has_tr
717737 }
718738