forge
Explore
Log in

Don't you dare go Hollow

lane-av1422warp: a 4:2:2 rect leaf's chroma dc-sign vote must sample chroma cells

Browse files at this commit

cb5d22b0bd04fbc52d91e027cc18168c47c8bc6bAhmet Kaan GümüşParent: 3d97c32
decode_leaf_rect's around_mi_rect call was the one 4:2:2 chroma gather in
the file still ungated: at ss (1,0) a 16x8/8x16 luma leaf's chroma is a
SQUARE (side/2, side) block, so `side` chroma 4-px cells above it spread
over `side` LUMA mi columns, one chroma column per PAIR of luma mi cells,
and both cells of a pair carry the covering unit's whole-unit dc sign. The
per-mi rect gather therefore double-counts every chroma column's sign.
around_mi_422_chroma's every-second above-cell sampling IS libaom's
txb_w_unit sum, and every sibling gather in this file already routes
through it under `ss_x == 1 && ss_y == 0`; this one did not, so a 4:2:2
rect leaf voted over luma unit counts.

Measured on the pinned 4:2:2 rotzoom stream (a1.obu frame 0, cut to
a1_f0.obu). The 16x8 leaf at mi(48,28) resolved its V plane's dc sign
from vote 0 -- dc_sign_cdf[0] -- where the oracle resolves a negative
vote, dc_sign_cdf[1]:

  before  EC_DCDUMP    mi=(48,28) plane=2 wh=(16,8) vote=0
          above=[None/6,None/6,Some(false)/7,Some(false)/7]  FOUR cells
  after   EC_DCDUMP422 mi=(48,28) plane=2 wh=(16,8) vote=-1
          above=[None/6,Some(false)/7]                       TWO cells

Red/green. The bit offset between the two decoders is a clean constant
through coefficient unit 1418 and turned 6 bits at 1419; after this fix
unit 1418 pairs and the first divergence moves to unit 2427. Frame 0
coefficient units: 1959 wrong-shaped before, 2680 after (oracle 2512).
Whole stream, 16 frames vs aomdec --rawvideo: 1619115 -> 1380482
differing samples. Still 0/16 frames exact -- see the hand-off below.

Identity, measured four ways, all unchanged:
 - 4:2:0 control a420.obu byte-identical to aomdec --rawvideo. The gate
   is ss (1,0), so the sampler is not reached at 4:2:0 or 4:4:4; `chroma_422`
   is already computed in this arm for the scan selection.
 - 4:4:4 444_sb128rect_lr_witness.obu byte-identical to the pre-lane build.
 - pinned 422_allskip_2f.obu (2 frames) and 422_sb128_3f.obu (3 frames)
   still pixel-exact against aomdec.
 - the decodetxb/aomdec EC_DCSIGN and EC_COEFF_STEP bitpos rungs used to
   pin this are all reverted; aomdec is rebuilt to its committed shape.

Hand-off: the new first divergence is at coefficient unit 2427 / TU 2428,
mi(64,24), where the oracle codes a 32x32 luma TU and we code 8x8 leaves.
That is a different CLASS from this fix -- block/partition structure, not a
neighbour vote -- so it is reported rather than chased.
crates/ec-av1/src/decode.rsmodified+22 -1
@@ -13701,7 +13701,28 @@ fn decode_leaf_rect(
1370113701 } else {
1370213702 TxbSet::ChromaRect8x4
1370313703 };
13704- let around = neighbours.around_mi_rect(leaf_mi, bw, bh);
13704+ // lane-av1422warp: at ss (1,0) this leaf's chroma is a SQUARE
13705+ // (side/2, side) block, so `side` chroma 4-px cells above it spread
13706+ // over `side` LUMA mi columns -- one chroma column per PAIR of luma
13707+ // mi cells, and both carry the covering unit's whole-unit dc sign.
13708+ // The per-mi rect gather therefore double-counts every chroma
13709+ // column's sign. `around_mi_422_chroma`'s every-second above-cell
13710+ // sampling is libaom's `txb_w_unit` sum, and every other 4:2:2 chroma
13711+ // gather in this file already routes through it (see the gate at this
13712+ // arm's siblings); this one did not, so a 4:2:2 rect leaf voted over
13713+ // luma unit counts. Measured on the pinned 4:2:2 rotzoom stream
13714+ // (a1.obu frame 0): the 16x8 leaf at mi(48,28) resolved its V plane's
13715+ // dc sign from vote 0 (`dc_sign_cdf[0]`) where the oracle resolves a
13716+ // negative vote (`dc_sign_cdf[1]`), which is the first bit-position
13717+ // divergence in the frame (the bit offset is a clean constant through
13718+ // coefficient unit 1418 and turns 6 bits at 1419). Luma keeps the
13719+ // per-mi gather; 4:2:0 and 4:4:4 keep the plain rect walk verbatim.
13720+ let mut around = neighbours.around_mi_rect(leaf_mi, bw, bh);
13721+ if chroma_422 {
13722+ let c = neighbours.around_mi_422_chroma(leaf_mi, bw, bh);
13723+ around[1] = c[1];
13724+ around[2] = c[2];
13725+ }
1370513726 let luma_set = if reduced_tx_set {
1370613727 TxbSet::LumaRect16x8
1370713728 } else {