forge
Explore
Log in

Don't you dare go Hollow

lane-av1422warp: the chroma-above reference is one mi column right of libaom's

Browse files at this commit

cc66ecf830aa575318dce979ae5656b058894c77Ahmet Kaan GümüşParent: 16a2dff
smooth_uv_neighbour_unsnapped read the above chroma neighbour at
(mi_r - 1, mi_c) and the left at (mi_r, mi_c - 1). libaom's
set_mi_row_col (av1_common_int.h:1395-1412) puts them at
base_mi[-stride + ss_x] and base_mi[ss_y*stride - 1], with base_mi the
block's own mi already de-offset by (mi_row & ss_y) / (mi_col & ss_x) --
which is exactly the snap the caller applies. So the above read is
(mi_r - 1, mi_c + ss_x) and the left read is (mi_r, mi_c - 1): the
ss_y*stride term is a COLUMN offset of -1 (row delta 0) at every
subsampling, so only the above COLUMN gains ss_x. One chroma column
spans two luma mi columns, so the chroma edge reaches into the right-hand
luma block's territory and that is where its reference lives.

Measured on the pinned 4:2:2 rotzoom stream (a1.obu, frame 0 PREFILT vs
aomdec): 56142 -> 53395 diffing samples. The first divergent block is
fixed outright -- the chroma 4x8 D67_PRED block at chroma (88, 72) =
mi(18,44) now reproduces the oracle's prediction exactly (row0
132,150,157,148) instead of the strength-0 edge (135,147,172,145), and
its reconstructed U row is byte-equal.

Identity, measured three ways:
 - 4:2:0 control (a420.obu, same recipe at --profile=0) byte-identical to
   aomdec --rawvideo before and after;
 - 4:4:4 (444_sb128rect_lr_witness.obu) output byte-identical to this
   branch's pre-change build (ss_x == 0 makes the column term vanish);
 - the left read is unchanged, so the one term an earlier attempt got
   wrong (applying ss_y to the left ROW) is gone -- that term alone was
   what regressed 4:2:0.
crates/ec-av1/src/decode.rsmodified+26 -16
@@ -8953,24 +8953,17 @@ impl Neighbours {
89538953 // mi(5,15): left neighbour SMOOTH_V at mi(5,14), read at mi(4,13)).
89548954 let snap_y = (1usize << ss_y(fctx)) - 1;
89558955 let snap_x = (1usize << ss_x(fctx)) - 1;
8956- // `set_mi_row_col` (libaom `av1_common_int.h:1395-1412`) puts the two
8957- // chroma references at `base_mi[-stride + ss_x]` and
8958- // `base_mi[ss_y*stride - 1]`, with `base_mi` the block's own mi already
8959- // de-offset by `(mi_row & ss_y)` / `(mi_col & ss_x)`. The snap above IS
8960- // that de-offsetting, so the references are
8961- // `(snapped_r + ss_y - 1, snapped_c + ss_x)` and
8962- // `(snapped_r, snapped_c - 1)` -- NOT `(snapped_r - 1, snapped_c)` /
8963- // `(snapped_r, snapped_c - 1)` as this used to read them. At 4:4:4
8964- // both shifts vanish; at 4:2:0 and 4:2:2 the above reference sits one
8965- // mi column further right (one chroma column spans two luma mi
8966- // columns, so the chroma edge reaches into the right-hand luma block)
8967- // and the left reference one mi row further up.
8956+ // The snap IS libaom's `base_mi` de-offsetting (`set_mi_row_col`,
8957+ // `av1_common_int.h:1395-1412`): `base_mi` is the block's own mi moved
8958+ // by `-(mi_row & ss_y) * stride - (mi_col & ss_x)`. The helper applies
8959+ // the two chroma-reference offsets on top of it -- see its own comment
8960+ // for which axis each one moves.
89688961 self.smooth_uv_neighbour_unsnapped(
89698962 mi_r & !snap_y,
89708963 mi_c & !snap_x,
89718964 r,
89728965 c,
8973- (ss_x(fctx), ss_y(fctx)),
8966+ ss_x(fctx),
89748967 )
89758968 }
89768969
@@ -8985,7 +8978,7 @@ impl Neighbours {
89858978 mi_c: usize,
89868979 r: usize,
89878980 c: usize,
8988- (ss_x, ss_y): (usize, usize),
8981+ ss_x: usize,
89898982 ) -> bool {
89908983 // lane-mtfix r1: availability is TILE-relative on BOTH axes and on the
89918984 // coarse fallback too. `above_uv_mode` is a frame-wide [`SUB`]-grid
@@ -9018,7 +9011,24 @@ impl Neighbours {
90189011 // identity on the values this already read (measured: the 4:2:0
90199012 // control stream is byte-exact with them folded in), and at 4:4:4
90209013 // `ss_x == 0` does the same -- so only 4:2:2 takes the new column.
9021- let above_mi = (mi_r.saturating_sub(1), mi_c);
9014+ // `set_mi_row_col` (libaom `av1_common_int.h:1395-1412`), with `mi_r`/
9015+ // `mi_c` already de-offset by the caller's `(mi_row & ss_y)` /
9016+ // `(mi_col & ss_x)` snap, i.e. already libaom's `base_mi`:
9017+ // chroma_above_mi = base_mi[-stride + ss_x]
9018+ // chroma_left_mi = base_mi[ss_y*stride - 1]
9019+ // The second offset is `ss_y` ROWS down and one COLUMN left; at every
9020+ // subsampling `ss_y*stride - 1` lands on `base_mi`'s OWN row (the row
9021+ // term is at most `stride - 1` elements, so its row delta is 0), so
9022+ // the left read is `(mi_r, mi_c - 1)` -- unchanged. The first offset
9023+ // is one row up and `ss_x` columns right, and the `ss_x` COLUMN was
9024+ // what this dropped: one chroma column spans two luma mi columns, so
9025+ // the chroma edge reaches into the right-hand luma block and that is
9026+ // where its reference lives.
9027+ //
9028+ // Measured: the column term is right at EVERY subsampling -- the
9029+ // 4:2:0 control is byte-exact with it folded in, and 4:4:4 is
9030+ // untouched because `ss_x == 0` there.
9031+ let above_mi = (mi_r.saturating_sub(1), mi_c + ss_x);
90229032 let left_mi = (mi_r, mi_c.saturating_sub(1));
90239033 let above = match self.uv_mode_col.get(above_mi.1) {
90249034 _ if have_above && let Some(m) = cell(&self.uv_mode_grid, above_mi.0, above_mi.1) => m,
@@ -15505,7 +15515,7 @@ fn decode_rect4_16_strip(
1550515515 // directional chroma strip, moving 4 samples by 1.
1550615516 let smooth_neighbor_uv =
1550715517 neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c, fctx);
15508- if smooth_neighbor_uv != neighbours.smooth_uv_neighbour_unsnapped(lmi.0, lmi.1, r, c, (ss_x(fctx), ss_y(fctx)))
15518+ if smooth_neighbor_uv != neighbours.smooth_uv_neighbour_unsnapped(lmi.0, lmi.1, r, c, ss_x(fctx))
1550915519 {
1551015520 hit!(RECT4_16_UV_PAIR_FILT_HITS);
1551115521 }