From 10647bf6530252e04fc4afa98795787237df1c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 28 Sep 2026 11:02:49 +0300 Subject: [PATCH] lane-av1422warp: correct the chroma-reference comment and report; no behaviour change Comment-only. The decode paths are byte-identical to a9611ea2; re-verified after the edit: the 4:2:0 control a420.obu is still byte-exact against aomdec --rawvideo and 444_sb128rect_lr_witness.obu is still byte-identical to the pre-lane build. Two false statements are corrected, in decode.rs's smooth_uv_neighbour_unsnapped comment and in the lane report. 1. The left-reference derivation. The comment claimed `base_mi[ss_y*mi_stride - 1]` is a COLUMN offset of -1 whose row delta is 0 "at every subsampling, since the row term is at most `stride - 1` elements". That is arithmetically wrong: at `ss_y == 1` the offset is a FULL row down less one element, so the row delta is 1 and the column delta -1. The comment also contradicted itself -- one line said "ss_y ROWS down", the next claimed row delta 0. The block now states the two offsets as plain (row, column) deltas and drops the bogus arithmetic. 2. "only 4:2:2 takes the new column" was wrong. The above column term is `+ss_x`, so it moves the read at 4:2:0 and 4:4:0 as well (both have `ss_x == 1`); only 4:4:4 (`ss_x == 0`) leaves it alone. What the measurement actually showed is that the resulting boolean was unchanged on the 4:2:0 control -- not that the shift is the identity there. The comment and the report now say that. Both now also carry the consequence as a NAMED UNRESOLVED discrepancy rather than a settled one: the left read's `+ss_y` row term is NOT shipped, because no committed fixture presents a 1-mi-tall left neighbour (an 8x4 leaf's left block) at 4:2:0/4:4:0 and so nothing in the tree can witness the correct term today. Unblock is one such stream. History note: the a9611ea2 commit message overreaches. It asserts the shipped form "is libaom's own at every subsampling" and that the left read "never moved" -- both follow from the wrong arithmetic corrected here. Left unamended per history hygiene; this commit supersedes it. --- crates/ec-av1/src/decode.rs | 50 +++++++++++++++++++------------------ lanes/av1422warp.report.md | 47 ++++++++++++++++++++++++---------- 2 files changed, 60 insertions(+), 37 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 0172775a..9fad6be0 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -9003,31 +9003,33 @@ impl Neighbours { .filter(|&m| m != u8::MAX) .map(usize::from) }; - // libaom's two chroma-reference mi, per the shift the caller applies. - // 4:2:2 ONLY. `ss_y == 0` makes the above reference's row term - // `snapped_r - 1` (what this always read) and the left reference's - // row term `snapped_r` (unchanged); `ss_x == 1` moves the above - // reference one mi column right. At 4:2:0 both shifts are the - // identity on the values this already read (measured: the 4:2:0 - // control stream is byte-exact with them folded in), and at 4:4:4 - // `ss_x == 0` does the same -- so only 4:2:2 takes the new column. - // `set_mi_row_col` (libaom `av1_common_int.h:1395-1412`), with `mi_r`/ - // `mi_c` already de-offset by the caller's `(mi_row & ss_y)` / - // `(mi_col & ss_x)` snap, i.e. already libaom's `base_mi`: - // chroma_above_mi = base_mi[-stride + ss_x] - // chroma_left_mi = base_mi[ss_y*stride - 1] - // The second offset is `ss_y` ROWS down and one COLUMN left; at every - // subsampling `ss_y*stride - 1` lands on `base_mi`'s OWN row (the row - // term is at most `stride - 1` elements, so its row delta is 0), so - // the left read is `(mi_r, mi_c - 1)` -- unchanged. The first offset - // is one row up and `ss_x` columns right, and the `ss_x` COLUMN was - // what this dropped: one chroma column spans two luma mi columns, so - // the chroma edge reaches into the right-hand luma block and that is - // where its reference lives. + // libaom's two chroma-reference mi, from `set_mi_row_col` + // (`av1_common_int.h:1400-1401`), with `mi_r`/`mi_c` already + // de-offset by the caller's `(mi_row & ss_y)` / `(mi_col & ss_x)` + // snap -- i.e. already libaom's `base_mi`: // - // Measured: the column term is right at EVERY subsampling -- the - // 4:2:0 control is byte-exact with it folded in, and 4:4:4 is - // untouched because `ss_x == 0` there. + // chroma_above_mi = base_mi[-mi_stride + ss_x] row -1, col +ss_x + // chroma_left_mi = base_mi[ss_y*mi_stride - 1] row +ss_y, col -1 + // + // SHIPPED: the above COLUMN. It is `+ss_x` wherever `ss_x == 1` -- + // 4:2:0, 4:2:2 AND 4:4:0 all carry that column shift, and only 4:4:4 + // (`ss_x == 0`) leaves the read where it was. Measured: folding it in + // leaves the 4:2:0 control byte-identical to `aomdec --rawvideo`; the + // boolean it feeds is simply not exercised differently by that stream + // at its blocks. One chroma column spans two luma mi columns, so the + // chroma edge reaches into the right-hand luma block, and that is where + // its reference lives. + // + // NOT SHIPPED -- KNOWN UNRESOLVED: the left read's `+ss_y` ROW term. + // libaom puts the left reference one mi row DOWN at 4:2:0 and 4:4:0 + // (`ss_y == 1`) and on its own row at 4:2:2 (`ss_y == 0`); this reads + // its own row at every subsampling. An earlier attempt applied the + // `ss_y` term to the WRONG read (the above) and regressed the + // byte-exact 4:2:0 control, which is what exposed the crossing. No + // committed fixture presents a 1-mi-tall left neighbour (an 8x4 leaf's + // left block) at 4:2:0/4:4:0, so nothing here can witness the correct + // term today -- treat this as a named open discrepancy, not a settled + // one. Unblock: one such stream. let above_mi = (mi_r.saturating_sub(1), mi_c + ss_x); let left_mi = (mi_r, mi_c.saturating_sub(1)); let above = match self.uv_mode_col.get(above_mi.1) { diff --git a/lanes/av1422warp.report.md b/lanes/av1422warp.report.md index ea88c279..012cabc0 100644 --- a/lanes/av1422warp.report.md +++ b/lanes/av1422warp.report.md @@ -58,25 +58,35 @@ with `chroma_stride`, and the two are equal at 4:2:0 and 4:4:4. Site: `Neighbours::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]`, where `base_mi` is 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 above is `(mi_r - 1, mi_c + ss_x)` and -left is `(mi_r, mi_c - 1)`: **`ss_y*stride - 1` is a COLUMN offset of -1** (its -row delta is 0 at every subsampling, since the row term is at most `stride - 1` -elements). 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 — that is -where its reference lives. +`set_mi_row_col` (`av1_common_int.h:1400-1401`) puts them at +`base_mi[-mi_stride + ss_x]` and `base_mi[ss_y*mi_stride - 1]`, where `base_mi` +is 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. Read as (row, column) deltas that +is `above = (-1, +ss_x)` and `left = (+ss_y, -1)`. + +**Shipped: the above column.** It carries `+ss_x` wherever `ss_x == 1` — 4:2:0, +4:2:2 **and 4:4:0** all carry that column shift; only 4:4:4 (`ss_x == 0`) leaves +the read where it was. Measured: folding it in leaves the 4:2:0 control +byte-identical to `aomdec --rawvideo`. The honest statement of what that +measurement shows is that the boolean the column feeds came out the same on the +control's blocks — not that the shift is the identity there. + +**Not shipped, and KNOWN UNRESOLVED: the left row term `+ss_y`.** libaom puts the +left reference one mi row DOWN at 4:2:0 and 4:4:0 (`ss_y == 1`) and on its own +row at 4:2:2 (`ss_y == 0`); this reads its own row at every subsampling. No +committed fixture presents a 1-mi-tall left neighbour (an 8x4 leaf's left block) +at 4:2:0/4:4:0, so nothing in the tree can witness the correct term today. This +is a named open discrepancy, not a settled one. ### How the split was chosen, and why 4:2:0 stays exact An earlier attempt applied libaom's formula to BOTH reads (`above` row `mi_r + ss_y - 1`, `left` row `mi_r + ss_y - 1`). That improved 4:2:2 (56142 → 53395) but regressed the byte-exact 4:2:0 control, and gating only the column -shift to 4:2:2 still regressed it — the row term, not the column term, was the -wrong part. Doing the offset arithmetic settled it: `ss_y*stride - 1` elements -from `base_mi` has row delta 0 for `ss_y ∈ {0,1}`, so the left read never moved. -The shipped form is libaom's own at every subsampling. +shift to 4:2:2 still regressed it — the `ss_y` term had been applied to the +WRONG read (the above), and that crossing is what the regression exposed. The +column term on its own is the part that measures clean; the row term is the part +that is still open, and shipping it is deferred to a lane that can witness it. **Identity, measured three ways:** @@ -160,6 +170,17 @@ does open the OBMC-chroma and chroma-edge-filter defects, which no prior 4:2:2 fixture reached — that is real coverage progress, and it is not the same thing as the bar. +## Known unresolved + +- **Left chroma reference row term (`+ss_y`, libaom `av1_common_int.h:1400-1401`) + is NOT shipped.** `smooth_uv_neighbour_unsnapped` reads the left neighbour on + its own mi row at every subsampling; libaom reads it one row down at 4:2:0 and + 4:4:0. Unblock: a stream with a 1-mi-tall left neighbour (an 8x4 leaf's left + block) at 4:2:0/4:4:0 — no committed fixture has one, which is why the + current read is byte-exact on the control and why the correct term cannot be + witnessed today. The above column term (`+ss_x`) IS shipped, at every + subsampling where `ss_x == 1`. + ## State Two commits on `lane-av1422warp`, no push. Worktree clean; the