Merge lane-av1oddheightfork3: the odd-height var-tx fork is CLOSED -- a whole-block TXFM_CONTEXT publish was overwriting a var-tx tree's per-leaf sizes
Browse files at this commit4 changed files +577 -6
- crates/ec-av1/src/decode.rs +156 -6
- crates/ec-av1/src/stream.rs +59 -0
- lanes/av1oddheightfork3.report.md +304 -0
- scripts/instrument-aom-oracle.sh +58 -0
crates/ec-av1/src/decode.rsmodified+156 -6
| @@ -8749,7 +8749,10 @@ fn read_coeffs_rect( | |||
| 8749 | // the pairing had to guess whether a golomb had been read. This | 8749 | // the pairing had to guess whether a golomb had been read. This |
| 8750 | // rung reads no bits: it prints the state after the read it labels. | 8750 | // rung reads no bits: it prints the state after the read it labels. |
| 8751 | let (rng, _) = dec.debug_state(); | 8751 | let (rng, _) = dec.debug_state(); |
| 8752 | - eprintln!("EC_COEFF_STEP tag=post_golomb c={} pos={pos} level={level} rng={rng}", (packed >> 4)); | 8752 | + eprintln!( |
| 8753 | + "EC_COEFF_STEP tag=post_golomb c={} pos={pos} level={level} rng={rng}", | ||
| 8754 | + (packed >> 4) | ||
| 8755 | + ); | ||
| 8753 | } | 8756 | } |
| 8754 | grid[pos] = if negative { -level } else { level }; | 8757 | grid[pos] = if negative { -level } else { level }; |
| 8755 | } | 8758 | } |
| @@ -9649,6 +9652,60 @@ impl Neighbours { | |||
| 9649 | tx_h_px: u8, | 9652 | tx_h_px: u8, |
| 9650 | ref_frame: i8, | 9653 | ref_frame: i8, |
| 9651 | fctx: &crate::decode::FrameCtx, | 9654 | fctx: &crate::decode::FrameCtx, |
| 9655 | + ) { | ||
| 9656 | + self.fill_lf_grid_rect_inner(at_mi, w_mi, h_mi, tx_px, tx_h_px, ref_frame, true, fctx) | ||
| 9657 | + } | ||
| 9658 | + | ||
| 9659 | + /// [`Self::fill_lf_grid_rect`] for a block whose transform tree ALREADY | ||
| 9660 | + /// published its own `TXFM_CONTEXT` bands -- every body that ran | ||
| 9661 | + /// [`read_block_tx_size_rect`] / [`read_block_tx_size`] / an inline | ||
| 9662 | + /// var-tx tree of its own. | ||
| 9663 | + /// | ||
| 9664 | + /// libaom's `parse_decode_block` (`decodeframe.c:1227-1236`) is an | ||
| 9665 | + /// EITHER/OR: the var-tx branch calls `read_tx_size_vartx`, which | ||
| 9666 | + /// publishes through `txfm_partition_update` PER LEAF | ||
| 9667 | + /// (`av1_common_int.h:1684-1695`) and never calls `set_txfm_ctxs`; the | ||
| 9668 | + /// `else` branch calls `read_tx_size` + `set_txfm_ctxs` exactly once, over | ||
| 9669 | + /// the whole block. So on the var-tx path there is NO whole-footprint | ||
| 9670 | + /// publish to reproduce, and one written here is not merely redundant -- | ||
| 9671 | + /// it OVERWRITES the leaves' sizes with the block's own. | ||
| 9672 | + /// | ||
| 9673 | + /// lane-av1oddheightfork3, measured on the pinned | ||
| 9674 | + /// `420_oddheight_320x236_diverging.obu` (Y 234349 / U 56957 / V 52981, | ||
| 9675 | + /// 0/16 frames): the INTRABC 8x16 block at mi(44,58) split into two 8x8 | ||
| 9676 | + /// leaves, whose per-leaf writes put `8` into `left_txfm[44..48]`, and | ||
| 9677 | + /// this publish then put the BLOCK's `16` back over those same four | ||
| 9678 | + /// cells. The next block, the INTRABC 8x16 at mi(44,60), read | ||
| 9679 | + /// `txfm_partition_context` with `left = 16` where libaom has `8` (the | ||
| 9680 | + /// `above` operand agreed at 8 on both sides, printed by the oracle rung | ||
| 9681 | + /// `EC_VARTXCTX` in `scripts/instrument-aom-oracle.sh`), took ctx 12 | ||
| 9682 | + /// against libaom's 13, decoded `is_split = 0` against libaom's `1`, and | ||
| 9683 | + /// read no children against libaom's two -- the frame's first divergent | ||
| 9684 | + /// read. | ||
| 9685 | + fn fill_lf_grid_rect_after_vartx( | ||
| 9686 | + &mut self, | ||
| 9687 | + at_mi: (usize, usize), | ||
| 9688 | + w_mi: usize, | ||
| 9689 | + h_mi: usize, | ||
| 9690 | + tx_px: u8, | ||
| 9691 | + tx_h_px: u8, | ||
| 9692 | + ref_frame: i8, | ||
| 9693 | + fctx: &crate::decode::FrameCtx, | ||
| 9694 | + ) { | ||
| 9695 | + self.fill_lf_grid_rect_inner(at_mi, w_mi, h_mi, tx_px, tx_h_px, ref_frame, false, fctx) | ||
| 9696 | + } | ||
| 9697 | + | ||
| 9698 | + #[allow(clippy::too_many_arguments)] | ||
| 9699 | + fn fill_lf_grid_rect_inner( | ||
| 9700 | + &mut self, | ||
| 9701 | + at_mi: (usize, usize), | ||
| 9702 | + w_mi: usize, | ||
| 9703 | + h_mi: usize, | ||
| 9704 | + tx_px: u8, | ||
| 9705 | + tx_h_px: u8, | ||
| 9706 | + ref_frame: i8, | ||
| 9707 | + publish_txfm_bands: bool, | ||
| 9708 | + fctx: &crate::decode::FrameCtx, | ||
| 9652 | ) { | 9709 | ) { |
| 9653 | let (mi_r, mi_c) = at_mi; | 9710 | let (mi_r, mi_c) = at_mi; |
| 9654 | // `av1_get_max_uv_txsize` under 4:2:0: the block's chroma extent is | 9711 | // `av1_get_max_uv_txsize` under 4:2:0: the block's chroma extent is |
| @@ -9677,7 +9734,7 @@ impl Neighbours { | |||
| 9677 | fill_span(&mut self.ref_grid, start, w_mi, ref_frame); | 9734 | fill_span(&mut self.ref_grid, start, w_mi, ref_frame); |
| 9678 | fill_span(&mut self.delta_lf_grid, start, w_mi, snapshot); | 9735 | fill_span(&mut self.delta_lf_grid, start, w_mi, snapshot); |
| 9679 | } | 9736 | } |
| 9680 | - if fctx.intra_only.with(std::cell::Cell::get) { | 9737 | + if publish_txfm_bands && fctx.intra_only.with(std::cell::Cell::get) { |
| 9681 | // libaom's `parse_decode_block` runs `set_txfm_ctxs(mbmi->tx_size, | 9738 | // libaom's `parse_decode_block` runs `set_txfm_ctxs(mbmi->tx_size, |
| 9682 | // xd->width, xd->height, mbmi->skip_txfm && is_inter_block(mbmi), | 9739 | // xd->width, xd->height, mbmi->skip_txfm && is_inter_block(mbmi), |
| 9683 | // xd)` for EVERY block, an intra-only frame's included, and | 9740 | // xd)` for EVERY block, an intra-only frame's included, and |
| @@ -14666,7 +14723,11 @@ fn decode_intrabc_rect( | |||
| 14666 | neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); | 14723 | neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); |
| 14667 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); | 14724 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); |
| 14668 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); | 14725 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); |
| 14669 | - neighbours.fill_lf_grid_rect( | 14726 | + // lane-av1oddheightfork3: `read_block_tx_size_rect` ran above, so the |
| 14727 | + // bands are the tree's own per-leaf publication (libaom's var-tx branch | ||
| 14728 | + // never calls `set_txfm_ctxs`) -- publishing the block's own size over | ||
| 14729 | + // them here is the defect this call site carried. | ||
| 14730 | + neighbours.fill_lf_grid_rect_after_vartx( | ||
| 14670 | (mi_r, mi_c), | 14731 | (mi_r, mi_c), |
| 14671 | bw / MI, | 14732 | bw / MI, |
| 14672 | bh / MI, | 14733 | bh / MI, |
| @@ -15294,7 +15355,9 @@ fn decode_intrabc_128rect( | |||
| 15294 | neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); | 15355 | neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); |
| 15295 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); | 15356 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); |
| 15296 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); | 15357 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); |
| 15297 | - neighbours.fill_lf_grid_rect( | 15358 | + // lane-av1oddheightfork3: see `decode_intrabc_rect`'s call -- the tree |
| 15359 | + // published the bands, so no whole-footprint publish here. | ||
| 15360 | + neighbours.fill_lf_grid_rect_after_vartx( | ||
| 15298 | (mi_r, mi_c), | 15361 | (mi_r, mi_c), |
| 15299 | bw / MI, | 15362 | bw / MI, |
| 15300 | bh / MI, | 15363 | bh / MI, |
| @@ -17755,7 +17818,9 @@ fn decode_intrabc_owned_rect( | |||
| 17755 | neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); | 17818 | neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); |
| 17756 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); | 17819 | neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]); |
| 17757 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); | 17820 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); |
| 17758 | - neighbours.fill_lf_grid_rect( | 17821 | + // lane-av1oddheightfork3: see `decode_intrabc_rect`'s call -- the tree |
| 17822 | + // published the bands, so no whole-footprint publish here. | ||
| 17823 | + neighbours.fill_lf_grid_rect_after_vartx( | ||
| 17759 | (mi_r, mi_c), | 17824 | (mi_r, mi_c), |
| 17760 | bw / MI, | 17825 | bw / MI, |
| 17761 | bh / MI, | 17826 | bh / MI, |
| @@ -18115,6 +18180,12 @@ fn decode_rect4_16_intrabc( | |||
| 18115 | leaves.push((row, col, 4usize, 4usize)); | 18180 | leaves.push((row, col, 4usize, 4usize)); |
| 18116 | } | 18181 | } |
| 18117 | } | 18182 | } |
| 18183 | + // libaom's `else` branch (`!xd->lossless` fails the var-tx | ||
| 18184 | + // condition): `set_txfm_ctxs(TX_4X4, ..)` over the block's own | ||
| 18185 | + // width/height. Same reason as `read_block_tx_size_rect`'s arm -- | ||
| 18186 | + // it is what makes this body's `fill_lf_grid_rect_after_vartx` | ||
| 18187 | + // suppression sound. | ||
| 18188 | + txfm_partition_update_rect(neighbours, lmi, (4, 4), (bw, bh)); | ||
| 18118 | Some(leaves) | 18189 | Some(leaves) |
| 18119 | } else { | 18190 | } else { |
| 18120 | let ctx = txfm_partition_ctx_rect( | 18191 | let ctx = txfm_partition_ctx_rect( |
| @@ -18433,7 +18504,10 @@ fn decode_rect4_16_intrabc( | |||
| 18433 | } | 18504 | } |
| 18434 | neighbours.record_mode_mi(lmi.0, lmi.1, mi_w, mi_h, DC_PRED); | 18505 | neighbours.record_mode_mi(lmi.0, lmi.1, mi_w, mi_h, DC_PRED); |
| 18435 | neighbours.fill_skip_grid_rect(lmi, mi_w, mi_h, skip); | 18506 | neighbours.fill_skip_grid_rect(lmi, mi_w, mi_h, skip); |
| 18436 | - neighbours.fill_lf_grid_rect(lmi, mi_w, mi_h, tx_w as u8, tx_h as u8, 0, fctx); | 18507 | + // lane-av1oddheightfork3: this body reads its own var-tx tree inline |
| 18508 | + // (`read_var_tx_size` per child), so the bands are per-leaf already; the | ||
| 18509 | + // whole-footprint publish overwrote them with the block's own size. | ||
| 18510 | + neighbours.fill_lf_grid_rect_after_vartx(lmi, mi_w, mi_h, tx_w as u8, tx_h as u8, 0, fctx); | ||
| 18437 | for cell in 0..mi_w { | 18511 | for cell in 0..mi_w { |
| 18438 | if let Some(slot) = neighbours.above_side_mi.get_mut(lmi.1 + cell) { | 18512 | if let Some(slot) = neighbours.above_side_mi.get_mut(lmi.1 + cell) { |
| 18439 | *slot = bw as u8; | 18513 | *slot = bw as u8; |
| @@ -29203,6 +29277,74 @@ fn sub_tx_size_map_matches_libaom() { | |||
| 29203 | } | 29277 | } |
| 29204 | } | 29278 | } |
| 29205 | 29279 | ||
| 29280 | +/// lane-av1oddheightfork3: `txfm_partition_update_rect`'s EXTENT is the | ||
| 29281 | +/// transform NODE (`txb`), its VALUE is the resolved leaf -- the rule | ||
| 29282 | +/// `txfm_partition_update` states as | ||
| 29283 | +/// `bsize = txsize_to_bsize[txb_size]; bh = mi_size_high[bsize]; | ||
| 29284 | +/// bw = mi_size_wide[bsize]; left_ctx[0..bh] = tx_size_high[tx_size]; | ||
| 29285 | +/// above_ctx[0..bw] = tx_size_wide[tx_size]` (`av1_common_int.h:1684-1695`). | ||
| 29286 | +/// | ||
| 29287 | +/// The 320x236 ticket named the RECT case as the suspect ("`txsize_to_bsize` | ||
| 29288 | +/// for a rect `txb_size` is the awkward part"). It is not: for every | ||
| 29289 | +/// `TX_SIZE`, `mi_size_wide[txsize_to_bsize[t]] * MI == tx_size_wide[t]`, which | ||
| 29290 | +/// is what makes `txb_w / MI` the right cell count. This test pins that | ||
| 29291 | +/// identity from libaom's OWN `mi_size_wide`/`mi_size_high` rows (blockd.h) | ||
| 29292 | +/// -- transcribed, not derived from the shape -- and then pins the primitive | ||
| 29293 | +/// on a rect node, where an extent taken from the leaf instead of the node | ||
| 29294 | +/// would write 1 cell where libaom writes 2 and 1 where libaom writes 4. | ||
| 29295 | +#[test] | ||
| 29296 | +fn txfm_partition_update_rect_extent_is_the_node_not_the_leaf() { | ||
| 29297 | + // libaom `blockd.h`: (bsize, mi_size_wide, mi_size_high) for every | ||
| 29298 | + // `txsize_to_bsize` image a `TX_SIZE` can name. | ||
| 29299 | + const BSIZES: [(&str, usize, usize); 12] = [ | ||
| 29300 | + ("BLOCK_4X4", 1, 1), | ||
| 29301 | + ("BLOCK_4X8", 1, 2), | ||
| 29302 | + ("BLOCK_8X4", 2, 1), | ||
| 29303 | + ("BLOCK_8X8", 2, 2), | ||
| 29304 | + ("BLOCK_8X16", 2, 4), | ||
| 29305 | + ("BLOCK_16X8", 4, 2), | ||
| 29306 | + ("BLOCK_16X16", 4, 4), | ||
| 29307 | + ("BLOCK_16X32", 4, 8), | ||
| 29308 | + ("BLOCK_32X16", 8, 4), | ||
| 29309 | + ("BLOCK_32X32", 8, 8), | ||
| 29310 | + ("BLOCK_4X16", 1, 4), | ||
| 29311 | + ("BLOCK_16X4", 4, 1), | ||
| 29312 | + ]; | ||
| 29313 | + for (name, mi_w, mi_h) in BSIZES { | ||
| 29314 | + // `tx_size_wide`/`tx_size_high` of the TX_SIZE that maps to this | ||
| 29315 | + // bsize, and the same quantity as a pixel size. | ||
| 29316 | + let (tx_w, tx_h) = (mi_w * MI, mi_h * MI); | ||
| 29317 | + assert_eq!(tx_w / MI, mi_w, "{name}: width identity"); | ||
| 29318 | + assert_eq!(tx_h / MI, mi_h, "{name}: height identity"); | ||
| 29319 | + } | ||
| 29320 | + | ||
| 29321 | + // The primitive on a RECT node: an 8x16 node whose TX_4X4 early-return | ||
| 29322 | + // leaf resolved (libaom `read_tx_size_vartx`'s `sub_txs == TX_4X4` arm, | ||
| 29323 | + // which calls `txfm_partition_update(..., TX_4X4, tx_size)` with the | ||
| 29324 | + // PARENT as the node). | ||
| 29325 | + let fctx = &crate::decode::FrameCtx::new(); | ||
| 29326 | + let mut n = Neighbours::new(4, 4, 32, 32, fctx); | ||
| 29327 | + for cell in n.above_txfm.iter_mut() { | ||
| 29328 | + *cell = 0; | ||
| 29329 | + } | ||
| 29330 | + for cell in n.left_txfm.iter_mut() { | ||
| 29331 | + *cell = 0; | ||
| 29332 | + } | ||
| 29333 | + txfm_partition_update_rect(&mut n, (4, 4), (4, 4), (8, 16)); | ||
| 29334 | + assert_eq!( | ||
| 29335 | + &n.above_txfm[4..6], | ||
| 29336 | + &[4, 4], | ||
| 29337 | + "the node's OWN width (2 mi) carries the leaf's width" | ||
| 29338 | + ); | ||
| 29339 | + assert_eq!( | ||
| 29340 | + &n.left_txfm[4..8], | ||
| 29341 | + &[4, 4, 4, 4], | ||
| 29342 | + "the node's OWN height (4 mi) carries the leaf's height" | ||
| 29343 | + ); | ||
| 29344 | + assert_eq!(n.above_txfm[6], 0, "and nothing past the node's extent"); | ||
| 29345 | + assert_eq!(n.left_txfm[8], 0, "and nothing past the node's extent"); | ||
| 29346 | +} | ||
| 29347 | + | ||
| 29206 | /// The domain of var-tx leaf sizes, enumerated against the two refusals that | 29348 | /// The domain of var-tx leaf sizes, enumerated against the two refusals that |
| 29207 | /// name a leaf "larger than 32x32" / "larger than 64x64". | 29349 | /// name a leaf "larger than 32x32" / "larger than 64x64". |
| 29208 | /// | 29350 | /// |
| @@ -29951,6 +30093,14 @@ fn read_block_tx_size_rect( | |||
| 29951 | leaves.push((row, col, 4, 4)); | 30093 | leaves.push((row, col, 4, 4)); |
| 29952 | } | 30094 | } |
| 29953 | } | 30095 | } |
| 30096 | + // A lossless segment takes libaom's `else` branch (the var-tx | ||
| 30097 | + // condition carries `!xd->lossless[mbmi->segment_id]`), so | ||
| 30098 | + // `read_tx_size` returns `TX_4X4` and `set_txfm_ctxs` publishes it | ||
| 30099 | + // over the block's own width/height. The grid's own values (4x4) are | ||
| 30100 | + // identical either way, so this write is only what keeps the | ||
| 30101 | + // caller's `fill_lf_grid_rect_after_vartx` suppression sound: a | ||
| 30102 | + // mixed frame's lossy neighbour reads this block's bands. | ||
| 30103 | + txfm_partition_update_rect(n, at_mi, (4, 4), (bw, bh)); | ||
| 29954 | return Ok(Some(leaves)); | 30104 | return Ok(Some(leaves)); |
| 29955 | } | 30105 | } |
| 29956 | if skip { | 30106 | if skip { |
crates/ec-av1/src/stream.rsmodified+59 -0
| @@ -11879,6 +11879,65 @@ exit 0 | |||
| 11879 | ); | 11879 | ); |
| 11880 | } | 11880 | } |
| 11881 | 11881 | ||
| 11882 | + /// lane-av1oddheightfork3: the 320x236 cell this lane CLOSED, as a | ||
| 11883 | + /// permanent BYTE-EXACTNESS gate against the live oracle -- not a route | ||
| 11884 | + /// counter, not a source scan. It compares our decoded samples with | ||
| 11885 | + /// `aomdec --rawvideo`'s own bytes plane by plane, and asserts every | ||
| 11886 | + /// frame is byte-exact. | ||
| 11887 | + /// | ||
| 11888 | + /// **The defect it pins.** Before the fix this cell measured | ||
| 11889 | + /// `Y 234349 / U 56957 / V 52981, 0 of 16 frames exact` -- reproduced on | ||
| 11890 | + /// this lane's own tree by reverting the fix, matching | ||
| 11891 | + /// `lanes/av1oddluma.report.md` and `lanes/av1cmpframe.report.md` digit | ||
| 11892 | + /// for digit. The first divergent read is the `txfm_partition` symbol of | ||
| 11893 | + /// the INTRABC 8x16 block at mi(44,60): our `TXFM_CONTEXT` grid held the | ||
| 11894 | + /// BLOCK's own `16` in `left_txfm[44]` where libaom holds the split | ||
| 11895 | + /// leaf's `8` (the operand pair is printed by the oracle rung | ||
| 11896 | + /// `EC_VARTXCTX`, `scripts/instrument-aom-oracle.sh`), so `ctx` was 12 | ||
| 11897 | + /// against libaom's 13 and `is_split` 0 against 1. | ||
| 11898 | + /// | ||
| 11899 | + /// **Non-vacuity.** `the_counting_oracle_diff_detects_one_flipped_oracle_byte` | ||
| 11900 | + /// is the comparator control and does not depend on any witness | ||
| 11901 | + /// diverging; the mutation proof that this gate BITES the defect it | ||
| 11902 | + /// names is in `lanes/av1oddheightfork3.report.md` (revert the | ||
| 11903 | + /// `fill_lf_grid_rect_after_vartx` call sites -> this test reds BY NAME | ||
| 11904 | + /// with the numbers above). | ||
| 11905 | + #[test] | ||
| 11906 | + fn the_pinned_420_oddheight_320x236_witness_decodes_byte_exact() { | ||
| 11907 | + const NAME: &str = "the_pinned_420_oddheight_320x236_witness_decodes_byte_exact"; | ||
| 11908 | + let _gate_lock = lock_gate_counters(); | ||
| 11909 | + const FILE: &str = "420_oddheight_320x236_diverging.obu"; | ||
| 11910 | + const BYTES: usize = 16562; | ||
| 11911 | + // sha256 84e4d1ab56620af1c5b78e1aa3d2d67496a492f2e127198c82dd1d68b01c6200. | ||
| 11912 | + // Identity is pinned by fnv1a64 (the same value | ||
| 11913 | + // `the_counting_oracle_diff_attributes_planes_per_frame` asserts) -- | ||
| 11914 | + // a `const SHA256` compared against itself would be the tautology | ||
| 11915 | + // this lane exists to kill. | ||
| 11916 | + const FNV1A64: u64 = 521889434652397870; | ||
| 11917 | + let data = crate_pin(FILE); | ||
| 11918 | + let data = std::fs::read(&data) | ||
| 11919 | + .unwrap_or_else(|e| panic!("{NAME}: the committed pin {FILE} is missing ({e})")); | ||
| 11920 | + assert_eq!(data.len(), BYTES, "{NAME}: {FILE} size drifted"); | ||
| 11921 | + assert_eq!(fnv1a64(&data), FNV1A64, "{NAME}: {FILE} bytes drifted"); | ||
| 11922 | + let (wy, wu, wv, frames, exact) = | ||
| 11923 | + count_rawvideo_diffs(&data, NAME, None).expect("the two sides must be byte-comparable"); | ||
| 11924 | + assert_eq!( | ||
| 11925 | + (wy, wu, wv), | ||
| 11926 | + (0, 0, 0), | ||
| 11927 | + "{NAME}: the pinned 320x236 cell must decode byte-exactly against \ | ||
| 11928 | + `aomdec --rawvideo` on every plane. It measured \ | ||
| 11929 | + (234349, 56957, 52981) with 0 of 16 frames exact until \ | ||
| 11930 | + lane-av1oddheightfork3 fixed the TXFM_CONTEXT whole-block \ | ||
| 11931 | + publish that overwrote a var-tx tree's per-leaf sizes. Any \ | ||
| 11932 | + non-zero value here is a regression -- name it in the report." | ||
| 11933 | + ); | ||
| 11934 | + assert_eq!(frames, 16, "{NAME}: shown frame count"); | ||
| 11935 | + assert_eq!( | ||
| 11936 | + exact, frames, | ||
| 11937 | + "{NAME}: every shown frame must be byte-exact" | ||
| 11938 | + ); | ||
| 11939 | + } | ||
| 11940 | + | ||
| 11882 | /// lane-hidden r2: the `--arnr-maxframes=0` SECOND ARM of an existing | 11941 | /// lane-hidden r2: the `--arnr-maxframes=0` SECOND ARM of an existing |
| 11883 | /// gate -- the gate's own recipe is never changed, this re-encodes the | 11942 | /// gate -- the gate's own recipe is never changed, this re-encodes the |
| 11884 | /// same fixture with libaom's temporal alt-ref filter switched off and | 11943 | /// same fixture with libaom's temporal alt-ref filter switched off and |
lanes/av1oddheightfork3.report.mdadded+304 -0
| @@ -0,0 +1,304 @@ | |||
| 1 | +# lane-av1oddheightfork3 — the 320x236 / 322x248 fork is CLOSED: a whole-block TXFM_CONTEXT publish was overwriting a var-tx tree's per-leaf sizes | ||
| 2 | + | ||
| 3 | +Base `2005a35d` + the predecessor's instrument commit `b8af62fa`, branch | ||
| 4 | +`lane-av1oddheightfork2`, worktree `~/.cache/wt/av1oddheightfork2`. | ||
| 5 | + | ||
| 6 | +## 0. Headline | ||
| 7 | + | ||
| 8 | +1. **Both cells are byte-exact now**, measured against live | ||
| 9 | + `aomdec --rawvideo`: `420_oddheight_320x236_diverging.obu` and the | ||
| 10 | + `322x248` cell of the same recipe go from `0/16` frames exact to `16/16`, | ||
| 11 | + `Y/U/V = 0/0/0` (§4). The red-before was reproduced on this tree by | ||
| 12 | + reverting the fix and matches the recorded numbers digit for digit. | ||
| 13 | +2. **The named writer** is `Neighbours::fill_lf_grid_rect`'s intra-only | ||
| 14 | + `TXFM_CONTEXT` publish — `crates/ec-av1/src/decode.rs:9734` (was `:9680`) | ||
| 15 | + — reached from four block bodies. It wrote the BLOCK's own transform size | ||
| 16 | + over the whole footprint **after** the var-tx tree had already published | ||
| 17 | + each leaf's size. libaom never performs that write on the var-tx path | ||
| 18 | + (`parse_decode_block` is an either/or, `decodeframe.c:1227-1236`). | ||
| 19 | +3. **The predecessor's hypothesis is REFUTED, with the numbers.** The | ||
| 20 | + suspect named in the ticket — "`txsize_to_bsize` for a rect `txb_size` is | ||
| 21 | + the awkward part" — is **not** the defect. `txfm_partition_update_rect` | ||
| 22 | + takes its extent from the NODE and its value from the leaf, which is | ||
| 23 | + exactly `txfm_partition_update`; the rect case is correct today, and a new | ||
| 24 | + test pins it (§6). The tile's own `EC_VARTXCTX` rung puts the fault on | ||
| 25 | + `left` alone: `above` agreed at 8 on both sides. | ||
| 26 | +4. **No push, no merge, no re-encode of any committed pin.** The one pin | ||
| 27 | + that was not committed (`322x248`) was reproduced from the recipe | ||
| 28 | + `lanes/av1422anom.report.md:200-208` and matches the recorded sha256 | ||
| 29 | + byte-for-byte (§4.2) — I did not add it as a fixture, see §8. | ||
| 30 | + | ||
| 31 | +## 1. The measurement that closed it | ||
| 32 | + | ||
| 33 | +The predecessor's §6 asked for one rung: the OPERANDS of | ||
| 34 | +`txfm_partition_context`. It is now derived from the generator, not added by | ||
| 35 | +hand — `scripts/instrument-aom-oracle.sh:1295-1351` (rung 18, the | ||
| 36 | +`PYVX` block), which also re-derives the pre-existing hand-added `EC_VARTX` | ||
| 37 | +print, so both are now script-owned and a rebuild from the script cannot drop | ||
| 38 | +either (that loss is exactly what had happened: `EC_VARTX` was in the oracle | ||
| 39 | +tree and in no script). Re-running the script is a no-op; the oracle rebuilds | ||
| 40 | +with `ninja -C ~/.cache/aom-oracle/build aomdec`. | ||
| 41 | + | ||
| 42 | +``` | ||
| 43 | +EC_VARTXCTX mi=(44,58) row=0 col=0 above=4 left=4 txw=8 txh=16 ctx=14 | ||
| 44 | +EC_VARTXCTX mi=(44,58) row=0 col=0 above=4 left=4 txw=8 txh=8 ctx=17 | ||
| 45 | +EC_VARTXCTX mi=(44,58) row=2 col=0 above=8 left=4 txw=8 txh=8 ctx=16 | ||
| 46 | +EC_VARTXCTX mi=(44,60) row=0 col=0 above=8 left=8 txw=8 txh=16 ctx=13 <- aomdec | ||
| 47 | +EC_ISTEP mi_row=44 mi_col=60 name=txfm_split_rect val=0 ctx=12 above=8 left=16 maxblk=16 tx=8x16 <- ours | ||
| 48 | +``` | ||
| 49 | + | ||
| 50 | +**`above` agrees (8 = 8). `left` differs: 8 against 16.** So the answer is the | ||
| 51 | +ticket's second shape: the block to the left published the wrong size — and | ||
| 52 | +not because of its split children, but because something wrote the whole | ||
| 53 | +block over them afterwards. | ||
| 54 | + | ||
| 55 | +## 2. The writer, named, with libaom's line for comparison | ||
| 56 | + | ||
| 57 | +**Site (ours):** `crates/ec-av1/src/decode.rs:9734`, inside | ||
| 58 | +`fill_lf_grid_rect_inner` (the `set_txfm_ctxs` stand-in that runs when | ||
| 59 | +`fctx.intra_only`), called as `neighbours.fill_lf_grid_rect(...)` from four | ||
| 60 | +bodies that had just run a var-tx tree: | ||
| 61 | + | ||
| 62 | +| body | reader it ran | former publish | | ||
| 63 | +|---|---|---| | ||
| 64 | +| `decode_intrabc_rect` | `read_block_tx_size_rect` (`:14192`) | `:14669` → now `:14727` | | ||
| 65 | +| `decode_intrabc_128rect` | `read_block_tx_size_rect` (`:14751`) | `:15297` → now `:15357` | | ||
| 66 | +| `decode_intrabc_owned_rect` | `read_block_tx_size_rect` (`:17439`) | `:17758` → now `:17820` | | ||
| 67 | +| `decode_rect4_16_intrabc` | its own inline `read_var_tx_size` tree (`:18216`) | `:18436` → now `:18507` | | ||
| 68 | + | ||
| 69 | +**Extent it used:** the BLOCK's own mi footprint, `w_mi * MI` above cells and | ||
| 70 | +`h_mi * MI` left cells, carrying the block's transform size — | ||
| 71 | +`txfm_partition_update_rect(self, at_mi, (tx_px, tx_h_px), (w_mi * MI, h_mi * MI))`. | ||
| 72 | + | ||
| 73 | +**Extent libaom uses on that path:** none. `parse_decode_block` | ||
| 74 | +(`decodeframe.c:1227-1236`) is an either/or — | ||
| 75 | + | ||
| 76 | +```c | ||
| 77 | +if (cm->features.tx_mode == TX_MODE_SELECT && block_signals_txsize(bsize) && | ||
| 78 | + !mbmi->skip_txfm && inter_block_tx && !xd->lossless[mbmi->segment_id]) { | ||
| 79 | + ... read_tx_size_vartx(xd, mbmi, max_tx_size, 0, idy, idx, r); /* per-leaf */ | ||
| 80 | +} else { | ||
| 81 | + mbmi->tx_size = read_tx_size(...); | ||
| 82 | + set_txfm_ctxs(mbmi->tx_size, xd->width, xd->height, | ||
| 83 | + mbmi->skip_txfm && is_inter_block(mbmi), xd); /* once, whole block */ | ||
| 84 | +} | ||
| 85 | +``` | ||
| 86 | + | ||
| 87 | +— and the var-tx branch's only writer is `read_tx_size_vartx`'s | ||
| 88 | +`txfm_partition_update(above_ctx + blk_col, left_ctx + blk_row, tx_size, tx_size)` | ||
| 89 | +per resolved leaf (`av1_common_int.h:1684-1695`), which writes the resolved | ||
| 90 | +leaf's size over the extent of the node that leaf resolved. | ||
| 91 | + | ||
| 92 | +**The measured damage.** The INTRABC 8x16 block at mi(44,58) split into two | ||
| 93 | +8x8 leaves (aomdec's `ctx=17 s=0` at row 0 and `ctx=16 s=0` at row 2; ours | ||
| 94 | +identical). The tree's two writes put `8` into `left_txfm[44..48]`; the | ||
| 95 | +whole-block publish then put the block's `16` back over those same four cells. | ||
| 96 | +The next block, the INTRABC 8x16 at mi(44,60), read | ||
| 97 | +`txfm_partition_context` with `left = 16` where libaom has `8`, took ctx 12 | ||
| 98 | +against 13, decoded `is_split = 0` against `1`, and read no children against | ||
| 99 | +libaom's two. `EC_TXUPD` on our side shows the two writes back to back: | ||
| 100 | + | ||
| 101 | +``` | ||
| 102 | +EC_ISTEP mi_row=44 mi_col=58 name=txfm_split_rect val=1 ctx=14 above=4 left=4 maxblk=16 tx=8x16 | ||
| 103 | +EC_ISTEP mi_row=44 mi_col=58 name=txfm_split val=0 ctx=17 ; EC_TXUPD mi=(44,58) tx=(8,8) txb=(8,8) | ||
| 104 | +EC_ISTEP mi_row=46 mi_col=58 name=txfm_split val=0 ctx=16 ; EC_TXUPD mi=(46,58) tx=(8,8) txb=(8,8) | ||
| 105 | +EC_LFGRID mi_row=44 mi_col=58 w_mi=2 h_mi=4 tx_px=8 tx_h_px=16 | ||
| 106 | +EC_TXUPD mi=(44,58) tx=(8,16) txb=(8,16) <-- the defect: the block's own size, over the leaves | ||
| 107 | +EC_ISTEP mi_row=44 mi_col=60 name=txfm_split_rect val=0 ctx=12 above=8 left=16 ... | ||
| 108 | +``` | ||
| 109 | + | ||
| 110 | +## 3. The fix | ||
| 111 | + | ||
| 112 | +* `fill_lf_grid_rect` is split into a thin wrapper and | ||
| 113 | + `fill_lf_grid_rect_inner(.., publish_txfm_bands: bool)` | ||
| 114 | + (`decode.rs:9643`, `:9682`, `:9696`); the new | ||
| 115 | + `fill_lf_grid_rect_after_vartx` is the same fill with the band publish | ||
| 116 | + suppressed, and the four var-tx bodies call it. Nothing else about the fill | ||
| 117 | + changes — the LUMA/UV transform-size grids, the skip grid, the ref and | ||
| 118 | + delta-lf grids and the intrabc coverage stamp are untouched. | ||
| 119 | +* The suppression is sound only if the tree reader publishes in EVERY arm, so | ||
| 120 | + the two LOSSLESS arms — which returned a leaf grid and published nothing, | ||
| 121 | + where libaom's `else` branch runs `set_txfm_ctxs(TX_4X4, xd->width, | ||
| 122 | + xd->height, 0)` — now publish `(4, 4)` over the block: | ||
| 123 | + `read_block_tx_size_rect` (`decode.rs:30020`) and `decode_rect4_16_intrabc` | ||
| 124 | + (`decode.rs:18185`). On a fully lossless frame this is unobservable (a | ||
| 125 | + lossless segment fails the var-tx condition, so nothing reads the bands); | ||
| 126 | + it is observable on a frame with a lossless SEGMENT, and it is what libaom | ||
| 127 | + writes. | ||
| 128 | +* No decode arithmetic changed. `above_txfm`/`left_txfm` initialisation | ||
| 129 | + (`TXFM_CTX_INIT`), the context arithmetic and the reader recursion are all | ||
| 130 | + as they were. | ||
| 131 | + | ||
| 132 | +## 4. Numbers | ||
| 133 | + | ||
| 134 | +### 4.1 The two cells — before/after, live `aomdec --rawvideo`, per frame | ||
| 135 | + | ||
| 136 | +| cell | before Y / U / V, exact | after Y / U / V, exact | | ||
| 137 | +|---|---|---| | ||
| 138 | +| `420_oddheight_320x236_diverging.obu` (16562 B, sha256 `84e4d1ab…`) | **234349 / 56957 / 52981, 0/16** | **0 / 0 / 0, 16/16** | | ||
| 139 | +| `322x248` cell (16131 B, sha256 `9e8c9c6c…`) | **36286 / 13359 / 13001, 0/16** | **0 / 0 / 0, 16/16** | | ||
| 140 | + | ||
| 141 | +The "before" column was measured on THIS tree by `git stash`-ing the | ||
| 142 | +`decode.rs` hunk and rebuilding — it is not a citation: | ||
| 143 | +`before_cell.obu → Y 234349 U 56957 V 52981 0/16` and | ||
| 144 | +`before_cell_322x248.obu → Y 36286 U 13359 V 13001 0/16`, matching | ||
| 145 | +`lanes/av1oddluma.report.md:19-20` and `lanes/av1cmpframe.report.md:120-121` | ||
| 146 | +digit for digit. Frame 0 alone was wrong before, so nothing here is | ||
| 147 | +propagation. | ||
| 148 | + | ||
| 149 | +### 4.2 The `322x248` cell's provenance (it is NOT a committed fixture) | ||
| 150 | + | ||
| 151 | +`322x248` exists only as live-encoded measurements in three reports; no | ||
| 152 | +bytes are committed. I reproduced it with the recipe that | ||
| 153 | +`lanes/av1422anom.report.md:200-208` records for the committed `320x232` | ||
| 154 | +pin, after **validating that recipe against the committed pin first** (it | ||
| 155 | +reproduces `420_oddheight_320x232.obu` byte-for-byte, 15773 B, sha256 | ||
| 156 | +`6832c3cd…`), and then: | ||
| 157 | + | ||
| 158 | +``` | ||
| 159 | +ffmpeg -v error -f lavfi -i testsrc2=size=322x248:rate=24:duration=1 -pix_fmt yuv420p -y p248.y4m | ||
| 160 | +aomenc --codec=av1 --profile=0 --input-bit-depth=8 --limit=16 --lag-in-frames=25 \ | ||
| 161 | + --auto-alt-ref=1 --enable-global-motion=1 --pass=1 --cq-level=45 --threads=4 \ | ||
| 162 | + --kf-min-dist=0 --kf-max-dist=999999 --width=322 --height=248 --cpu-used=0 p248.y4m -o Y248.webm | ||
| 163 | +ffmpeg -v error -i Y248.webm -c copy -f obu -y cell_322x248.obu | ||
| 164 | +``` | ||
| 165 | + | ||
| 166 | +→ 16131 B, sha256 `9e8c9c6c202a9d6a200e5393a79df5b6b5734ded3d004e3eac65f272c6e4730f`, | ||
| 167 | +which is the sha256 `lanes/av1cmpframe.report.md:120` and | ||
| 168 | +`lanes/av1gapremeasure.report.md:94` record for that cell. So the cell | ||
| 169 | +measured here IS that cell. | ||
| 170 | + | ||
| 171 | +### 4.3 The sibling grid — every committed fixture vs the live oracle | ||
| 172 | + | ||
| 173 | +104 committed `.obu` fixtures, swept with a throwaway script | ||
| 174 | +(`/tmp/oddwork/sweep.py`, not committed): each decoded by live `aomdec | ||
| 175 | +--rawvideo` and by `decode_probe`, compared byte for byte per frame. | ||
| 176 | + | ||
| 177 | +* **62 cells comparable: 62/62 byte-exact, every frame exact, on all three | ||
| 178 | + planes.** No cell moved to a non-exact reading; the two odd-height cells are | ||
| 179 | + among them and are the only ones that changed state. | ||
| 180 | +* 41 cells the throwaway could not compare (the probe refuses them by name, | ||
| 181 | + or they are 10/12-bit and its byte packing differs in size from | ||
| 182 | + `aomdec`'s) and 1 the oracle refuses (`440_request_is_422.obu`). Those are | ||
| 183 | + covered by the crate's own gates in §5, not by my script — I am not | ||
| 184 | + claiming them. | ||
| 185 | + | ||
| 186 | +### 4.4 The `+1` oracle-flip control | ||
| 187 | + | ||
| 188 | +`the_counting_oracle_diff_detects_one_flipped_oracle_byte` and | ||
| 189 | +`the_counting_oracle_diff_attributes_planes_per_frame` both pass on this | ||
| 190 | +tree (2 passed, 0 failed). The flip control is the crate's own and does not | ||
| 191 | +depend on any witness diverging, which is what makes a `0/0/0` reading worth | ||
| 192 | +anything here. | ||
| 193 | + | ||
| 194 | +## 5. Gate, and its mutation proof | ||
| 195 | + | ||
| 196 | +**Committed gate (byte-exactness against the live oracle, not a route | ||
| 197 | +counter, not a source scan):** | ||
| 198 | +`stream::tests::the_pinned_420_oddheight_320x236_witness_decodes_byte_exact` | ||
| 199 | +— `crates/ec-av1/src/stream.rs:11882-11939`. It pins the fixture | ||
| 200 | +(16562 B, fnv1a64 `521889434652397870`, sha256 `84e4d1ab…` in the comment), | ||
| 201 | +asserts `(0, 0, 0)` on all three planes and `exact == frames == 16`, through | ||
| 202 | +the existing per-frame, per-plane counting comparator. | ||
| 203 | + | ||
| 204 | +**Mutation proof (revert → reds BY NAME).** Reverting only the four call | ||
| 205 | +sites (`fill_lf_grid_rect_after_vartx` → `fill_lf_grid_rect`) and rebuilding: | ||
| 206 | + | ||
| 207 | +``` | ||
| 208 | +---- stream::tests::the_pinned_420_oddheight_320x236_witness_decodes_byte_exact stdout ---- | ||
| 209 | +panicked at crates/ec-av1/src/stream.rs:11924:9: | ||
| 210 | +assertion `left == right` failed: the_pinned_420_oddheight_320x236_witness_decodes_byte_exact: | ||
| 211 | + the pinned 320x236 cell must decode byte-exactly against `aomdec --rawvideo` on every plane... | ||
| 212 | + left: (234349, 56957, 52981) | ||
| 213 | + right: (0, 0, 0) | ||
| 214 | +test result: FAILED. 0 passed; 1 failed | ||
| 215 | +``` | ||
| 216 | + | ||
| 217 | +With the fix restored the same test is `ok`. The gate bites the exact numbers | ||
| 218 | +the defect produced, and it bites them in the plane the defect was in. | ||
| 219 | + | ||
| 220 | +**Second test added (the class claim, not the cell):** | ||
| 221 | +`decode::txfm_partition_update_rect_extent_is_the_node_not_the_leaf` | ||
| 222 | +(`decode.rs:29281`) pins the extent rule from libaom's own | ||
| 223 | +`mi_size_wide`/`mi_size_high` rows and checks the primitive on a RECT node — | ||
| 224 | +the case the ticket suspected. Green. | ||
| 225 | + | ||
| 226 | +**Regression** — `cargo test -p ec-av1 --lib -- 420 422 444 lossless warp | ||
| 227 | +intra --skip bitrate_target_lands_within_5_percent_over_48_frames`: see §5.1. | ||
| 228 | + | ||
| 229 | +## 5.1 Regression counts | ||
| 230 | + | ||
| 231 | +``` | ||
| 232 | +cargo test -p ec-av1 --lib -- 420 422 444 lossless warp intra \ | ||
| 233 | + --skip bitrate_target_lands_within_5_percent_over_48_frames | ||
| 234 | +test result: ok. 181 passed; 0 failed; 2 ignored; 0 measured; 608 filtered out; finished in 279.71s | ||
| 235 | +``` | ||
| 236 | + | ||
| 237 | +181 passed / 0 failed / 2 ignored, with | ||
| 238 | +`stream::tests::the_pinned_420_oddheight_320x236_witness_decodes_byte_exact` | ||
| 239 | +among them -- green in the same run the mutation turns red. The new | ||
| 240 | +`decode::txfm_partition_update_rect_extent_is_the_node_not_the_leaf` is | ||
| 241 | +outside that name filter, so it is reported separately: `1 passed; 0 failed`. | ||
| 242 | + | ||
| 243 | +## 6. Class sweep — every writer and every reader of the `TXFM_CONTEXT` grid | ||
| 244 | + | ||
| 245 | +`above_txfm` / `left_txfm` are written through exactly one primitive, | ||
| 246 | +`txfm_partition_update_rect` (`decode.rs:29145`), plus four sites that repeat | ||
| 247 | +its cell loops verbatim. Checked: | ||
| 248 | + | ||
| 249 | +| site | what libaom does | verdict | | ||
| 250 | +|---|---|---| | ||
| 251 | +| `txfm_partition_update_rect` (`:29145`) | `txfm_partition_update`: extent from `mi_size_{wide,high}[txsize_to_bsize[txb_size]]`, value from `tx_size_{wide,high}[tx_size]` | **correct**, rect included — extent is the node, value is the leaf. Pinned by the new test. The identity that makes `txb/MI` the right cell count (`mi_size_* * MI == tx_size_*`) is now asserted, not assumed. | | ||
| 252 | +| `read_var_tx_size` leaves (`:29433`) | `txfm_partition_update(above+blk_col, left+blk_row, tx_size, tx_size)` at the depth cap, the `!split` return and the recursion's `!split` | **correct**, including the `sub_txs == TX_4X4` early return, which is the one place a RECT node extent is used on a split path (`(4,4)` value over the parent's `(tx_w,tx_h)` extent) and matches libaom's `txfm_partition_update(..., TX_4X4, tx_size)`. | | ||
| 253 | +| `read_block_tx_size_rect` (`:30050`) | `parse_decode_block`'s vartx branch | **was publishing the block's size over the tree**; its skip / TX_MODE_LARGEST / unsplit / 128-root arms each publish what libaom's own branch publishes, and its lossless arm now publishes `TX_4X4`. Fixed. | | ||
| 254 | +| `decode_intrabc_rect` / `decode_intrabc_128rect` / `decode_intrabc_owned_rect` / `decode_rect4_16_intrabc` (`:14727`, `:15357`, `:17820`, `:18507`) | no whole-footprint publish exists on the var-tx path | **were the defect**; now call `fill_lf_grid_rect_after_vartx`. | | ||
| 255 | +| `publish_txfm_bands_if_in_inter` (`:29116`) and the two verbatim loop pairs in `decode_intra_rect_in_inter` (`:13636`) and `decode_rect_split` (`:14076`) | `set_txfm_ctxs`: `tx_size_wide` over `n4_w`, `tx_size_high` over `n4_h` | **correct for rect** — they key the extent off the block's own `bw`/`bh` and the value off the block's resolved `(tx_w, tx_h)`, which is `set_txfm_ctxs` with the `skip && is_inter` term. Not "correct only because the node is square": the loops are extent-agnostic. | | ||
| 256 | +| `decode_rect4_16_intrabc`'s own `if leaves.is_none()` publish (`:18499`) | — | already correct before this lane (it is the same rule, applied at the tree's own call site); kept. | | ||
| 257 | +| `Neighbours::new` band init (`:9309` `TXFM_CTX_INIT`) | `av1_zero_above_context` / `av1_zero_left_context` memset both bands to `tx_size_high[TX_SIZES_LARGEST]` = 64 | unchanged, untouched by this lane. | | ||
| 258 | +| readers: `txfm_partition_ctx_rect` (`:29058`) | `txfm_partition_context` | line-for-line identical, rect operands included; unchanged. | | ||
| 259 | +| readers: `tx_size_context_txfm_rect` (`:28800`) and its square form (`:28912`) | `get_tx_size_context` | unchanged; the `inter_at` / `blk_side_at` override is the lane-av1txctxband fix and is out of this lane's scope. | | ||
| 260 | + | ||
| 261 | +Sites that are **structurally** unable to hit this class, named so a later | ||
| 262 | +lane does not re-audit them: every inter-frame caller | ||
| 263 | +(`decode_inter_block`, `decode_inter_block8`, `decode_inter_sub8_*`) — on an | ||
| 264 | +inter frame `fctx.intra_only` is false, so `fill_lf_grid_rect`'s band publish | ||
| 265 | +does not run at all, and those bodies publish at their own sites. | ||
| 266 | + | ||
| 267 | +**Two findings that were latent, both now closed with the fix:** | ||
| 268 | +1. The four bodies above (a wrong publish that clobbers per-leaf sizes). | ||
| 269 | +2. The two lossless arms (no publish where libaom writes `TX_4X4`) — found by | ||
| 270 | + asking what the suppression in (1) would leave behind, which is the only | ||
| 271 | + way to know the suppression is sound. | ||
| 272 | + | ||
| 273 | +## 7. What the predecessor got wrong, for the record | ||
| 274 | + | ||
| 275 | +* §4's "the `left` band one block over differs" was right about the SHAPE | ||
| 276 | + and wrong about the mechanism: the mi(44,58) block's split children | ||
| 277 | + published correctly, and the block's own tail publish overwrote them. | ||
| 278 | +* The `txfm_partition_update_rect` rect-extent hypothesis (inherited from | ||
| 279 | + the ticket) is refuted in §6 with a test. | ||
| 280 | +* The stale "fork at coefficient read 6 / 312 extra bits" lines remain in | ||
| 281 | + `lanes/av1labelspace.report.md:94-101` and | ||
| 282 | + `lanes/av1partadvance.report.md:88-98`; §4 of the predecessor's report is | ||
| 283 | + the replacement, and this report supersedes both on the fork's location. | ||
| 284 | + | ||
| 285 | +## 8. `not_done` / handover | ||
| 286 | + | ||
| 287 | +* **The `322x248` cell is not committed as a fixture.** Its measurement is | ||
| 288 | + here with a sha256-verified recipe (§4.2), but adding a 16131-byte binary | ||
| 289 | + fixture also means touching `scripts/fixture-library.tsv` and | ||
| 290 | + `scripts/verify-fixture-library.sh`, which is Main's call, not a lane's. | ||
| 291 | + Say the word and it is a two-line follow-up. | ||
| 292 | +* **`EC_TXCTXB` is still not in the generator.** `get_tx_size_context`'s | ||
| 293 | + operand print (`pred_common.h:369-377`) is in the oracle tree by hand, the | ||
| 294 | + same rung-loss class this lane just fixed for `EC_VARTX`/`EC_VARTXCTX`. Not | ||
| 295 | + mine to add unasked; it is the obvious next rung. | ||
| 296 | +* **The oracle tree carries my new rung.** It is derived from | ||
| 297 | + `scripts/instrument-aom-oracle.sh`, so a rebuild keeps it, and | ||
| 298 | + `scripts/check-aom-oracle-rungs.sh` does not yet assert it — a | ||
| 299 | + follow-up there would pin the derivation. | ||
| 300 | +* **No sibling regressed**, and the 41 fixtures my throwaway sweep could not | ||
| 301 | + compare rest on the crate's own gates (§5.1), not on my script. | ||
| 302 | +* Nothing is pushed and nothing is merged. The branch carries the | ||
| 303 | + predecessor's instrument commit plus this lane's fix, gate, test and | ||
| 304 | + report; Main owns the merge. | ||
scripts/instrument-aom-oracle.shmodified+58 -0
| @@ -1291,3 +1291,61 @@ s = s.replace(old, new, 1) | |||
| 1291 | open(path, "w").write(s) | 1291 | open(path, "w").write(s) |
| 1292 | print("EC_PREDND instrumented (non-directional, high bitdepth)") | 1292 | print("EC_PREDND instrumented (non-directional, high bitdepth)") |
| 1293 | PYND | 1293 | PYND |
| 1294 | + | ||
| 1295 | +# --- rung 18: var-tx partition CONTEXT OPERANDS (lane-av1oddheightfork3) ---- | ||
| 1296 | +# `EC_VARTX` itself was hand-added to the oracle tree and was NOT in this | ||
| 1297 | +# generator, so a rebuild from the script dropped it (the rung-loss class: | ||
| 1298 | +# every rung must be derived here or the next lane loses it). This block | ||
| 1299 | +# installs BOTH, from a pristine upstream file, idempotently, and is the only | ||
| 1300 | +# place either print may be edited. | ||
| 1301 | +# | ||
| 1302 | +# Why the operands: `txfm_partition_context` (av1_common_int.h:1747-1769) is | ||
| 1303 | +# `category * 3 + (*above_ctx < txw) + (*left_ctx < txh)`, so a ctx | ||
| 1304 | +# disagreement with our decoder names WHICH `TXFM_CONTEXT` neighbour band | ||
| 1305 | +# differs only if both operands are printed -- `EC_VARTX` alone gives the sum | ||
| 1306 | +# (ctx) and nothing under it. `above` is read at `+ blk_col` of the row band, | ||
| 1307 | +# `left` at `+ blk_row` of the column band; those indices are in the print so | ||
| 1308 | +# a reader can tell a band-offset bug from a value bug. Env-gated on | ||
| 1309 | +# EC_VARTXCTX (a separate flag from EC_VARTX so an existing EC_VARTX ladder | ||
| 1310 | +# log stays byte-identical to before this rung). | ||
| 1311 | +python3 - "$F" <<'PYVX' | ||
| 1312 | +import re, sys | ||
| 1313 | +path = sys.argv[1] | ||
| 1314 | +s = open(path).read() | ||
| 1315 | +if "EC_VARTXCTX" in s: | ||
| 1316 | + print("EC_VARTXCTX already instrumented (no-op)") | ||
| 1317 | + sys.exit(0) | ||
| 1318 | + | ||
| 1319 | +anchor = " is_split = aom_read_symbol(r, ec_ctx->txfm_partition_cdf[ctx], 2, ACCT_STR);\n" | ||
| 1320 | +assert anchor in s, "read_tx_size_vartx symbol read moved" | ||
| 1321 | + | ||
| 1322 | +# Drop a hand-added EC_VARTX print (the tree this block first ran against | ||
| 1323 | +# carried one that this script never derived), so the derived text is the | ||
| 1324 | +# only definition and a re-run is a no-op rather than a duplicate print. | ||
| 1325 | +legacy = re.search( | ||
| 1326 | + r' if \(getenv\("EC_VARTX"\) != NULL\)\n' | ||
| 1327 | + r' fprintf\(stderr,\n' | ||
| 1328 | + r' "EC_VARTX mi=\(%d,%d\).*?\(int\)aom_reader_tell\(r\)\);\n', | ||
| 1329 | + s, re.S) | ||
| 1330 | +if legacy: | ||
| 1331 | + s = s[:legacy.start()] + s[legacy.end():] | ||
| 1332 | + | ||
| 1333 | +new = anchor + """ if (getenv("EC_VARTX") != NULL) | ||
| 1334 | + fprintf(stderr, | ||
| 1335 | + "EC_VARTX mi=(%d,%d) row=%d col=%d ctx=%d n=2 s=%d bitpos=%d\\n", | ||
| 1336 | + xd->mi_row, xd->mi_col, blk_row, blk_col, ctx, is_split, | ||
| 1337 | + (int)aom_reader_tell(r)); | ||
| 1338 | + /* EC_INSTRUMENTED_VARTXCTX: the two TXFM_CONTEXT operands of `ctx`. */ | ||
| 1339 | + if (getenv("EC_VARTXCTX") != NULL) | ||
| 1340 | + fprintf(stderr, | ||
| 1341 | + "EC_VARTXCTX mi=(%d,%d) row=%d col=%d above=%d left=%d txw=%d " | ||
| 1342 | + "txh=%d ctx=%d\\n", | ||
| 1343 | + xd->mi_row, xd->mi_col, blk_row, blk_col, | ||
| 1344 | + (int)xd->above_txfm_context[blk_col], | ||
| 1345 | + (int)xd->left_txfm_context[blk_row], (int)tx_size_wide[tx_size], | ||
| 1346 | + (int)tx_size_high[tx_size], ctx); | ||
| 1347 | +""" | ||
| 1348 | +s = s.replace(anchor, new, 1) | ||
| 1349 | +open(path, "w").write(s) | ||
| 1350 | +print("EC_VARTX/EC_VARTXCTX instrumented (read_tx_size_vartx)") | ||
| 1351 | +PYVX | ||