forge
Explore
Log in

Don't you dare go Hollow

lane-av1422warp: gate the 32x16 strip reader's 4:2:2 chroma dc-sign vote

Browse files at this commit

b86686a78ba61f20dd9a9020a5d02fee3d18835eAhmet Kaan GümüşParent: e998e97
decode_block_rect built its chroma vote with `around_rect` and no 4:2:2
rerouting -- the sibling decode_leaf_rect, which lane's round-6 fix
gated, was not. At ss (1,0) that strip's chroma is a square (side/2, side)
block whose above cells spread over `side` LUMA mi columns, so the per-mi
rect gather double-counts every chroma column's whole-unit dc sign.

Found with the EC_SYMR sequence diff (see the report): of 46260 symbol
reads on a1_f0.obu, reads 0..45259 pair EXACTLY on value, range, CDF row
(32768 - ours == oracle), alphabet, symbol and post-read range, and read
45260 is the first divergence -- the chroma-U 4x4 transform of the 32x16
strip at mi(68,16), whose DC sign this decoder reads from dc_sign_ctx 1
where libaom reads row 0. Same position, same symbol, same bits, different
row: the signature the ladder cannot see.

After the fix all 46260 reads match at state level (the only residual
difference is the `bit` field over the last 17 reads, which is the
reference's own buffer-end tell convention). Frame 0 is PIXEL-EXACT
against aomdec for the first time on this stream; the 16-frame measure
goes 0/16 -> 3/16 frames exact and 1619115 -> 1332125 differing samples.

Identity, all four unchanged: the 4:2:0 control a420.obu byte-identical to
aomdec --rawvideo; 444_sb128rect_lr_witness.obu byte-identical to the
pre-lane build; pinned 422_allskip_2f.obu and 422_sb128_3f.obu still
pixel-exact against aomdec. The gate is ss (1,0), so 4:2:0 and 4:4:4
never reach the sampler.

Also restores EC_SYMR in SymbolDecoder::symbol (msac.rs), which an earlier
`git checkout` in this lane had wiped along with the oracle's copy; the
format follows skill ec-av1-consumption-gap-symr Step 3.
crates/ec-av1/src/decode.rsmodified+22 -1
@@ -13256,7 +13256,28 @@ fn decode_block_rect(
13256 // --enable-tx-size-search=0 the encoder writes no such symbol, so the13256 // --enable-tx-size-search=0 the encoder writes no such symbol, so the
13257 // decoder consumed one that was never there.13257 // decoder consumed one that was never there.
13258 {13258 {
13259- let around = neighbours.around_rect(at, bw, bh);13259+ // lane-av1422warp r20: this 32x16/16x32 strip reader is the SIBLING of
13260+ // `decode_leaf_rect`, and it was the one left ungated: at ss (1,0) the
13261+ // strip's chroma is a square (side/2, side) block whose above cells
13262+ // spread over `side` LUMA mi columns, so the per-mi rect gather
13263+ // double-counts every chroma column's whole-unit dc sign. Measured on
13264+ // the pinned 4:2:2 rotzoom stream (a1.obu frame 0): the chroma-U 4x4
13265+ // transform of the 32x16 strip at mi(68,16) reads its DC sign from
13266+ // `dc_sign_ctx` 1 where libaom reads row 0 -- the first read of
13267+ // 45260 whose pre-state, bit position and symbol all match and only
13268+ // the CDF row differs, and the first divergence in the EC_SYMR
13269+ // sequence (all 45259 reads before it pair exactly). Luma keeps the
13270+ // per-mi gather; 4:2:0 and 4:4:4 keep the plain rect walk verbatim.
13271+ let mut around = neighbours.around_rect(at, bw, bh);
13272+ if ss_x(fctx) == 1 && ss_y(fctx) == 0 {
13273+ let c2 = neighbours.around_mi_422_chroma(
13274+ (at.0 * (SUB / MI), at.1 * (SUB / MI)),
13275+ bw,
13276+ bh,
13277+ );
13278+ around[1] = c2[1];
13279+ around[2] = c2[2];
13280+ }
13260 let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, fi_tx_row(mode, filter_intra));13281 let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, fi_tx_row(mode, filter_intra));
13261 let (luma_levels, luma_tx_type) = read_coeffs_rect(13282 let (luma_levels, luma_tx_type) = read_coeffs_rect(
13262 dec,13283 dec,
crates/ec-av1/src/msac.rsmodified+22 -0
@@ -396,8 +396,18 @@ impl<'a> SymbolDecoder<'a> {
396 }396 }
397 397
398 /// `decode_symbol` (spec 8.2.6), with the adaptation of 8.3.2.398 /// `decode_symbol` (spec 8.2.6), with the adaptation of 8.3.2.
399+ ///
400+ /// `EC_SYMR=1` dumps every symbol read's PRE state (before the read and
401+ /// before the adaptation) together with the symbol and the post-read
402+ /// range, so a divergence against a reference decoder can be bisected
403+ /// read by read. `cdf0` is the PRE-adapt row[0] -- the reference's own
404+ /// print of the same row is POST-adapt, so compare `32768 - ours_cdf0`
405+ /// against its `cdf0`, never the raw numbers.
399 #[inline]406 #[inline]
400 pub fn symbol(&mut self, cdf: &mut [u16]) -> usize {407 pub fn symbol(&mut self, cdf: &mut [u16]) -> usize {
408+ let symr = std::env::var_os("EC_SYMR").is_some();
409+ let (pre_value, pre_range, pre_bit) = (self.value, self.range, self.bit);
410+ let pre_cdf0 = cdf.first().copied().unwrap_or(0);
401 // lane-census: the syntax census charges this symbol's bits to the411 // lane-census: the syntax census charges this symbol's bits to the
402 // TABLE it read, so every coding tool is accounted without a412 // TABLE it read, so every coding tool is accounted without a
403 // per-call-site label. Off (`EC_AV1_BITCENSUS` unset) this is one413 // per-call-site label. Off (`EC_AV1_BITCENSUS` unset) this is one
@@ -419,6 +429,18 @@ impl<'a> SymbolDecoder<'a> {
419 if crate::census::armed() {429 if crate::census::armed() {
420 crate::census::charge(cdf.as_ptr() as usize, self.tell_bits() - t0);430 crate::census::charge(cdf.as_ptr() as usize, self.tell_bits() - t0);
421 }431 }
432+ if symr {
433+ eprintln!(
434+ "EC_SYMR pre=({},{},{}) cdf0={} n={} s={} post_rng={}",
435+ pre_value,
436+ pre_range,
437+ pre_bit,
438+ pre_cdf0,
439+ cdf.len() - 1,
440+ s,
441+ self.range
442+ );
443+ }
422 s444 s
423 }445 }
424 446