lane-av1422warp: gate the 32x16 strip reader's 4:2:2 chroma dc-sign vote
Browse files at this commitb86686a78ba61f20dd9a9020a5d02fee3d18835eParent: e998e972 changed files +44 -1
- crates/ec-av1/src/decode.rs +22 -1
- crates/ec-av1/src/msac.rs +22 -0
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 the | 13256 | // --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 the | 411 | // lane-census: the syntax census charges this symbol's bits to the |
| 402 | // TABLE it read, so every coding tool is accounted without a | 412 | // TABLE it read, so every coding tool is accounted without a |
| 403 | // per-call-site label. Off (`EC_AV1_BITCENSUS` unset) this is one | 413 | // 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 | s | 444 | s |
| 423 | } | 445 | } |
| 424 | 446 | ||