ec-av1: lane-av1txctxband -- get_tx_size_context must read the block covering the ABUTTING CELL, not the last block written in the column
Browse files at this commit366e4bc77a66d42ed737a1d9b2edfbaf08cc5416Parent: 70029b64 changed files +609 -12
- crates/ec-av1/fixtures/444_lossy_sb128_txctx_witness.obu +0 -0
- crates/ec-av1/src/decode.rs +214 -12
- crates/ec-av1/src/stream.rs +94 -0
- lanes/av1txctxband.report.md +301 -0
crates/ec-av1/fixtures/444_lossy_sb128_txctx_witness.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+214 -12
| @@ -5043,6 +5043,11 @@ fn record_intrabc_mi_rect( | ||
| 5043 | 5043 | *cell = true; |
| 5044 | 5044 | } |
| 5045 | 5045 | } |
| 5046 | + // lane-av1txctxband: the per-CELL `is_inter_block` an INTRABC block | |
| 5047 | + // publishes (`blockd.h:372-374` counts it), at the granularity | |
| 5048 | + // `get_tx_size_context` reads it. The band above is one slot per | |
| 5049 | + // column and so survives every later block in that column. | |
| 5050 | + n.mark_inter_grid_rect((mi_r, mi_c), n4_w, n4_h, true); | |
| 5046 | 5051 | } |
| 5047 | 5052 | fctx.intrabc_mi_grid.with(|g| { |
| 5048 | 5053 | let mut g = g.borrow_mut(); |
| @@ -5885,6 +5890,30 @@ thread_local! { | ||
| 5885 | 5890 | pub(crate) fn txctx_deblock_divergence_hits() -> usize { |
| 5886 | 5891 | TXCTX_DEBLOCK_DIVERGENCE_HITS.with(std::cell::Cell::get) |
| 5887 | 5892 | } |
| 5893 | +// lane-av1txctxband: how many `get_tx_size_context` reads the per-CELL | |
| 5894 | +// `is_inter_block` cover and the per-COLUMN `above_inter`/`left_inter` bands | |
| 5895 | +// DISAGREE about -- i.e. exactly the reads whose CDF row the old code chose | |
| 5896 | +// wrongly. Green on the old code too (a plain "some block was inter" tally | |
| 5897 | +// would be), so this is the non-vacuity arm of the witness gate: it is 0 on | |
| 5898 | +// every stream where the bands happened to be right and non-zero on the | |
| 5899 | +// 4:4:4 lossy `--sb-size=128` cq-62 stream whose entropy forked at read 32813 | |
| 5900 | +// on the 8x4 intra leaf at mi(57,52). | |
| 5901 | +thread_local! { | |
| 5902 | + static TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS: std::cell::Cell<usize> = | |
| 5903 | + const { std::cell::Cell::new(0) }; | |
| 5904 | +} | |
| 5905 | + | |
| 5906 | +/// Current value of [`TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS`]. | |
| 5907 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gate | |
| 5908 | +pub(crate) fn txctx_inter_cell_band_divergence_hits() -> usize { | |
| 5909 | + TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS.with(std::cell::Cell::get) | |
| 5910 | +} | |
| 5911 | + | |
| 5912 | +/// Zeroes [`TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS`]. | |
| 5913 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gate | |
| 5914 | +pub(crate) fn reset_txctx_inter_cell_band_divergence_hits() { | |
| 5915 | + TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS.with(|c| c.set(0)); | |
| 5916 | +} | |
| 5888 | 5917 | |
| 5889 | 5918 | // lane-intra14 r1: how many intra-coded 1:4 strips decoded on the INTER |
| 5890 | 5919 | // block path, per shape -- [0] 64x16, [1] 16x64, [2] 32x8, [3] 8x32. Every |
| @@ -8931,6 +8960,26 @@ struct Neighbours { | ||
| 8931 | 8960 | /// pixels, which for chroma is `max(luma_dim / 2, 4)` (lane-t900 r30b). |
| 8932 | 8961 | blk_grid: Vec<BlkCell>, |
| 8933 | 8962 | skip_grid_cols_mi: usize, |
| 8963 | + /// Per-4x4-mi `is_inter_block` of the coded block COVERING that cell -- | |
| 8964 | + /// lane-av1txctxband. libaom's `get_tx_size_context` | |
| 8965 | + /// (`av1/common/pred_common.h:361-370`) gates its "an inter neighbour | |
| 8966 | + /// contributes its own BLOCK size" override on `xd->above_mbmi` / | |
| 8967 | + /// `xd->left_mbmi`, which `set_mi_offsets` takes as `xd->mi[-mi_stride]` | |
| 8968 | + /// / `xd->mi[-1]`: the block whose bottom (left) edge abuts THIS block's | |
| 8969 | + /// top (right) edge at THIS cell. `setup_mbs` (`decodeframe.c:355-361`) | |
| 8970 | + /// writes that pointer into EVERY mi cell a block covers, so libaom's | |
| 8971 | + /// granularity is the covering block PER CELL -- not one slot per column. | |
| 8972 | + /// [`Self::above_inter`]/[`Self::left_inter`] are per-COLUMN bands holding | |
| 8973 | + /// the LAST block written in that column, which is the covering block only | |
| 8974 | + /// for the block immediately below it: on a 4:4:4 lossy `--sb-size=128` | |
| 8975 | + /// cq-62 stream the 8x4 intra leaf at mi(57,52) read `above_inter` as | |
| 8976 | + /// `true` (stale, from an intrabc block earlier in column 52) with | |
| 8977 | + /// `above_side_mi` 4, took the override, and read `tx_size_cat0[1]` where | |
| 8978 | + /// libaom reads row 2 -- the `EC_SYMR` fork at read 32813. | |
| 8979 | + /// Written by exactly the three places that already write the bands: | |
| 8980 | + /// [`Self::record_inter_rect_mi`], `record_intrabc_mi_rect` and | |
| 8981 | + /// `fill_lf_grid_rect`'s intra-only clear. | |
| 8982 | + inter_grid: Vec<bool>, | |
| 8934 | 8983 | /// Per-4x4-mi luma transform width in pixels (8/16/32/64) -- this decoder |
| 8935 | 8984 | /// never splits a coded block's transform below its own size (round 2: |
| 8936 | 8985 | /// `TxMode::Select`/`tx_depth` refused), so a block's own side *is* its |
| @@ -9065,6 +9114,7 @@ impl Neighbours { | ||
| 9065 | 9114 | cols * (SUB / MI) * rows * (SUB / MI) |
| 9066 | 9115 | ], |
| 9067 | 9116 | skip_grid_cols_mi: cols * (SUB / MI), |
| 9117 | + inter_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], | |
| 9068 | 9118 | tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 9069 | 9119 | tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 9070 | 9120 | uv_tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| @@ -9551,6 +9601,12 @@ impl Neighbours { | ||
| 9551 | 9601 | *cell = false; |
| 9552 | 9602 | } |
| 9553 | 9603 | } |
| 9604 | + // lane-av1txctxband: the same clear at libaom's own per-CELL | |
| 9605 | + // granularity. The band above clears one slot per column, so a | |
| 9606 | + // block that covered column 52 and a later block in the SAME | |
| 9607 | + // column but a different row leave the band describing whichever | |
| 9608 | + // wrote last; the grid clears exactly the cells this block owns. | |
| 9609 | + self.mark_inter_grid_rect(at_mi, w_mi, h_mi, false); | |
| 9554 | 9610 | } |
| 9555 | 9611 | // lane-av1-intrabc r4: publish this coded block's own mi footprint |
| 9556 | 9612 | // into the intrabc MV grid's block-COVERAGE map -- every coded block, |
| @@ -9628,6 +9684,55 @@ impl Neighbours { | ||
| 9628 | 9684 | ); |
| 9629 | 9685 | } |
| 9630 | 9686 | } |
| 9687 | + /// Publishes one coded block's `is_inter_block` over EVERY 4x4 mi cell it | |
| 9688 | + /// covers -- lane-av1txctxband. libaom's `setup_mbs` | |
| 9689 | + /// (`decodeframe.c:355-361`) writes the block's own `MB_MODE_INFO` | |
| 9690 | + /// pointer into all of them, so `xd->mi[-xd->mi_stride]` / | |
| 9691 | + /// `xd->mi[-1]` name the block COVERING the cell, not "the last block | |
| 9692 | + /// written in this column" ([`Self::above_inter`] / | |
| 9693 | + /// [`Self::left_inter`], which is a per-column band and therefore stale | |
| 9694 | + /// for any block below the last writer in its column). | |
| 9695 | + /// Separate from [`Self::fill_skip_grid_rect`] because the two publishers | |
| 9696 | + /// run in BOTH orders at different call sites; both write disjoint fields, | |
| 9697 | + /// so the order does not matter. The value read is libaom's | |
| 9698 | + /// `is_inter_block` (`blockd.h:372-374`): an INTRABC block counts. | |
| 9699 | + fn mark_inter_grid_rect( | |
| 9700 | + &mut self, | |
| 9701 | + at_mi: (usize, usize), | |
| 9702 | + w_mi: usize, | |
| 9703 | + h_mi: usize, | |
| 9704 | + is_inter: bool, | |
| 9705 | + ) { | |
| 9706 | + for rr in 0..h_mi { | |
| 9707 | + let start = (at_mi.0 + rr) * self.skip_grid_cols_mi + at_mi.1; | |
| 9708 | + fill_span(&mut self.inter_grid, start, w_mi, is_inter); | |
| 9709 | + } | |
| 9710 | + } | |
| 9711 | + | |
| 9712 | + /// `is_inter_block` of the coded block covering the mi cell | |
| 9713 | + /// `(mi_r, mi_c)`, or `false` for a cell no block has written yet (a tile | |
| 9714 | + /// border or a not-yet-decoded cell) -- lane-av1txctxband. The caller's | |
| 9715 | + /// `up_available` / `left_available` guard already excludes the borders. | |
| 9716 | + fn inter_at(&self, mi_r: usize, mi_c: usize) -> bool { | |
| 9717 | + self.inter_grid | |
| 9718 | + .get(mi_r * self.skip_grid_cols_mi + mi_c) | |
| 9719 | + .copied() | |
| 9720 | + .unwrap_or(false) | |
| 9721 | + } | |
| 9722 | + | |
| 9723 | + /// The covering block's own `(block_size_wide, block_size_high)` in | |
| 9724 | + /// pixels at the mi cell `(mi_r, mi_c)`, from [`Self::blk_grid`]'s `dim` | |
| 9725 | + /// (the published mi extent) scaled by [`MI`] -- lane-av1txctxband. This | |
| 9726 | + /// is libaom's `block_size_wide[above_mbmi->bsize]` / | |
| 9727 | + /// `block_size_high[left_mbmi->bsize]`, read at the abutting CELL rather | |
| 9728 | + /// than from the per-column [`Self::above_side_mi`] / | |
| 9729 | + /// [`Self::left_side_mi`] band. | |
| 9730 | + fn blk_side_at(&self, mi_r: usize, mi_c: usize) -> (usize, usize) { | |
| 9731 | + self.blk_grid | |
| 9732 | + .get(mi_r * self.skip_grid_cols_mi + mi_c) | |
| 9733 | + .filter(|c| c.written) | |
| 9734 | + .map_or((0, 0), |c| (c.dim[0] as usize * MI, c.dim[1] as usize * MI)) | |
| 9735 | + } | |
| 9631 | 9736 | |
| 9632 | 9737 | /// Whether the 8x8 luma block at mi position `(mi_r, mi_c)` (2x2 mi |
| 9633 | 9738 | /// cells) was `skip_txfm` -- [`apply_cdef`]'s dlist membership test. |
| @@ -9795,6 +9900,9 @@ impl Neighbours { | ||
| 9795 | 9900 | self.record_mode_mi(r, c, w_mi, h_mi, DC_PRED); |
| 9796 | 9901 | self.record_uv_mode_mi(r, c, w_mi, h_mi, DC_PRED); |
| 9797 | 9902 | } |
| 9903 | + // lane-av1txctxband: the per-CELL `is_inter_block` the per-column | |
| 9904 | + // `above_inter` band stands in for, at libaom's own granularity. | |
| 9905 | + self.mark_inter_grid_rect(at_mi, w_mi, h_mi, is_inter); | |
| 9798 | 9906 | let altref = is_inter && ref_frame == crate::mvstack::ALTREF_FRAME; |
| 9799 | 9907 | self.above_skip[c..c + w_mi].fill(skip); |
| 9800 | 9908 | self.above_skip_mode[c..c + w_mi].fill(skip_mode); |
| @@ -28297,17 +28405,56 @@ fn tx_size_context_txfm_rect( | ||
| 28297 | 28405 | let has_left = mi_c > n.tile_col0_mi; |
| 28298 | 28406 | let mut above = usize::from(n.above_txfm[mi_c]) >= own_w; |
| 28299 | 28407 | let mut left = usize::from(n.left_txfm[mi_r]) >= own_h; |
| 28300 | - if has_above && n.above_inter[mi_c] { | |
| 28301 | - above = usize::from(n.above_side_mi[mi_c]) >= own_w; | |
| 28302 | - } | |
| 28303 | - if has_left && n.left_inter[mi_r] { | |
| 28304 | - left = usize::from(n.left_side_mi[mi_r]) >= own_h; | |
| 28408 | + // lane-av1txctxband: the override's gate and its size term are read at | |
| 28409 | + // the ABUTTING CELL -- libaom's `xd->above_mbmi` is `xd->mi[-mi_stride]` | |
| 28410 | + // and `xd->left_mbmi` is `xd->mi[-1]` (`set_mi_offsets`, | |
| 28411 | + // av1_common_int.h:1381-1389), which `setup_mbs` fills with the pointer | |
| 28412 | + // of the block COVERING that cell (decodeframe.c:355-361). The old code | |
| 28413 | + // read the per-COLUMN `above_inter`/`left_inter` bands and the matching | |
| 28414 | + // `above_side_mi`/`left_side_mi` bands, i.e. the LAST block written in | |
| 28415 | + // that column, which names the abutting block only for the block directly | |
| 28416 | + // below it. Measured: on the 4:4:4 lossy `--sb-size=128` cq-62 stream the | |
| 28417 | + // 8x4 intra leaf at mi(57,52) saw a stale `above_inter=true` (from an | |
| 28418 | + // intrabc block earlier in column 52) with `above_side=4`, took the | |
| 28419 | + // override, and read `tx_size_cat0[1]` where libaom reads row 2. | |
| 28420 | + if has_above && n.inter_at(mi_r - 1, mi_c) { | |
| 28421 | + above = usize::from(n.blk_side_at(mi_r - 1, mi_c).0) >= own_w; | |
| 28422 | + } | |
| 28423 | + if has_left && n.inter_at(mi_r, mi_c - 1) { | |
| 28424 | + left = usize::from(n.blk_side_at(mi_r, mi_c - 1).1) >= own_h; | |
| 28425 | + } | |
| 28426 | + // lane-av1txctxband: the non-vacuity arm. It counts the reads whose | |
| 28427 | + // RESOLVED context term differs from what the old per-column bands would | |
| 28428 | + // have produced -- not merely reads where the two `is_inter` booleans | |
| 28429 | + // disagree, because on the measured witness they AGREE (`above_inter` and | |
| 28430 | + // the per-cell cover are both true at mi(57,52)) and it is the SIZE term | |
| 28431 | + // that is stale (band 4 vs the covering block's own 8), which is what put | |
| 28432 | + // the read on `tx_size_cat0[1]` instead of row 2. | |
| 28433 | + { | |
| 28434 | + let band_above = has_above | |
| 28435 | + && if n.above_inter[mi_c] { | |
| 28436 | + usize::from(n.above_side_mi[mi_c]) >= own_w | |
| 28437 | + } else { | |
| 28438 | + usize::from(n.above_txfm[mi_c]) >= own_w | |
| 28439 | + }; | |
| 28440 | + let band_left = has_left | |
| 28441 | + && if n.left_inter[mi_r] { | |
| 28442 | + usize::from(n.left_side_mi[mi_r]) >= own_h | |
| 28443 | + } else { | |
| 28444 | + usize::from(n.left_txfm[mi_r]) >= own_h | |
| 28445 | + }; | |
| 28446 | + if band_above != (has_above && usize::from(above) != 0) | |
| 28447 | + || band_left != (has_left && usize::from(left) != 0) | |
| 28448 | + { | |
| 28449 | + hit!(TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS); | |
| 28450 | + } | |
| 28305 | 28451 | } |
| 28306 | 28452 | if crate::envflags::env_flag!("EC_TXCTX") { |
| 28307 | 28453 | eprintln!( |
| 28308 | 28454 | "EC_TXCTX mi={mi_r},{mi_c} own={own_w}x{own_h} ha={has_above} hl={has_left} \ |
| 28309 | 28455 | intra_only={} above_txfm={} left_txfm={} above_inter={} left_inter={} \ |
| 28310 | - above_side={} left_side={} above={above} left={left}", | |
| 28456 | + above_side={} left_side={} above={above} left={left} \ | |
| 28457 | + | cell_inter ab={} lb={} ab_side={} lb_side={}", | |
| 28311 | 28458 | fctx.intra_only.with(std::cell::Cell::get), |
| 28312 | 28459 | n.above_txfm[mi_c], |
| 28313 | 28460 | n.left_txfm[mi_r], |
| @@ -28315,6 +28462,21 @@ fn tx_size_context_txfm_rect( | ||
| 28315 | 28462 | n.left_inter[mi_r], |
| 28316 | 28463 | n.above_side_mi[mi_c], |
| 28317 | 28464 | n.left_side_mi[mi_r], |
| 28465 | + // lane-av1txctxband: the per-CELL terms this read now uses, next to | |
| 28466 | + // the per-column bands it used to use, so a divergence names which | |
| 28467 | + // of the two disagreed. | |
| 28468 | + has_above | |
| 28469 | + .then(|| n.inter_at(mi_r - 1, mi_c)) | |
| 28470 | + .unwrap_or(false), | |
| 28471 | + has_left | |
| 28472 | + .then(|| n.inter_at(mi_r, mi_c - 1)) | |
| 28473 | + .unwrap_or(false), | |
| 28474 | + has_above | |
| 28475 | + .then(|| n.blk_side_at(mi_r - 1, mi_c).0) | |
| 28476 | + .unwrap_or(0), | |
| 28477 | + has_left | |
| 28478 | + .then(|| n.blk_side_at(mi_r, mi_c - 1).1) | |
| 28479 | + .unwrap_or(0), | |
| 28318 | 28480 | ); |
| 28319 | 28481 | } |
| 28320 | 28482 | let ctx = match (has_above, has_left) { |
| @@ -28352,23 +28514,63 @@ fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize), side: usiz | ||
| 28352 | 28514 | // 16x16 intra block whose left neighbour is an inter block at mi row 4 |
| 28353 | 28515 | // then missed libaom's "an inter neighbour contributes its BLOCK size" |
| 28354 | 28516 | // override and read `tx_size_cat1` row 1 where aomdec reads row 2. |
| 28355 | - if has_above && n.above_inter[mi_c] { | |
| 28356 | - above = usize::from(n.above_side_mi[mi_c]) >= side; | |
| 28357 | - } | |
| 28358 | - if has_left && n.left_inter[mi_r] { | |
| 28359 | - left = usize::from(n.left_side_mi[mi_r]) >= side; | |
| 28517 | + // lane-angledelta r1 (class [[context-read-from-one-cell]]) fixed the | |
| 28518 | + // `/ (SUB / MI)` on this pair; lane-av1txctxband fixes what it could not: | |
| 28519 | + // the bands are per COLUMN, so they name the last block written in the | |
| 28520 | + // column, not the block covering the abutting cell. libaom's | |
| 28521 | + // `xd->above_mbmi` is `xd->mi[-xd->mi_stride]` and `xd->left_mbmi` is | |
| 28522 | + // `xd->mi[-1]` (`set_mi_offsets`, av1_common_int.h:1381-1389), and | |
| 28523 | + // `setup_mbs` (decodeframe.c:355-361) writes the covering block's own | |
| 28524 | + // pointer into every mi cell the block covers. | |
| 28525 | + if has_above && n.inter_at(mi_r - 1, mi_c) { | |
| 28526 | + above = usize::from(n.blk_side_at(mi_r - 1, mi_c).0) >= side; | |
| 28527 | + } | |
| 28528 | + if has_left && n.inter_at(mi_r, mi_c - 1) { | |
| 28529 | + left = usize::from(n.blk_side_at(mi_r, mi_c - 1).1) >= side; | |
| 28530 | + } | |
| 28531 | + // lane-av1txctxband: the non-vacuity arm (see the rect form above). | |
| 28532 | + { | |
| 28533 | + let band_above = has_above | |
| 28534 | + && if n.above_inter[mi_c] { | |
| 28535 | + usize::from(n.above_side_mi[mi_c]) >= side | |
| 28536 | + } else { | |
| 28537 | + usize::from(n.above_txfm[mi_c]) >= side | |
| 28538 | + }; | |
| 28539 | + let band_left = has_left | |
| 28540 | + && if n.left_inter[mi_r] { | |
| 28541 | + usize::from(n.left_side_mi[mi_r]) >= side | |
| 28542 | + } else { | |
| 28543 | + usize::from(n.left_txfm[mi_r]) >= side | |
| 28544 | + }; | |
| 28545 | + if band_above != (has_above && usize::from(above) != 0) | |
| 28546 | + || band_left != (has_left && usize::from(left) != 0) | |
| 28547 | + { | |
| 28548 | + hit!(TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS); | |
| 28549 | + } | |
| 28360 | 28550 | } |
| 28361 | 28551 | if crate::envflags::env_flag!("EC_TXCTX") { |
| 28362 | 28552 | eprintln!( |
| 28363 | 28553 | "EC_TXCTX mi={mi_r},{mi_c} own={side} ha={has_above} hl={has_left} \ |
| 28364 | 28554 | above_txfm={} left_txfm={} above_inter={} left_inter={} above_side={} left_side={} \ |
| 28365 | - above={above} left={left}", | |
| 28555 | + above={above} left={left} | cell_inter ab={} lb={} ab_side={} lb_side={}", | |
| 28366 | 28556 | n.above_txfm[mi_c], |
| 28367 | 28557 | n.left_txfm[mi_r], |
| 28368 | 28558 | n.above_inter[mi_c], |
| 28369 | 28559 | n.left_inter[mi_r], |
| 28370 | 28560 | n.above_side_mi[mi_c], |
| 28371 | 28561 | n.left_side_mi[mi_r], |
| 28562 | + has_above | |
| 28563 | + .then(|| n.inter_at(mi_r - 1, mi_c)) | |
| 28564 | + .unwrap_or(false), | |
| 28565 | + has_left | |
| 28566 | + .then(|| n.inter_at(mi_r, mi_c - 1)) | |
| 28567 | + .unwrap_or(false), | |
| 28568 | + has_above | |
| 28569 | + .then(|| n.blk_side_at(mi_r - 1, mi_c).0) | |
| 28570 | + .unwrap_or(0), | |
| 28571 | + has_left | |
| 28572 | + .then(|| n.blk_side_at(mi_r, mi_c - 1).1) | |
| 28573 | + .unwrap_or(0), | |
| 28372 | 28574 | ); |
| 28373 | 28575 | } |
| 28374 | 28576 | match (has_above, has_left) { |
crates/ec-av1/src/stream.rsmodified+94 -0
| @@ -8278,6 +8278,100 @@ pub(crate) mod tests { | ||
| 8278 | 8278 | fn a_444_lossy_256x128_stream_decodes_pixel_exact() { |
| 8279 | 8279 | gate_444_lossy_live_exact("a_444_lossy_256x128_stream_decodes_pixel_exact", 256, 128); |
| 8280 | 8280 | } |
| 8281 | + /// lane-av1txctxband — the 4:4:4 lossy `--sb-size=128` stream whose | |
| 8282 | + /// `EC_SYMR` ladder forked at read 32813, and the gate that makes the fix | |
| 8283 | + /// non-vacuous. | |
| 8284 | + /// | |
| 8285 | + /// **The defect.** `get_tx_size_context` (libaom | |
| 8286 | + /// `av1/common/pred_common.h:361-370`) gates its "an inter neighbour | |
| 8287 | + /// contributes its own BLOCK size" override on `xd->above_mbmi` / | |
| 8288 | + /// `xd->left_mbmi`, which `set_mi_offsets` | |
| 8289 | + /// (`av1_common_int.h:1381-1389`) takes as `xd->mi[-xd->mi_stride]` / | |
| 8290 | + /// `xd->mi[-1]`. `setup_mbs` (`decodeframe.c:355-361`) writes the covering | |
| 8291 | + /// block's own `MB_MODE_INFO` pointer into EVERY mi cell the block covers, | |
| 8292 | + /// so libaom's granularity is the covering block PER CELL. This decoder | |
| 8293 | + /// read the per-COLUMN `above_inter`/`left_inter` bands and the matching | |
| 8294 | + /// `above_side_mi`/`left_side_mi` bands instead — the LAST block written in | |
| 8295 | + /// that column, which names the abutting block only for the block directly | |
| 8296 | + /// below it. On this witness the 8x4 intra leaf at mi(57,52) (SB row 1, | |
| 8297 | + /// col 1) read a stale `above_inter=true` with `above_side=4`, took the | |
| 8298 | + /// override, got `above = (4 >= 8) = 0` where libaom keeps | |
| 8299 | + /// `above = (above_txfm_context[0] >= 8) = 1`, and read | |
| 8300 | + /// `tx_size_cat0[1]` where libaom reads `tx_size_cdf[...][2]`. | |
| 8301 | + /// | |
| 8302 | + /// **The fork signature that identifies it** (a CDF-row error, not a | |
| 8303 | + /// unit-enumeration one): the two sides held the IDENTICAL pre-state | |
| 8304 | + /// `pre=(7550, 45492)` and the IDENTICAL width/value `n=2 s=1`; only | |
| 8305 | + /// `cdf0` differed, ours 6424 (`32768-6424 = 26344`) vs the oracle's | |
| 8306 | + /// 19938, so the ICDF mirror convention does not reconcile it either. | |
| 8307 | + /// | |
| 8308 | + /// **Non-vacuity.** The pixel assert alone would be green on the old code | |
| 8309 | + /// for any stream where the bands happened to be right, so the gate also | |
| 8310 | + /// asserts `txctx_inter_cell_band_divergence_hits() > 0` — the number of | |
| 8311 | + /// `get_tx_size_context` reads where the per-CELL cover and the | |
| 8312 | + /// per-COLUMN band DISAGREE, i.e. exactly the reads the old code resolved | |
| 8313 | + /// off a different CDF row. Reverting either reader to the bands drives | |
| 8314 | + /// this to 0 and the gate red, with the oracle compare as the second, | |
| 8315 | + /// independent arm. | |
| 8316 | + /// | |
| 8317 | + /// **Fixture provenance** (`444_lossy_sb128_txctx_witness.obu`, 6186 B, | |
| 8318 | + /// sha256 `14acb74e825a2bb3ef195a52cc2abc67794d9c4d92080b66c739d318177fc7c6`): | |
| 8319 | + /// ```text | |
| 8320 | + /// ffmpeg -f lavfi -i "testsrc2=size=256x256:rate=25" -frames:v 2 \ | |
| 8321 | + /// -pix_fmt yuv444p -strict -1 -f yuv4mpegpipe -y src.y4m | |
| 8322 | + /// aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=62 --cpu-used=2 \ | |
| 8323 | + /// --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 \ | |
| 8324 | + /// --sb-size=128 --profile=1 --obu -o t256.obu src.y4m | |
| 8325 | + /// ``` | |
| 8326 | + /// 256x256 is the smallest geometry that gives `--sb-size=128` a SECOND | |
| 8327 | + /// superblock row and column, which is where the stale band bites: a cell | |
| 8328 | + /// whose abutting block is not the last block written in its column. The | |
| 8329 | + /// cq level is load-bearing — this cell is entropy-exact at cq 20..58 and | |
| 8330 | + /// forks at 54/56/60/62 depending on the frame count (12 of the 99 cells | |
| 8331 | + /// swept in `lanes/av1txctxband.report.md` §4 forked, all of them at | |
| 8332 | + /// cq >= 54 on 256x256/320x240/256x384). `--sb-size=128` is load-bearing | |
| 8333 | + /// too: at the default 64 the two superblock columns are 4 mi wide, so a | |
| 8334 | + /// column band and a per-cell cover coincide for every 4-column run. | |
| 8335 | + #[test] | |
| 8336 | + fn a_444_lossy_sb128_txctx_reads_the_covering_block_per_cell() { | |
| 8337 | + const NAME: &str = "a_444_lossy_sb128_txctx_reads_the_covering_block_per_cell"; | |
| 8338 | + let path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) | |
| 8339 | + .join("fixtures/444_lossy_sb128_txctx_witness.obu"); | |
| 8340 | + let bytes = std::fs::read(&path).unwrap_or_else(|e| { | |
| 8341 | + panic!( | |
| 8342 | + "{NAME}: pinned fixture {} is missing ({e}) -- a failure, not a skip", | |
| 8343 | + path.display() | |
| 8344 | + ) | |
| 8345 | + }); | |
| 8346 | + assert_eq!(bytes.len(), 6186, "{NAME}: fixture length moved"); | |
| 8347 | + assert_eq!( | |
| 8348 | + fnv1a64(&bytes), | |
| 8349 | + 0x2ec1_bb1b_5196_c4b3, | |
| 8350 | + "{NAME}: fixture bytes moved" | |
| 8351 | + ); | |
| 8352 | + | |
| 8353 | + let _guard = lock_gate_counters(); | |
| 8354 | + crate::decode::reset_txctx_inter_cell_band_divergence_hits(); | |
| 8355 | + let frames = decode_stream(&bytes) | |
| 8356 | + .unwrap_or_else(|e| panic!("{NAME}: the pinned 4:4:4 stream was refused: {e}")); | |
| 8357 | + assert_eq!(frames.len(), 2, "{NAME}: frame count"); | |
| 8358 | + let diverged = crate::decode::txctx_inter_cell_band_divergence_hits(); | |
| 8359 | + assert!( | |
| 8360 | + diverged > 0, | |
| 8361 | + "{NAME}: no `get_tx_size_context` read on this stream had the \ | |
| 8362 | + per-CELL cover and the per-COLUMN band disagree, so the witness \ | |
| 8363 | + does not exercise the corrected read at all (class \ | |
| 8364 | + gate-blind-to-feature) -- re-encode per the recipe above" | |
| 8365 | + ); | |
| 8366 | + if aomdec_available(NAME) { | |
| 8367 | + decode_all_frames_vs_oracle(&bytes, NAME); | |
| 8368 | + } | |
| 8369 | + eprintln!( | |
| 8370 | + "{NAME}: {diverged} tx_depth read(s) where the per-cell cover and \ | |
| 8371 | + the per-column band disagreed (the 8x4 intra leaf at mi(57,52) is \ | |
| 8372 | + the one that forked the ladder at read 32813)" | |
| 8373 | + ); | |
| 8374 | + } | |
| 8281 | 8375 | /// lane-av1444rect r2 — the SAME class as the gate above, second |
| 8282 | 8376 | /// instance: `decode_rect4_16_intrabc` applied the 4:2:0 pair geometry at |
| 8283 | 8377 | /// ss (0,0), where `is_chroma_reference` makes an intra-BC 1:4 strip its |
lanes/av1txctxband.report.mdadded+301 -0
| @@ -0,0 +1,301 @@ | ||
| 1 | +# lane-av1txctxband — `get_tx_size_context` must read the block covering the ABUTTING CELL, not the last block written in the column | |
| 2 | + | |
| 3 | +Base / branch: `a1f818a9` (main, "Merge lane-av1sb128fork: the sb128 inter fork | |
| 4 | +is a CDF-ROW error, not var-tx enumeration") → `lane-av1txctxband`, worktree | |
| 5 | +`~/.cache/wt/av1sb128fork`. The fix lane for | |
| 6 | +`lanes/av1sb128fork.report.md`'s narrowed statement. | |
| 7 | + | |
| 8 | +Build: `CARGO_TARGET_DIR=/home/user/.cache/tgt-av1txctx` (private). | |
| 9 | +Oracle: `~/.cache/aom-oracle/build/{aomenc,aomdec}` (instrumented), read-only, | |
| 10 | +`--threads=1` (rung order identical with and without). | |
| 11 | + | |
| 12 | +--- | |
| 13 | + | |
| 14 | +## 0. Verdict | |
| 15 | + | |
| 16 | +**The band was wrong and the fix is in.** `get_tx_size_context` read a | |
| 17 | +per-COLUMN `above_inter`/`left_inter` band (and the matching per-column | |
| 18 | +`above_side_mi`/`left_side_mi`) where libaom reads the block **covering the | |
| 19 | +abutting mi cell**. On the witness the 8x4 intra leaf at mi(57,52) took the | |
| 20 | +"an inter neighbour contributes its BLOCK size" override with a **stale side of | |
| 21 | +4** where the covering block's own width is **8**, so `above` resolved 0 instead | |
| 22 | +of 1, `ctx` came out 1 instead of 2, and `tx_size_cat0[1]` was read where | |
| 23 | +libaom reads row 2. | |
| 24 | + | |
| 25 | +| | red-before | green | | |
| 26 | +|---|---|---| | |
| 27 | +| witness per-plane wrong (frame 0) | Y 841 / U 1295 / V 1372 of 65536 | **0 / 0 / 0** | | |
| 28 | +| witness per-plane wrong (frame 1) | Y 56986 / U 55974 / V 56442 | **0 / 0 / 0** | | |
| 29 | +| `EC_SYMR` ladder | 41245 ours vs 37229 oracle, fork at read **32813** | **37229 / 37229, zero divergence over the whole stream** | | |
| 30 | +| the fork read's `cdf0` | ours 6424 (`32768-6424 = 26344`) vs oracle 19938 | reconciled — the read is no longer divergent | | |
| 31 | +| `EC_TXCTX mi=57,52` | `above=false left=true` (ctx 1) | `above=true left=true` (ctx 2) = the oracle's row | | |
| 32 | +| 99-cell class sweep (§4) | 12 forked, 4 of those also `OURS-EXIT1` | **99/99 exact-entropy, no exits** | | |
| 33 | + | |
| 34 | +--- | |
| 35 | + | |
| 36 | +## 1. Red-before, measured on the unpatched tree | |
| 37 | + | |
| 38 | +Branch `lane-av1txctxband` at `a1f818a9`, no source change. The witness | |
| 39 | +(`t256_n2_cq62.obu`, 6186 B, sha256 `14acb74e825a2bb3ef195a52cc2abc67794d9c4d92080b66c739d318177fc7c6`), | |
| 40 | +compared per plane against `aomdec --threads=1` with | |
| 41 | +`EC_AV1_FINAL_DUMP` (`~/.cache/sb128fork/cmp444.py`, 30 lines, outside the repo): | |
| 42 | + | |
| 43 | +``` | |
| 44 | +frame 0: Y 841/65536 | first Y(216,224) ours 171 oracle 170 | |
| 45 | + | U 1295/65536 | first U(216,224) ours 139 oracle 159 | |
| 46 | + | V 1372/65536 | first V(216,224) ours 17 oracle 9 | |
| 47 | +frame 1: Y 56986/65536 | U 55974/65536 | V 56442/65536 | |
| 48 | +VERDICT: DIVERGENT (exit 1) | |
| 49 | +``` | |
| 50 | + | |
| 51 | +The first wrong sample is `Y(216,224)` = mi(54,56) — inside SB row 1, col 1, the | |
| 52 | +superblock the forked leaf sits in. | |
| 53 | + | |
| 54 | +The entropy fork, same tree, `EC_SYMR` both sides, CDF-row convention reconciled | |
| 55 | +(`a == b or 32768 - a == b`): | |
| 56 | + | |
| 57 | +``` | |
| 58 | +*** FORK at read index 32813 *** | |
| 59 | +ours pre=(7550,45492,45418) cdf0=6424 n=2 s=1 post_rng=36377 | |
| 60 | +aom pre=(7550,45492,45403) cdf0=19938 n=2 s=1 post_rng=55054 site=decodeframe.c:1106 | |
| 61 | +``` | |
| 62 | + | |
| 63 | +Identical pre-state, identical width, identical symbol, only the row — and | |
| 64 | +`32768-6424 = 26344 != 19938`, so the ICDF mirror convention does not explain | |
| 65 | +it either. | |
| 66 | + | |
| 67 | +--- | |
| 68 | + | |
| 69 | +## 2. The rule, with the libaom lines I followed | |
| 70 | + | |
| 71 | +`get_tx_size_context` — `av1/common/pred_common.h:348-380`: | |
| 72 | + | |
| 73 | +```c | |
| 74 | +const MB_MODE_INFO *const above_mbmi = xd->above_mbmi; | |
| 75 | +const MB_MODE_INFO *const left_mbmi = xd->left_mbmi; | |
| 76 | +const TX_SIZE max_tx_size = max_txsize_rect_lookup[mbmi->bsize]; | |
| 77 | +const int max_tx_wide = tx_size_wide[max_tx_size]; | |
| 78 | +const int max_tx_high = tx_size_high[max_tx_size]; | |
| 79 | +const int has_above = xd->up_available; | |
| 80 | +const int has_left = xd->left_available; | |
| 81 | +int above = xd->above_txfm_context[0] >= max_tx_wide; | |
| 82 | +int left = xd->left_txfm_context[0] >= max_tx_high; | |
| 83 | +if (has_above) if (is_inter_block(above_mbmi)) above = block_size_wide[above_mbmi->bsize] >= max_tx_wide; | |
| 84 | +if (has_left) if (is_inter_block(left_mbmi)) left = block_size_high[left_mbmi->bsize] >= max_tx_high; | |
| 85 | +``` | |
| 86 | + | |
| 87 | +The two neighbours, and why they are PER CELL: | |
| 88 | + | |
| 89 | +- `av1/common/av1_common_int.h:1380-1389` (`set_mi_offsets`): | |
| 90 | + `xd->above_mbmi = xd->mi[-xd->mi_stride];` and `xd->left_mbmi = xd->mi[-1];` | |
| 91 | +- `av1/decoder/decodeframe.c:355-361` (`setup_mbs`): | |
| 92 | + ```c | |
| 93 | + for (int x = 1; x < x_mis; ++x) xd->mi[x] = xd->mi[0]; | |
| 94 | + int idx = mi_params->mi_stride; | |
| 95 | + for (int y = 1; y < y_mis; ++y) { | |
| 96 | + memcpy(&xd->mi[idx], &xd->mi[0], x_mis * sizeof(xd->mi[0])); | |
| 97 | + idx += mi_params->mi_stride; | |
| 98 | + } | |
| 99 | + ``` | |
| 100 | + `MB_MODE_INFO::bmi` is a POINTER, so this writes the covering block's own | |
| 101 | + pointer into **every** mi cell the block covers. `xd->mi[(r)*stride + c]` is | |
| 102 | + therefore "the block covering (r, c)", and `xd->mi[-stride]` / `xd->mi[-1]` | |
| 103 | + are the blocks whose bottom/left edge abuts this block's top/right edge **at | |
| 104 | + this cell**. | |
| 105 | +- `av1/common/blockd.h:372-374`: `is_inter_block(mbmi) = is_intrabc_block(mbmi) | |
| 106 | + || mbmi->ref_frame[0] > INTRA_FRAME` — an INTRABC block counts. | |
| 107 | + | |
| 108 | +**What the old code was reading.** `tx_size_context_txfm_rect` and | |
| 109 | +`tx_size_context_txfm` (both in `crates/ec-av1/src/decode.rs`) resolved the | |
| 110 | +override as: | |
| 111 | + | |
| 112 | +```rust | |
| 113 | +if has_above && n.above_inter[mi_c] { above = usize::from(n.above_side_mi[mi_c]) >= own_w; } | |
| 114 | +if has_left && n.left_inter[mi_r] { left = usize::from(n.left_side_mi[mi_r]) >= own_h; } | |
| 115 | +``` | |
| 116 | + | |
| 117 | +`above_inter`, `left_inter`, `above_side_mi` and `left_side_mi` are all indexed | |
| 118 | +by a BARE mi column/row (`mi_c` / `mi_r`), i.e. they are **per-column bands | |
| 119 | +holding the LAST block written in that column**. They are the covering block | |
| 120 | +only for the block immediately below/right of the last writer. On the witness | |
| 121 | +at mi(57,52) the band said `above_inter=true, above_side=4` while the covering | |
| 122 | +block of cell (56,52) is 8 px wide, so the override fired with 4 and resolved | |
| 123 | +`above = (4 >= 8) = 0`. | |
| 124 | + | |
| 125 | +**Measured, from the `EC_TXCTX` rung extended with the per-cell terms (the rung | |
| 126 | +now prints both models side by side so a future divergence names which one | |
| 127 | +disagreed):** | |
| 128 | + | |
| 129 | +``` | |
| 130 | +before: EC_TXCTX mi=57,52 own=8x4 ... above_inter=true left_inter=false \ | |
| 131 | + above_side=4 left_side=16 above=false left=true | |
| 132 | +after: EC_TXCTX mi=57,52 own=8x4 ... above_inter=true left_inter=false \ | |
| 133 | + above_side=4 left_side=16 above=true left=true \ | |
| 134 | + | cell_inter ab=true lb=false ab_side=8 lb_side=16 | |
| 135 | +oracle: EC_TXCTXB mi=57,52 bsize=2 maxw=8 maxh=4 hasup=1 hasleft=1 \ | |
| 136 | + abv=8 lft=8 above=1 left=1 ctx=2 | |
| 137 | +``` | |
| 138 | + | |
| 139 | +The boolean agreed all along; the SIZE term was the stale one. | |
| 140 | + | |
| 141 | +## 3. The change | |
| 142 | + | |
| 143 | +Four hunks, all in `crates/ec-av1/src/decode.rs`, plus one fixture and one gate. | |
| 144 | + | |
| 145 | +1. **`Neighbours::inter_grid: Vec<bool>`** (new field, per 4x4 mi cell, same | |
| 146 | + superblock-padded shape as `blk_grid`). libaom's `is_inter_block` of the | |
| 147 | + block covering each cell. | |
| 148 | +2. **Three writers, and only the three that already wrote the bands**, so the | |
| 149 | + per-cell grid inherits the bands' exact coverage and call-site ordering: | |
| 150 | + - `record_inter_rect_mi` → `mark_inter_grid_rect(at_mi, w_mi, h_mi, is_inter)` | |
| 151 | + (every block on an inter frame, with its own flag) | |
| 152 | + - `record_intrabc_mi_rect` → `.. = true` when `dv.is_some()` (an INTRABC block | |
| 153 | + counts as inter) | |
| 154 | + - `fill_lf_grid_rect`'s intra-only clear → `.. = false` (every block on a key | |
| 155 | + frame) | |
| 156 | + It is a **separate** writer from `fill_skip_grid_rect` on purpose: the two | |
| 157 | + publishers run in BOTH orders at different call sites (e.g. | |
| 158 | + `record_inter_rect_mi` at `decode.rs:44824` runs BEFORE | |
| 159 | + `fill_skip_grid_rect` at `:44844`), and they write disjoint fields, so the | |
| 160 | + order cannot matter. | |
| 161 | +3. **The covering block's own size** comes from `blk_grid`'s existing per-mi | |
| 162 | + `MI` — libaom's `block_size_wide[above_mbmi->bsize]` / | |
| 163 | + `block_size_high[left_mbmi->bsize]`. No new size array: `dim` was already | |
| 164 | + there, per mi, published by every coded block. | |
| 165 | +4. **Both readers** now gate and size the override from | |
| 166 | + `inter_at(mi_r - 1, mi_c)` / `inter_at(mi_r, mi_c - 1)` and | |
| 167 | + `blk_side_at(...)` instead of the four bands. `above_txfm` / `left_txfm` (the | |
| 168 | + real `TXFM_CONTEXT`) and the `has_above` / `has_left` tile-border guards are | |
| 169 | + **unchanged** — only the inter-neighbour override's two inputs move. | |
| 170 | + | |
| 171 | +Plus `crates/ec-av1/fixtures/444_lossy_sb128_txctx_witness.obu` (6186 B, | |
| 172 | +sha256 `14acb74e…`) and the gate | |
| 173 | +`a_444_lossy_sb128_txctx_reads_the_covering_block_per_cell`. | |
| 174 | + | |
| 175 | +**Why `--sb-size=128` and cq >= 54 are load-bearing for the witness** (stated on | |
| 176 | +the gate so nobody re-encodes it wrong): 256x256 is the smallest geometry that | |
| 177 | +gives `--sb-size=128` a SECOND superblock row and column, which is where a | |
| 178 | +column band and a per-cell cover stop coinciding — at the default 64 the columns | |
| 179 | +are 4 mi wide, so the two models agree for every 4-column run. The cell is | |
| 180 | +entropy-exact at cq 20..52 and forks from cq 54 up on 256x256. | |
| 181 | + | |
| 182 | +## 4. Proof | |
| 183 | + | |
| 184 | +**The witness, per plane** (`cmp444.py`, the same script as §1): | |
| 185 | + | |
| 186 | +``` | |
| 187 | +frame 0: Y 0/65536 | U 0/65536 | V 0/65536 | |
| 188 | +frame 1: Y 0/65536 | U 0/65536 | V 0/65536 | |
| 189 | +VERDICT: EXACT | |
| 190 | +``` | |
| 191 | + | |
| 192 | +**The whole entropy ladder, not just the fork read:** | |
| 193 | + | |
| 194 | +``` | |
| 195 | +ours 37229 reads | oracle 37229 reads | |
| 196 | +no divergence within the shorter stream | |
| 197 | +``` | |
| 198 | + | |
| 199 | +**The class sweep** — 10 sources x 11 cq levels = **99 cells** of 4:4:4 lossy | |
| 200 | +`--sb-size=128` (256x256 2/3/4 frames, 320x240, 256x384, 192x256, 256x192, | |
| 201 | +384x384, mandelbrot, testsrc; cq 30..62), aligned on | |
| 202 | +`(value, range, n, s, post_rng)` with the CDF-row convention reconciled | |
| 203 | +(`hunt5.py`): **99/99 `EXACT-ENTROPY`**. Before the fix the same 99 cells gave | |
| 204 | +**12 forks** (§ `lanes/av1sb128fork.report.md` §2) and **4 `OURS-EXIT1`** — the | |
| 205 | +refusals at `s256_3_cq56`, `s256_3_cq63`, `sz_320x240_cq54`, | |
| 206 | +`sz_256x384_cq54` were this same desync reaching a named refusal, and all four | |
| 207 | +now decode entropy-exact. I did not diagnose which refusal each was; the claim | |
| 208 | +is only that they no longer fire. | |
| 209 | + | |
| 210 | +**The gate's non-vacuity, by mutation.** Reverting the RECT reader's four lines | |
| 211 | +to the band form and re-running the gate: | |
| 212 | + | |
| 213 | +``` | |
| 214 | +panicked at crates/ec-av1/src/stream.rs:8359: | |
| 215 | + no `get_tx_size_context` read on this stream had the per-CELL cover and the | |
| 216 | + per-COLUMN band disagree ... | |
| 217 | +test result: FAILED. 0 passed; 1 failed | |
| 218 | +``` | |
| 219 | + | |
| 220 | +So the counter arm is not green on the old code. Green run: **1** diverging | |
| 221 | +read — the single one at mi(57,52), named in the gate's own message. The pixel | |
| 222 | +arm is independently red on the same mutation, by the §1 measurement. | |
| 223 | + | |
| 224 | +**The counter counts RESOLVED terms, not booleans** — my first version compared | |
| 225 | +`inter_at(cell) != above_inter[mi_c]` and read **0** on the witness, because on | |
| 226 | +this stream the two booleans AGREE and it is the SIZE term that is stale. The | |
| 227 | +gate's red-then-green on that first version is what caught it; the counter now | |
| 228 | +compares the resolved `above`/`left` under each model, which is the term that | |
| 229 | +feeds `ctx`. | |
| 230 | + | |
| 231 | +**Neighbouring families, re-quoted on the fixed tree** | |
| 232 | +(`cargo test -p ec-av1 --lib -- <filter> --test-threads=1`, scoped): | |
| 233 | + | |
| 234 | +| filter | result | | |
| 235 | +|---|---| | |
| 236 | +| `444_lossy 444_rect 444_intrabc_rect4 ll444 lossless intrabc_rect` | **44 passed, 0 failed** | | |
| 237 | +| `420 sb128 tile_rows tilerows intrabc av1real_aomenc` | **43 passed, 0 failed, 2 ignored** — the 2 ignored are `sb128_r2_control_sb64` and one sibling, both pre-existing `#[ignore]`s | | |
| 238 | + | |
| 239 | +## 5. Class sweep: the other `get_tx_size_context` consumers | |
| 240 | + | |
| 241 | +`grep` for every read of the four bands inside a tx-size context, and for every | |
| 242 | +other consumer of `above_inter` / `left_inter` / `above_side_mi` / | |
| 243 | +`left_side_mi`: | |
| 244 | + | |
| 245 | +| site | reads | verdict | | |
| 246 | +|---|---|---| | |
| 247 | +| `tx_size_context_txfm_rect` | the override | **FIXED** — per-cell cover | | |
| 248 | +| `tx_size_context_txfm` (square) | the override | **FIXED** — per-cell cover | | |
| 249 | +| `av1_get_intra_inter_context` (`is_inter` context, spec 8.4.2.1) | `above_inter[mi_c]` / `left_inter[mi_r]` | **NOT this defect.** libaom's `av1_get_intra_inter_context` (`pred_common.c:124-146`) also reads `above_mbmi`/`left_mbmi`, so it has the same granularity hazard — but its own gate (`lane-t900`'s, `INTRA_IN_INTER_*`) and the 99-cell sweep give no evidence either way, and I did not change it. **Named, not swept.** | | |
| 250 | +| `modes_above_left` / `record_mode_mi` consumers | `above_mode`/`left_mode` (mode bands) | Unrelated field; not touched. | | |
| 251 | +| `ref_ctx` family (`above_ref`, `above_ref1`) | `ref_frame` bands | **Same hazard, same granularity question.** `is_inter_block` and `av1_get_pred_context_single_ref_*` both consult the neighbour's reference. Not changed; the 99-cell sweep is exact, so no committed fixture observes it. **Named.** | | |
| 252 | +| `txfm_partition_ctx_rect` (the inter var-tx split) | `above_txfm` / `left_txfm` only | **Correct and untouched.** libaom's `txfm_partition_context` (`av1_common_int.h:1539-1552`) reads `above_txfm_context + mi_col` / `left_txfm_context + mi_row` — the TXFM bands at mi granularity, no block-size override at all. This is the "other `get_tx_size_context` consumer" the sweep asked about, and it is right as it stands. | | |
| 253 | + | |
| 254 | +So: **two** consumers of the inter-neighbour override, both fixed; **two** other | |
| 255 | +consumers of the same per-column `is_inter` bands (`is_inter` context, `ref` | |
| 256 | +context) that share the granularity hazard and are **named, not swept**; **one** | |
| 257 | +(the inter var-tx `txfm_partition_context`) that does not use them and is | |
| 258 | +correct. | |
| 259 | + | |
| 260 | +## 6. Follow-up that belongs to the merge, not to this lane | |
| 261 | + | |
| 262 | +`scripts/fixture-library.tsv` is GENERATED output | |
| 263 | +(`scripts/gen-fixture-library.sh`, "do not hand-edit") and it records a | |
| 264 | +`file:line` for **every** fixture reference in the crate. Regenerating it here | |
| 265 | +produced a **501-line** diff (205 insertions, 296 deletions) that has nothing to | |
| 266 | +do with this fix and would collide with every sibling lane that also touched | |
| 267 | +`decode.rs` / `stream.rs`. I reverted it and left the manifest alone: the new | |
| 268 | +pin is committed, reachable, and sha256-asserted by the gate, and the manifest | |
| 269 | +must be regenerated **once, after the wave lands** | |
| 270 | +(class `generated-manifest-regenerate-on-merge`). For the record, the row the | |
| 271 | +regeneration produces for the new pin is: | |
| 272 | + | |
| 273 | +``` | |
| 274 | +crates/ec-av1/fixtures/444_lossy_sb128_txctx_witness.obu crates/ec-av1/src/stream.rs:8339 captured - ok no 14acb74e825a2bb3ef195a52cc2abc67794d9c4d92080b66c739d318177fc7c6 | |
| 275 | +``` | |
| 276 | + | |
| 277 | +## 7. What I did NOT do | |
| 278 | + | |
| 279 | +- **No sweep of the `is_inter` / `ref` context consumers** (§5). They share the | |
| 280 | + granularity hazard; nothing in the 99-cell sweep or the re-quoted families | |
| 281 | + observes them, so changing them would be a blind refactor. | |
| 282 | +- **No diagnosis of the four `OURS-EXIT1` cells** the fix also cured. The claim | |
| 283 | + is that they no longer exit, not why they did. | |
| 284 | +- **No change to the `above_inter` / `left_inter` / `above_side_mi` / | |
| 285 | + `left_side_mi` bands themselves.** They still have their other readers (§5); | |
| 286 | + deleting them is a separate cleanup with its own re-quote. | |
| 287 | +- **The `EC_PART` rung's `mi` misprint** found in the previous lane (one of its | |
| 288 | + four arms prints the 16-px-unit index) is still there. Diagnostic-rung defect, | |
| 289 | + not a decode defect, not this lane's fix. | |
| 290 | + | |
| 291 | +## 8. Files | |
| 292 | + | |
| 293 | +- `crates/ec-av1/src/decode.rs` — `inter_grid` field + constructor entry, | |
| 294 | + `mark_inter_grid_rect` / `inter_at` / `blk_side_at`, the three writer calls, | |
| 295 | + both readers, `TXCTX_INTER_CELL_BAND_DIVERGENCE_HITS` + accessors, and the | |
| 296 | + `EC_TXCTX` rung extended with the per-cell terms. | |
| 297 | +- `crates/ec-av1/src/stream.rs` — the gate | |
| 298 | + `a_444_lossy_sb128_txctx_reads_the_covering_block_per_cell` (+94 lines). | |
| 299 | +- `crates/ec-av1/fixtures/444_lossy_sb128_txctx_witness.obu` — new pin. | |
| 300 | +- Throwaway, outside the repo: `~/.cache/sb128fork/` (`cmp444.py`, `align.py`, | |
| 301 | + `hunt5.py`, the `rb/` red-before and `gr2/` green dumps, and the 99 encodes). |