Merge branch 'lane-av1422warp'
Browse files at this commit7 changed files +2763 -54
- crates/ec-av1/examples/decode_probe.rs +0 -2
- crates/ec-av1/fixtures/422_residual_compound_warp_16f.obu +0 -0
- crates/ec-av1/src/decode.rs +386 -36
- crates/ec-av1/src/msac.rs +72 -0
- crates/ec-av1/src/restoration.rs +66 -14
- crates/ec-av1/src/stream.rs +78 -2
- lanes/av1422warp.report.md +2161 -0
crates/ec-av1/examples/decode_probe.rsmodified+0 -2
| @@ -1,5 +1,3 @@ | |||
| 1 | -/home/user/Documents/Code/Rust/edith_codecs/crates/ec-av1/examples/decode_probe.rs: | ||
| 2 | - | ||
| 3 | //! Where does a real stream stop? Decode one AV1 file and print the answer. | 1 | //! Where does a real stream stop? Decode one AV1 file and print the answer. |
| 4 | //! | 2 | //! |
| 5 | //! The gates in [`ec_av1::stream`] each pin one capability against one encoder | 3 | //! The gates in [`ec_av1::stream`] each pin one capability against one encoder |
crates/ec-av1/fixtures/422_residual_compound_warp_16f.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+386 -36
| @@ -1,5 +1,3 @@ | |||
| 1 | -/home/user/Documents/Code/Rust/edith_codecs/crates/ec-av1/src/decode.rs: | ||
| 2 | - | ||
| 3 | //! Software decoder for this crate's own key-frame tile payloads (spec 5.11), | 1 | //! Software decoder for this crate's own key-frame tile payloads (spec 5.11), |
| 4 | //! the reader half of [`crate::tile`]'s writer. | 2 | //! the reader half of [`crate::tile`]'s writer. |
| 5 | //! | 3 | //! |
| @@ -4918,6 +4916,47 @@ pub(crate) fn warp_selected_hits() -> usize { | |||
| 4918 | // into the compound intermediate) rather than translationally -- the | 4916 | // into the compound intermediate) rather than translationally -- the |
| 4919 | // gate's proof that a `GLOBAL_GLOBALMV` block under a ROTZOOM/AFFINE model | 4917 | // gate's proof that a `GLOBAL_GLOBALMV` block under a ROTZOOM/AFFINE model |
| 4920 | // really reached [`crate::warp::warp_affine_compound`]. | 4918 | // really reached [`crate::warp::warp_affine_compound`]. |
| 4919 | +// lane-av1422warp: the 4:2:2 coverage witness has to show compound and warped | ||
| 4920 | +// motion firing ABOVE the vertical midpoint, and every pre-existing warp | ||
| 4921 | +// counter is frame-global. These two are the same arms restricted to blocks | ||
| 4922 | +// whose top mode-info row is in the frame's upper half, which is the half | ||
| 4923 | +// this lane's evidence covers. | ||
| 4924 | +thread_local! { | ||
| 4925 | + static TOP_HALF_COMPOUND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 4926 | + static TOP_HALF_WARP_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 4927 | +} | ||
| 4928 | + | ||
| 4929 | +/// How many `GLOBAL_GLOBALMV` (compound) inter blocks decoded in the frame's | ||
| 4930 | +/// upper half -- the block's top mode-info row is under `mi_rows / 2`. | ||
| 4931 | +/// | ||
| 4932 | +/// NO COMMITTED TEST READS THIS, and none can while the 4:2:2 header refusal | ||
| 4933 | +/// stands: the pinned 4:2:2 coverage gate asserts the byte pin and the | ||
| 4934 | +/// refusal by name, so nothing in the suite ever decodes a 4:2:2 stream. | ||
| 4935 | +/// The figure quoted for that fixture comes from a patch-run-restore build | ||
| 4936 | +/// with the `EC_AV1_ALLOW_422_PROBE` bypass applied and then reverted, which | ||
| 4937 | +/// is the same discipline every 4:2:2 lane in this family uses. | ||
| 4938 | +#[allow(dead_code)] | ||
| 4939 | +pub(crate) fn top_half_compound_hits() -> usize { | ||
| 4940 | + TOP_HALF_COMPOUND_HITS.with(std::cell::Cell::get) | ||
| 4941 | +} | ||
| 4942 | + | ||
| 4943 | +/// How many inter blocks in the frame's upper half satisfy libaom's | ||
| 4944 | +/// `is_global_mv_block` on at least one reference slot -- mode | ||
| 4945 | +/// `GLOBAL_GLOBALMV` AND block >= 8x8 AND that slot's own global-motion | ||
| 4946 | +/// model > `TRANSLATION`. This is the block set whose prediction goes | ||
| 4947 | +/// through `crate::warp`, and it is exactly `is_global_mv0 || is_global_mv1` | ||
| 4948 | +/// as computed at the increment site; it is NOT merely "some slot has a | ||
| 4949 | +/// non-TRANSLATION model", which also counts blocks that are not global-mv | ||
| 4950 | +/// blocks. | ||
| 4951 | +/// | ||
| 4952 | +/// Like [`top_half_compound_hits`], no committed test reads it: with the | ||
| 4953 | +/// 4:2:2 header refusal in force nothing in the suite decodes the stream | ||
| 4954 | +/// these numbers describe. | ||
| 4955 | +#[allow(dead_code)] | ||
| 4956 | +pub(crate) fn top_half_warp_hits() -> usize { | ||
| 4957 | + TOP_HALF_WARP_HITS.with(std::cell::Cell::get) | ||
| 4958 | +} | ||
| 4959 | + | ||
| 4921 | thread_local! { | 4960 | thread_local! { |
| 4922 | static COMPOUND_WARP_HITS: std::cell::Cell<usize> = | 4961 | static COMPOUND_WARP_HITS: std::cell::Cell<usize> = |
| 4923 | const { std::cell::Cell::new(0) }; | 4962 | const { std::cell::Cell::new(0) }; |
| @@ -9511,7 +9550,12 @@ impl Neighbours { | |||
| 9511 | // mi(5,15): left neighbour SMOOTH_V at mi(5,14), read at mi(4,13)). | 9550 | // mi(5,15): left neighbour SMOOTH_V at mi(5,14), read at mi(4,13)). |
| 9512 | let snap_y = (1usize << ss_y(fctx)) - 1; | 9551 | let snap_y = (1usize << ss_y(fctx)) - 1; |
| 9513 | let snap_x = (1usize << ss_x(fctx)) - 1; | 9552 | let snap_x = (1usize << ss_x(fctx)) - 1; |
| 9514 | - self.smooth_uv_neighbour_unsnapped(mi_r & !snap_y, mi_c & !snap_x, r, c) | 9553 | + // The snap IS libaom's `base_mi` de-offsetting (`set_mi_row_col`, |
| 9554 | + // `av1_common_int.h:1395-1412`): `base_mi` is the block's own mi moved | ||
| 9555 | + // by `-(mi_row & ss_y) * stride - (mi_col & ss_x)`. The helper applies | ||
| 9556 | + // the two chroma-reference offsets on top of it -- see its own comment | ||
| 9557 | + // for which axis each one moves. | ||
| 9558 | + self.smooth_uv_neighbour_unsnapped(mi_r & !snap_y, mi_c & !snap_x, r, c, ss_x(fctx)) | ||
| 9515 | } | 9559 | } |
| 9516 | 9560 | ||
| 9517 | /// [`Self::smooth_uv_neighbour`] without the chroma-reference snap, i.e. | 9561 | /// [`Self::smooth_uv_neighbour`] without the chroma-reference snap, i.e. |
| @@ -9519,7 +9563,14 @@ impl Neighbours { | |||
| 9519 | /// counter wants this: it measures how often the snap CHANGES the answer, | 9563 | /// counter wants this: it measures how often the snap CHANGES the answer, |
| 9520 | /// which is what the lane-kf1200/kf900 chroma-reference fix buys. Every | 9564 | /// which is what the lane-kf1200/kf900 chroma-reference fix buys. Every |
| 9521 | /// decode path uses the snapping form. | 9565 | /// decode path uses the snapping form. |
| 9522 | - fn smooth_uv_neighbour_unsnapped(&self, mi_r: usize, mi_c: usize, r: usize, c: usize) -> bool { | 9566 | + fn smooth_uv_neighbour_unsnapped( |
| 9567 | + &self, | ||
| 9568 | + mi_r: usize, | ||
| 9569 | + mi_c: usize, | ||
| 9570 | + r: usize, | ||
| 9571 | + c: usize, | ||
| 9572 | + ss_x: usize, | ||
| 9573 | + ) -> bool { | ||
| 9523 | // lane-mtfix r1: availability is TILE-relative on BOTH axes and on the | 9574 | // lane-mtfix r1: availability is TILE-relative on BOTH axes and on the |
| 9524 | // coarse fallback too. `above_uv_mode` is a frame-wide [`SUB`]-grid | 9575 | // coarse fallback too. `above_uv_mode` is a frame-wide [`SUB`]-grid |
| 9525 | // array that `start_tile` does not clear, so a block on a tile's first | 9576 | // array that `start_tile` does not clear, so a block on a tile's first |
| @@ -9543,15 +9594,44 @@ impl Neighbours { | |||
| 9543 | .filter(|&m| m != u8::MAX) | 9594 | .filter(|&m| m != u8::MAX) |
| 9544 | .map(usize::from) | 9595 | .map(usize::from) |
| 9545 | }; | 9596 | }; |
| 9546 | - let above = match self.uv_mode_col.get(mi_c) { | 9597 | + // libaom's two chroma-reference mi, from `set_mi_row_col` |
| 9547 | - _ if have_above && let Some(m) = cell(&self.uv_mode_grid, mi_r - 1, mi_c) => m, | 9598 | + // (`av1_common_int.h:1400-1401`), with `mi_r`/`mi_c` already |
| 9548 | - Some(&(row, m)) if have_above && usize::from(row) == mi_r - 1 => usize::from(m), | 9599 | + // de-offset by the caller's `(mi_row & ss_y)` / `(mi_col & ss_x)` |
| 9600 | + // snap -- i.e. already libaom's `base_mi`: | ||
| 9601 | + // | ||
| 9602 | + // chroma_above_mi = base_mi[-mi_stride + ss_x] row -1, col +ss_x | ||
| 9603 | + // chroma_left_mi = base_mi[ss_y*mi_stride - 1] row +ss_y, col -1 | ||
| 9604 | + // | ||
| 9605 | + // SHIPPED: the above COLUMN. It is `+ss_x` wherever `ss_x == 1` -- | ||
| 9606 | + // 4:2:0, 4:2:2 AND 4:4:0 all carry that column shift, and only 4:4:4 | ||
| 9607 | + // (`ss_x == 0`) leaves the read where it was. Measured: folding it in | ||
| 9608 | + // leaves the 4:2:0 control byte-identical to `aomdec --rawvideo`; the | ||
| 9609 | + // boolean it feeds is simply not exercised differently by that stream | ||
| 9610 | + // at its blocks. One chroma column spans two luma mi columns, so the | ||
| 9611 | + // chroma edge reaches into the right-hand luma block, and that is where | ||
| 9612 | + // its reference lives. | ||
| 9613 | + // | ||
| 9614 | + // NOT SHIPPED -- KNOWN UNRESOLVED: the left read's `+ss_y` ROW term. | ||
| 9615 | + // libaom puts the left reference one mi row DOWN at 4:2:0 and 4:4:0 | ||
| 9616 | + // (`ss_y == 1`) and on its own row at 4:2:2 (`ss_y == 0`); this reads | ||
| 9617 | + // its own row at every subsampling. An earlier attempt applied the | ||
| 9618 | + // `ss_y` term to the WRONG read (the above) and regressed the | ||
| 9619 | + // byte-exact 4:2:0 control, which is what exposed the crossing. No | ||
| 9620 | + // committed fixture presents a 1-mi-tall left neighbour (an 8x4 leaf's | ||
| 9621 | + // left block) at 4:2:0/4:4:0, so nothing here can witness the correct | ||
| 9622 | + // term today -- treat this as a named open discrepancy, not a settled | ||
| 9623 | + // one. Unblock: one such stream. | ||
| 9624 | + let above_mi = (mi_r.saturating_sub(1), mi_c + ss_x); | ||
| 9625 | + let left_mi = (mi_r, mi_c.saturating_sub(1)); | ||
| 9626 | + let above = match self.uv_mode_col.get(above_mi.1) { | ||
| 9627 | + _ if have_above && let Some(m) = cell(&self.uv_mode_grid, above_mi.0, above_mi.1) => m, | ||
| 9628 | + Some(&(row, m)) if have_above && usize::from(row) == above_mi.0 => usize::from(m), | ||
| 9549 | _ if have_above => self.above_uv_mode[c], | 9629 | _ if have_above => self.above_uv_mode[c], |
| 9550 | _ => DC_PRED, | 9630 | _ => DC_PRED, |
| 9551 | }; | 9631 | }; |
| 9552 | - let left = match self.uv_mode_row.get(mi_r) { | 9632 | + let left = match self.uv_mode_row.get(left_mi.0) { |
| 9553 | - _ if have_left && let Some(m) = cell(&self.uv_mode_grid, mi_r, mi_c - 1) => m, | 9633 | + _ if have_left && let Some(m) = cell(&self.uv_mode_grid, left_mi.0, left_mi.1) => m, |
| 9554 | - Some(&(col, m)) if have_left && usize::from(col) == mi_c - 1 => usize::from(m), | 9634 | + Some(&(col, m)) if have_left && usize::from(col) == left_mi.1 => usize::from(m), |
| 9555 | _ if have_left => self.left_uv_mode[r], | 9635 | _ if have_left => self.left_uv_mode[r], |
| 9556 | _ => DC_PRED, | 9636 | _ => DC_PRED, |
| 9557 | }; | 9637 | }; |
| @@ -10518,6 +10598,7 @@ fn read_intra_mode_rect( | |||
| 10518 | // `palette_uv` even on a chroma-reference strip. Fold the plane count | 10598 | // `palette_uv` even on a chroma-reference strip. Fold the plane count |
| 10519 | // into the same `has_chroma` this reader already gates on. | 10599 | // into the same `has_chroma` this reader already gates on. |
| 10520 | let has_chroma = has_chroma && !mono(fctx); | 10600 | let has_chroma = has_chroma && !mono(fctx); |
| 10601 | + crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64); | ||
| 10521 | let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); | 10602 | let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); |
| 10522 | if ec_istep { | 10603 | if ec_istep { |
| 10523 | // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line | 10604 | // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line |
| @@ -10619,6 +10700,7 @@ fn read_intra_mode_rect( | |||
| 10619 | // frame's `read_intra_frame_mode_info` (decodemv.c:1065 `read_intra_mode` | 10700 | // frame's `read_intra_frame_mode_info` (decodemv.c:1065 `read_intra_mode` |
| 10620 | // off `kf_y_mode_cdf[above][left]`). | 10701 | // off `kf_y_mode_cdf[above][left]`). |
| 10621 | let mode = if let Some((size_group, _)) = inter { | 10702 | let mode = if let Some((size_group, _)) = inter { |
| 10703 | + crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | ||
| 10622 | dec.symbol(&mut cdfs.y_mode[size_group]) | 10704 | dec.symbol(&mut cdfs.y_mode[size_group]) |
| 10623 | } else { | 10705 | } else { |
| 10624 | let above_ctx = INTRA_MODE_CTX[above_mode]; | 10706 | let above_ctx = INTRA_MODE_CTX[above_mode]; |
| @@ -10643,8 +10725,10 @@ fn read_intra_mode_rect( | |||
| 10643 | let uv_mode = if !has_chroma { | 10725 | let uv_mode = if !has_chroma { |
| 10644 | DC_PRED | 10726 | DC_PRED |
| 10645 | } else if cfl { | 10727 | } else if cfl { |
| 10728 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 10646 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 10729 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 10647 | } else { | 10730 | } else { |
| 10731 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 10648 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 10732 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 10649 | }; | 10733 | }; |
| 10650 | istep!("uv_mode", uv_mode as i32); | 10734 | istep!("uv_mode", uv_mode as i32); |
| @@ -12457,6 +12541,7 @@ fn decode_intra_rect_in_inter( | |||
| 12457 | } | 12541 | } |
| 12458 | return Ok(()); | 12542 | return Ok(()); |
| 12459 | } | 12543 | } |
| 12544 | + crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | ||
| 12460 | let mode = dec.symbol(&mut cdfs.y_mode[size_group]); | 12545 | let mode = dec.symbol(&mut cdfs.y_mode[size_group]); |
| 12461 | // lane-t900 r1: this arm read six mode symbols with no ladder rung of its | 12546 | // lane-t900 r1: this arm read six mode symbols with no ladder rung of its |
| 12462 | // own, so a cross-decoder bisection could only see the block's first | 12547 | // own, so a cross-decoder bisection could only see the block's first |
| @@ -12495,8 +12580,10 @@ fn decode_intra_rect_in_inter( | |||
| 12495 | let uv_mode = if !has_chroma { | 12580 | let uv_mode = if !has_chroma { |
| 12496 | DC_PRED | 12581 | DC_PRED |
| 12497 | } else if cfl_allowed { | 12582 | } else if cfl_allowed { |
| 12583 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 12498 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 12584 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 12499 | } else { | 12585 | } else { |
| 12586 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 12500 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 12587 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 12501 | }; | 12588 | }; |
| 12502 | if step_trace { | 12589 | if step_trace { |
| @@ -14258,7 +14345,25 @@ fn decode_block_rect( | |||
| 14258 | // --enable-tx-size-search=0 the encoder writes no such symbol, so the | 14345 | // --enable-tx-size-search=0 the encoder writes no such symbol, so the |
| 14259 | // decoder consumed one that was never there. | 14346 | // decoder consumed one that was never there. |
| 14260 | { | 14347 | { |
| 14261 | - let around = neighbours.around_rect(at, bw, bh); | 14348 | + // lane-av1422warp r20: this 32x16/16x32 strip reader is the SIBLING of |
| 14349 | + // `decode_leaf_rect`, and it was the one left ungated: at ss (1,0) the | ||
| 14350 | + // strip's chroma is a square (side/2, side) block whose above cells | ||
| 14351 | + // spread over `side` LUMA mi columns, so the per-mi rect gather | ||
| 14352 | + // double-counts every chroma column's whole-unit dc sign. Measured on | ||
| 14353 | + // the pinned 4:2:2 rotzoom stream (a1.obu frame 0): the chroma-U 4x4 | ||
| 14354 | + // transform of the 32x16 strip at mi(68,16) reads its DC sign from | ||
| 14355 | + // `dc_sign_ctx` 1 where libaom reads row 0 -- the first read of | ||
| 14356 | + // 45260 whose pre-state, bit position and symbol all match and only | ||
| 14357 | + // the CDF row differs, and the first divergence in the EC_SYMR | ||
| 14358 | + // sequence (all 45259 reads before it pair exactly). Luma keeps the | ||
| 14359 | + // per-mi gather; 4:2:0 and 4:4:4 keep the plain rect walk verbatim. | ||
| 14360 | + let mut around = neighbours.around_rect(at, bw, bh); | ||
| 14361 | + if ss_x(fctx) == 1 && ss_y(fctx) == 0 { | ||
| 14362 | + let c2 = | ||
| 14363 | + neighbours.around_mi_422_chroma((at.0 * (SUB / MI), at.1 * (SUB / MI)), bw, bh); | ||
| 14364 | + around[1] = c2[1]; | ||
| 14365 | + around[2] = c2[2]; | ||
| 14366 | + } | ||
| 14262 | let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, fi_tx_row(mode, filter_intra)); | 14367 | let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, fi_tx_row(mode, filter_intra)); |
| 14263 | let (luma_levels, luma_tx_type) = read_coeffs_rect( | 14368 | let (luma_levels, luma_tx_type) = read_coeffs_rect( |
| 14264 | dec, | 14369 | dec, |
| @@ -14809,7 +14914,28 @@ fn decode_leaf_rect( | |||
| 14809 | } else { | 14914 | } else { |
| 14810 | TxbSet::ChromaRect8x4 | 14915 | TxbSet::ChromaRect8x4 |
| 14811 | }; | 14916 | }; |
| 14812 | - let around = neighbours.around_mi_rect(leaf_mi, bw, bh); | 14917 | + // lane-av1422warp: at ss (1,0) this leaf's chroma is a SQUARE |
| 14918 | + // (side/2, side) block, so `side` chroma 4-px cells above it spread | ||
| 14919 | + // over `side` LUMA mi columns -- one chroma column per PAIR of luma | ||
| 14920 | + // mi cells, and both carry the covering unit's whole-unit dc sign. | ||
| 14921 | + // The per-mi rect gather therefore double-counts every chroma | ||
| 14922 | + // column's sign. `around_mi_422_chroma`'s every-second above-cell | ||
| 14923 | + // sampling is libaom's `txb_w_unit` sum, and every other 4:2:2 chroma | ||
| 14924 | + // gather in this file already routes through it (see the gate at this | ||
| 14925 | + // arm's siblings); this one did not, so a 4:2:2 rect leaf voted over | ||
| 14926 | + // luma unit counts. Measured on the pinned 4:2:2 rotzoom stream | ||
| 14927 | + // (a1.obu frame 0): the 16x8 leaf at mi(48,28) resolved its V plane's | ||
| 14928 | + // dc sign from vote 0 (`dc_sign_cdf[0]`) where the oracle resolves a | ||
| 14929 | + // negative vote (`dc_sign_cdf[1]`), which is the first bit-position | ||
| 14930 | + // divergence in the frame (the bit offset is a clean constant through | ||
| 14931 | + // coefficient unit 1418 and turns 6 bits at 1419). Luma keeps the | ||
| 14932 | + // per-mi gather; 4:2:0 and 4:4:4 keep the plain rect walk verbatim. | ||
| 14933 | + let mut around = neighbours.around_mi_rect(leaf_mi, bw, bh); | ||
| 14934 | + if chroma_422 { | ||
| 14935 | + let c = neighbours.around_mi_422_chroma(leaf_mi, bw, bh); | ||
| 14936 | + around[1] = c[1]; | ||
| 14937 | + around[2] = c[2]; | ||
| 14938 | + } | ||
| 14813 | let luma_set = if reduced_tx_set { | 14939 | let luma_set = if reduced_tx_set { |
| 14814 | TxbSet::LumaRect16x8 | 14940 | TxbSet::LumaRect16x8 |
| 14815 | } else { | 14941 | } else { |
| @@ -17234,7 +17360,13 @@ fn decode_rect4_16_strip( | |||
| 17234 | // `av1_use_intra_edge_upsample` on (blk_wh 12 <= 16) for a | 17360 | // `av1_use_intra_edge_upsample` on (blk_wh 12 <= 16) for a |
| 17235 | // directional chroma strip, moving 4 samples by 1. | 17361 | // directional chroma strip, moving 4 samples by 1. |
| 17236 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c, fctx); | 17362 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c, fctx); |
| 17237 | - if smooth_neighbor_uv != neighbours.smooth_uv_neighbour_unsnapped(lmi.0, lmi.1, r, c) { | 17363 | + // lane-av1422warp: `smooth_uv_neighbour_unsnapped` now takes the |
| 17364 | + // frame's own `ss_x` -- the unsnapped read is the pair-merge witness | ||
| 17365 | + // counter's mirror of the snapping form, and the shipped read offsets | ||
| 17366 | + // the above COLUMN by `+ss_x` (libaom's `chroma_above_mi`). | ||
| 17367 | + if smooth_neighbor_uv | ||
| 17368 | + != neighbours.smooth_uv_neighbour_unsnapped(lmi.0, lmi.1, r, c, ss_x(fctx)) | ||
| 17369 | + { | ||
| 17238 | hit!(RECT4_16_UV_PAIR_FILT_HITS); | 17370 | hit!(RECT4_16_UV_PAIR_FILT_HITS); |
| 17239 | } | 17371 | } |
| 17240 | // lane-av1-rect14: a lossless frame forces TX_4X4 on every plane | 17372 | // lane-av1-rect14: a lossless frame forces TX_4X4 on every plane |
| @@ -18441,6 +18573,7 @@ fn read_intra_mode( | |||
| 18441 | // shape the oracle's own `ec_read_intra_frame_mode_info_impl` prints | 18573 | // shape the oracle's own `ec_read_intra_frame_mode_info_impl` prints |
| 18442 | // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for | 18574 | // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for |
| 18443 | // line against the instrumented aomdec, not just `tell()`. | 18575 | // line against the instrumented aomdec, not just `tell()`. |
| 18576 | + crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64); | ||
| 18444 | let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); | 18577 | let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); |
| 18445 | if ec_istep { | 18578 | if ec_istep { |
| 18446 | // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line | 18579 | // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line |
| @@ -18568,8 +18701,10 @@ fn read_intra_mode( | |||
| 18568 | let uv_mode = if !has_chroma { | 18701 | let uv_mode = if !has_chroma { |
| 18569 | DC_PRED | 18702 | DC_PRED |
| 18570 | } else if cfl { | 18703 | } else if cfl { |
| 18704 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 18571 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 18705 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 18572 | } else { | 18706 | } else { |
| 18707 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 18573 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 18708 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 18574 | }; | 18709 | }; |
| 18575 | if trace { | 18710 | if trace { |
| @@ -22865,6 +23000,7 @@ fn read_intra_mode_sub8( | |||
| 22865 | let has_chroma = has_chroma && !mono(fctx); | 23000 | let has_chroma = has_chroma && !mono(fctx); |
| 22866 | let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); | 23001 | let trace = crate::envflags::env_flag!("EC_AV1_TRACE"); |
| 22867 | let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); | 23002 | let ec_istep = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); |
| 23003 | + crate::msac::SymbolDecoder::set_symr_mi(mi_r as i64, mi_c as i64); | ||
| 22868 | if ec_istep { | 23004 | if ec_istep { |
| 22869 | eprintln!( | 23005 | eprintln!( |
| 22870 | "EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sub8 rng={}", | 23006 | "EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sub8 rng={}", |
| @@ -22968,8 +23104,10 @@ fn read_intra_mode_sub8( | |||
| 22968 | // divergence at the rect leaf mi (8,16) of `ll444.obu`; class | 23104 | // divergence at the rect leaf mi (8,16) of `ll444.obu`; class |
| 22969 | // `wrong-alphabet-same-value`, lane-av1-llsub8). | 23105 | // `wrong-alphabet-same-value`, lane-av1-llsub8). |
| 22970 | let uv_mode = if cfl_allowed_px(seg_w_mi * MI, seg_h_mi * MI, fctx) { | 23106 | let uv_mode = if cfl_allowed_px(seg_w_mi * MI, seg_h_mi * MI, fctx) { |
| 23107 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 22971 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 23108 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 22972 | } else { | 23109 | } else { |
| 23110 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 22973 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 23111 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 22974 | }; | 23112 | }; |
| 22975 | if trace { | 23113 | if trace { |
| @@ -32017,9 +32155,19 @@ fn read_sb128_root( | |||
| 32017 | lr, | 32155 | lr, |
| 32018 | lr_grid, | 32156 | lr_grid, |
| 32019 | lr_reference, | 32157 | lr_reference, |
| 32020 | - mi_r128, | 32158 | + // `read_lr` is the ONE consumer that turns this superblock's |
| 32021 | - mi_c128, | 32159 | + // mode-info origin into ABSOLUTE frame space -- it divides by the |
| 32022 | - SB_MI * 2, | 32160 | + // restoration-unit size, which is a real pixel count. The partition |
| 32161 | + // decode below is self-consistent with `mi_r128` as written (it | ||
| 32162 | + // only ever uses relative offsets from it), which is why a 128x128 | ||
| 32163 | + // stream decoded correctly for 4:2:0 and 4:4:4 while placing its | ||
| 32164 | + // loop-restoration units at double the offset. `sb_r`/`sb_c` index | ||
| 32165 | + // 64px superblocks, so a 128px superblock's origin is half a | ||
| 32166 | + // `SB_MI` per 64px step -- `(sb_r & !1) * SB_MI` is twice the true | ||
| 32167 | + // mi row. The extent is `SB_MI`: a 128px superblock is 16 mi. | ||
| 32168 | + (sb_r & !1) * (SB_MI / 2), | ||
| 32169 | + (sb_c & !1) * (SB_MI / 2), | ||
| 32170 | + SB_MI, | ||
| 32023 | fctx, | 32171 | fctx, |
| 32024 | ); | 32172 | ); |
| 32025 | let at128 = ((mi_r128 / SUB_MI) as usize, (mi_c128 / SUB_MI) as usize); | 32173 | let at128 = ((mi_r128 / SUB_MI) as usize, (mi_c128 / SUB_MI) as usize); |
| @@ -32654,9 +32802,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 32654 | lr, | 32802 | lr, |
| 32655 | &mut lr_grid, | 32803 | &mut lr_grid, |
| 32656 | &mut lr_reference, | 32804 | &mut lr_reference, |
| 32657 | - sb_r * SB_MI, | 32805 | + // True mode-info units: a 64px superblock is 8, and `SB_MI` is 16. |
| 32658 | - sb_c * SB_MI, | 32806 | + // `read_lr` divides by the restoration-unit size (a real pixel count), |
| 32659 | - SB_MI, | 32807 | + // so it is the one consumer that needs the absolute origin in real mi. |
| 32808 | + // The half-mi convention these arguments used to carry only worked | ||
| 32809 | + // while `read_lr` also counted in half-mi -- the two cancelled. | ||
| 32810 | + sb_r * (SB_MI / 2), | ||
| 32811 | + sb_c * (SB_MI / 2), | ||
| 32812 | + SB_MI / 2, | ||
| 32660 | fctx, | 32813 | fctx, |
| 32661 | ); | 32814 | ); |
| 32662 | } | 32815 | } |
| @@ -35832,6 +35985,16 @@ fn overlappable_above( | |||
| 35832 | // The pair merge: the walk snaps back to the pair's even column | 35985 | // The pair merge: the walk snaps back to the pair's even column |
| 35833 | // and the ODD half (the chroma-carrying one) is the neighbour for | 35986 | // and the ODD half (the chroma-carrying one) is the neighbour for |
| 35834 | // both -- a 4-wide 1:4 strip is never an OBMC source on its own. | 35987 | // both -- a 4-wide 1:4 strip is never an OBMC source on its own. |
| 35988 | + // lane-av1422warp r33 (reviewer P2): the snap must be UNCONDITIONAL. | ||
| 35989 | + // libaom `obmc.h:41-46` is | ||
| 35990 | + // `above_mi = prev_row_mi + (above_mi_col & ~1) + 1` -- the snapped | ||
| 35991 | + // COLUMN is used as-is and the +1 is what lands it back on the | ||
| 35992 | + // block's own left edge. Clamping the snapped INDEX to `mi_col` | ||
| 35993 | + // (an earlier r25 attempt) moved the index itself, so this | ||
| 35994 | + // decoded the neighbour one column RIGHT of libaom's and, after | ||
| 35995 | + // `col += step`, never visited `mi_col + 1`. Only the REPORTED | ||
| 35996 | + // offset can be negative -- `above_mi - mi_col == -1` -- so the | ||
| 35997 | + // clamp belongs there, not on the index. | ||
| 35835 | col &= !1; | 35998 | col &= !1; |
| 35836 | src = col + 1; | 35999 | src = col + 1; |
| 35837 | nb = grid.get(mi_row - 1, src); | 36000 | nb = grid.get(mi_row - 1, src); |
| @@ -35848,7 +36011,12 @@ fn overlappable_above( | |||
| 35848 | // neighbour PREDICTION at a frame edge, which picks the | 36011 | // neighbour PREDICTION at a frame edge, which picks the |
| 35849 | // 4-tap kernel below 8 px (class narrow-block-sharp-kernel); | 36012 | // 4-tap kernel below 8 px (class narrow-block-sharp-kernel); |
| 35850 | // the destination clip stays in `obmc_blend`. | 36013 | // the destination clip stays in `obmc_blend`. |
| 35851 | - out.push((col - mi_col, step.min(bw4), info, src - mi_col)); | 36014 | + out.push(( |
| 36015 | + col.saturating_sub(mi_col), | ||
| 36016 | + step.min(bw4), | ||
| 36017 | + info, | ||
| 36018 | + src - mi_col, | ||
| 36019 | + )); | ||
| 35852 | } | 36020 | } |
| 35853 | } | 36021 | } |
| 35854 | col += step; | 36022 | col += step; |
| @@ -35888,6 +36056,12 @@ fn overlappable_left( | |||
| 35888 | // The pair merge, left-column mirror: a 4-TALL neighbour (a 16x4 | 36056 | // The pair merge, left-column mirror: a 4-TALL neighbour (a 16x4 |
| 35889 | // strip) is half of a chroma pair and the pair's SECOND row is the | 36057 | // strip) is half of a chroma pair and the pair's SECOND row is the |
| 35890 | // neighbour for both. | 36058 | // neighbour for both. |
| 36059 | + // lane-av1422warp r33 (reviewer P2): the row mirror of the | ||
| 36060 | + // `overlappable_above` fix. libaom's left-column walk snaps | ||
| 36061 | + // `(left_mi_row & ~1)` and adds 1; the snap is unconditional and | ||
| 36062 | + // only the REPORTED `row - mi_row` can be -1. The r25 clamp moved | ||
| 36063 | + // the snapped index itself, which read the neighbour one row | ||
| 36064 | + // BELOW libaom's and then skipped `mi_row + 1` entirely. | ||
| 35891 | row &= !1; | 36065 | row &= !1; |
| 35892 | src = row + 1; | 36066 | src = row + 1; |
| 35893 | nb = grid.get(src, mi_col - 1); | 36067 | nb = grid.get(src, mi_col - 1); |
| @@ -35900,7 +36074,12 @@ fn overlappable_left( | |||
| 35900 | } | 36074 | } |
| 35901 | // lane-t900 r14: `AOMMIN(xd->height, mi_step)` -- see | 36075 | // lane-t900 r14: `AOMMIN(xd->height, mi_step)` -- see |
| 35902 | // `overlappable_above`. | 36076 | // `overlappable_above`. |
| 35903 | - out.push((row - mi_row, step.min(bh4), info, src - mi_row)); | 36077 | + out.push(( |
| 36078 | + row.saturating_sub(mi_row), | ||
| 36079 | + step.min(bh4), | ||
| 36080 | + info, | ||
| 36081 | + src - mi_row, | ||
| 36082 | + )); | ||
| 35904 | } | 36083 | } |
| 35905 | } | 36084 | } |
| 35906 | row += step; | 36085 | row += step; |
| @@ -36575,7 +36754,7 @@ pub(crate) fn obmc_plan( | |||
| 36575 | // divides by zero at 4:4:4 (`trailing_zeros(0)` = 64, a debug shift panic). | 36754 | // divides by zero at 4:4:4 (`trailing_zeros(0)` = 64, a debug shift panic). |
| 36576 | ss_x: usize, | 36755 | ss_x: usize, |
| 36577 | ss_y: usize, | 36756 | ss_y: usize, |
| 36578 | - chroma_side: usize, | 36757 | + chroma_stride: usize, |
| 36579 | px: usize, | 36758 | px: usize, |
| 36580 | py: usize, | 36759 | py: usize, |
| 36581 | cpx: usize, | 36760 | cpx: usize, |
| @@ -36714,7 +36893,7 @@ pub(crate) fn obmc_plan( | |||
| 36714 | above, | 36893 | above, |
| 36715 | left, | 36894 | left, |
| 36716 | side, | 36895 | side, |
| 36717 | - chroma_side, | 36896 | + chroma_stride, |
| 36718 | write_w, | 36897 | write_w, |
| 36719 | write_h, | 36898 | write_h, |
| 36720 | px, | 36899 | px, |
| @@ -36794,7 +36973,16 @@ pub(crate) struct ObmcPlan { | |||
| 36794 | above: Vec<ObmcNb>, | 36973 | above: Vec<ObmcNb>, |
| 36795 | left: Vec<ObmcNb>, | 36974 | left: Vec<ObmcNb>, |
| 36796 | side: usize, | 36975 | side: usize, |
| 36797 | - chroma_side: usize, | 36976 | + /// The chroma PREDICTION buffer's own stride -- `chroma_stride`, the PLANE |
| 36977 | + /// BLOCK's per-axis width, NOT the enclosing square `chroma_side`. At | ||
| 36978 | + /// 4:2:2 that buffer is `(side/2, side)` (lane-av1-422blockhalf), and | ||
| 36979 | + /// striding it with `chroma_side` put row `r` at `r*side`: a 32x16 luma | ||
| 36980 | + /// strip's left-pass chroma blend wrote row 15 at index 15*32 = 480 of a | ||
| 36981 | + /// 256-sample `16 x 16` buffer -- the out-of-bounds panic in | ||
| 36982 | + /// `obmc_blend_h` the pinned 4:2:2 rotzoom stream opened. Every other | ||
| 36983 | + /// consumer of `pred_u`/`pred_v` in this block already strides with | ||
| 36984 | + /// `chroma_stride`; at 4:2:0 and 4:4:4 the two are equal. | ||
| 36985 | + chroma_stride: usize, | ||
| 36798 | write_w: usize, | 36986 | write_w: usize, |
| 36799 | write_h: usize, | 36987 | write_h: usize, |
| 36800 | px: usize, | 36988 | px: usize, |
| @@ -36821,7 +37009,7 @@ pub(crate) fn obmc_run( | |||
| 36821 | ) { | 37009 | ) { |
| 36822 | let &ObmcPlan { | 37010 | let &ObmcPlan { |
| 36823 | side, | 37011 | side, |
| 36824 | - chroma_side, | 37012 | + chroma_stride, |
| 36825 | write_w, | 37013 | write_w, |
| 36826 | write_h, | 37014 | write_h, |
| 36827 | px, | 37015 | px, |
| @@ -36868,7 +37056,7 @@ pub(crate) fn obmc_run( | |||
| 36868 | let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); | 37056 | let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); |
| 36869 | eprintln!("OUR_MCB pre f={idx} cpx={cpx} cpy={cpy} cw={cw} ch={ch}"); | 37057 | eprintln!("OUR_MCB pre f={idx} cpx={cpx} cpy={cpy} cw={cw} ch={ch}"); |
| 36870 | for r in 0..ch { | 37058 | for r in 0..ch { |
| 36871 | - let row: Vec<u16> = (0..cw).map(|c| pred_u[r * chroma_side + c]).collect(); | 37059 | + let row: Vec<u16> = (0..cw).map(|c| pred_u[r * chroma_stride + c]).collect(); |
| 36872 | eprintln!("OUR_MCB prerow{r}: {row:?}"); | 37060 | eprintln!("OUR_MCB prerow{r}: {row:?}"); |
| 36873 | } | 37061 | } |
| 36874 | } | 37062 | } |
| @@ -36921,7 +37109,7 @@ pub(crate) fn obmc_run( | |||
| 36921 | &mut tmp_u, | 37109 | &mut tmp_u, |
| 36922 | fctx, | 37110 | fctx, |
| 36923 | ); | 37111 | ); |
| 36924 | - obmc_blend_v(pred_u, chroma_side, cox, 0, cw, cbh, cbw, &tmp_u); | 37112 | + obmc_blend_v(pred_u, chroma_stride, cox, 0, cw, cbh, cbw, &tmp_u); |
| 36925 | obmc_neighbour_pred( | 37113 | obmc_neighbour_pred( |
| 36926 | nv, | 37114 | nv, |
| 36927 | cpx + cox, | 37115 | cpx + cox, |
| @@ -36936,7 +37124,7 @@ pub(crate) fn obmc_run( | |||
| 36936 | &mut tmp_v, | 37124 | &mut tmp_v, |
| 36937 | fctx, | 37125 | fctx, |
| 36938 | ); | 37126 | ); |
| 36939 | - obmc_blend_v(pred_v, chroma_side, cox, 0, cw, cbh, cbw, &tmp_v); | 37127 | + obmc_blend_v(pred_v, chroma_stride, cox, 0, cw, cbh, cbw, &tmp_v); |
| 36940 | } | 37128 | } |
| 36941 | } | 37129 | } |
| 36942 | 37130 | ||
| @@ -36990,7 +37178,7 @@ pub(crate) fn obmc_run( | |||
| 36990 | } | 37178 | } |
| 36991 | } | 37179 | } |
| 36992 | let ch = cbh.min((write_h >> ss_y(fctx)) - coy); | 37180 | let ch = cbh.min((write_h >> ss_y(fctx)) - coy); |
| 36993 | - obmc_blend_h(pred_u, chroma_side, 0, coy, cbw, ch, &tmp_u); | 37181 | + obmc_blend_h(pred_u, chroma_stride, 0, coy, cbw, ch, &tmp_u); |
| 36994 | obmc_neighbour_pred( | 37182 | obmc_neighbour_pred( |
| 36995 | nv, | 37183 | nv, |
| 36996 | cpx, | 37184 | cpx, |
| @@ -37005,12 +37193,12 @@ pub(crate) fn obmc_run( | |||
| 37005 | &mut tmp_v, | 37193 | &mut tmp_v, |
| 37006 | fctx, | 37194 | fctx, |
| 37007 | ); | 37195 | ); |
| 37008 | - obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, ch, &tmp_v); | 37196 | + obmc_blend_h(pred_v, chroma_stride, 0, coy, cbw, ch, &tmp_v); |
| 37009 | } | 37197 | } |
| 37010 | if let Some((_, _, idx)) = ec_mcb { | 37198 | if let Some((_, _, idx)) = ec_mcb { |
| 37011 | let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); | 37199 | let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); |
| 37012 | for r in 0..ch { | 37200 | for r in 0..ch { |
| 37013 | - let row: Vec<u16> = (0..cw).map(|c| pred_u[r * chroma_side + c]).collect(); | 37201 | + let row: Vec<u16> = (0..cw).map(|c| pred_u[r * chroma_stride + c]).collect(); |
| 37014 | eprintln!("OUR_MCB post f={idx} row{r}: {row:?}"); | 37202 | eprintln!("OUR_MCB post f={idx} row{r}: {row:?}"); |
| 37015 | } | 37203 | } |
| 37016 | } | 37204 | } |
| @@ -37525,6 +37713,11 @@ fn decode_inter_block( | |||
| 37525 | frame_width: usize, | 37713 | frame_width: usize, |
| 37526 | fctx: &crate::decode::FrameCtx, | 37714 | fctx: &crate::decode::FrameCtx, |
| 37527 | ) -> Result<()> { | 37715 | ) -> Result<()> { |
| 37716 | + // Round 27: the per-read trace is the only instrument that reaches the inter | ||
| 37717 | + // path (the coefficient rungs stop well before the frame-3 divergence), | ||
| 37718 | + // so publish the phase and the block's mi for every read it makes. | ||
| 37719 | + crate::msac::SymbolDecoder::set_symr_phase("inter"); | ||
| 37720 | + crate::msac::SymbolDecoder::set_symr_mi(at.0 as i64, at.1 as i64); | ||
| 37528 | // lane-inter4 r1: `at` is in MI units (4 px) so a 32-level 1:4 strip can | 37721 | // lane-inter4 r1: `at` is in MI units (4 px) so a 32-level 1:4 strip can |
| 37529 | // name an 8-px offset; `(r, c)` stays the enclosing 16-px cell for the | 37722 | // name an 8-px offset; `(r, c)` stays the enclosing 16-px cell for the |
| 37530 | // few 16-px-granular uses below. | 37723 | // few 16-px-granular uses below. |
| @@ -37887,7 +38080,6 @@ fn decode_inter_block( | |||
| 37887 | } | 38080 | } |
| 37888 | } | 38081 | } |
| 37889 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV | 38082 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV |
| 37890 | - // spec `is_nontrans_global_motion`: ALL active refs' models must | ||
| 37891 | // be non-TRANSLATION (IDENTITY counts) for the compound block's | 38083 | // be non-TRANSLATION (IDENTITY counts) for the compound block's |
| 37892 | // interp-filter read to be suppressed. | 38084 | // interp-filter read to be suppressed. |
| 37893 | let gm_nontrans_models = is_globalmv | 38085 | let gm_nontrans_models = is_globalmv |
| @@ -37916,6 +38108,22 @@ fn decode_inter_block( | |||
| 37916 | let is_global_mv1 = is_globalmv | 38108 | let is_global_mv1 = is_globalmv |
| 37917 | && side >= 8 | 38109 | && side >= 8 |
| 37918 | && global_motion[(ref1 - LAST_FRAME) as usize].model as u8 > 1; | 38110 | && global_motion[(ref1 - LAST_FRAME) as usize].model as u8 > 1; |
| 38111 | + // lane-av1422warp r33 (reviewer P3): the top-half census is | ||
| 38112 | + // placed HERE, after `is_global_mv0`/`is_global_mv1`, so it | ||
| 38113 | + // counts the same blocks libaom's `is_global_mv_block` does -- | ||
| 38114 | + // mode GLOBAL_GLOBALMV AND block >= 8x8 AND that slot's own gm | ||
| 38115 | + // model > TRANSLATION. An earlier placement tested the model term | ||
| 38116 | + // alone, which counts blocks that are not global-mv blocks at | ||
| 38117 | + // all, so its number was an upper bound dressed up as an | ||
| 38118 | + // engagement figure. | ||
| 38119 | + if mi_row < mi_rows as usize / 2 { | ||
| 38120 | + if is_globalmv { | ||
| 38121 | + TOP_HALF_COMPOUND_HITS.with(|c| c.set(c.get() + 1)); | ||
| 38122 | + } | ||
| 38123 | + if is_global_mv0 || is_global_mv1 { | ||
| 38124 | + TOP_HALF_WARP_HITS.with(|c| c.set(c.get() + 1)); | ||
| 38125 | + } | ||
| 38126 | + } | ||
| 37919 | // libaom `av1_init_warp_params` + `allow_warp`'s | 38127 | // libaom `av1_init_warp_params` + `allow_warp`'s |
| 37920 | // `global_warp_allowed` branch, run once per reference for a | 38128 | // `global_warp_allowed` branch, run once per reference for a |
| 37921 | // compound block exactly as for a single-ref one (reconinter.c | 38129 | // compound block exactly as for a single-ref one (reconinter.c |
| @@ -38025,6 +38233,7 @@ fn decode_inter_block( | |||
| 38025 | && enable_masked_compound | 38233 | && enable_masked_compound |
| 38026 | && is_any_masked_compound_used_here(write_w, write_h) | 38234 | && is_any_masked_compound_used_here(write_w, write_h) |
| 38027 | { | 38235 | { |
| 38236 | + crate::msac::SymbolDecoder::set_symr_cdf("comp_group_idx"); | ||
| 38028 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) | 38237 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) |
| 38029 | } else { | 38238 | } else { |
| 38030 | 0 | 38239 | 0 |
| @@ -38315,6 +38524,7 @@ fn decode_inter_block( | |||
| 38315 | ref_order_hints[(ref0 - LAST_FRAME) as usize], | 38524 | ref_order_hints[(ref0 - LAST_FRAME) as usize], |
| 38316 | ref_order_hints[(ref1 - LAST_FRAME) as usize], | 38525 | ref_order_hints[(ref1 - LAST_FRAME) as usize], |
| 38317 | ); | 38526 | ); |
| 38527 | + crate::msac::SymbolDecoder::set_symr_cdf("compound_idx"); | ||
| 38318 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); | 38528 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); |
| 38319 | if crate::envflags::env_flag!("EC_TRACE_MODE") { | 38529 | if crate::envflags::env_flag!("EC_TRACE_MODE") { |
| 38320 | eprintln!( | 38530 | eprintln!( |
| @@ -39651,6 +39861,7 @@ fn decode_inter_block( | |||
| 39651 | // TRUE footprint -- a 16x8 strip is group 1, a 32x16 strip | 39861 | // TRUE footprint -- a 16x8 strip is group 1, a 32x16 strip |
| 39652 | // group 2, not their square `side`'s 2/3. | 39862 | // group 2, not their square `side`'s 2/3. |
| 39653 | let bsize_group = size_group_wh(write_w, write_h); | 39863 | let bsize_group = size_group_wh(write_w, write_h); |
| 39864 | + crate::msac::SymbolDecoder::set_symr_cdf("interintra"); | ||
| 39654 | let interintra = dec.symbol(&mut cdfs.interintra[bsize_group]) == 1; | 39865 | let interintra = dec.symbol(&mut cdfs.interintra[bsize_group]) == 1; |
| 39655 | if interintra { | 39866 | if interintra { |
| 39656 | // lane-interintra r1 (decodemv.c 1540-1555): interintra_mode, | 39867 | // lane-interintra r1 (decodemv.c 1540-1555): interintra_mode, |
| @@ -39837,6 +40048,7 @@ fn decode_inter_block( | |||
| 39837 | hit!(FIMV_ALPHABET_HITS); | 40048 | hit!(FIMV_ALPHABET_HITS); |
| 39838 | } | 40049 | } |
| 39839 | if warp_eligible { | 40050 | if warp_eligible { |
| 40051 | + crate::msac::SymbolDecoder::set_symr_cdf("motion_mode"); | ||
| 39840 | let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); | 40052 | let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); |
| 39841 | match mode { | 40053 | match mode { |
| 39842 | 0 => {} | 40054 | 0 => {} |
| @@ -40147,7 +40359,7 @@ fn decode_inter_block( | |||
| 40147 | write_h, | 40359 | write_h, |
| 40148 | ss_x(fctx), | 40360 | ss_x(fctx), |
| 40149 | ss_y(fctx), | 40361 | ss_y(fctx), |
| 40150 | - chroma_side, | 40362 | + chroma_stride, |
| 40151 | px, | 40363 | px, |
| 40152 | py, | 40364 | py, |
| 40153 | cpx, | 40365 | cpx, |
| @@ -41327,6 +41539,7 @@ fn decode_inter_block( | |||
| 41327 | ); | 41539 | ); |
| 41328 | return Ok(()); | 41540 | return Ok(()); |
| 41329 | } | 41541 | } |
| 41542 | + crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | ||
| 41330 | let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]); | 41543 | let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]); |
| 41331 | if crate::envflags::env_flag!("EC_IIS") { | 41544 | if crate::envflags::env_flag!("EC_IIS") { |
| 41332 | eprintln!( | 41545 | eprintln!( |
| @@ -41380,8 +41593,10 @@ fn decode_inter_block( | |||
| 41380 | let uv_mode = if !has_chroma { | 41593 | let uv_mode = if !has_chroma { |
| 41381 | DC_PRED | 41594 | DC_PRED |
| 41382 | } else if cfl_allowed { | 41595 | } else if cfl_allowed { |
| 41596 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 41383 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 41597 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 41384 | } else { | 41598 | } else { |
| 41599 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 41385 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 41600 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 41386 | }; | 41601 | }; |
| 41387 | if (9..=12).contains(&uv_mode) { | 41602 | if (9..=12).contains(&uv_mode) { |
| @@ -43772,6 +43987,7 @@ fn decode_intra_sub8_leaf( | |||
| 43772 | let step = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); | 43987 | let step = crate::envflags::env_flag!("EC_TRACE_MODE_STEP"); |
| 43773 | // `size_group_lookup[BLOCK_8X4] == size_group_lookup[BLOCK_4X8] == 0` | 43988 | // `size_group_lookup[BLOCK_8X4] == size_group_lookup[BLOCK_4X8] == 0` |
| 43774 | // (libaom common_data.h:61). | 43989 | // (libaom common_data.h:61). |
| 43990 | + crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | ||
| 43775 | let mode = dec.symbol(&mut cdfs.y_mode[0]); | 43991 | let mode = dec.symbol(&mut cdfs.y_mode[0]); |
| 43776 | if step { | 43992 | if step { |
| 43777 | eprintln!( | 43993 | eprintln!( |
| @@ -43794,8 +44010,10 @@ fn decode_intra_sub8_leaf( | |||
| 43794 | // always 4x4-or-smaller, so the predicate stays true and this read | 44010 | // always 4x4-or-smaller, so the predicate stays true and this read |
| 43795 | // is unchanged. | 44011 | // is unchanged. |
| 43796 | let uv_mode = if cfl_allowed_px(bw, bh, fctx) { | 44012 | let uv_mode = if cfl_allowed_px(bw, bh, fctx) { |
| 44013 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 43797 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 44014 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 43798 | } else { | 44015 | } else { |
| 44016 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 43799 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 44017 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 43800 | }; | 44018 | }; |
| 43801 | if step { | 44019 | if step { |
| @@ -45872,6 +46090,13 @@ fn decode_inter_block8( | |||
| 45872 | [u8; 2], | 46090 | [u8; 2], |
| 45873 | (i8, Option<i8>), | 46091 | (i8, Option<i8>), |
| 45874 | )> { | 46092 | )> { |
| 46093 | + // Round 27: this is the function whose mode read carries the block's real | ||
| 46094 | + // mi (the `EC_MODE_VAL8` rung prints it). The `decode_inter_block` | ||
| 46095 | + // entry sets the same label from ITS `at`, which is a different block -- | ||
| 46096 | + // publishing from here is what makes the EC_SYMR mi trustworthy on the | ||
| 46097 | + // inter path, which is what round 22 got wrong by assuming it was not. | ||
| 46098 | + crate::msac::SymbolDecoder::set_symr_phase("inter8"); | ||
| 46099 | + crate::msac::SymbolDecoder::set_symr_mi(leaf_mi.0 as i64, leaf_mi.1 as i64); | ||
| 45875 | const LAST_FRAME: i8 = 1; | 46100 | const LAST_FRAME: i8 = 1; |
| 45876 | // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back | 46101 | // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back |
| 45877 | // so the caller stamps them into `Neighbours` instead of the `[3, 3]` | 46102 | // so the caller stamps them into `Neighbours` instead of the `[3, 3]` |
| @@ -46144,6 +46369,7 @@ fn decode_inter_block8( | |||
| 46144 | && enable_masked_compound | 46369 | && enable_masked_compound |
| 46145 | && is_any_masked_compound_used_here(SIDE, SIDE) | 46370 | && is_any_masked_compound_used_here(SIDE, SIDE) |
| 46146 | { | 46371 | { |
| 46372 | + crate::msac::SymbolDecoder::set_symr_cdf("comp_group_idx"); | ||
| 46147 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) | 46373 | dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) |
| 46148 | } else { | 46374 | } else { |
| 46149 | 0 | 46375 | 0 |
| @@ -46198,6 +46424,7 @@ fn decode_inter_block8( | |||
| 46198 | ref_order_hints[(ref0 - LAST_FRAME) as usize], | 46424 | ref_order_hints[(ref0 - LAST_FRAME) as usize], |
| 46199 | ref_order_hints[(ref1 - LAST_FRAME) as usize], | 46425 | ref_order_hints[(ref1 - LAST_FRAME) as usize], |
| 46200 | ); | 46426 | ); |
| 46427 | + crate::msac::SymbolDecoder::set_symr_cdf("compound_idx"); | ||
| 46201 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); | 46428 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); |
| 46202 | if idx == 1 { | 46429 | if idx == 1 { |
| 46203 | (8, 8, 1u8) | 46430 | (8, 8, 1u8) |
| @@ -47071,6 +47298,7 @@ fn decode_inter_block8( | |||
| 47071 | let mut interintra_mode: Option<u8> = None; | 47298 | let mut interintra_mode: Option<u8> = None; |
| 47072 | let mut wedge_mask: Option<(&'static [u8], usize)> = None; | 47299 | let mut wedge_mask: Option<(&'static [u8], usize)> = None; |
| 47073 | if enable_interintra_compound && !skip_mode { | 47300 | if enable_interintra_compound && !skip_mode { |
| 47301 | + crate::msac::SymbolDecoder::set_symr_cdf("interintra"); | ||
| 47074 | let interintra = dec.symbol(&mut cdfs.interintra[SIZE_GROUP_8]) == 1; | 47302 | let interintra = dec.symbol(&mut cdfs.interintra[SIZE_GROUP_8]) == 1; |
| 47075 | if interintra { | 47303 | if interintra { |
| 47076 | // lane-interintra r1: same read pair as the 16/32 site; | 47304 | // lane-interintra r1: same read pair as the 16/32 site; |
| @@ -47177,6 +47405,7 @@ fn decode_inter_block8( | |||
| 47177 | hit!(FIMV_ALPHABET_HITS); | 47405 | hit!(FIMV_ALPHABET_HITS); |
| 47178 | } | 47406 | } |
| 47179 | if warp_eligible { | 47407 | if warp_eligible { |
| 47408 | + crate::msac::SymbolDecoder::set_symr_cdf("motion_mode"); | ||
| 47180 | let mode = dec.symbol(&mut cdfs.motion_mode[0]); | 47409 | let mode = dec.symbol(&mut cdfs.motion_mode[0]); |
| 47181 | match mode { | 47410 | match mode { |
| 47182 | 0 => {} | 47411 | 0 => {} |
| @@ -47766,6 +47995,7 @@ fn decode_inter_block8( | |||
| 47766 | } | 47995 | } |
| 47767 | } | 47996 | } |
| 47768 | } else { | 47997 | } else { |
| 47998 | + crate::msac::SymbolDecoder::set_symr_cdf("y_mode"); | ||
| 47769 | let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]); | 47999 | let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]); |
| 47770 | if mode >= 13 { | 48000 | if mode >= 13 { |
| 47771 | return Err(unsupported( | 48001 | return Err(unsupported( |
| @@ -47827,8 +48057,10 @@ fn decode_inter_block8( | |||
| 47827 | let uv_mode = if !has_chroma { | 48057 | let uv_mode = if !has_chroma { |
| 47828 | DC_PRED | 48058 | DC_PRED |
| 47829 | } else if cfl_allowed_px(SIDE, SIDE, fctx) { | 48059 | } else if cfl_allowed_px(SIDE, SIDE, fctx) { |
| 48060 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 47830 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | 48061 | dec.symbol(&mut cdfs.uv_mode_cfl[mode]) |
| 47831 | } else { | 48062 | } else { |
| 48063 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 47832 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | 48064 | dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) |
| 47833 | }; | 48065 | }; |
| 47834 | if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { | 48066 | if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") { |
| @@ -49350,9 +49582,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 49350 | lr, | 49582 | lr, |
| 49351 | &mut lr_grid, | 49583 | &mut lr_grid, |
| 49352 | &mut lr_reference, | 49584 | &mut lr_reference, |
| 49353 | - sb_r * SB_MI, | 49585 | + // True mode-info units: a 64px superblock is 8, and `SB_MI` is 16. |
| 49354 | - sb_c * SB_MI, | 49586 | + // `read_lr` divides by the restoration-unit size (a real pixel count), |
| 49355 | - SB_MI, | 49587 | + // so it is the one consumer that needs the absolute origin in real mi. |
| 49588 | + // The half-mi convention these arguments used to carry only worked | ||
| 49589 | + // while `read_lr` also counted in half-mi -- the two cancelled. | ||
| 49590 | + sb_r * (SB_MI / 2), | ||
| 49591 | + sb_c * (SB_MI / 2), | ||
| 49592 | + SB_MI / 2, | ||
| 49356 | fctx, | 49593 | fctx, |
| 49357 | ); | 49594 | ); |
| 49358 | } | 49595 | } |
| @@ -52108,6 +52345,118 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 52108 | 52345 | ||
| 52109 | #[cfg(test)] | 52346 | #[cfg(test)] |
| 52110 | mod tests { | 52347 | mod tests { |
| 52348 | + /// lane-av1422warp r33: the OBMC pair-merge snap must move the READ to | ||
| 52349 | + /// libaom's position, not the reported offset. | ||
| 52350 | + /// | ||
| 52351 | + /// libaom `obmc.h:44-46`: | ||
| 52352 | + /// ```c | ||
| 52353 | + /// if (mi_step == 1) { | ||
| 52354 | + /// above_mi_col &= ~1; // snap the INDEX, unconditional | ||
| 52355 | + /// above_mi = prev_row_mi + above_mi_col + 1; // read at snap + 1 | ||
| 52356 | + /// mi_step = 2; | ||
| 52357 | + /// } | ||
| 52358 | + /// ``` | ||
| 52359 | + /// and the relative offset handed to | ||
| 52360 | + /// `av1_setup_build_prediction_by_above_pred` is | ||
| 52361 | + /// `above_mi_col - mi_col` **after** the snap, which is `-1` at an odd | ||
| 52362 | + /// `mi_col`. An earlier fix clamped the snapped INDEX to `mi_col` to | ||
| 52363 | + /// stop that subtraction underflowing, which silenced the underflow and | ||
| 52364 | + /// in exchange read the neighbour one column RIGHT of libaom's and then | ||
| 52365 | + /// stepped past the block's own right edge. | ||
| 52366 | + /// | ||
| 52367 | + /// The grid here carries DISTINGUISHABLE neighbours at the pair's even | ||
| 52368 | + /// half, its odd half, and the column to the right of the pair, so the | ||
| 52369 | + /// test fails if the walk reads any position but the odd half. It is the | ||
| 52370 | + /// snapped READ this pins -- and no stream in the corpus exercises it | ||
| 52371 | + /// (a1.obu's 1338 traced OBMC neighbours are byte-identical before and | ||
| 52372 | + /// after the fix, because its 4-wide pair never starts on an odd edge), | ||
| 52373 | + /// so nothing else covers this branch. | ||
| 52374 | + #[test] | ||
| 52375 | + fn the_obmc_pair_merge_snap_reads_libaoms_neighbour_not_one_to_the_right() { | ||
| 52376 | + const NAME: &str = "the_obmc_pair_merge_snap_reads_libaoms_neighbour_not_one_to_the_right"; | ||
| 52377 | + // `ref_frame` 1 == LAST_FRAME, which is what `is_inter` consumers | ||
| 52378 | + // expect; the MV makes each cell individually identifiable. | ||
| 52379 | + let cell = |mv: (i16, i16), size: u8| MiInfo { | ||
| 52380 | + is_inter: true, | ||
| 52381 | + ref_frame: 1, | ||
| 52382 | + ref_frame1: 0, | ||
| 52383 | + mv: mv, | ||
| 52384 | + mv1: (0, 0), | ||
| 52385 | + is_new_mv: true, | ||
| 52386 | + size, | ||
| 52387 | + size_h: size, | ||
| 52388 | + is_global_mv0: false, | ||
| 52389 | + is_global_mv1: false, | ||
| 52390 | + }; | ||
| 52391 | + const EVEN: (i16, i16) = (10, 10); | ||
| 52392 | + const ODD: (i16, i16) = (20, 20); | ||
| 52393 | + const RIGHT: (i16, i16) = (30, 30); | ||
| 52394 | + | ||
| 52395 | + // --- the above walk, at an ODD `mi_col` --- | ||
| 52396 | + let mut grid = crate::mvstack::MiGrid::new(16, 16); | ||
| 52397 | + // The block under test sits at mi_col 5; the neighbour row is 4. | ||
| 52398 | + // A 4-wide inter cell at the ODD half (5) is what forces | ||
| 52399 | + // `mi_step == 1` and therefore the pair merge. | ||
| 52400 | + grid.set(4, 4, cell(EVEN, 1)); | ||
| 52401 | + grid.set(4, 5, cell(ODD, 1)); | ||
| 52402 | + grid.set(4, 6, cell(RIGHT, 4)); // one column RIGHT of the pair | ||
| 52403 | + // `bw4 == 2` so `AOMMIN(xd->width, mi_step)` is the pair's own 2 | ||
| 52404 | + // rather than clipped to a 1-wide block's 1. | ||
| 52405 | + let nb = overlappable_above(&grid, 5, 5, 2, 16, 4); | ||
| 52406 | + assert!( | ||
| 52407 | + !nb.is_empty(), | ||
| 52408 | + "{NAME}: the above walk found no neighbour at all" | ||
| 52409 | + ); | ||
| 52410 | + let (off4, span4, info, src4) = nb[0]; | ||
| 52411 | + assert_eq!( | ||
| 52412 | + info.mv, ODD, | ||
| 52413 | + "{NAME}: the above pair merge read the wrong neighbour -- libaom \ | ||
| 52414 | + snaps the column and reads snap+1, which is the ODD half" | ||
| 52415 | + ); | ||
| 52416 | + assert_ne!( | ||
| 52417 | + info.mv, RIGHT, | ||
| 52418 | + "{NAME}: the clamp moved the snapped index onto mi_col, so the \ | ||
| 52419 | + walk read one column RIGHT of libaom" | ||
| 52420 | + ); | ||
| 52421 | + assert_eq!(src4, 0, "{NAME}: the read column's relative offset"); | ||
| 52422 | + assert_eq!(span4, 2, "{NAME}: the pair steps over BOTH halves"); | ||
| 52423 | + // libaom's `above_mi_col - mi_col` is -1 here; this tuple is | ||
| 52424 | + // `usize`, so the reported offset saturates to 0 rather than | ||
| 52425 | + // wrapping to `usize::MAX`. The snap is what the read depends on. | ||
| 52426 | + assert_eq!( | ||
| 52427 | + off4, 0, | ||
| 52428 | + "{NAME}: the reported offset must saturate, not wrap" | ||
| 52429 | + ); | ||
| 52430 | + | ||
| 52431 | + // --- the left walk, at an ODD `mi_row`: the same shape --- | ||
| 52432 | + let mut grid = crate::mvstack::MiGrid::new(16, 16); | ||
| 52433 | + grid.set(4, 4, cell(EVEN, 1)); | ||
| 52434 | + grid.set(5, 4, cell(ODD, 1)); | ||
| 52435 | + grid.set(6, 4, cell(RIGHT, 4)); | ||
| 52436 | + let nb = overlappable_left(&grid, 5, 5, 2, 16, 4); | ||
| 52437 | + assert!( | ||
| 52438 | + !nb.is_empty(), | ||
| 52439 | + "{NAME}: the left walk found no neighbour at all" | ||
| 52440 | + ); | ||
| 52441 | + let (off4, span4, info, src4) = nb[0]; | ||
| 52442 | + assert_eq!( | ||
| 52443 | + info.mv, ODD, | ||
| 52444 | + "{NAME}: the left pair merge read the wrong neighbour -- libaom \ | ||
| 52445 | + snaps the row and reads snap+1, which is the ODD half" | ||
| 52446 | + ); | ||
| 52447 | + assert_ne!( | ||
| 52448 | + info.mv, RIGHT, | ||
| 52449 | + "{NAME}: the clamp moved the snapped row onto mi_row, so the walk \ | ||
| 52450 | + read one row BELOW libaom" | ||
| 52451 | + ); | ||
| 52452 | + assert_eq!(src4, 0, "{NAME}: the read row's relative offset"); | ||
| 52453 | + assert_eq!(span4, 2, "{NAME}: the pair steps over BOTH halves"); | ||
| 52454 | + assert_eq!( | ||
| 52455 | + off4, 0, | ||
| 52456 | + "{NAME}: the reported offset must saturate, not wrap" | ||
| 52457 | + ); | ||
| 52458 | + } | ||
| 52459 | + | ||
| 52111 | /// lane-twostage: the reference bank these gates decode against -- | 52460 | /// lane-twostage: the reference bank these gates decode against -- |
| 52112 | /// `LAST_FRAME` alone, already in hand (`ref_frame` index 1). | 52461 | /// `LAST_FRAME` alone, already in hand (`ref_frame` index 1). |
| 52113 | fn last_only(reference: &Picture) -> RefPix<'_> { | 52462 | fn last_only(reference: &Picture) -> RefPix<'_> { |
| @@ -53375,6 +53724,7 @@ mod tests { | |||
| 53375 | DC_PRED, | 53724 | DC_PRED, |
| 53376 | &mut cdfs.kf_y_mode[INTRA_MODE_CTX[DC_PRED]][INTRA_MODE_CTX[DC_PRED]], | 53725 | &mut cdfs.kf_y_mode[INTRA_MODE_CTX[DC_PRED]][INTRA_MODE_CTX[DC_PRED]], |
| 53377 | ); | 53726 | ); |
| 53727 | + crate::msac::SymbolDecoder::set_symr_cdf("uv_mode"); | ||
| 53378 | enc.symbol(DC_PRED, &mut cdfs.uv_mode_no_cfl[DC_PRED]); | 53728 | enc.symbol(DC_PRED, &mut cdfs.uv_mode_no_cfl[DC_PRED]); |
| 53379 | let data = enc.finish(); | 53729 | let data = enc.finish(); |
| 53380 | let decoded = decode_key_frame_tile( | 53730 | let decoded = decode_key_frame_tile( |
crates/ec-av1/src/msac.rsmodified+72 -0
| @@ -321,6 +321,34 @@ impl Drop for SymbolDecoder<'_> { | |||
| 321 | } | 321 | } |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | +thread_local! { | ||
| 325 | + /// The `(mi_row, mi_col)` the enclosing block reader is inside, for the | ||
| 326 | + /// `EC_SYMR` trace. A symbol read carries no mi of its own, so without it | ||
| 327 | + /// the per-read stream can only be located by correlating it against a | ||
| 328 | + /// SEPARATE trace -- and that correlation is what mis-attributed reads in | ||
| 329 | + /// rounds 22 and 23. Set by the mode readers at entry; `(-1,-1)` outside. | ||
| 330 | + pub(crate) static SYMR_MI: std::cell::Cell<(i64, i64)> = | ||
| 331 | + const { std::cell::Cell::new((-1, -1)) }; | ||
| 332 | + /// A short tag for the READER PHASE ("intra", "inter", "mv", ...), printed | ||
| 333 | + /// on every `EC_SYMR` line. The coefficient rungs stop well before some | ||
| 334 | + /// divergences, so the per-read stream is the only instrument that covers | ||
| 335 | + /// the inter path; without a phase its reads are unattributable. | ||
| 336 | + pub(crate) static SYMR_PHASE: std::cell::Cell<&'static str> = | ||
| 337 | + const { std::cell::Cell::new("") }; | ||
| 338 | + /// The CDF TABLE NAME for the NEXT read, mirroring the oracle's | ||
| 339 | + /// `ec_symr_cdf_tag`. `cdf0` alone cannot identify a table -- two rows | ||
| 340 | + /// can share a first entry -- so this is what turns "two 2-symbol reads" | ||
| 341 | + /// into a named pair. | ||
| 342 | + /// | ||
| 343 | + /// ONE-SHOT, consumed by the next `symbol()`. Round 30: it used to be | ||
| 344 | + /// sticky, so every read after a tagged one carried that tag -- which is | ||
| 345 | + /// how an 8-symbol read came to be labelled `interintra`, a 2-symbol | ||
| 346 | + /// table. An EMPTY `cdf=` therefore means "no table set for this read", | ||
| 347 | + /// never "the previous read's table". | ||
| 348 | + pub(crate) static SYMR_CDF: std::cell::Cell<&'static str> = | ||
| 349 | + const { std::cell::Cell::new("") }; | ||
| 350 | +} | ||
| 351 | + | ||
| 324 | impl<'a> SymbolDecoder<'a> { | 352 | impl<'a> SymbolDecoder<'a> { |
| 325 | /// `init_symbol` (spec 8.2.2). | 353 | /// `init_symbol` (spec 8.2.2). |
| 326 | #[must_use] | 354 | #[must_use] |
| @@ -396,8 +424,36 @@ impl<'a> SymbolDecoder<'a> { | |||
| 396 | } | 424 | } |
| 397 | 425 | ||
| 398 | /// `decode_symbol` (spec 8.2.6), with the adaptation of 8.3.2. | 426 | /// `decode_symbol` (spec 8.2.6), with the adaptation of 8.3.2. |
| 427 | + /// | ||
| 428 | + pub(crate) fn set_symr_cdf(t: &'static str) { | ||
| 429 | + SYMR_CDF.with(|c| c.set(t)); | ||
| 430 | + } | ||
| 431 | + | ||
| 432 | + pub(crate) fn set_symr_phase(p: &'static str) { | ||
| 433 | + SYMR_PHASE.with(|c| c.set(p)); | ||
| 434 | + } | ||
| 435 | + | ||
| 436 | + pub(crate) fn set_symr_mi(mi_r: i64, mi_c: i64) { | ||
| 437 | + SYMR_MI.with(|c| c.set((mi_r, mi_c))); | ||
| 438 | + } | ||
| 439 | + | ||
| 440 | + /// `EC_SYMR=1` dumps every symbol read's PRE state (before the read and | ||
| 441 | + /// before the adaptation) together with the symbol and the post-read | ||
| 442 | + /// range, so a divergence against a reference decoder can be bisected | ||
| 443 | + /// read by read. `cdf0` is the PRE-adapt row[0] -- the reference's own | ||
| 444 | + /// print of the same row is POST-adapt, so compare `32768 - ours_cdf0` | ||
| 445 | + /// against its `cdf0`, never the raw numbers. | ||
| 399 | #[inline] | 446 | #[inline] |
| 400 | pub fn symbol(&mut self, cdf: &mut [u16]) -> usize { | 447 | pub fn symbol(&mut self, cdf: &mut [u16]) -> usize { |
| 448 | + // lane-av1422warp r33 (reviewer P2): this ran on EVERY symbol read of | ||
| 449 | + // EVERY stream, production formats included, and `std::env::var_os` | ||
| 450 | + // is a real environment scan each time (~30ns x every symbol). | ||
| 451 | + // `env_flag!` keeps one `LazyLock<bool>` per call SITE, so the check | ||
| 452 | + // compiles to an atomic load. The trace is byte-identical: same | ||
| 453 | + // condition, same format, same fields. | ||
| 454 | + let symr = crate::envflags::env_flag!("EC_SYMR"); | ||
| 455 | + let (pre_value, pre_range, pre_bit) = (self.value, self.range, self.bit); | ||
| 456 | + let pre_cdf0 = cdf.first().copied().unwrap_or(0); | ||
| 401 | // lane-census: the syntax census charges this symbol's bits to the | 457 | // lane-census: the syntax census charges this symbol's bits to the |
| 402 | // TABLE it read, so every coding tool is accounted without a | 458 | // TABLE it read, so every coding tool is accounted without a |
| 403 | // per-call-site label. Off (`EC_AV1_BITCENSUS` unset) this is one | 459 | // per-call-site label. Off (`EC_AV1_BITCENSUS` unset) this is one |
| @@ -419,6 +475,22 @@ impl<'a> SymbolDecoder<'a> { | |||
| 419 | if crate::census::armed() { | 475 | if crate::census::armed() { |
| 420 | crate::census::charge(cdf.as_ptr() as usize, self.tell_bits() - t0); | 476 | crate::census::charge(cdf.as_ptr() as usize, self.tell_bits() - t0); |
| 421 | } | 477 | } |
| 478 | + if symr { | ||
| 479 | + eprintln!( | ||
| 480 | + "EC_SYMR ph={} cdf={} mi=({},{}) pre=({},{},{}) cdf0={} n={} s={} post_rng={}", | ||
| 481 | + SYMR_PHASE.with(std::cell::Cell::get), | ||
| 482 | + SYMR_CDF.with(|c| c.replace("")), | ||
| 483 | + SYMR_MI.with(std::cell::Cell::get).0, | ||
| 484 | + SYMR_MI.with(std::cell::Cell::get).1, | ||
| 485 | + pre_value, | ||
| 486 | + pre_range, | ||
| 487 | + pre_bit, | ||
| 488 | + pre_cdf0, | ||
| 489 | + cdf.len() - 1, | ||
| 490 | + s, | ||
| 491 | + self.range | ||
| 492 | + ); | ||
| 493 | + } | ||
| 422 | s | 494 | s |
| 423 | } | 495 | } |
| 424 | 496 | ||
crates/ec-av1/src/restoration.rsmodified+66 -14
| @@ -479,8 +479,16 @@ fn ceil_div(a: u32, b: u32) -> u32 { | |||
| 479 | /// is >= 64px, so only the top-of-superblock call ever has non-empty | 479 | /// is >= 64px, so only the top-of-superblock call ever has non-empty |
| 480 | /// corners, matching this decoder's own once-per-SB call site) and reads | 480 | /// corners, matching this decoder's own once-per-SB call site) and reads |
| 481 | /// one `read_lr_unit` per covered `(rrow, rcol)`, per plane, in plane | 481 | /// one `read_lr_unit` per covered `(rrow, rcol)`, per plane, in plane |
| 482 | -/// order. `sb_mi` is the superblock's mode-info width (`SB_MI`, 16 for the | 482 | +/// order. |
| 483 | -/// 64px superblocks this decoder always uses). | 483 | +/// |
| 484 | +/// `mi_row`/`mi_col`/`sb_mi` are all in **mode-info units (4x4)**, in true | ||
| 485 | +/// frame coordinates -- this is the one call that converts a superblock's | ||
| 486 | +/// position into absolute frame space, so it cannot carry the half-mi | ||
| 487 | +/// convention the partition walks use. A 64px superblock is 8 mi and a | ||
| 488 | +/// 128px superblock is 16 mi; the callers pass `SB_MI / 2` and `SB_MI` | ||
| 489 | +/// respectively (`SB_MI` being 16). The corners themselves then step each | ||
| 490 | +/// axis by [`MI_SIZE_8PX`] pixels -- see that constant's doc for why it is | ||
| 491 | +/// 8 and not libaom's 4. | ||
| 484 | #[allow(clippy::too_many_arguments)] | 492 | #[allow(clippy::too_many_arguments)] |
| 485 | pub(crate) fn read_lr( | 493 | pub(crate) fn read_lr( |
| 486 | dec: &mut SymbolDecoder, | 494 | dec: &mut SymbolDecoder, |
| @@ -501,27 +509,50 @@ pub(crate) fn read_lr( | |||
| 501 | if ftype == RestorationType::None { | 509 | if ftype == RestorationType::None { |
| 502 | continue; | 510 | continue; |
| 503 | } | 511 | } |
| 504 | - let mi_size = if plane == 0 { | 512 | + // `av1_loop_restoration_corners_in_sb` (restoration.c:1303-1338), |
| 505 | - 4u32 | 513 | + // transcribed per axis. The two axes are NOT symmetric: libaom |
| 514 | + // derives `mi_size_x` from `subsampling_x` and `mi_size_y` from | ||
| 515 | + // `subsampling_y`, and derives the row corners from the Y term | ||
| 516 | + // alone. This decoder used one `mi_size = 4 >> subsampling_x` for | ||
| 517 | + // both axes, so at 4:2:2 (ss_x 1, ss_y 0) the row range was | ||
| 518 | + // computed from the COLUMN axis's subsampling -- a 4x-too-small | ||
| 519 | + // row step, which made `rrow0 == rrow1` (an empty range, zero | ||
| 520 | + // `read_lr_unit` calls) wherever libaom reads a chroma unit. That | ||
| 521 | + // is the two missing `wiener_restore_cdf` reads this lane spent | ||
| 522 | + // nine rounds localising: the oracle reads three at mi(30,62), | ||
| 523 | + // this decoder read one. | ||
| 524 | + // | ||
| 525 | + // One mode-info unit is 8 pixels (`MI_SIZE_8PX`; see its doc for why | ||
| 526 | + // that is not libaom's `MI_SIZE`). Superres | ||
| 527 | + // widens the column axis only (spec 7.16), so it enters `num_x` | ||
| 528 | + // and `denom_x` and leaves the row axis alone, exactly as libaom | ||
| 529 | + // does with `av1_superres_scaled`. | ||
| 530 | + let is_uv = plane != 0; | ||
| 531 | + let ss_x = if is_uv { | ||
| 532 | + crate::decode::ss_x(fctx) as u32 | ||
| 506 | } else { | 533 | } else { |
| 507 | - 4u32 >> (crate::decode::ss_x(fctx) as u32) | 534 | + 0 |
| 535 | + }; | ||
| 536 | + let ss_y = if is_uv { | ||
| 537 | + crate::decode::ss_y(fctx) as u32 | ||
| 538 | + } else { | ||
| 539 | + 0 | ||
| 508 | }; | 540 | }; |
| 541 | + let mi_size_x = MI_SIZE_8PX >> ss_x; | ||
| 542 | + let mi_size_y = MI_SIZE_8PX >> ss_y; | ||
| 509 | let unit_size = lr.loop_restoration_size[plane]; | 543 | let unit_size = lr.loop_restoration_size[plane]; |
| 510 | let horz_units = grid.horz_units[plane] as u32; | 544 | let horz_units = grid.horz_units[plane] as u32; |
| 511 | let vert_units = grid.vert_units[plane] as u32; | 545 | let vert_units = grid.vert_units[plane] as u32; |
| 512 | - // `av1_loop_restoration_corners_in_sb` (restoration.c:1314): under | ||
| 513 | - // superres the mi column is in DOWNSCALED units while the unit grid | ||
| 514 | - // is in upscaled ones, so the column division scales by | ||
| 515 | - // `superres_denom / SCALE_NUMERATOR` (`mi_to_num_x`/`denom_x`). Rows | ||
| 516 | - // are never scaled (spec 7.16 widens columns only). | ||
| 517 | let (num_x, denom_x) = match crate::decode::superres(fctx) { | 546 | let (num_x, denom_x) = match crate::decode::superres(fctx) { |
| 518 | - Some((_, denom)) => (mi_size * denom, unit_size * 8), | 547 | + Some((_, d)) => (mi_size_x * d, unit_size * SCALE_NUMERATOR), |
| 519 | - None => (mi_size, unit_size), | 548 | + None => (mi_size_x, unit_size), |
| 520 | }; | 549 | }; |
| 550 | + let num_y = mi_size_y; | ||
| 551 | + let denom_y = unit_size; | ||
| 521 | let rcol0 = ceil_div(mi_col * num_x, denom_x); | 552 | let rcol0 = ceil_div(mi_col * num_x, denom_x); |
| 522 | let rcol1 = ceil_div((mi_col + sb_mi) * num_x, denom_x).min(horz_units); | 553 | let rcol1 = ceil_div((mi_col + sb_mi) * num_x, denom_x).min(horz_units); |
| 523 | - let rrow0 = ceil_div(mi_row * mi_size, unit_size); | 554 | + let rrow0 = ceil_div(mi_row * num_y, denom_y); |
| 524 | - let rrow1 = ceil_div((mi_row + sb_mi) * mi_size, unit_size).min(vert_units); | 555 | + let rrow1 = ceil_div((mi_row + sb_mi) * num_y, denom_y).min(vert_units); |
| 525 | let chroma = plane != 0; | 556 | let chroma = plane != 0; |
| 526 | for rrow in rrow0..rrow1 { | 557 | for rrow in rrow0..rrow1 { |
| 527 | for rcol in rcol0..rcol1 { | 558 | for rcol in rcol0..rcol1 { |
| @@ -555,6 +586,27 @@ thread_local! { | |||
| 555 | static LR_LAST_STRIPE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 586 | static LR_LAST_STRIPE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 556 | } | 587 | } |
| 557 | 588 | ||
| 589 | +/// Pixels per mode-info unit (4x4 mi is 8 pixels). This is what | ||
| 590 | +/// `av1_loop_restoration_corners_in_sb` (`restoration.c:1303-1338`) steps | ||
| 591 | +/// each axis by, subsampled per axis: `MI_SIZE_8PX >> ss_x` for columns, | ||
| 592 | +/// `MI_SIZE_8PX >> ss_y` for rows. | ||
| 593 | +/// | ||
| 594 | +/// NAMING, because it is a trap: libaom's own `MI_SIZE` is **4** | ||
| 595 | +/// (`av1/common/enums.h:39-40`, `1 << MI_SIZE_LOG2` with `MI_SIZE_LOG2 2`), | ||
| 596 | +/// and libaom writes `mi_size_x = MI_SIZE >> ss_x` -- the same expression, | ||
| 597 | +/// at half this value. The factor of two is not a transcription slip: its | ||
| 598 | +/// `denom_x`/`denom_y` (`rsi->restoration_unit_size`) is a PIXEL count | ||
| 599 | +/// (128 for a 128px superblock), so libaom's numerator and denominator | ||
| 600 | +/// already sit on opposite scales, and doubling the numerator lands both in | ||
| 601 | +/// pixels. This constant is deliberately NOT called `MI_SIZE`, so nobody | ||
| 602 | +/// "corrects" it back to 4 and halves every restoration-unit range. | ||
| 603 | +/// | ||
| 604 | +/// The authority is the paired trace, not this comment: at 8 the whole | ||
| 605 | +/// 16-frame 4:2:2 stream pairs 246735-for-246735 against the instrumented | ||
| 606 | +/// oracle, and at 4 it does not. | ||
| 607 | +const MI_SIZE_8PX: u32 = 8; | ||
| 608 | +/// `SCALE_NUMERATOR` (aom_scale.h): the superres scale's fixed point, 8. | ||
| 609 | +const SCALE_NUMERATOR: u32 = 8; | ||
| 558 | /// Current value of [`LR_STRIPE0_HITS`]. | 610 | /// Current value of [`LR_STRIPE0_HITS`]. |
| 559 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 611 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| 560 | pub(crate) fn lr_stripe0_hits() -> usize { | 612 | pub(crate) fn lr_stripe0_hits() -> usize { |
crates/ec-av1/src/stream.rsmodified+78 -2
| @@ -1,5 +1,3 @@ | |||
| 1 | -/home/user/Documents/Code/Rust/edith_codecs/crates/ec-av1/src/stream.rs: | ||
| 2 | - | ||
| 3 | //! The stream-level entry point a real decoder needs: walk a raw AV1 OBU | 1 | //! The stream-level entry point a real decoder needs: walk a raw AV1 OBU |
| 4 | //! stream (`Encoded::stream`, or any low-overhead-format bitstream this | 2 | //! stream (`Encoded::stream`, or any low-overhead-format bitstream this |
| 5 | //! crate's own writers produce) via [`ec_av1_syntax::Av1Parser`] and dispatch | 3 | //! crate's own writers produce) via [`ec_av1_syntax::Av1Parser`] and dispatch |
| @@ -2503,6 +2501,84 @@ pub(crate) mod tests { | |||
| 2503 | ); | 2501 | ); |
| 2504 | } | 2502 | } |
| 2505 | } | 2503 | } |
| 2504 | + /// lane-av1422warp: the SECOND 4:2:2 coverage witness -- the one | ||
| 2505 | + /// `422_sb128_3f.obu` could not be, because that stream's inter content | ||
| 2506 | + /// is skip-heavy (see `lanes/av1422stripwrite.report.md`, which named a | ||
| 2507 | + /// second fixture with real residuals, compound and warped motion above | ||
| 2508 | + /// the vertical midpoint as the thing that would justify lifting the | ||
| 2509 | + /// refusal). This is that fixture. | ||
| 2510 | + /// | ||
| 2511 | + /// `422_residual_compound_warp_16f.obu` (38845 bytes), sha256 | ||
| 2512 | + /// `d78e2afb43ce311d3d82335a945c6f80f62db4537966d881c1349a68b3aecb95`: | ||
| 2513 | + /// | ||
| 2514 | + /// ```text | ||
| 2515 | + /// ffmpeg -f lavfi -i "mandelbrot=size=256x288:rate=24:maxiter=220: | ||
| 2516 | + /// start_scale=3:end_scale=0.35:end_pts=300:rotate=a=0.10" | ||
| 2517 | + /// -frames:v 24 -pix_fmt yuv422p -f yuv4mpegpipe src422.y4m | ||
| 2518 | + /// aomenc --codec=av1 --profile=2 --input-bit-depth=8 --limit=16 | ||
| 2519 | + /// --width=256 --height=288 --lag-in-frames=25 --auto-alt-ref=1 | ||
| 2520 | + /// --enable-global-motion=1 --cq-level=24 --cpu-used=0 | ||
| 2521 | + /// --threads=4 --kf-min-dist=0 --kf-max-dist=999999 \ | ||
| 2522 | + /// -n ffp --pass=2 --fpf=src422.y4m -o a1.webm | ||
| 2523 | + /// ffmpeg -i a1.webm -c copy -f obu -y a1.obu | ||
| 2524 | + /// ``` | ||
| 2525 | + /// | ||
| 2526 | + /// Measured on a patch-run-restore build (the `EC_AV1_ALLOW_422_PROBE` | ||
| 2527 | + /// bypass applied for the run, reverted after -- it is deliberately NOT | ||
| 2528 | + /// committed, and the refusal below is what the committed tree asserts): | ||
| 2529 | + /// | ||
| 2530 | + /// - all 16 frames pixel-exact against `aomdec --rawvideo`, 2359296 | ||
| 2531 | + /// bytes each, sha256 `4bfc2395e5ca6ea178f606e6b1ced773e26fc2d85b | ||
| 2532 | + /// c3a6cdb63a402939aeb203` on both sides; | ||
| 2533 | + /// - the entropy stream pairs bit-for-bit against the instrumented | ||
| 2534 | + /// oracle -- 246735 symbol reads each, no divergence anywhere in the | ||
| 2535 | + /// stream, not merely at the window this lane spent nine rounds | ||
| 2536 | + /// narrowing; | ||
| 2537 | + /// - the arms this fixture exists to cover really fire ABOVE the | ||
| 2538 | + /// vertical midpoint: 3 upper-half blocks on a non-`TRANSLATION` | ||
| 2539 | + /// global-motion model (`top_half_warp_hits`, gated on libaom's | ||
| 2540 | + /// `is_global_mv_block` per slot) and 3 upper-half | ||
| 2541 | + /// `GLOBAL_GLOBALMV` compound blocks (`top_half_compound_hits`), | ||
| 2542 | + /// alongside 25 compound-warp, 18 compound-warp-8x8-leaf, 84 | ||
| 2543 | + /// rotzoom global-warp, 22 Wiener and 10 SGRPROJ loop-restoration | ||
| 2544 | + /// units frame-globally. | ||
| 2545 | + /// | ||
| 2546 | + /// The loop-restoration numbers are load-bearing twice over: decoding | ||
| 2547 | + /// this stream is what exposed the per-axis `read_lr` corner bug | ||
| 2548 | + /// (`restoration.rs`, `av1_loop_restoration_corners_in_sb`), whose fix | ||
| 2549 | + /// is what made the whole sequence pair. 4:2:0 and 4:4:4 are unchanged | ||
| 2550 | + /// by it -- byte-identical to their pre-lane decodes, with the LR gate | ||
| 2551 | + /// family green. | ||
| 2552 | + /// | ||
| 2553 | + /// Like its two siblings, the committed assertion is the byte pin plus | ||
| 2554 | + /// the refusal-by-name contract: with the header refusal standing, | ||
| 2555 | + /// NO committed test can decode a 4:2:2 stream, because the bypass that | ||
| 2556 | + /// would allow it must never be committed. | ||
| 2557 | + #[test] | ||
| 2558 | + fn the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name() { | ||
| 2559 | + const NAME: &str = | ||
| 2560 | + "the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name"; | ||
| 2561 | + const REFUSAL: &str = "a chroma format of 4:2:2"; | ||
| 2562 | + const FILE: &str = "422_residual_compound_warp_16f.obu"; | ||
| 2563 | + const BYTES: usize = 38845; | ||
| 2564 | + const FP: u64 = 0x0e73a51e2cc0c424; | ||
| 2565 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 2566 | + .join("fixtures") | ||
| 2567 | + .join(FILE); | ||
| 2568 | + let data = std::fs::read(&path).unwrap_or_else(|e| { | ||
| 2569 | + panic!( | ||
| 2570 | + "{NAME}: pinned witness {} is missing ({e}) -- the gate cannot run", | ||
| 2571 | + path.display() | ||
| 2572 | + ) | ||
| 2573 | + }); | ||
| 2574 | + assert_eq!(data.len(), BYTES, "{NAME}: {FILE} size drifted"); | ||
| 2575 | + assert_eq!(fnv1a64(&data), FP, "{NAME}: {FILE} bytes drifted"); | ||
| 2576 | + let err = decode_stream(&data).unwrap_err().to_string(); | ||
| 2577 | + assert!( | ||
| 2578 | + err.contains(REFUSAL), | ||
| 2579 | + "{NAME}: {FILE} must refuse by name, got: {err}" | ||
| 2580 | + ); | ||
| 2581 | + } | ||
| 2506 | 2582 | ||
| 2507 | /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the | 2583 | /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the |
| 2508 | /// old gate `a_frame_using_quantisation_matrices_is_refused_by_name` is | 2584 | /// old gate `a_frame_using_quantisation_matrices_is_refused_by_name` is |
lanes/av1422warp.report.mdadded+2161 -0
Diff too large; view file
| @@ -0,0 +1,2161 @@ | |||
| 1 | +# lane-av1422warp — the second 4:2:2 coverage witness: stream pixel-exact 16/16, fixture pinned, refusal KEPT | ||
| 2 | + | ||
| 3 | +Base `a7d22aec`, worktree `~/.cache/wt/av1422warp`, branch `lane-av1422warp`, no | ||
| 4 | +push. Target dir `$HOME/.cache/cargo-target-av1422warp`. | ||
| 5 | + | ||
| 6 | +## Verdict | ||
| 7 | + | ||
| 8 | +The charter asked for a pixel-exact 4:2:2 stream with real residuals, compound | ||
| 9 | +and warped motion above the vertical midpoint. **It is pixel-exact**: all 16 | ||
| 10 | +frames match `aomdec --rawvideo` byte for byte, and the entropy stream pairs | ||
| 11 | +246735-for-246735 against the instrumented oracle with no divergence anywhere. | ||
| 12 | +The fixture is **pinned** and a **coverage gate is committed**. The | ||
| 13 | +sequence-header refusal **stays** — see the lift section, which sets out why | ||
| 14 | +"exact" and "covered" are not the same bar. | ||
| 15 | + | ||
| 16 | +| commit | what it settles | before | after | | ||
| 17 | +|---|---|---|---| | ||
| 18 | +| `af3285d5` | **the lift-blocker fix**: `read_lr` stepped the row axis by the COLUMN axis's term, and the superblock extent was 2x too large — the two cancelled exactly at 4:2:0, so 4:2:0/4:4:4 decoded byte-exact while carrying the bug | first divergence at symbol 107517; 16 frames non-exact | **246735/246735 paired, 16/16 pixel-exact** | | ||
| 19 | +| `4579d209` | OBMC strides the 4:2:2 chroma prediction with the square `chroma_side` | 0 frames decoded (panic) | 16/16 decode | | ||
| 20 | +| `a9611ea2` | chroma-above neighbour read one mi column left of libaom's | frame 0 PREFILT 56142 diffs | 53395 diffs; first divergent block byte-exact | | ||
| 21 | +| `a4532a41` → superseded | the OBMC pair-merge snap was clamped on the INDEX rather than the reported offset (reviewer P2) | read one column right of libaom, then skipped `mi_col + 1` | snap unconditional, offset saturates | | ||
| 22 | + | ||
| 23 | +## Pinned, and the gate | ||
| 24 | + | ||
| 25 | +`crates/ec-av1/fixtures/422_residual_compound_warp_16f.obu` — 38845 B, sha256 | ||
| 26 | +`d78e2afb43ce311d3d82335a945c6f80f62db4537966d881c1349a68b3aecb95`, fnv1a64 | ||
| 27 | +`0x0e73a51e2cc0c424`. Gate | ||
| 28 | +`the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name` | ||
| 29 | +— pin plus refuse-by-name, the established 4:2:2 pattern, because with the | ||
| 30 | +header refusal standing no committed test *can* decode a 4:2:2 stream. It is | ||
| 31 | +mutation-proven both ways (flipped fixture byte panics `bytes drifted`; wrong | ||
| 32 | +refusal string panics `must refuse by name`). | ||
| 33 | + | ||
| 34 | +## The stream (source recipe; the fixture is now committed) | ||
| 35 | + | ||
| 36 | +- pinned `a1.obu` 38845 B, sha256 `d78e2afb43ce311d3d82335a945c6f80f62db4537966d881c1349a68b3aecb95` | ||
| 37 | +- source `src422.y4m` sha256 `4d35eaf65d1a5541b3177e1183644c163b3868d8f141bed0ce9fdf833280ba9f` | ||
| 38 | +- 4:2:0 control `a420.obu` sha256 `1f43ef1ace6f7fa2f38c2deff765dd0bc529cbf7432788c736c7261350525e5b` | ||
| 39 | + | ||
| 40 | +Measured against `aomdec --rawvideo`: 2359296 bytes, sha256 | ||
| 41 | +`4bfc2395e5ca6ea178f606e6b1ced773e26fc2d85bc3a6cdb63a402939aeb203` on both | ||
| 42 | +sides. | ||
| 43 | + | ||
| 44 | +Rotzoom mandelbrot is lane-av1gwarp12's lever (a similarity transform is exactly | ||
| 45 | +the family the 4-parameter ROTZOOM model expresses); `lag-in-frames=25` plus | ||
| 46 | +`auto-alt-ref` gives the multi-reference compound needs. Decode is | ||
| 47 | +`EC_AV1_ALLOW_422_PROBE=1` through the local patch-run-restore bypass, compared | ||
| 48 | +against `aomdec --rawvideo`; the bypass is in neither commit. | ||
| 49 | + | ||
| 50 | +## Defect 1 — OBMC chroma prediction stride (`4579d209`) | ||
| 51 | + | ||
| 52 | +Site: `ObmcPlan.chroma_side`, `obmc_plan`'s parameter, `obmc_run`'s destructure, | ||
| 53 | +consumed at the four chroma blend sites and the two `EC_MCB` prediction dumps. | ||
| 54 | + | ||
| 55 | +Since lane-av1-422blockhalf the 4:2:2 chroma PREDICTION buffer is | ||
| 56 | +`(chroma_stride, chroma_buf_h)` — the plane block's own per-axis shape — but | ||
| 57 | +`obmc_run` strided it with the enclosing square `chroma_side`, so row `r` was | ||
| 58 | +read at `r * side`. Measured on `a1.obu`: the 32x16 luma strip at px=160, py=0 has | ||
| 59 | +`side=32, write_w=32, write_h=16, chroma_stride=16, chroma_buf_h=16`, so `pred_u` | ||
| 60 | +is 256 samples and the left-pass chroma blend wrote row 15 at index `15*32 = 480` | ||
| 61 | +(needs 520): `index out of bounds: the len is 256 but the index is 256` in | ||
| 62 | +`obmc_blend_h`. Before: zero frames decoded. After: `OK: 16 frames decoded, | ||
| 63 | +256x288`. Every other consumer of `pred_u`/`pred_v` in that block already strides | ||
| 64 | +with `chroma_stride`, and the two are equal at 4:2:0 and 4:4:4. | ||
| 65 | + | ||
| 66 | +## Defect 2 — the chroma-above reference mi (`a9611ea2`) | ||
| 67 | + | ||
| 68 | +Site: `Neighbours::smooth_uv_neighbour_unsnapped` read the above chroma neighbour | ||
| 69 | +at `(mi_r - 1, mi_c)` and the left at `(mi_r, mi_c - 1)`. libaom's | ||
| 70 | +`set_mi_row_col` (`av1_common_int.h:1400-1401`) puts them at | ||
| 71 | +`base_mi[-mi_stride + ss_x]` and `base_mi[ss_y*mi_stride - 1]`, where `base_mi` | ||
| 72 | +is the block's own mi already de-offset by `(mi_row & ss_y)` / `(mi_col & ss_x)` — | ||
| 73 | +which is exactly the snap the caller applies. Read as (row, column) deltas that | ||
| 74 | +is `above = (-1, +ss_x)` and `left = (+ss_y, -1)`. | ||
| 75 | + | ||
| 76 | +**Shipped: the above column.** It carries `+ss_x` wherever `ss_x == 1` — 4:2:0, | ||
| 77 | +4:2:2 **and 4:4:0** all carry that column shift; only 4:4:4 (`ss_x == 0`) leaves | ||
| 78 | +the read where it was. Measured: folding it in leaves the 4:2:0 control | ||
| 79 | +byte-identical to `aomdec --rawvideo`. The honest statement of what that | ||
| 80 | +measurement shows is that the boolean the column feeds came out the same on the | ||
| 81 | +control's blocks — not that the shift is the identity there. | ||
| 82 | + | ||
| 83 | +**Not shipped, and KNOWN UNRESOLVED: the left row term `+ss_y`.** libaom puts the | ||
| 84 | +left reference one mi row DOWN at 4:2:0 and 4:4:0 (`ss_y == 1`) and on its own | ||
| 85 | +row at 4:2:2 (`ss_y == 0`); this reads its own row at every subsampling. No | ||
| 86 | +committed fixture presents a 1-mi-tall left neighbour (an 8x4 leaf's left block) | ||
| 87 | +at 4:2:0/4:4:0, so nothing in the tree can witness the correct term today. This | ||
| 88 | +is a named open discrepancy, not a settled one. | ||
| 89 | + | ||
| 90 | +### How the split was chosen, and why 4:2:0 stays exact | ||
| 91 | + | ||
| 92 | +An earlier attempt applied libaom's formula to BOTH reads (`above` row | ||
| 93 | +`mi_r + ss_y - 1`, `left` row `mi_r + ss_y - 1`). That improved 4:2:2 (56142 → | ||
| 94 | +53395) but regressed the byte-exact 4:2:0 control, and gating only the column | ||
| 95 | +shift to 4:2:2 still regressed it — the `ss_y` term had been applied to the | ||
| 96 | +WRONG read (the above), and that crossing is what the regression exposed. The | ||
| 97 | +column term on its own is the part that measures clean; the row term is the part | ||
| 98 | +that is still open, and shipping it is deferred to a lane that can witness it. | ||
| 99 | + | ||
| 100 | +**Identity, measured three ways:** | ||
| 101 | + | ||
| 102 | +1. 4:2:0 control `a420.obu` (same recipe at `--profile=0`) byte-identical to | ||
| 103 | + `aomdec --rawvideo` before and after both commits. | ||
| 104 | +2. 4:4:4 `444_sb128rect_lr_witness.obu` output byte-identical to this branch's | ||
| 105 | + pre-change build (stash-and-rebuild) — `ss_x == 0` makes the column vanish. | ||
| 106 | +3. Both pinned 4:2:2 witnesses still decode pixel-exact vs `aomdec`: | ||
| 107 | + `422_allskip_2f.obu` (2 frames, 128x128) and `422_sb128_3f.obu` (3 frames, | ||
| 108 | + 128x128). | ||
| 109 | + | ||
| 110 | +The column term was also A/B'd as 4:2:2-only versus all-subsamplings: identical | ||
| 111 | +(53395) with the 4:2:0 control byte-exact either way, so the unconditional | ||
| 112 | +libaom form ships — libaom's formula, not a 4:2:2 special case. | ||
| 113 | + | ||
| 114 | +### Red/green | ||
| 115 | + | ||
| 116 | +| measurement | before | after | | ||
| 117 | +|---|---|---| | ||
| 118 | +| `a1.obu` frame 0 PREFILT vs aomdec (diffing samples) | 56142 | **53395** | | ||
| 119 | +| chroma 4x8 D67 block at chroma (88,72) = mi(18,44) | row0 `135,147,172,145` | **byte-equal to oracle `125,178,181,124`** | | ||
| 120 | +| first 1419 TUs' prediction sums vs oracle | 1418 matched, #1419 mismatched | **1419/1419 match** | | ||
| 121 | +| `a1.obu` all 16 frames vs aomdec | 1639654 diffs, 0/16 exact | 1619115 diffs, 0/16 exact | | ||
| 122 | +| 4:2:0 control | byte-exact | byte-exact | | ||
| 123 | +| 4:4:4 witness vs pre-change build | — | byte-identical | | ||
| 124 | + | ||
| 125 | +The first divergent block is fixed outright. Confirmed offline against the spec: | ||
| 126 | +with edge-filter strength 1 the prediction reproduces the oracle exactly (row0 | ||
| 127 | +`132,150,157,148`, col0 `132,140,147,154,159,157,155,149`); with strength 0 it | ||
| 128 | +reproduces ours (`135,147,172,145`). The oracle printed `ft=1`, we computed 0. | ||
| 129 | + | ||
| 130 | +## Defect 3 — PARTIALLY FIXED (`abae108a`), hand-off continues | ||
| 131 | + | ||
| 132 | +**The first version of this section mis-attributed the class** (it called this | ||
| 133 | +transform-size selection for a twice-as-tall plane block). Paired traces refute | ||
| 134 | +that: see "What the class actually is" below. | ||
| 135 | + | ||
| 136 | +### The measurement, on a clean single-frame stream | ||
| 137 | + | ||
| 138 | +`a1.obu`'s frame 0 cut at the second OBU temporal delimiter, `a1_f0.obu` | ||
| 139 | +(11802 B, decodes 1 frame on both sides). With both sides frame-scoped, two | ||
| 140 | +independent pairings agree on the same boundary: | ||
| 141 | + | ||
| 142 | +- **coefficient ladder** (`EC_TRACE_COEFF`, oracle `EC_COEFF_STEP` vs ours, paired | ||
| 143 | + on `all_zero` + post-read `rng`): units pair exactly through **1418**; unit | ||
| 144 | + **1419** is the first mismatch. Oracle 2512 units, ours 1959. | ||
| 145 | +- **prediction ladder** (`EC_PREDOUT8` vs `OUR_PRED`, paired on sum + shape): | ||
| 146 | + same boundary, index **1419**. | ||
| 147 | + | ||
| 148 | +``` | ||
| 149 | +1413 O mi(50,26) plane 0 '8x8' 5799 M '8x8' 5799 <- mi(50,26) block is FINE | ||
| 150 | +1414 O mi(50,26) plane 1 '4x8' 3784 M '4x8' 3784 | ||
| 151 | +1415 O mi(50,26) plane 2 '4x8' 2468 M '4x8' 2468 | ||
| 152 | +1416 O mi(48,28) plane 0 '16x8' 16683 M '16x8' 16683 | ||
| 153 | +1417 O mi(48,28) plane 1 '8x8' 5504 M '8x8' 5504 | ||
| 154 | +1418 O mi(48,28) plane 2 '8x8' 9024 M '8x8' 9024 | ||
| 155 | +1419 O mi(50,28) plane 0 '8x8' 5715 M '4x4' 1424 <- FIRST divergence | ||
| 156 | +1420 O mi(50,28) plane 1 '4x8' 3370 M '4x4' 1344 | ||
| 157 | +1421 O mi(50,28) plane 2 '4x8' 2513 M '4x4' 1488 | ||
| 158 | +``` | ||
| 159 | + | ||
| 160 | +Our unit 1419 averages 89.0 and the oracle's 89.3 over the same 8x8 footprint, so | ||
| 161 | +the luma CONTENT agrees; only the tiling differs (one TX_8X8 vs four TX_4X4). | ||
| 162 | + | ||
| 163 | +### What the class actually is: a MODE desync at mi(50,28) | ||
| 164 | + | ||
| 165 | +`EC_TRACE_MODE_STEP` exists on BOTH sides and is directly comparable: | ||
| 166 | + | ||
| 167 | +``` | ||
| 168 | +oracle mi(50,28): skip 35588 cdef 35588 dq 35588 mode val=0 41524 | ||
| 169 | + angle_y 0 41524 uv_mode val=4 60976 angle_uv val=3 50488 | ||
| 170 | + use_filter_intra val=1 38616 filter_intra_mode val=3 35858 | ||
| 171 | +ours mi(50,28): skip 52484 cdef 52484 dq 52484 mode val=0 61324 | ||
| 172 | + angle_y 0 61324 uv_mode val=13 54978 angle_uv val=0 41424 | ||
| 173 | + use_filter_intra val=0 39456 (no filter_intra_mode read) | ||
| 174 | +``` | ||
| 175 | + | ||
| 176 | +Same mi, same luma `mode` value (0), but **`uv_mode` 4 (oracle) vs 13 (ours)** and | ||
| 177 | +a different `use_filter_intra` bit. The reader is already at a different state | ||
| 178 | +when mi(50,28)'s `skip` is read, so the divergence is at or before it — this is an | ||
| 179 | +ENTROPY desync, not a transform-size choice. The transform-shape difference is | ||
| 180 | +downstream damage, not the defect. | ||
| 181 | + | ||
| 182 | +What is **ruled out** for the desync: | ||
| 183 | + | ||
| 184 | +- Not the tx_size lookup. Both sides read `tx_size_cdf[0]` at `ctx = 2` for the | ||
| 185 | + same 8x8 block (oracle `EC_TXCTXB mi=50,26 ... maxw=8 maxh=8 ctx=2`; ours | ||
| 186 | + `read_tx_size mi=(50,26) side=8 max_tx=8 ctx=2`), and `bsize_to_tx_size_cat` | ||
| 187 | + gives cat 0 for both BLOCK_8X8 and BLOCK_16X8 (`blockd.h:1344`, depth table | ||
| 188 | + index 1 and 3 both map to 0). Same row, same alphabet (2 symbols). | ||
| 189 | +- Not `get_tx_size_context`. `pred_common.h:348-384` is `above + left` with the | ||
| 190 | + inter-neighbour override — the form `tx_size_context_txfm` already implements; | ||
| 191 | + both compute ctx 2 here. | ||
| 192 | +- Not the frame header. `read_tx_mode` (`decodeframe.c:139`) and our | ||
| 193 | + `crates/ec-av1-syntax/src/frame.rs:1039` are the same function, and the header | ||
| 194 | + parses identically (the block modes before this point pair). | ||
| 195 | +- Not the chroma sharing. mi(50,26) is even, so it owns the 4:2:2 chroma block and | ||
| 196 | + mi(50,27) shares it; all three of mi(50,26)'s units pair, and the oracle's | ||
| 197 | + `EC_IMODE` shows no block at mi(50,27). | ||
| 198 | + | ||
| 199 | +**So: one symbol is consumed or skipped between mi(50,26)'s last unit and | ||
| 200 | +mi(50,28)'s `skip`, and this lane did not identify which.** The oracle's | ||
| 201 | +`EC_ISTEP` has no `tx_depth` print at all (it goes `angle_uv` straight to the | ||
| 202 | +next block's `skip` at every site, including mi(48,26) and mi(48,28) where both | ||
| 203 | +sides demonstrably stay aligned) — that is a rung-coverage gap, NOT evidence of | ||
| 204 | +a missing read, and the `EC_ISTEP` line ORDER is not comparable between the two | ||
| 205 | +builds (the oracle's trace jumps back from mi(50,26) to mi(48,28)), so the | ||
| 206 | +step-by-step pairing cannot be used to bracket the extra read either. | ||
| 207 | + | ||
| 208 | +### The bit-position bisect (run; narrows it, does not close it) | ||
| 209 | + | ||
| 210 | +I added an exact bit position to the coefficient rungs on BOTH sides — ours via | ||
| 211 | +the existing `SymbolDecoder::debug_bitpos()` (`msac.rs:520`), the oracle via | ||
| 212 | +`aom_reader_tell(r)` in `decodetxb.c`'s `EC_COEFF_STEP` prints — rebuilt | ||
| 213 | +`aomdec` with ninja, and paired the all_zero-level traces on bit position rather | ||
| 214 | +than on the colliding 16-bit `rng`. Both rungs have since been reverted (the | ||
| 215 | +oracle's `aomdec` is rebuilt to its committed shape; `strings aomdec | grep -c | ||
| 216 | +bitpos` = 0). | ||
| 217 | + | ||
| 218 | +The result is a clean constant, and it is the strongest statement this lane can | ||
| 219 | +make about the desync: | ||
| 220 | + | ||
| 221 | +``` | ||
| 222 | +unit oracle bit ours bit delta | ||
| 223 | +1414 56335 56349 -14 | ||
| 224 | +1415 56347 56361 -14 | ||
| 225 | +1416 56374 56388 -14 | ||
| 226 | +1417 56424 56438 -14 | ||
| 227 | +1418 56469 56483 -14 <- last unit that pairs | ||
| 228 | +1419 56507 56527 -20 <- first divergent unit | ||
| 229 | +``` | ||
| 230 | + | ||
| 231 | +The offset is a **constant -14** for every unit from 0 to 1418 — a fixed | ||
| 232 | +convention difference between `debug_bitpos` and `aom_reader_tell`, nothing more. | ||
| 233 | +At unit 1419 it becomes **-20**: relative to that baseline we are **exactly 6 bits | ||
| 234 | +ahead**. So whatever the defect is, between unit 1418's `txb_skip` read and unit | ||
| 235 | +1419's, we consume 6 more bits than libaom. That is a magnitude, and it is | ||
| 236 | +bounded and small — not a whole skipped block or a whole mis-sized symbol read. | ||
| 237 | + | ||
| 238 | +**Why this does not name the symbol.** I extended the same `bitpos` field to the | ||
| 239 | +per-coefficient `tag=base` / `tag=br` prints to bisect inside the window, and | ||
| 240 | +tried a bit-anchored greedy alignment of the two step streams. It does not work, | ||
| 241 | +and the reason is worth recording: the two readers traverse a transform unit's | ||
| 242 | +coefficients in DIFFERENT ORDERS (the oracle goes `read_coeffs_reverse_2d`, `c` | ||
| 243 | +descending from `end_si`; ours emits `c=53, c=52, c=51` on what is plainly a | ||
| 244 | +different unit), so their step streams have no index correspondence — 32500 | ||
| 245 | +oracle steps against 16464 of ours. Matching on bit position alone is ambiguous | ||
| 246 | +and the alignment breaks within the first few hundred steps, long before the | ||
| 247 | +window of interest. **A next lane must not trust a step-index pairing here.** | ||
| 248 | + | ||
| 249 | +The workable refinement, which this lane did not have the budget to run: restrict | ||
| 250 | +the comparison to ONE transform unit at a time (pair on the unit's own | ||
| 251 | +coordinates, per the `ec-av1-oracle-trace-pairing` skill's "restrict pairing to | ||
| 252 | +one frame/block" rule) rather than to the whole step stream. The 6-bit magnitude | ||
| 253 | +says the target is very close — the same unit's tail, or the mode reads between | ||
| 254 | +two units. | ||
| 255 | + | ||
| 256 | +### The per-TU window bisect (run; the read is NAMED) | ||
| 257 | + | ||
| 258 | +Extending `bitpos` to EVERY `EC_COEFF_STEP` rung on both sides and pairing | ||
| 259 | +inside the single transform unit at index 1418 (its own coordinates, per the | ||
| 260 | +`ec-av1-oracle-trace-pairing` rule) enumerates the window completely. Both | ||
| 261 | +instrumentations are reverted again (oracle `aomdec` rebuilt, `grep -c bitpos` = | ||
| 262 | +0). | ||
| 263 | + | ||
| 264 | +**The window, 27 oracle reads against 28 of ours** (the extra one is a duplicate | ||
| 265 | +PRINT of the same read, at the same bit, not a second read). Through the whole | ||
| 266 | +base/br/Golomb loop the two sides are IDENTICAL — same tags, same order, same | ||
| 267 | +values, same bit positions under the constant -14: | ||
| 268 | + | ||
| 269 | +``` | ||
| 270 | + O 0 bit=56469 all_zero plane=2 ... all_zero=0 rng=42420 | ||
| 271 | + O 1 bit=56469 tx_type plane=2 txtype=0 txsize=1 | ||
| 272 | + O 2 bit=56475 eob eob=8 | ||
| 273 | + O 3..26 base/br/after_bases/sign/post_golomb (c = 7,6,5,4,3,2,1,0) | ||
| 274 | + M 0 bit=56483 all_zero plane=0 ctx=2 entry=45064 all_zero=0 rng=42420 | ||
| 275 | + M 1..21 eob/base/br/after_bases (c = 7,6,5,4,3,2,1,0) | ||
| 276 | +``` | ||
| 277 | + | ||
| 278 | +**The divergence is the first SIGN read.** Both decode the same value (1), but | ||
| 279 | +from a different CDF row: | ||
| 280 | + | ||
| 281 | +``` | ||
| 282 | +oracle O 15 tag=sign c=0 sign=1 dcctx=1 rng=35769 bit=56491 | ||
| 283 | +ours M 22 tag=sign_rect pos=0 sign=1 dcctx=0 rng=52678 bit=56506 | ||
| 284 | +``` | ||
| 285 | + | ||
| 286 | +`dcctx` — the DC sign context — is **1 on the oracle and 0 on ours**. Same symbol | ||
| 287 | +value, different row, so the range coder leaves in a different state and every | ||
| 288 | +later bit in the window shifts; that is the 6-bit excess, and it is why the | ||
| 289 | +`rng` pairing that looked "identical through the base loop" turns over exactly at | ||
| 290 | +the sign pass. | ||
| 291 | + | ||
| 292 | +libaom takes that context from `txb_ctx->dc_sign_ctx` (`decodetxb.c:366`), which | ||
| 293 | +is a **3-symbol read from `dc_sign_cdf_extra[plane_type]` taken once per | ||
| 294 | +transform block** — a CDF that no `EC_COEFF_STEP` rung prints on either side, so | ||
| 295 | +this lane could not pair that symbol and cannot say whether our value is wrong or | ||
| 296 | +merely reflects an already-drifted `dc_sign_cdf_extra` adaptation state. | ||
| 297 | + | ||
| 298 | +**Second, separate finding, worth its own look:** our scan table maps scan | ||
| 299 | +indices to different raster positions than the oracle's for this unit — oracle | ||
| 300 | +`c1 -> pos 8`, `c2 -> pos 1`; ours `c1 -> pos 1`, `c2 -> pos 8` (and | ||
| 301 | +`c3 -> pos 2` vs ours `pos 16`, `c6 -> pos 24` vs ours `pos 3`). The coefficient | ||
| 302 | +VALUES match by scan index on both sides, so this does not by itself move a bit, | ||
| 303 | +but it places coefficients in the wrong cells and would corrupt the transform | ||
| 304 | +independently of the entropy question. | ||
| 305 | + | ||
| 306 | +### The dc-sign verdict: the VALUE is wrong, and the input is the rect path | ||
| 307 | + | ||
| 308 | +Rung on both sides: ours is the existing `EC_DCDUMP` (which prints the vote and | ||
| 309 | +every sampled neighbour cell), the oracle's is a new `DCSIGN` print in | ||
| 310 | +`get_txb_ctx_general` reading `txb_ctx->dc_sign_ctx`, its `dc_sign` sum, and the | ||
| 311 | +individual `a[]`/`l[]` sign fields over `txb_w_unit`/`txb_h_unit`. Both reverted | ||
| 312 | +(oracle `aomdec` rebuilt, `grep -c DCSIGN` = 0). | ||
| 313 | + | ||
| 314 | +**First, a wrong turn worth recording: our `dc_sign_ctx` table is CORRECT.** | ||
| 315 | +libaom's `dc_sign_contexts` is 65 entries read at `dc_sign + 32`; extracted | ||
| 316 | +programmatically it is `dc_sign < 0 -> 1`, `== 0 -> 0`, `> 0 -> 2`, which is | ||
| 317 | +exactly what [`dc_sign_ctx`]'s `signum` buckets compute. A hand count of that | ||
| 318 | +table literal suggests a different mapping and would have sent the next lane | ||
| 319 | +after a non-bug; the table is fine. | ||
| 320 | + | ||
| 321 | +**The vote differs.** libaom's own print at the neighbouring units is shaped | ||
| 322 | +`dc_sign=-4 ctx=1 above=[-1,-1,-1,-1] left=[0,0,0,0,0,0,0,0]` — and the symbol | ||
| 323 | +ladder showed the oracle resolving ctx **1** where we resolve **0**, i.e. | ||
| 324 | +libaom's `dc_sign` is negative and ours is 0. | ||
| 325 | + | ||
| 326 | +**The input, from our own `EC_DCDUMP` at the block in question:** | ||
| 327 | + | ||
| 328 | +``` | ||
| 329 | +EC_DCDUMP mi=(48,28) plane=2 wh=(16,8) vote=0 | ||
| 330 | + above=[None/6, None/6, Some(false)/7, Some(false)/7] <- FOUR cells | ||
| 331 | + left =[Some(true)/7, Some(true)/7] <- TWO cells | ||
| 332 | +``` | ||
| 333 | + | ||
| 334 | +`wh=(16,8)` is the block's LUMA footprint, so the rect path summed the vote over | ||
| 335 | +**4 above + 2 left** cells. The unit actually being decoded is the 8x8 V CHROMA | ||
| 336 | +transform, whose own `txb_w_unit`/`txb_h_unit` are **2 and 2** — libaom reads two | ||
| 337 | +above cells, not four. Dropping two above cells can drop a negative contribution | ||
| 338 | +and turn a negative vote into exactly the 0 we produce. | ||
| 339 | + | ||
| 340 | +**So: the 4:2:2 chroma correction exists but is not wired into this path.** | ||
| 341 | +[`around_mi_422_chroma`] — the function whose own comment says "libaom | ||
| 342 | +`get_txb_ctx_general` reads its above votes over `txb_w_unit` CHROMA 4-px cells, | ||
| 343 | +and at ss_x 1 one chroma cell spans TWO luma mi columns... Sampling every second | ||
| 344 | +above cell counts each chroma column once, which IS libaom's sum" — is reached | ||
| 345 | +1653 times on this stream, but NOT for this block: mi(48,28) prints | ||
| 346 | +`EC_DCDUMP`, not `EC_DCDUMP422`. The **rect** path (`around_mi_rect`) has no 4:2:2 | ||
| 347 | +variant, so a 4:2:2 RECT block votes over the luma unit counts. | ||
| 348 | + | ||
| 349 | +That is the same neighbour-read family as the `smooth_uv` fix, in the same file, | ||
| 350 | +for the same reason: a per-axis shape correction that was applied to some paths | ||
| 351 | +and not to the rect one. ****LANDED in `abae108a`.** `decode_leaf_rect`'s | ||
| 352 | +`around_mi_rect` call was the one 4:2:2 chroma gather in the file still | ||
| 353 | +ungated; it now mirrors the sibling gate (`chroma_422`, which that arm | ||
| 354 | +already computes for its scan selection), luma keeping the per-mi gather: | ||
| 355 | + | ||
| 356 | +``` | ||
| 357 | +before EC_DCDUMP mi=(48,28) plane=2 wh=(16,8) vote=0 | ||
| 358 | + above=[None/6,None/6,Some(false)/7,Some(false)/7] FOUR cells | ||
| 359 | +after EC_DCDUMP422 mi=(48,28) plane=2 wh=(16,8) vote=-1 | ||
| 360 | + above=[None/6,Some(false)/7] TWO cells | ||
| 361 | +``` | ||
| 362 | + | ||
| 363 | +Red/green: the bit offset is a clean constant through coefficient unit | ||
| 364 | +1418 and turned 6 bits at 1419; after the fix unit 1418 pairs and the | ||
| 365 | +first divergence moves to **2427**. Frame-0 coefficient units 1959 → | ||
| 366 | +2680 (oracle 2512). Whole stream, 16 frames vs `aomdec --rawvideo`: | ||
| 367 | +**1619115 → 1380482** differing samples, still 0/16 exact. | ||
| 368 | + | ||
| 369 | +Identity, four ways, all unchanged: 4:2:0 control `a420.obu` | ||
| 370 | +byte-identical to aomdec; 4:4:4 `444_sb128rect_lr_witness.obu` | ||
| 371 | +byte-identical to the pre-lane build; pinned `422_allskip_2f.obu` and | ||
| 372 | +`422_sb128_3f.obu` still pixel-exact. The gate is ss (1,0), so the sampler | ||
| 373 | +is not reached at 4:2:0 or 4:4:4 at all. | ||
| 374 | + | ||
| 375 | +### Round 7 — the mi(64,24) boundary localized to a PARTITION/bsize decision | ||
| 376 | + | ||
| 377 | +Paired on `a1_f0.obu` with the round-6 fix in place. The boundary is a | ||
| 378 | +**block-structure** decision, not a transform lookup and not another | ||
| 379 | +neighbour vote: | ||
| 380 | + | ||
| 381 | +``` | ||
| 382 | +oracle EC_IMODE mi_row=64 mi_col=24 bsize=9 (BLOCK_64X32) | ||
| 383 | + -> codes a 32x32 luma TU (TU 2428, sum 174006), chroma 16x32 | ||
| 384 | +ours EC_IMODE mi_row=64 mi_col=24 fn=sq side=32 (a 32x32 SQUARE) | ||
| 385 | + EC_ISTEP ... name=tx_depth val=2 ctx=1 -> 32 >> 2 = TX_8X8 | ||
| 386 | + -> codes 8x8 leaves (sum 10816), chroma 8x8 | ||
| 387 | +``` | ||
| 388 | + | ||
| 389 | +So at the same mi the oracle walks a 64x32 rect and we walk a 32x32 | ||
| 390 | +square — the PARTITION symbol, not `tx_depth`, is where the two decoders | ||
| 391 | +part company. The block sits on the frame's last superblock row (288 | ||
| 392 | +tall, SB rows at 0/128/256, the last only 32 rows), inside SB(mi_row 64, | ||
| 393 | +mi_col 0). | ||
| 394 | + | ||
| 395 | +**Where the reader actually parts.** Both step traces already differ at | ||
| 396 | +that block's FIRST symbol (`skip`, oracle rng 39524 against ours 40716), | ||
| 397 | +so the desync precedes it; and the coefficient ladder pairs through unit | ||
| 398 | +2427, which is mi(68,16)'s V chroma. The window is therefore the reads | ||
| 399 | +between mi(68,16)'s chroma tail and mi(64,24)'s mode read — not the | ||
| 400 | +tx_size lookup (the oracle's `get_tx_size_context` for that block is | ||
| 401 | +printable and ours computes the same `above + left` form as everywhere | ||
| 402 | +else). | ||
| 403 | + | ||
| 404 | +### Round 19 — the tail pairing FAILED; the poisoning read is NOT named | ||
| 405 | + | ||
| 406 | +All instrumentation reverted; `aomdec` restored (zero stray strings, | ||
| 407 | +2995 `EC_COEFF_STEP` lines, 4:2:0 control byte-exact). Build discipline | ||
| 408 | +followed: touch before ninja, rung verified before use. | ||
| 409 | + | ||
| 410 | +**What was set up.** Same-line bit positions on every coefficient rung | ||
| 411 | +on both sides — 13 sites here, 11 in the oracle's `decodetxb.c` — and | ||
| 412 | +verified (75970 rung lines with the field live). So round 18's | ||
| 413 | +instrument is reproducible and the walk is no longer blocked by | ||
| 414 | +emission. | ||
| 415 | + | ||
| 416 | +**What failed, and why this lane stops here.** Pairing the mi(68,16) | ||
| 417 | +tail by bit position does not work, and the failure is structural: | ||
| 418 | + | ||
| 419 | +``` | ||
| 420 | + O bit=92304 all_zero plane=2 | M bit=92331 eob | ||
| 421 | + O bit=92315 all_zero plane=0 | M bit=92332 base | ||
| 422 | + O bit=92316 all_zero plane=1 | M bit=92332 after_bases | ||
| 423 | + O bit=92316 tx_type plane=1 | M bit=92333 sign_rect | ||
| 424 | +``` | ||
| 425 | + | ||
| 426 | +The two rung streams have **different granularity**: this decoder | ||
| 427 | +prints one line per transform unit with a different tag set, the oracle | ||
| 428 | +one line per coefficient step with another. Bit-position inference | ||
| 429 | +inside a single unit's tail therefore pairs UNRELATED reads. The 1:1 | ||
| 430 | +correspondence that made rounds 10 and 14 work came from the | ||
| 431 | +`all_zero` ANCHOR — one per transform unit, on both sides. **Inside a | ||
| 432 | +unit there is no such anchor**, and this round had none. | ||
| 433 | + | ||
| 434 | +**Consequence for the earlier attributions, stated precisely.** The | ||
| 435 | +round-10 "3 bits short" and the round-14 window were taken at | ||
| 436 | +`all_zero` granularity, which IS reliable, and their conclusion (the | ||
| 437 | +first-delta read is the luma mode at mi(64,24)) stands. Anything finer | ||
| 438 | +than one transform unit was never established. | ||
| 439 | + | ||
| 440 | +**A lead withdrawn.** The round-18 "the oracle emits a `tx_type` step | ||
| 441 | +at mi(68,16) where our rungs emit none" is NOT evidence. Our | ||
| 442 | +`tag=tx_type` prints sit at two sites; the oracle's print is per plane. | ||
| 443 | +The 2080-against-1033 count difference is rung coverage, and the | ||
| 444 | +absence of a line here is an instrumentation gap. Withdrawn. | ||
| 445 | + | ||
| 446 | +**The instrument that would close it.** A per-READ trace emitted from | ||
| 447 | +the symbol decoder ITSELF on both sides — our `SymbolDecoder::symbol` | ||
| 448 | +and `literal`, libaom's `aom_read_symbol` — carrying an explicit read | ||
| 449 | +SEQUENCE NUMBER alongside (row, decoded value, post-read rng, bit | ||
| 450 | +position). With a shared counter the two streams are 1:1 **by | ||
| 451 | +construction** rather than by bit-position inference, and the first | ||
| 452 | +read whose rng diverges names the poisoner directly, inside whatever | ||
| 453 | +block it falls. That is a real round of work and it is not a | ||
| 454 | +continuation of this one. | ||
| 455 | + | ||
| 456 | +### Round 18 — the table did NOT drift; the coder state already had | ||
| 457 | + | ||
| 458 | +All instrumentation reverted; `aomdec` restored (744 `name=mode` lines, | ||
| 459 | +zero stray strings), 4:2:0 control byte-exact. Build discipline | ||
| 460 | +followed: touch before ninja, known-firing rung verified before any new | ||
| 461 | +field was read. | ||
| 462 | + | ||
| 463 | +**1. The `kf_y_mode` row immediately BEFORE the mi(64,24) read is | ||
| 464 | +IDENTICAL on both sides.** (Our storage is `32768 - cdf`; converted, the | ||
| 465 | +twelve entries are the same twelve numbers to the digit:) | ||
| 466 | + | ||
| 467 | +``` | ||
| 468 | +oracle 20236, 19127, 17626, 16471, 13708, 11379, 9074, 7617, 6502, 1079, 805, 127 | ||
| 469 | +ours 20236, 19127, 17626, 16471, 13708, 11379, 9074, 7617, 6502, 1079, 805, 127 | ||
| 470 | +``` | ||
| 471 | + | ||
| 472 | +**So the table-state verdict is CLEAN — it did not drift.** That kills | ||
| 473 | +the round-17 hypothesis and answers Main's step 2 negatively: there is | ||
| 474 | +no read whose adaptation update differs. | ||
| 475 | + | ||
| 476 | +**2. But the range coder is ALREADY in a different state at that | ||
| 477 | +read**, at the same bit position (the constant -14): | ||
| 478 | + | ||
| 479 | +``` | ||
| 480 | +oracle KFPRE rng=39524 dif=833299967 bitpos=92323 | ||
| 481 | +ours KFPRE rng=40716 val=24467 bitpos=92337 | ||
| 482 | +``` | ||
| 483 | + | ||
| 484 | +Same CDF row, same bit position, different `rng` — therefore a | ||
| 485 | +different decoded value (1 against 6) and a different bit cost (4 bits | ||
| 486 | +against 5). The decode itself is innocent; the STATE is the defect. | ||
| 487 | + | ||
| 488 | +**3. mi(64,24) is the FIRST such block.** Across all 742 mode reads | ||
| 489 | +common to both traces, every block before it agrees in BOTH its decoded | ||
| 490 | +mode and its post-read `rng`; mi(64,24) is the first that differs, and | ||
| 491 | +the 18 after it are downstream. Its very first read (`skip`) is already | ||
| 492 | +divergent, so the cause is in the PREVIOUS block's tail (mi(68,16)) or | ||
| 493 | +in mi(64,24)'s own pre-mode reads. | ||
| 494 | + | ||
| 495 | +**This is the round-6 dc-sign shape, one level up.** Every read in that | ||
| 496 | +window consumes the SAME BITS on both sides, and the bit delta is | ||
| 497 | +constant — but a symbol read from a different CDF row (or the same value | ||
| 498 | +decoded from a different row) consumes the same bits and leaves a | ||
| 499 | +different `rng`. The ladder cannot see it; only a state comparison can, | ||
| 500 | +and this is the first place the state comparison has been run. | ||
| 501 | + | ||
| 502 | +**4. Prime suspect, with its evidence and its limits.** The ladder's | ||
| 503 | +window shows the oracle emitting a `tx_type` step at mi(68,16) where our | ||
| 504 | +rungs emit none. But the raw counts are oracle 2080 `tx_type` reads to | ||
| 505 | +our 1033 across the frame, and that is a RUNG-COVERAGE difference (our | ||
| 506 | +`tag=tx_type` prints sit at two of several sites), **not** evidence of a | ||
| 507 | +missing read. Recorded as a lead, not a finding. | ||
| 508 | + | ||
| 509 | +**Unblock.** Pair, bit-position-anchored, the pre-read CDF ROW and the | ||
| 510 | +decoded VALUE for every read in the mi(68,16) tail — the same | ||
| 511 | +instrument that produced this verdict, applied one block earlier. The | ||
| 512 | +first read whose row or value differs names the root. With the | ||
| 513 | +instrument now proven (it produced a clean, digit-exact table match and | ||
| 514 | +a clean state mismatch), that run is mechanical. | ||
| 515 | + | ||
| 516 | +### Round 17 — MEASURED: the bands MATCH, and round 15's mystery is solved | ||
| 517 | + | ||
| 518 | +Build discipline first: `touch` before `ninja`, and the known-firing rung | ||
| 519 | +verified at **744 `name=mode` lines** before any new field was trusted. | ||
| 520 | +All instrumentation reverted; `aomdec` restored (744 lines, zero stray | ||
| 521 | +strings), 4:2:0 control byte-exact. | ||
| 522 | + | ||
| 523 | +**Round 15's mystery, solved.** The `MODECTX` rung there did not | ||
| 524 | +"fail to fire" — it fired, printed for the first block, and then the | ||
| 525 | +**process died**. `above_mi` is NULL for a block on the frame's first | ||
| 526 | +row (and `left_mi` on its first column), and the unguarded | ||
| 527 | +`above_mi->mode` dereference killed the decode, so nothing after that | ||
| 528 | +one line was ever emitted. A `MODEMARK` printed BEFORE the field access | ||
| 529 | +made it unambiguous: 1 marker, 0 mode lines. Guarded | ||
| 530 | +(`above_mi ? above_mi->mode : -1`), the extended print works and the | ||
| 531 | +rung returns to 744. **Round 15's conclusion was an artefact of a NULL | ||
| 532 | +dereference, and is now closed rather than left as a mystery.** | ||
| 533 | + | ||
| 534 | +**The band-match verdict: THEY MATCH.** With the guard, the oracle at | ||
| 535 | +mi(64,24) reports | ||
| 536 | + | ||
| 537 | +``` | ||
| 538 | +EC_ISTEP mi_row=64 mi_col=24 name=mode val=6 rng=44416 above_mode=0 left_mode=6 | ||
| 539 | +``` | ||
| 540 | + | ||
| 541 | +against ours `above_mode=0 left_mode=6 above_ctx=0 left_ctx=4 -> mode=1`. | ||
| 542 | +Compared across the WHOLE frame — all 744 mode reads, ours from all | ||
| 543 | +three `kf_y_mode` sites (square, rect, sub-8) — the contexts are | ||
| 544 | +identical up to and including mi(64,24) (oracle mode-read index 723 of | ||
| 545 | +744). The 37 raw differences are all libaom's NULL neighbour (`-1`) | ||
| 546 | +against our `DC_PRED`, which `get_y_mode_cdf` maps to the same context; | ||
| 547 | +after that mapping 17 remain, and **every one of them is at index >= 724, | ||
| 548 | +i.e. strictly after the divergence**. The first differing context is the | ||
| 549 | +first one downstream of it. | ||
| 550 | + | ||
| 551 | +**So: not a neighbour-lookup defect.** The lane-rectx r5 mi-exact | ||
| 552 | +override hypothesis is **ruled out** for this block — the square path's | ||
| 553 | +coarse bands carry exactly what libaom's `above_mbmi` / `left_mbmi` | ||
| 554 | +carry here. (Whether the square path *should* use the mi-exact map | ||
| 555 | +generally is a separate question this block does not answer.) | ||
| 556 | + | ||
| 557 | +**Where that leaves the defect.** Same context, same bit position, | ||
| 558 | +different symbol value (1 against 6) — so the divergence is the | ||
| 559 | +`kf_y_mode[0][4]` **table state**, not the row. AV1's | ||
| 560 | +`aom_read_symbol` adapts backwards as well as forwards, so a read from a | ||
| 561 | +NEIGHBOURING row can move `[0][4]` without moving any bit position, and | ||
| 562 | +the ladder cannot see that. Main's step 4 is therefore the live | ||
| 563 | +question and the one worth the next round. | ||
| 564 | + | ||
| 565 | +**Unblock.** Print `kf_y_mode[0][4]` (and the whole `kf_y_mode` table, or | ||
| 566 | +just that entry) immediately BEFORE the mi(64,24) mode read on both | ||
| 567 | +sides. If the entry already differs, the drift is upstream and the | ||
| 568 | +first read that moved it is findable by walking the table backwards | ||
| 569 | +across the 723 preceding mode reads. If the entry agrees and only the | ||
| 570 | +decoded value differs, the defect is in the symbol decode itself, not | ||
| 571 | +in the table — a much narrower target. | ||
| 572 | + | ||
| 573 | +### Round 16 — the unblock was NOT completed, and a build hazard was found | ||
| 574 | + | ||
| 575 | +No code change; `aomdec` restored to its committed shape | ||
| 576 | +(`grep -cE 'MODECTX|bitpos'` = 0, 744 `name=mode` lines again, 4:2:0 | ||
| 577 | +control byte-exact). | ||
| 578 | + | ||
| 579 | +**What happened.** The instruction was to extend the KNOWN-FIRING | ||
| 580 | +`EC_ISTEP name=mode` print with `above_mi->mode` / `left_mi->mode` | ||
| 581 | +rather than add a sibling `getenv` rung. That edit was made, the string | ||
| 582 | +confirmed in the binary — and the rebuilt `aomdec` then emitted **zero** | ||
| 583 | +`name=mode` lines, i.e. the instrumented decode stopped producing the | ||
| 584 | +rungs entirely. Reverting the print and rebuilding restored 744 lines. | ||
| 585 | +**The oracle-side context is therefore still unmeasured**, and this lane | ||
| 586 | +does not report a value it did not read. | ||
| 587 | + | ||
| 588 | +**The build hazard, which is the durable finding here.** `ninja` in | ||
| 589 | +`~/.cache/aom-oracle/build` does **not** reliably rebuild after a source | ||
| 590 | +edit: repeatedly it reported only `[1/1] Updating version info if | ||
| 591 | +necessary.` and left the binary stale, with the binary's mtime older | ||
| 592 | +than the source's. A `touch` on the edited source is required before | ||
| 593 | +`ninja aomdec`, and the result must be confirmed by running the binary | ||
| 594 | +and checking a known-firing rung — not by `strings` alone. | ||
| 595 | + | ||
| 596 | +**This bears directly on round 15.** Round 15 concluded that a | ||
| 597 | +`MODECTX` rung "does not fire" because it was placed immediately above | ||
| 598 | +`mbmi->mode = read_intra_mode(...)` in the same function as a rung that | ||
| 599 | +fires 744 times. Given this build behaviour, that conclusion is unsafe: | ||
| 600 | +the rung may not have been compiled at the moment it was tested, or the | ||
| 601 | +binary may have been in the same partial state seen this round. Round | ||
| 602 | +15's own evidence (`strings` finding the format string in the binary) | ||
| 603 | +argues it was compiled, so the mystery is unresolved — but the | ||
| 604 | +conclusion "the oracle does not print it" should be treated as | ||
| 605 | +UNVERIFIED, not as a property of the decoder. | ||
| 606 | + | ||
| 607 | +**Standing state of the mode-context question.** Ours is measured: | ||
| 608 | +mi(64,24), `above_mode=0 left_mode=6 above_ctx=0 left_ctx=4`, `mode=1` | ||
| 609 | +against the oracle's `mode=6`. The oracle's `above_mi->mode` / | ||
| 610 | +`left_mi->mode` are still unknown, so **the band-match verdict is not | ||
| 611 | +answered** and the lane-rectx r5 override is neither confirmed nor ruled | ||
| 612 | +out. Main's step 4 (the CDF-drift question) is likewise untouched: if | ||
| 613 | +the bands turn out to MATCH the cells, the next thing to check is | ||
| 614 | +whether the `kf_y_mode` table state itself drifted at an earlier read, | ||
| 615 | +and the ladder is now trustworthy enough to answer that. | ||
| 616 | + | ||
| 617 | +**Unblock, restated with the build caveat.** `touch | ||
| 618 | +~/.cache/aom-oracle/src/av1/decoder/decodemv.c`, rebuild, then verify | ||
| 619 | +the binary still emits its 744 `name=mode` lines BEFORE reading any | ||
| 620 | +extended field. Then compare against mi(63,24) / mi(64,23) on our side. | ||
| 621 | + | ||
| 622 | +### Round 15 — the mode context: OUR side measured, the ORACLE side would not print | ||
| 623 | + | ||
| 624 | +Both prints reverted; `aomdec` rebuilt to its committed shape | ||
| 625 | +(`MODECTX` = 0). | ||
| 626 | + | ||
| 627 | +**Our side, at mi(64,24), from the square `read_intra_mode`** (the path | ||
| 628 | +this block actually takes — the `read_intra_mode_rect` site does not | ||
| 629 | +fire for it, and neither does `read_intra_mode_sub8`): | ||
| 630 | + | ||
| 631 | +``` | ||
| 632 | +MODECTXM mi=(64,24) above_mode=0 left_mode=6 above_ctx=0 left_ctx=4 | ||
| 633 | + -> mode val=1 (oracle: mode val=6) | ||
| 634 | +``` | ||
| 635 | + | ||
| 636 | +**The oracle side could not be measured, and this lane will not guess | ||
| 637 | +past that — SOLVED in round 17: the rung fired and the unguarded | ||
| 638 | +`above_mi->mode` dereference killed the decode at the frame's first | ||
| 639 | +row, so nothing after the first line was ever emitted. Guarded, the | ||
| 640 | +extended print works. Round 15's "does not fire" was a NULL | ||
| 641 | +dereference, not a property of the decoder. A `MODECTX` rung placed immediately above | ||
| 642 | +`mbmi->mode = read_intra_mode(r, get_y_mode_cdf(ec_ctx, above_mi, | ||
| 643 | +left_mi))` in `decodemv.c:936`, rebuilt, with its format string | ||
| 644 | +confirmed present in the binary and the env var set, emits nothing — | ||
| 645 | +while the `EC_ISTEP name=mode` print three lines below it in the SAME | ||
| 646 | +function fires 744 times, so the code provably runs. One occurrence of | ||
| 647 | +the site in the source, in `ec_read_intra_frame_mode_info_impl`. Not | ||
| 648 | +resolved. | ||
| 649 | + | ||
| 650 | +**What is established.** The divergence is the | ||
| 651 | +`kf_y_mode[above_ctx][left_ctx]` row: same block, same bit position, | ||
| 652 | +different symbol VALUE (1 against 6). Our square reader takes | ||
| 653 | +`above_mode` / `left_mode` from the **coarse** `above_mode[c]` / | ||
| 654 | +`left_mode[r]` bands, whereas the rect path goes through | ||
| 655 | +`modes_above_left_mi` (the mi-exact map, lane-rectx r5's override) and | ||
| 656 | +libaom's `get_y_mode_cdf` uses `xd->above_mbmi` = `mi[-mi_stride]` = | ||
| 657 | +mi(63,24) and `xd->left_mbmi` = `mi[-1]` = mi(64,23). So there is a | ||
| 658 | +concrete question — does the square path's coarse band hold what | ||
| 659 | +mi(63,24) / mi(64,23) hold — and this lane did not get to answer it. | ||
| 660 | + | ||
| 661 | +**A coincidence recorded as a lead, not a claim.** Our `left_mode=6` | ||
| 662 | +at mi(64,24) is the same number the oracle DECODES as that block's | ||
| 663 | +mode. That is what a neighbour-cell mix-up would look like, and it is | ||
| 664 | +the shape Main predicted (the rect intra-mode path's own unsnapped | ||
| 665 | +lookup). It is one data point and is not evidence. | ||
| 666 | + | ||
| 667 | +**Unblock, and it is short.** Print `above_mi->mode` / `left_mi->mode` | ||
| 668 | +from the `EC_ISTEP name=mode` site itself — the print that is known to | ||
| 669 | +fire — rather than from a sibling `getenv` rung, and compare against | ||
| 670 | +mi(63,24) / mi(64,23) on our side. If the square path's coarse bands | ||
| 671 | +differ from those cells, the fix is lane-rectx r5's mi-exact override | ||
| 672 | +applied to the square `read_intra_mode` path, the same way the rect | ||
| 673 | +path already has it — the same neighbour-context family as the | ||
| 674 | +`around_mi_422_chroma` and dc-sign fixes, and the third instance of it. | ||
| 675 | + | ||
| 676 | +### Round 14 — the ladder walked: the first-delta read is the LUMA `mode` at mi(64,24) | ||
| 677 | + | ||
| 678 | +Ladder rebuilt with the round-13 emission fix on both sides (position | ||
| 679 | +appended before the format string's `\n`; 14 `EC_ISTEP` + 11 | ||
| 680 | +`EC_COEFF_STEP` sites in the oracle, 18 coefficient + 2 mode-macro sites | ||
| 681 | +here), then reverted (`grep -c bitpos` = 0, `MODECTX` = 0). | ||
| 682 | + | ||
| 683 | +Instrument note, earned the hard way twice already: our `EC_ISTEP` | ||
| 684 | +positions come from the `istep!` macro and our `EC_COEFF_STEP` from the | ||
| 685 | +per-rung prints, and a strict index walk between the two sides breaks | ||
| 686 | +immediately because the two rung SETS differ per path (the oracle emits | ||
| 687 | +a `tx_type` step this decoder's rect reader has no print for). The | ||
| 688 | +ladder is therefore walked on the **all_zero anchors** — the rung both | ||
| 689 | +sides emit once per transform unit — and the delta map is read off the | ||
| 690 | +bit positions in between. | ||
| 691 | + | ||
| 692 | +**The delta map.** Constant **-14** (ours 14 bits ahead) for every | ||
| 693 | +transform unit from 0 to 2427, changing to **-11** at unit 2428. Inside | ||
| 694 | +that window, with `+14` folded in and every oracle read checked for a | ||
| 695 | +counterpart on our side: | ||
| 696 | + | ||
| 697 | +``` | ||
| 698 | + 92321 all_zero plane=2 OK | ||
| 699 | + 92323 skip mi(64,24) OK | ||
| 700 | + 92323 cdef mi(64,24) OK | ||
| 701 | + 92323 dq mi(64,24) OK | ||
| 702 | + 92327 mode mi(64,24) <-- first read with NO counterpart | ||
| 703 | + 92330 angle_y mi(64,24) (re-paired, shifted) | ||
| 704 | + ... | ||
| 705 | + 92339 all_zero <-- delta now -11 | ||
| 706 | +``` | ||
| 707 | + | ||
| 708 | +**The named read is the luma `mode` symbol of mi(64,24).** Oracle | ||
| 709 | +`mode val=6`, ours `mode val=1`. Cost: the oracle's read spans 92323 → | ||
| 710 | +92327 (4 bits), ours 92337 → 92342 (5 bits). Every read before it pairs | ||
| 711 | +exactly at +14; the deviation begins at this one and persists to the | ||
| 712 | +window's end, which is where the -14 → -11 step in the unit ladder | ||
| 713 | +comes from. The same block then carries the round-7 structural | ||
| 714 | +consequence: one 32x32 luma TU (oracle) against 8x8 leaves (ours). | ||
| 715 | + | ||
| 716 | +**What is not yet named, stated plainly.** Same block size and same | ||
| 717 | +bit position at the read, different symbol VALUE — so the divergence is | ||
| 718 | +in the mode CDF ROW, i.e. the `kf_y_mode[above_ctx][left_ctx]` context. | ||
| 719 | +This lane tried to print that context on both sides and did not get a | ||
| 720 | +paired measurement: our block reaches `read_intra_mode_rect`, not the | ||
| 721 | +square `read_intra_mode` the print was placed in, and the oracle-side | ||
| 722 | +`MODECTX` rung did not fire under its env var in the time available. | ||
| 723 | +Both prints are reverted. **No fix is claimed.** | ||
| 724 | + | ||
| 725 | +**Unblock.** Print the mode context at mi(64,24) on both sides — ours | ||
| 726 | +from `read_intra_mode_rect` (the path that block actually takes), the | ||
| 727 | +oracle's `get_y_mode_cdf(ec_ctx, above_mi, left_mi)` — and compare | ||
| 728 | +`above_mode` / `left_mode` at mi(64,24). The unit ladder is now a | ||
| 729 | +trustworthy instrument, so once the context is paired the fix follows | ||
| 730 | +directly and the ladder re-run confirms it. | ||
| 731 | + | ||
| 732 | +**Credit where it is due.** Round 13's instrument correction — moving | ||
| 733 | +the bit position onto the same physical line as its read — is what made | ||
| 734 | +this round possible. Rounds 11 and 12 both reported findings that were | ||
| 735 | +artefacts of that placement; without the fix this window would have | ||
| 736 | +been "analysed" a third time and reached a third wrong conclusion. | ||
| 737 | + | ||
| 738 | +### Round 13 — SETTLED: the oracle DOES consume them, and our reads match exactly | ||
| 739 | + | ||
| 740 | +**Outcome (a).** The rung emission is fixed — the bit position is now | ||
| 741 | +appended BEFORE the format string's `\n`, so it lands on the same | ||
| 742 | +physical line (all 18 `EC_ISTEP` and 14 `EC_COEFF_STEP` sites in | ||
| 743 | +`decodemv.c` / `decodetxb.c`; `aomdec` rebuilt, all reverted again, | ||
| 744 | +`grep -c bitpos` = 0). | ||
| 745 | + | ||
| 746 | +With correct emission, the oracle at mi(68,16): | ||
| 747 | + | ||
| 748 | +``` | ||
| 749 | +angle_uv val=-2 rng=57128 bitpos=92312 | ||
| 750 | +use_filter_intra val=1 rng=37468 bitpos=92312 | ||
| 751 | +filter_intra_mode val=3 rng=35632 bitpos=92313 | ||
| 752 | +next block mi(64,24) skip bitpos=92323 | ||
| 753 | +``` | ||
| 754 | + | ||
| 755 | +and ours, from the same trace: | ||
| 756 | + | ||
| 757 | +``` | ||
| 758 | +angle_uv val=-2 bitpos 92312 | ||
| 759 | +use_filter_intra val=1 bitpos 92312 | ||
| 760 | +filter_intra_mode val=3 bitpos 92313 | ||
| 761 | +next block mi(64,24) skip bitpos 92323 | ||
| 762 | +``` | ||
| 763 | + | ||
| 764 | +**Identical — same values, same bit positions, same next-block | ||
| 765 | +position.** The oracle consumes both symbols; so do we; the reads | ||
| 766 | +agree. This window is CLOSED and the two extra reads that rounds 11 and | ||
| 767 | +12 chased never existed. | ||
| 768 | + | ||
| 769 | +**Why rounds 11 and 12 saw them anyway — the mechanism, recorded so it | ||
| 770 | +is not repeated.** With the position on the previous line, a | ||
| 771 | +record-wise parse (split on `EC_ISTEP`, read `bitpos=` from inside the | ||
| 772 | +record) attributes each read's position to the PRECEDING read, because | ||
| 773 | +that is the line it was physically printed on. So the two | ||
| 774 | +`use_filter_intra` / `filter_intra_mode` reads carried the bit positions | ||
| 775 | +of the reads before them, and a window bounded on those positions | ||
| 776 | +silently excluded them. The lesson is sharper than round 8's: **with a | ||
| 777 | +multi-field rung, a positional parse is only as good as the field's | ||
| 778 | +placement** — and a field that lands on an adjacent line does not | ||
| 779 | +announce itself, it just quietly misattributes. | ||
| 780 | + | ||
| 781 | +**What the round-10 "3 bits short" number now means.** It stands as a | ||
| 782 | +measurement — the coefficient-unit bit delta is constant -14 through | ||
| 783 | +unit 2427 and changes at 2428 — but the window attributed to it does | ||
| 784 | +NOT contain the divergence: the mode reads in it are now proven to | ||
| 785 | +match symbol for symbol and bit for bit. The three bits are elsewhere | ||
| 786 | +in that span, or the all_zero-level delta change at 2428 has a cause | ||
| 787 | +this lane has not reached. **This lane ran out of budget before | ||
| 788 | +re-anchoring the ladder past mi(68,16) to find the real first-delta | ||
| 789 | +read**, which is the next step and is unchanged from round 12's option | ||
| 790 | +(a) branch. | ||
| 791 | + | ||
| 792 | +### Round 12 — CORRECTION to round 11: the extra reads are real, the CAUSE is not what round 11 said | ||
| 793 | + | ||
| 794 | +Round 11 was wrong twice over, both times from trusting a print | ||
| 795 | +without checking how it is emitted. Recorded here rather than left | ||
| 796 | +standing. | ||
| 797 | + | ||
| 798 | +**Error 1, a parse artefact.** The oracle's `EC_ISTEP` lines carry | ||
| 799 | +`bitpos=` but the insertion point placed it after the format string's | ||
| 800 | +`\n`, so the position lands on the PREVIOUS line. Round 11's | ||
| 801 | +line-filtered window therefore dropped every oracle `use_filter_intra` / | ||
| 802 | +`filter_intra_mode` line it was looking for. Re-parsed RECORD-WISE | ||
| 803 | +(splitting on `EC_ISTEP` and reading the bit position out of the record | ||
| 804 | +rather than the physical line), the oracle emits 241 `use_filter_intra` | ||
| 805 | +lines and the two sides read: | ||
| 806 | + | ||
| 807 | +``` | ||
| 808 | +ORACLE [92304] skip/cdef/dq [92305] mode 0 angle_y 0 | ||
| 809 | + [92309] uv_mode 4 [92312] angle_uv -2 | ||
| 810 | + [92323] skip <- next block, no filter_intra in between | ||
| 811 | +OURS [92304] skip/cdef/dq [92305] mode 0 angle_y 0 | ||
| 812 | + [92309] uv_mode 4 [92312] angle_uv -2 | ||
| 813 | + [92312] use_filter_intra val=1 | ||
| 814 | + [92313] filter_intra_mode val=3 | ||
| 815 | + [92323] skip | ||
| 816 | +``` | ||
| 817 | + | ||
| 818 | +So the OBSERVATION survives the correction: at mi(68,16) we make those | ||
| 819 | +two reads and the oracle shows none in that span. | ||
| 820 | + | ||
| 821 | +**Error 2, and this one kills round 11's conclusion.** Round 11 said | ||
| 822 | +libaom's `av1_filter_intra_allowed` should have suppressed them and that | ||
| 823 | +the suppressing input was `enable_filter_intra` or `palette_size[0]`. | ||
| 824 | +Measured directly, with a rung inside libaom's own | ||
| 825 | +`read_filter_intra_mode_info`: | ||
| 826 | + | ||
| 827 | +``` | ||
| 828 | +PALSZ mi=68,16 bsize=8 mode=0 psize0=0 efi=1 wide=32 high=16 allowed=1 | ||
| 829 | +``` | ||
| 830 | + | ||
| 831 | +**`allowed=1`.** libaom's predicate is SATISFIED at that block — mode is | ||
| 832 | +DC_PRED (0), `palette_size[0]` is 0, `enable_filter_intra` is 1, and the | ||
| 833 | +32x16 footprint passes `wide <= 32 && high <= 32`. So libaom DOES read | ||
| 834 | +`use_filter_intra` there, and round 11's "the read should not have | ||
| 835 | +happened" framing is wrong. The two unmeasured inputs were measured and | ||
| 836 | +BOTH AGREE with us; there is no stale palette state and no header-bit | ||
| 837 | +disagreement. | ||
| 838 | + | ||
| 839 | +**What is left, stated honestly.** Our two extra reads are real in the | ||
| 840 | +bit stream, and libaom's own predicate says the corresponding reads are | ||
| 841 | +allowed — so the divergence is NOT a missing/extra gate in the sense | ||
| 842 | +round 11 described, and this lane cannot say what it is. The one | ||
| 843 | +remaining tension is internal to the instrumented oracle: its | ||
| 844 | +`allowed=1` and its absent `use_filter_intra` EC_ISTEP at mi(68,16) do | ||
| 845 | +not sit together, which points at the ORACLE's instrumentation (the | ||
| 846 | +`EC_ISTEP` print is inside the `if`, and something about that path is not | ||
| 847 | +reaching it) rather than at a decoder defect. **The next lane should | ||
| 848 | +re-verify the oracle side before touching ours** — on the strength of | ||
| 849 | +rounds 8, 11 and 12, this tree has twice rewarded a conclusion that a | ||
| 850 | +single print, read without checking its emission or its guard, | ||
| 851 | +contradicted. | ||
| 852 | + | ||
| 853 | +**Unblock, restated.** Do NOT gate our `use_filter_intra` read. First | ||
| 854 | +settle the oracle: does an unmodified-ish `aomdec` consume the | ||
| 855 | +`use_filter_intra` symbol at mi(68,16)? Compare its bit position after | ||
| 856 | +`angle_uv` with aomdec's mode-info trace, with the print placed so its | ||
| 857 | +bit position is on the SAME line (append the field before the `\n`). | ||
| 858 | +Only if the oracle genuinely does not consume it is our read the defect, | ||
| 859 | +and then the predicate that would have to differ is not | ||
| 860 | +`av1_filter_intra_allowed` — it is whatever else gates the call. | ||
| 861 | + | ||
| 862 | +### Round 11 — the two extra reads are NAMED: `use_filter_intra` + `filter_intra_mode` | ||
| 863 | + | ||
| 864 | +Bit positions added to the MODE rungs on both sides (our `EC_ISTEP` | ||
| 865 | +per-symbol macro, the oracle's twelve `EC_ISTEP` prints in | ||
| 866 | +`decodemv.c`), paired BIT-POSITION-ANCHORED throughout, then reverted | ||
| 867 | +(`grep -c bitpos` = 0). | ||
| 868 | + | ||
| 869 | +The window, with the constant −14 folded in (oracle bit in brackets): | ||
| 870 | + | ||
| 871 | +``` | ||
| 872 | + mi(68,16) mi(64,24) | ||
| 873 | +oracle 92304 skip/cdef/dq [92304] | ||
| 874 | + 92305 mode 0 [92305] angle_y 0 [92305] | ||
| 875 | + 92309 uv_mode 4 [92309] angle_uv -2 [92312] | ||
| 876 | + ---- block ends ---- 92323 skip/cdef/dq | ||
| 877 | +ours 92318 skip/cdef/dq [92304] | ||
| 878 | + 92319 mode 0 [92305] angle_y 0 [92305] | ||
| 879 | + 92323 uv_mode 4 [92309] angle_uv -2 [92312] | ||
| 880 | + 92326 use_filter_intra val=1 <-- EXTRA | ||
| 881 | + 92327 filter_intra_mode val=3 <-- EXTRA | ||
| 882 | + 92337 skip/cdef/dq | ||
| 883 | +``` | ||
| 884 | + | ||
| 885 | +**The two extra reads are at mi(68,16), and the oracle does not make | ||
| 886 | +them.** Its silence is not a rung gap: the oracle's `use_filter_intra` | ||
| 887 | +print sits inside `if (av1_filter_intra_allowed(cm, mbmi))` and its | ||
| 888 | +`filter_intra_mode` print inside `if (...use_filter_intra)` | ||
| 889 | +(`decodemv.c:638-656`), so a missing line means the read did not happen. | ||
| 890 | + | ||
| 891 | +**The block is the same on both sides** (enum-resolved, per the round-8 | ||
| 892 | +lesson): oracle `EC_IMODE mi_row=68 mi_col=16 bsize=8`, and | ||
| 893 | +`enums.h:100-115` makes 8 = **BLOCK_32X16**; ours reads | ||
| 894 | +`EC_IMODE ... fn=rect bw=32 bh=16`. Same footprint, same bit position. | ||
| 895 | + | ||
| 896 | +**Which gate should have suppressed them** — | ||
| 897 | +`av1_filter_intra_allowed` (`reconintra.h:75-79`) is | ||
| 898 | + | ||
| 899 | +``` | ||
| 900 | +mbmi->mode == DC_PRED && palette_size[0] == 0 | ||
| 901 | + && (enable_filter_intra && block_size_wide <= 32 && block_size_high <= 32) | ||
| 902 | +``` | ||
| 903 | + | ||
| 904 | +The block satisfies the mode (0 = DC_PRED) and size (32/16, both <= 32) | ||
| 905 | +conditions, so the suppressing input is one of the two this lane did NOT | ||
| 906 | +measure: the sequence header's `enable_filter_intra`, or the block's | ||
| 907 | +`palette_size[0]`. **This lane ran out of budget before measuring | ||
| 908 | +either, and does not claim which.** | ||
| 909 | + | ||
| 910 | +**Unblock, now short.** Print `enable_filter_intra` and | ||
| 911 | +`palette_size[0]` for this block on both sides and compare against the | ||
| 912 | +predicate above. If `enable_filter_intra` agrees, the defect is our | ||
| 913 | +`palette_size[0]` state for the block; if it disagrees, it is the | ||
| 914 | +sequence-header bit. Either way it is a single boolean, and the fix is | ||
| 915 | +one gate on the `use_filter_intra` read. | ||
| 916 | + | ||
| 917 | +### Round 10 — the second window: 3 bits, and they are in the MODE reads | ||
| 918 | + | ||
| 919 | +`EC_COEFF_STEP bitpos` re-added on both sides (18 rungs here, 11 in the | ||
| 920 | +oracle's `decodetxb.c`), `aomdec` rebuilt, all reverted again | ||
| 921 | +(`grep -c bitpos` = 0). | ||
| 922 | + | ||
| 923 | +The bit delta is the same constant **-14** for every coefficient unit | ||
| 924 | +from 0 through 2427, and changes at **2428**: the oracle consumes 18 | ||
| 925 | +bits across that unit, we consume 15. **We are 3 bits short** — the | ||
| 926 | +mirror image of round 6, where we were 6 bits long. | ||
| 927 | + | ||
| 928 | +The window, enumerated (both units are all_zero=1 skips, so no | ||
| 929 | +coefficient reads fall inside it): | ||
| 930 | + | ||
| 931 | +``` | ||
| 932 | +oracle 92321 all_zero plane=2 ctx=8 all_zero=1 rng=60208 | ||
| 933 | + 92339 all_zero plane=0 ctx=0 all_zero=1 rng=38996 (+18 bits) | ||
| 934 | +ours 92335 all_zero plane=0 ctx=1 all_zero=1 rng=61576 | ||
| 935 | + 92350 all_zero side=8 ctx=3 all_zero=0 rng=48464 (+15 bits) | ||
| 936 | +``` | ||
| 937 | + | ||
| 938 | +**What this does and does not establish.** It establishes the MAGNITUDE | ||
| 939 | +and the SIDE: 3 bits, consumed by block-mode reads, not by any | ||
| 940 | +coefficient read — the `EC_COEFF_STEP` stream shows only the two skip | ||
| 941 | +units, so the three bits live in the mode/mode-preface reads | ||
| 942 | +(`skip`, `cdef`, `delta_q`, `mode`, `angle_delta`, `uv_mode`, | ||
| 943 | +`angle_delta_uv`, `use_filter_intra`, `filter_intra_mode`) that no rung | ||
| 944 | +on either side currently carries a bit position for. | ||
| 945 | + | ||
| 946 | +**A trap recorded, per the round-8 lesson.** The unit INDEX pairing is | ||
| 947 | +only valid while the bit delta is constant, and it stops being a safe | ||
| 948 | +guide at exactly this point: our decoder emits 2680 coefficient units | ||
| 949 | +against the oracle's 2512, and a skipped unit's `txb_skip` read can | ||
| 950 | +cost as few as one bit, so extra skip units can coexist with a constant | ||
| 951 | +bit delta. Note in the window above that the oracle's unit 2427 is | ||
| 952 | +`plane=2` and ours is `plane=0` — the indices no longer name the same | ||
| 953 | +block even though the bit positions still agree. **Pair bit positions, | ||
| 954 | +never unit indices, from here on.** | ||
| 955 | + | ||
| 956 | +**Enum discipline applied to what IS printed here.** `plane=0/1/2` is | ||
| 957 | +libaom's `PLANE_TYPE_Y/U/V` ordering and matches ours; `side=8` on our | ||
| 958 | +line is the square `reconstruct`'s side, i.e. an 8x8 transform unit; | ||
| 959 | +`ctx` on both is the `txb_skip` context, not a tx_size context (the | ||
| 960 | +tx_size context is the separately printed `EC_TXCTXB`/`tx_depth ctx`). | ||
| 961 | +Nothing in this window is claimed to be a bsize, a partition, or a | ||
| 962 | +tx_size category, so no enum lookup is needed to read it. | ||
| 963 | + | ||
| 964 | +**Unblock.** Add a bit position to the MODE rung on both sides — the | ||
| 965 | +`EC_ISTEP` line ours already prints per symbol, and the oracle's | ||
| 966 | +equivalent in `decodeframe.c`'s intra mode-info read — and pair the eight | ||
| 967 | +mode reads across this window. Three bits across seven or eight reads is | ||
| 968 | +a single short read (most plausibly a `filter_intra_mode` or a | ||
| 969 | +`use_filter_intra` the oracle takes and we do not, or a cfL alpha read | ||
| 970 | +present on one side only), and a per-symbol bit position will name it | ||
| 971 | +directly. That is another instrumentation round and is left unscheduled | ||
| 972 | +here. | ||
| 973 | + | ||
| 974 | +### Round 9 — CORRECTION to round 8, and where the desync actually starts | ||
| 975 | + | ||
| 976 | +**Round 8's central claim was wrong and is retracted here.** It read the | ||
| 977 | +oracle's `PARTB bsize=9` as `BLOCK_64X32`. The real enum | ||
| 978 | +(`enums.h:100-115`) is | ||
| 979 | +`0 BLOCK_4X4, 1 BLOCK_4X8, 2 BLOCK_8X4, 3 BLOCK_8X8, 4 BLOCK_8X16, | ||
| 980 | +5 BLOCK_16X8, 6 BLOCK_16X16, 7 BLOCK_16X32, 8 BLOCK_32X16, 9 BLOCK_32X32, | ||
| 981 | +10 BLOCK_32X64, 11 BLOCK_64X32, 12 BLOCK_64X64, 13 BLOCK_64X128, | ||
| 982 | +14 BLOCK_128X64, 15 BLOCK_128X128`. So `bsize=9` is **BLOCK_32X32** — | ||
| 983 | +the SAME block size we decode. The oracle is not walking a 64x32 where we | ||
| 984 | +walk a 32x32; both are at BLOCK_32X32. Round 8 also mis-called `bsize=15` | ||
| 985 | +a 64x16 (it is BLOCK_128X128, the superblock root) and `bsize=12` — it is | ||
| 986 | +BLOCK_64X64, not BLOCK_128X64. The rest of round 8 stands: the | ||
| 987 | +partition reads pair, bottom-edge truncation is ruled out, and the | ||
| 988 | +oracle's lineage is `15 (128X128) -> 12 (64X64) -> 12 (64X64) -> | ||
| 989 | +9 (32X32) -> 9 (32X32)`. | ||
| 990 | + | ||
| 991 | +**What round 9 establishes, with the enum right this time.** At | ||
| 992 | +mi(64,24) both decoders are on a 32x32 block and read the same tx_size | ||
| 993 | +row at the same context: | ||
| 994 | + | ||
| 995 | +``` | ||
| 996 | +oracle EC_TXCTXB mi=64,24 bsize=9 maxw=32 maxh=32 abv=32 lft=16 above=1 left=0 ctx=1 | ||
| 997 | +ours EC_ISTEP mi_row=64 mi_col=24 name=tx_depth val=2 ctx=1 | ||
| 998 | +``` | ||
| 999 | + | ||
| 1000 | +`bsize_to_tx_size_cat(BLOCK_32X32)` is 2, and our `max_tx == 32` arm | ||
| 1001 | +reads `tx_size_cat2[ctx]` with `ctx = 1` — the same CDF row the oracle | ||
| 1002 | +uses, at the same bit position (the -14 constant still holds). So the | ||
| 1003 | +tx_size lookup is NOT the divergence either. | ||
| 1004 | + | ||
| 1005 | +**Where the desync actually starts.** The reader state already differs at | ||
| 1006 | +mi(64,24)'s FIRST symbol (`skip`, oracle rng 39524 against ours 40716), | ||
| 1007 | +and the coefficient ladder pairs through unit 2427. So the window is the | ||
| 1008 | +reads between unit 2427's block and mi(64,24)'s `skip` — the same | ||
| 1009 | +narrow "between two units" window round 6 characterised, now at its | ||
| 1010 | +second occurrence. Both this window and round 6's were closed by pairing | ||
| 1011 | +per transform unit; this one is still open. | ||
| 1012 | + | ||
| 1013 | +**Corrected summary of what is known at mi(64,24):** same bsize, same | ||
| 1014 | +tx context, same CDF row, same bit position — and still a different | ||
| 1015 | +outcome (oracle one 32x32 luma TU, us 8x8 leaves), with the reader | ||
| 1016 | +already out of step at the block's first read. The structural difference | ||
| 1017 | +is real and downstream; the DESYNC is upstream of it and is the thing | ||
| 1018 | +still to find. | ||
| 1019 | + | ||
| 1020 | +### Round 8 — the partition reads PAIR; the block size entering them does not | ||
| 1021 | + | ||
| 1022 | +Rungs added and reverted on both sides (ours `EC_TRACE`, the oracle a `PARTB` | ||
| 1023 | +print in `ec_read_partition_impl` with `has_rows`/`has_cols`/`ctx`/bit | ||
| 1024 | +position/value; `aomdec` rebuilt, `grep -c PARTB` = 0). | ||
| 1025 | + | ||
| 1026 | +Bottom-edge truncation is **ruled out**: libaom recomputes | ||
| 1027 | +`has_rows = (mi_row + hbs) < mi_rows` with the CURRENT bsize's `hbs` | ||
| 1028 | +(`decodeframe.c:1292`), and so does ours, per level — both go | ||
| 1029 | +`has_rows=0` at the SB and the 64 level and `has_rows=1` from the 64x32 | ||
| 1030 | +level down. The edge arithmetic agrees at every level of SB row 64. | ||
| 1031 | + | ||
| 1032 | +**The partition reads themselves are identical.** Bit positions carry the | ||
| 1033 | +same constant −14 right through, and the values agree: | ||
| 1034 | + | ||
| 1035 | +``` | ||
| 1036 | + oracle ours | ||
| 1037 | +mi=64,16 bsize=9 ctx=8 bitpos=92247 value=1 92261 value=1 | ||
| 1038 | +mi=64,24 bsize=9 ctx=10 bitpos=92321 value=0 92335 value=0 | ||
| 1039 | +mi=64,32 bsize=9 ctx=9 bitpos=92356 value=3 93518 value=2 <- DIVERGED | ||
| 1040 | +``` | ||
| 1041 | + | ||
| 1042 | +At mi(64,32) the oracle is at bit 92356 and we are at 93518 — **1162 bits | ||
| 1043 | +later**. The gap opens in the block that FOLLOWS mi(64,24): the oracle | ||
| 1044 | +spends 33 bits there (92323 -> 92356) and we spend ~1183. | ||
| 1045 | + | ||
| 1046 | +**RETRACTED — see round 9 below.** This section read the oracle's `bsize=9` | ||
| 1047 | +as `BLOCK_64X32` and concluded the block size entering the read was the | ||
| 1048 | +divergence. With the real enum (`enums.h:100-115`) `bsize=9` is | ||
| 1049 | +`BLOCK_32X32`, the same size we decode, and that conclusion is wrong. | ||
| 1050 | +What survives from round 8: the partition reads pair, and bottom-edge | ||
| 1051 | +truncation is ruled out. | ||
| 1052 | + | ||
| 1053 | +**What is left to do, and why it is not another step here.** Tracing the | ||
| 1054 | +bsize lineage from the SB root down to mi(64,24) on both sides — the | ||
| 1055 | +`PARTB bsize=` field at each level of SB row 64, which the oracle's rung | ||
| 1056 | +prints and ours does not — is a further instrumentation round, not a | ||
| 1057 | +continuation of this one. The oracle's own trace already shows the shape | ||
| 1058 | +to chase (`mi=64,0 bsize=15 -> bsize=12 -> mi=64,16 bsize=12 -> bsize=9` | ||
| 1059 | +with `has_rows` flipping 0 -> 1 at the 64x32 level), and the question is | ||
| 1060 | +which of those levels our decoder resolves to a different bsize. | ||
| 1061 | + | ||
| 1062 | +**Scan table, still open.** Unchanged and not yet re-checked: it cannot | ||
| 1063 | +be re-checked until the partition tree is right, since the tiling it was | ||
| 1064 | +observed under is decided by the same walk. | ||
| 1065 | + | ||
| 1066 | +**Why this round stops here rather than continuing.** The partition rungs | ||
| 1067 | +this lane has — ours `EC_TRACE_PART`, the oracle's `AOMMB` — do not fire | ||
| 1068 | +for these blocks at all, and the bit-position rungs used in rounds 5-6 are | ||
| 1069 | +reverted. Closing this needs a fresh instrumentation round aimed at the | ||
| 1070 | +SUPERBLOCK partition symbol and its context, which is a scheduling | ||
| 1071 | +decision rather than another step inside this lane. Flagged as such. | ||
| 1072 | + | ||
| 1073 | +**Still open, same structure family:** the scan-table disagreement recorded | ||
| 1074 | +above (unit 1418, values matching by scan index but positions not). It is | ||
| 1075 | +in this same block/transform-structure family and should be looked at | ||
| 1076 | +alongside this boundary. | ||
| 1077 | + | ||
| 1078 | +**Hand-off, new class.** The new first divergence is at coefficient unit | ||
| 1079 | +2427 / TU 2428, mi(64,24), where the oracle codes a **32x32** luma TU and | ||
| 1080 | +we code **8x8** leaves. That is block/partition structure, not a neighbour | ||
| 1081 | +vote — a different class from this fix — so it is reported rather than | ||
| 1082 | +chased. `a1.obu` stays unpinned and no gate is written. | ||
| 1083 | + | ||
| 1084 | +**On the scan-table finding (Main's caution): checked, and the caution does not | ||
| 1085 | +explain it.** Unit 1418 is mi(48,28) plane 2 and it PAIRED on both sides as 8x8 | ||
| 1086 | +with an identical prediction sum (9024) — the tiling divergence (TX_4X4 vs | ||
| 1087 | +TX_8X8) is at unit 1419, the NEXT unit. So unit 1418 is 8x8 on both sides and a | ||
| 1088 | +"different scan table by design because the tx size differs" explanation does not | ||
| 1089 | +apply to it. The finding stands, though it may still be downstream of something | ||
| 1090 | +else; it is second priority to the vote. | ||
| 1091 | + | ||
| 1092 | +### Unblock | ||
| 1093 | + | ||
| 1094 | +The per-TU window bisect below has been run and NAMES the read: the **DC sign | ||
| 1095 | +context** at the sign pass of unit 1418, `dcctx` 1 (oracle) against 0 (ours), | ||
| 1096 | +taken in libaom from `txb_ctx->dc_sign_ctx` — a 3-symbol read from | ||
| 1097 | +`dc_sign_cdf_extra[plane_type]` per transform block. Next step: add a rung for | ||
| 1098 | +that symbol on BOTH sides (it is the one read in the unit that no | ||
| 1099 | +`EC_COEFF_STEP` print covers) and pair it, which should say outright whether our | ||
| 1100 | +value is wrong or merely drifted. The scan-table disagreement found in the same | ||
| 1101 | +window (values match by scan index, positions do not) is a second, independent | ||
| 1102 | +lead to keep open. Fixtures and dumps are in | ||
| 1103 | +`~/.cache/av1422warp/` (`a1_f0.obu`, `f0.opred`, `f0.mpred`, `f0.ocoeff`, | ||
| 1104 | +`f0.mcoeff`, `f0.ostep`, `f0.step`, `f0.otx`); the probe bypass | ||
| 1105 | +(`EC_AV1_ALLOW_422_PROBE`) is reverted and in no commit. | ||
| 1106 | + | ||
| 1107 | +This is a 4:2:2-only entropy desync; no 4:2:0 or 4:4:4 evidence points at it, and | ||
| 1108 | +both controls stayed byte-exact throughout. | ||
| 1109 | + | ||
| 1110 | +## Round 20 — EC_SYMR restored, tree protected, and the POISONER NAMED | ||
| 1111 | + | ||
| 1112 | +### Restoration and protection | ||
| 1113 | + | ||
| 1114 | +`EC_SYMR` had been lost on BOTH sides (my accidental `git checkout` of | ||
| 1115 | +`aom_dsp/bitreader.h`, and an earlier one of `msac.rs`). Rebuilt to skill | ||
| 1116 | +`ec-av1-consumption-gap-symr` Step 3 — ours an env-gated eprintln in | ||
| 1117 | +`SymbolDecoder::symbol` printing `pre=(value,range,bit) cdf0=<PRE-adapt | ||
| 1118 | +row[0]> n=<cdf.len()-1> s=<symbol> post_rng=<rng>`; the oracle the same | ||
| 1119 | +fields around `aom_read_cdf`/`update_cdf`, with value = dif top-16 and | ||
| 1120 | +bit = `8*(bptr-buf)-(cnt+15)`. | ||
| 1121 | + | ||
| 1122 | +The validation bar also caught a SECOND defect I had introduced earlier: | ||
| 1123 | +11 format strings in the oracle's `decodetxb.c` carried `\\n` (a literal | ||
| 1124 | +backslash-n) where `\n` (the newline escape) belongs, collapsing each | ||
| 1125 | +unit's whole step run onto one line. Repaired. **Validation: the | ||
| 1126 | +`all_zero` chain on a1_f0.obu now byte-matches the saved oracle trace | ||
| 1127 | +(2512 lines) and 744 `name=mode` lines are emitted.** | ||
| 1128 | + | ||
| 1129 | +The oracle tree is now snapshotted — `86c3958 oracle instrumentation | ||
| 1130 | +snapshot: EC_SYMR + rungs` — so a stray checkout cannot wipe it again. | ||
| 1131 | +Pre-edit copies of both files also sit in | ||
| 1132 | +`~/.cache/av1422warp/oracle-backup/`. | ||
| 1133 | + | ||
| 1134 | +### The poisoner, named | ||
| 1135 | + | ||
| 1136 | +`EC_SYMR` makes the two streams 1:1 BY CONSTRUCTION (both emit one line | ||
| 1137 | +per symbol read, in decode order), which is what the earlier | ||
| 1138 | +bit-position pairing could not do. On a1_f0.obu: | ||
| 1139 | + | ||
| 1140 | +``` | ||
| 1141 | +reads: oracle 46260, ours 46260 | ||
| 1142 | +reads 0..45259 : MATCH on value, range, CDF row (32768 - ours == oracle), | ||
| 1143 | + alphabet, symbol AND post-read range | ||
| 1144 | +read 45260 : FIRST DIVERGENCE | ||
| 1145 | + oracle pre=(27066, 42934, 92317) cdf0=15650 n=2 s=0 post_rng=45112 | ||
| 1146 | + ours pre=(27066, 42934, 92332) cdf0=17486 n=2 s=0 post_rng=46114 | ||
| 1147 | + (as 32768- : 15282) | ||
| 1148 | +``` | ||
| 1149 | + | ||
| 1150 | +Same pre-state, same bit position, same alphabet, same symbol — a | ||
| 1151 | +**different CDF row**. The trace names the read: | ||
| 1152 | + | ||
| 1153 | +``` | ||
| 1154 | +oracle EC_COEFF_STEP tag=sign c=0 sign=0 dcctx=0 <- row 0 | ||
| 1155 | +ours EC_COEFF_STEP tag=sign_rect pos=0 sign=0 dcctx=1 <- row 1 | ||
| 1156 | +``` | ||
| 1157 | + | ||
| 1158 | +It is the **DC sign read of the chroma-U 4x4 transform of the 32x16 strip | ||
| 1159 | +at mi(68,16)**. The strip is decoded by `decode_block_rect`, which built | ||
| 1160 | +its chroma vote with `around_rect` and no 4:2:2 rerouting — the SIBLING | ||
| 1161 | +of `decode_leaf_rect`, which the round-6 fix gated. | ||
| 1162 | + | ||
| 1163 | +### The fix (`d7c25c3c`) | ||
| 1164 | + | ||
| 1165 | +`decode_block_rect` now routes planes 1 and 2 through | ||
| 1166 | +`around_mi_422_chroma` under the same `ss_x == 1 && ss_y == 0` gate the | ||
| 1167 | +square/leaf paths use. Luma keeps the per-mi gather; 4:2:0 and 4:4:4 keep | ||
| 1168 | +the plain rect walk verbatim. | ||
| 1169 | + | ||
| 1170 | +**Red/green.** All 46260 reads now match at STATE level; the only | ||
| 1171 | +residual difference is the `bit` field over the last 17 reads, which is | ||
| 1172 | +the reference's own buffer-end tell convention (its source says the tell | ||
| 1173 | +offset "becomes important once we hit the end of the buffer"). Frame 0 | ||
| 1174 | +is **pixel-exact against aomdec for the first time on this stream**; the | ||
| 1175 | +16-frame measure goes **0/16 -> 3/16** frames exact and **1619115 -> | ||
| 1176 | +1332125** differing samples. | ||
| 1177 | + | ||
| 1178 | +**Identity, all four unchanged:** 4:2:0 control `a420.obu` byte-identical | ||
| 1179 | +to `aomdec --rawvideo`; 4:4:4 `444_sb128rect_lr_witness.obu` | ||
| 1180 | +byte-identical to the pre-lane build; pinned `422_allskip_2f.obu` and | ||
| 1181 | +`422_sb128_3f.obu` still pixel-exact. | ||
| 1182 | + | ||
| 1183 | +### Not done | ||
| 1184 | + | ||
| 1185 | +`a1.obu` is still not all-exact (3/16 frames), so it stays unpinned and | ||
| 1186 | +no gate is written. The next divergence is past frame 0 and was not | ||
| 1187 | +localized this round — the natural continuation is the same EC_SYMR | ||
| 1188 | +sequence diff run over the whole 16-frame stream, which now has a | ||
| 1189 | +trustworthy instrument and a per-TU exactness baseline. | ||
| 1190 | + | ||
| 1191 | +## Round 21 — full-stream diff: frame 1 is a RECON defect, frame 2 is a NEW entropy class | ||
| 1192 | + | ||
| 1193 | +Bypass reverted, worktree clean at `9c86a18f`, 4:2:0 control byte-exact. | ||
| 1194 | + | ||
| 1195 | +### The EC_SYMR sequence diff over all 16 frames | ||
| 1196 | + | ||
| 1197 | +``` | ||
| 1198 | +oracle 246735 reads, ours 166211 | ||
| 1199 | +reads 0..107516 : MATCH on value, range, CDF row, alphabet, symbol, post_rng | ||
| 1200 | +read 107517 : FIRST DIVERGENCE (frame 2) | ||
| 1201 | + oracle pre=(45039, 61960, bit 3129) cdf0=24278 n=2 s=1 post_rng=45863 | ||
| 1202 | + ours pre=(45039, 61960, bit 3144) cdf0=6401 n=8 s=3 post_rng=45500 | ||
| 1203 | + (as 32768- : 26367) | ||
| 1204 | +``` | ||
| 1205 | + | ||
| 1206 | +Identical coder state and identical bit position, but the two decoders | ||
| 1207 | +take a **different syntax branch**: the oracle reads `n=2`, then `n=2`, | ||
| 1208 | +then its `n=8`; this decoder reads its `n=8` straight away. That is a | ||
| 1209 | +MISSING read, not a wrong row — a different class from the two closed | ||
| 1210 | +defects (the OBMC chroma stride and the chroma dc-sign vote), both of | ||
| 1211 | +which were same-position/same-value/different-row. | ||
| 1212 | + | ||
| 1213 | +Our block at that point is a sub-8x8 leaf, `EC_IMODE mi_row=24 mi_col=57 | ||
| 1214 | +fn=sub8`, reached after its own `skip`/`cdef`/`dq` reads — all of which | ||
| 1215 | +pair. So the two decoders agree up to the block's mode-info and then | ||
| 1216 | +disagree about what the block IS. | ||
| 1217 | + | ||
| 1218 | +### Two separate residuals, not one | ||
| 1219 | + | ||
| 1220 | +Per-frame differing-sample counts against `aomdec --rawvideo`: | ||
| 1221 | + | ||
| 1222 | +``` | ||
| 1223 | +frame 0: 0 EXACT frame 8: 118214 | ||
| 1224 | +frame 1: 33375 frame 9: 103043 | ||
| 1225 | +frame 2: 57364 frame 10: 119670 | ||
| 1226 | +frame 3: 59542 frame 11: 126676 | ||
| 1227 | +frame 4: 109837 frame 12: 127177 | ||
| 1228 | +frame 5: 96361 frame 13: 133154 | ||
| 1229 | +frame 6: 115869 frame 14: 131843 | ||
| 1230 | +frame 7: 0 EXACT frame 15: 0 EXACT | ||
| 1231 | +``` | ||
| 1232 | + | ||
| 1233 | +**3/16 frames exact (0, 7, 15)** — up from 0/16 — and the total is | ||
| 1234 | +1332125 differing samples, down from 1619115. | ||
| 1235 | + | ||
| 1236 | +**RETRACTED — see round 22.** This section indexed pictures by SHOW | ||
| 1237 | +order while the dumps and the EC_SYMR sequence are DECODE order. Scanned | ||
| 1238 | +correctly there is ONE defect: picture 3 is the first damaged picture and | ||
| 1239 | +the read-107517 entropy divergence is in that same picture. | ||
| 1240 | + | ||
| 1241 | +### Handoff | ||
| 1242 | + | ||
| 1243 | +Two open items, neither in the closed family: | ||
| 1244 | + | ||
| 1245 | +1. **Frame 1, reconstruction only.** Entropy exact, pixels wrong. Compare | ||
| 1246 | + the stage dumps for frame 1 (PREFILT/POSTDEBLOCK/POSTCDEF) to localise | ||
| 1247 | + it; the ladder will not help, it is already clean there. | ||
| 1248 | +2. **Frame 2 read 107517.** A missing read: our sub-8x8 leaf at | ||
| 1249 | + mi(24,57) takes an `n=8` mode read where libaom takes `n=2`, `n=2`, | ||
| 1250 | + `n=8`. The first step is to establish what the two `n=2` reads ARE — | ||
| 1251 | + the natural candidates at 4:2:2 are the chroma-reference pair | ||
| 1252 | + bookkeeping (`is_chroma_reference`: one chroma column per PAIR of luma | ||
| 1253 | + mi columns) and a frame's intra/inter block decision. The | ||
| 1254 | + sequence-numbered EC_SYMR diff is now a working instrument for that, | ||
| 1255 | + with per-TU exactness on frames 0/7/15 as the baseline. | ||
| 1256 | + | ||
| 1257 | +Not pinned, no gate, refusal untouched. | ||
| 1258 | + | ||
| 1259 | +## Round 22 — the stage exoneration, and a CORRECTION to round 21 | ||
| 1260 | + | ||
| 1261 | +No code shipped this round; the tree is back at `401118ea`, bypass | ||
| 1262 | +reverted, 4:2:0 control byte-exact. | ||
| 1263 | + | ||
| 1264 | +### CORRECTION to round 21: there is ONE defect, not two | ||
| 1265 | + | ||
| 1266 | +Round 21 said "frame 1 is a reconstruction defect with exact entropy" and | ||
| 1267 | +"frame 2 is the new entropy class". That was **output-index confusion**: | ||
| 1268 | +the stage dumps are indexed by DECODE-order picture, the raw output by | ||
| 1269 | +SHOW order, and with alt-ref they differ. Scanned properly, over the | ||
| 1270 | +decode-order pictures: | ||
| 1271 | + | ||
| 1272 | +``` | ||
| 1273 | +pictures 0, 1, 2 : PREFILT identical AND final identical | ||
| 1274 | +picture 3 : PREFILT DIFFERS (first Y at (128,0), U at (128,1), V at (128,9)) | ||
| 1275 | +pictures 4..15 : all differ | ||
| 1276 | +``` | ||
| 1277 | + | ||
| 1278 | +So picture 3 is the first damaged picture and the EC_SYMR divergence at | ||
| 1279 | +read 107517 is IN picture 3 — the same defect, entropy and pixels | ||
| 1280 | +together. The round-21 "two residuals" framing is withdrawn. | ||
| 1281 | + | ||
| 1282 | +### Loop filters exonerated | ||
| 1283 | + | ||
| 1284 | +On the oracle's own frame-1 dump, `post-deblock` and `post-CDEF` both | ||
| 1285 | +differ from `final` (first difference at index 116), so CDEF and loop | ||
| 1286 | +restoration are **active** on this picture, and the picture is exact at | ||
| 1287 | +PREFILT anyway. The defect is therefore upstream of the loop filters — | ||
| 1288 | +reconstruction, reached through the entropy desync, not a filter stage. | ||
| 1289 | + | ||
| 1290 | +### The block, named precisely | ||
| 1291 | + | ||
| 1292 | +At read 107517 both decoders are at the same coder state | ||
| 1293 | +(pre `value=45039, range=61960`, same bit). The block is the 4x4 sub-8x8 | ||
| 1294 | +leaf at **mi(24,57)** and the syntax pairs to its mode: | ||
| 1295 | + | ||
| 1296 | +``` | ||
| 1297 | +ours mi(24,57) skip cdef dq mode -> 41536 ... and stops | ||
| 1298 | +oracle mi(24,57) skip cdef dq mode=0 angle_y=0 | ||
| 1299 | + uv_mode=13 angle_uv=0 use_filter_intra=1 filter_intra_mode=0 | ||
| 1300 | +``` | ||
| 1301 | + | ||
| 1302 | +**RETRACTED — see round 23.** "This decoder reads no chroma syntax at | ||
| 1303 | +all on that leaf" was read off `EC_ISTEP`, and | ||
| 1304 | +`read_intra_mode_sub8` emits no `istep!` for `uv_mode` or | ||
| 1305 | +`use_filter_intra`, so their absence proves nothing. The leaf IS reached | ||
| 1306 | +through `decode_leaf_split4` with `has_chroma=true`. | ||
| 1307 | + | ||
| 1308 | +libaom's actual predicate (`av1_common_int.h:1459-1460`) is per axis | ||
| 1309 | + | ||
| 1310 | +``` | ||
| 1311 | +(mi_col & 1) || !(bw & 1) || !subsampling_x | ||
| 1312 | +``` | ||
| 1313 | + | ||
| 1314 | +so for a ONE-mi-wide leaf — what a VERT split of an 8x16 strip leaves — | ||
| 1315 | +the chroma reference is the ODD column, whichever leaf index that is. | ||
| 1316 | +`decode_leaf_split4` already implements exactly that (`(lmi.1 & 1) == 1`). | ||
| 1317 | +`decode_leaf_rect8`'s vert clause is `!vert || i == 1`, which names the | ||
| 1318 | +SECOND leaf unconditionally: right only when the split starts on an even | ||
| 1319 | +column, inverted when it starts on an odd one. | ||
| 1320 | + | ||
| 1321 | +**Implemented, measured, and REVERTED.** With the `i == 1` clause | ||
| 1322 | +corrected to the column parity, the 16-frame EC_SYMR sequence diff is | ||
| 1323 | +**bit-identical to before** (first divergence still 107517) — this stream | ||
| 1324 | +never reaches the inverted case, so the change is correct by source and | ||
| 1325 | +**unexercised here**. Shipping an unproven change is not this lane's | ||
| 1326 | +practice, so it is recorded as a candidate rather than committed. | ||
| 1327 | + | ||
| 1328 | +### Handoff | ||
| 1329 | + | ||
| 1330 | +The defect is a chroma-reference test that is wrong on an odd mi column. | ||
| 1331 | +Two of the three sub-8x8 arms are now known: `decode_leaf_split4` is | ||
| 1332 | +correct, `decode_leaf_rect8` is correct-by-source but unexercised. **A | ||
| 1333 | +trace of `has_chroma` fired 268 times on this stream and never once for | ||
| 1334 | +mi(24,57)**, so the arm that reads that leaf has not been identified — | ||
| 1335 | +neither `decode_leaf_split4` nor `decode_leaf_rect8` is called for it. | ||
| 1336 | +The first concrete step is to find that third path (or the condition | ||
| 1337 | +under which those two are reached for a 4x4 leaf at an odd column), | ||
| 1338 | +apply the `av1_common_int.h:1459-1460` predicate, and re-run the | ||
| 1339 | +sequence diff: the EC_SYMR instrument is a working oracle for it and | ||
| 1340 | +pictures 0/1/2 are per-TU exact as the baseline. | ||
| 1341 | + | ||
| 1342 | +Not pinned, no gate, refusal untouched. | ||
| 1343 | + | ||
| 1344 | +## Round 23 — the third path IS `decode_leaf_split4`, and round 22's read of it was a rung gap | ||
| 1345 | + | ||
| 1346 | +No code shipped; tree back at `7d274652`, bypass reverted, 4:2:0 control | ||
| 1347 | +byte-exact. | ||
| 1348 | + | ||
| 1349 | +### Path identified (`#[track_caller]` on `read_intra_mode_sub8`) | ||
| 1350 | + | ||
| 1351 | +The 4x4 sub-8x8 leaf at mi(24,57) is read by the call at | ||
| 1352 | +`decode.rs:21098` — inside **`decode_leaf_split4`**, not a third path. | ||
| 1353 | +The attribution of all 370 sub-8x8 mode reads splits 236 / | ||
| 1354 | +`decode_leaf_split4` and 134 / `decode_leaf_rect8`. The round-22 | ||
| 1355 | +conclusion that "neither arm is called for it" was wrong: the | ||
| 1356 | +`has_chroma` trace added in round 22 was grepped on the wrong field name | ||
| 1357 | +(`col=` against a format that prints `lmi=(...)`), so its "never fired | ||
| 1358 | +for mi(24,57)" was a grep artefact. | ||
| 1359 | + | ||
| 1360 | +Re-run correctly, at that leaf: | ||
| 1361 | + | ||
| 1362 | +``` | ||
| 1363 | +HC split4 lmi=(24,55) i=1 c422=true has_chroma=true | ||
| 1364 | +HC split4 lmi=(24,56) i=0 c422=true has_chroma=false | ||
| 1365 | +HC split4 lmi=(24,57) i=1 c422=true has_chroma=true | ||
| 1366 | +``` | ||
| 1367 | + | ||
| 1368 | +**So `has_chroma` is TRUE at mi(24,57)** and this decoder's chroma | ||
| 1369 | +gate is open and correct there. | ||
| 1370 | + | ||
| 1371 | +### Round 22's central claim is WITHDRAWN | ||
| 1372 | + | ||
| 1373 | +Round 22 concluded "this decoder reads no chroma syntax at that leaf, | ||
| 1374 | +where libaom reads uv_mode/angle_uv/use_filter_intra/filter_intra_mode" | ||
| 1375 | +and built the odd-column theory on it. That was read off `EC_ISTEP` — | ||
| 1376 | +and **`read_intra_mode_sub8` emits no `istep!` for `uv_mode` or | ||
| 1377 | +`use_filter_intra` at all** (its `chroma` and `filter_intra` blocks print | ||
| 1378 | +only under the separate `trace` flag, decode.rs:20406-20449). Their | ||
| 1379 | +absence from `EC_ISTEP` is a rung gap, not evidence that the symbol went | ||
| 1380 | +unread. This is the same class of error as rounds 8, 11 and 15: a | ||
| 1381 | +conclusion from a print without checking that the print covers the site. | ||
| 1382 | + | ||
| 1383 | +What survives from round 22: the loop filters are exonerated, and the | ||
| 1384 | +first damaged picture is 3 with the read-107517 divergence in it. | ||
| 1385 | + | ||
| 1386 | +### What the evidence now supports | ||
| 1387 | + | ||
| 1388 | +`has_chroma=true` at mi(24,57) and yet the EC_SYMR sequence diverges | ||
| 1389 | +there — so if the chroma symbols are read (which the open gate says they | ||
| 1390 | +should be), the divergence is a VALUE or ROW difference inside them | ||
| 1391 | +rather than a missing read, and the "n=2, n=2, n=8 against a bare n=8" | ||
| 1392 | +shape needs re-reading against a trace that actually covers the sub-8x8 | ||
| 1393 | +chroma symbols. | ||
| 1394 | + | ||
| 1395 | +`decode_leaf_rect8`'s column-parity correction is therefore **still | ||
| 1396 | +unlanded** — the evidence that motivated it has collapsed, and it stays | ||
| 1397 | +correct-by-source-but-unwitnessed rather than committed on a theory | ||
| 1398 | +this lane has already had to retract once. | ||
| 1399 | + | ||
| 1400 | +### Handoff | ||
| 1401 | + | ||
| 1402 | +The right instrument, and it is a small edit: put the **mi coordinates | ||
| 1403 | +into the `EC_SYMR` print itself** (it currently has no mi, which is why | ||
| 1404 | +read 107517 could only be located by a fragile cross-file correlation | ||
| 1405 | +against a trace whose rungs do not cover the sub-8x8 chroma symbols). | ||
| 1406 | +With `EC_SYMR ... mi=(r,c)` on both sides, read 107517 names its own | ||
| 1407 | +block, the n=2/n=2/n=8 vs n=8 shape can be attributed to real symbols, | ||
| 1408 | +and the same diff runs per picture against the pictures 0/1/2 exact | ||
| 1409 | +baseline. | ||
| 1410 | + | ||
| 1411 | +Not pinned, no gate, refusal untouched. | ||
| 1412 | + | ||
| 1413 | +## Round 24 — the instrument works, and it MOVES the divergence to a different block | ||
| 1414 | + | ||
| 1415 | +`c355c204` (instrument, no behaviour change; identity re-proved) on this | ||
| 1416 | +side, `35d97e5` in the oracle tree. | ||
| 1417 | + | ||
| 1418 | +**`EC_SYMR` now carries `mi` on every read**, on both sides: ours a | ||
| 1419 | +thread-local the three mode readers set at entry, the oracle two globals | ||
| 1420 | +`ec_symr_mi_row/col` its mode-info reader publishes. Same-line fields. | ||
| 1421 | +Identity after the edit: 4:2:0 control byte-exact, 4:4:4 witness | ||
| 1422 | +byte-identical to the pre-lane build, both pinned 422 witnesses | ||
| 1423 | +pixel-exact. | ||
| 1424 | + | ||
| 1425 | +`mi` is a LABEL for attribution and is deliberately **not** part of the | ||
| 1426 | +divergence criterion — the oracle publishes it one read later than we do, | ||
| 1427 | +so requiring equality reports a spurious divergence at read 5. | ||
| 1428 | + | ||
| 1429 | +### It moves the answer | ||
| 1430 | + | ||
| 1431 | +With the read naming its own block, the same divergence lands somewhere | ||
| 1432 | +**completely different** from rounds 22-23: | ||
| 1433 | + | ||
| 1434 | +``` | ||
| 1435 | +first DECODED-STATE divergence at seq=107517 | ||
| 1436 | + oracle mi=(64,56) pre=(val=45039, rng=61960, bit=3129) cdf0=24278 n=2 s=1 -> 45863 | ||
| 1437 | + ours mi=(64,56) pre=(val=45039, rng=61960, bit=3144) cdf0=6401 n=8 s=3 -> 45500 | ||
| 1438 | + (as 32768- : 26367) | ||
| 1439 | + [107513] n=2 s=0 | n=2 s=0 (pair) | ||
| 1440 | + [107514] n=3 s=1 | n=3 s=1 (pair) | ||
| 1441 | + [107515] n=3 s=0 | n=3 s=0 (pair) | ||
| 1442 | + [107516] n=2 s=1 | n=2 s=1 (pair) | ||
| 1443 | + [107517] n=2 s=1 | n=8 s=3 <-- DIVERGES | ||
| 1444 | + [107518] n=2 s=1 | n=10 s=0 | ||
| 1445 | + [107519] n=8 s=3 | n=2 s=0 | ||
| 1446 | +``` | ||
| 1447 | + | ||
| 1448 | +**The block is the 32x32 intra block at mi(64,56)** — the frame's | ||
| 1449 | +bottom-right corner at 4:2:2 (mi 64 of 72 rows, mi_col 56 of 64). Not the | ||
| 1450 | +4x4 leaf at mi(24,57) that rounds 22 and 23 named: that attribution came | ||
| 1451 | +from correlating the read stream against a SEPARATE trace, which is | ||
| 1452 | +precisely the failure mode the mi label removes. Rounds 22-23's | ||
| 1453 | +"the leaf reads no chroma syntax" and its odd-column theory are | ||
| 1454 | +**withdrawn twice over** and should not be revisited. | ||
| 1455 | + | ||
| 1456 | +**The mode-info reads at mi(64,56) pair exactly** — skip 0, cdef 0, dq, | ||
| 1457 | +mode 3, angle_y -2, uv_mode 8, angle_uv -1, and both sides report the | ||
| 1458 | +same block size (ours `fn=sq side=32`, the oracle's `bsize=9` = | ||
| 1459 | +`BLOCK_32X32`). So the divergence is in the block's **COEFFICIENT** reads, | ||
| 1460 | +not its mode info and not its size: the oracle reads `n=2, n=2, n=8` | ||
| 1461 | +where this decoder reads `n=8, n=10, n=2` from the identical pre-state. | ||
| 1462 | +The `n=8`/`n=10` alphabets are transform-type sized, and at 4:2:2 this | ||
| 1463 | +block's chroma is a 16x32 rect, so the leading candidates are the | ||
| 1464 | +rect transform-type set (`av1_get_tx_type` over a rect plane block) and | ||
| 1465 | +an eob/tx_type ordering difference for the rect chroma unit. | ||
| 1466 | + | ||
| 1467 | +### Handoff | ||
| 1468 | + | ||
| 1469 | +The instrument is now trustworthy end to end: same-line fields, mi on | ||
| 1470 | +both sides, oracle tree snapshotted, and the divergence criterion | ||
| 1471 | +excludes the label. The next step is to attribute reads 107517-107519 to | ||
| 1472 | +symbols — with `EC_COEFF_STEP`'s `tag=` alongside (both sides emit it and | ||
| 1473 | +it now lines up read-for-read against the same mi) — and read the | ||
| 1474 | +transform-type set libaom selects for a 16x32 chroma plane block at | ||
| 1475 | +4:2:2 against the one this decoder selects. | ||
| 1476 | + | ||
| 1477 | +Not pinned, no gate, refusal untouched. | ||
| 1478 | + | ||
| 1479 | +## Round 25 — attribution blocked by a rung gap; a real underflow found on the way | ||
| 1480 | + | ||
| 1481 | +New head for this section's code: `a4532a41`. Bypass reverted, worktree | ||
| 1482 | +clean, 4:2:0 control byte-exact. | ||
| 1483 | + | ||
| 1484 | +### The attribution could not be completed — and why | ||
| 1485 | + | ||
| 1486 | +`EC_COEFF_STEP` is emitted on both sides, but **neither side's tags | ||
| 1487 | +cover reads 107493-107517**: the last tagged read on both is 107492 | ||
| 1488 | +(`sign`/`post_golomb`) and the next is 107542 on ours and 107752 on the | ||
| 1489 | +oracle's. So the `n=2,n=2,n=8` against `n=8,n=10,n=2` shape sits in a | ||
| 1490 | +region where no coefficient rung fires on either side, and the promised | ||
| 1491 | +lookup is not available without extending coverage into the phase that | ||
| 1492 | +reads there (the `n=2` pair is partition-alphabet sized and the | ||
| 1493 | +`n=8`/`n=10` are transform-type sized, which points at `read_var_tx_size` | ||
| 1494 | +in `decodeframe.c` — untagged on both sides). | ||
| 1495 | + | ||
| 1496 | +### What the round did find: a real underflow in both OBMC walks | ||
| 1497 | + | ||
| 1498 | +Chasing the tag gap surfaced a **debug-build panic on a1.obu**: | ||
| 1499 | +`attempt to subtract with overflow` at `decode.rs:31540`, then | ||
| 1500 | +`31491` — `overlappable_left` and `overlappable_above`, both called | ||
| 1501 | +from `decode_inter_block`. | ||
| 1502 | + | ||
| 1503 | +The OBMC pair merge snaps back to the chroma pair's even row/column | ||
| 1504 | +(`row &= !1` / `col &= !1`, lane-obmcrec r1) so the ODD half is the | ||
| 1505 | +neighbour for both strips. That snap rounds DOWN, so at an ODD | ||
| 1506 | +`mi_row` / `mi_col` it lands on `mi_row - 1` / `mi_col - 1` and the | ||
| 1507 | +`row - mi_row` / `col - mi_col` offsets pushed into the neighbour list | ||
| 1508 | +underflow: `usize::MAX` in release, panic in debug. Both snaps are now | ||
| 1509 | +clamped with `.max(mi_row)` / `.max(mi_col)`; where the offset was | ||
| 1510 | +already non-negative the arithmetic is unchanged. | ||
| 1511 | + | ||
| 1512 | +**Witness and its limit.** The panic reproduces on a1.obu with | ||
| 1513 | +`EC_TRACE_MODE_STEP=1`, single- AND multi-threaded, and does NOT | ||
| 1514 | +reproduce without that flag — which I could not explain, and am | ||
| 1515 | +recording as unexplained rather than inventing a reason. It is a | ||
| 1516 | +provable arithmetic defect with a panic as its witness, so it is fixed; | ||
| 1517 | +but it is **not** the frame-3 divergence: the 16-frame EC_SYMR | ||
| 1518 | +sequence diff is unchanged and the first divergence is still seq=107517 | ||
| 1519 | +at mi(64,56). Identity re-proved after the edit: 4:2:0 control | ||
| 1520 | +byte-exact, 4:4:4 witness byte-identical to the pre-lane build, both | ||
| 1521 | +pinned 422 witnesses pixel-exact. | ||
| 1522 | + | ||
| 1523 | +### Handoff | ||
| 1524 | + | ||
| 1525 | +Two open items, and the first is now the smaller one: | ||
| 1526 | + | ||
| 1527 | +1. **Extend the coefficient/transform-type rung into `read_var_tx_size` | ||
| 1528 | + on both sides** (libaom `decodeframe.c`; this decoder's | ||
| 1529 | + `read_var_tx_size` / txfm_partition read). That is what turns | ||
| 1530 | + reads 107517-107519 from an alphabet guess into a symbol name, and | ||
| 1531 | + it is the same shape as the two rung-coverage gaps this lane has | ||
| 1532 | + already been bitten by. | ||
| 1533 | +2. **The mi(64,56) 32x32 block's coefficient reads.** With coverage in | ||
| 1534 | + place, read the transform-type set libaom selects for this block's | ||
| 1535 | + 16x32 rect chroma plane block at 4:2:2 against ours. The `n=8` vs | ||
| 1536 | + `n=10` alphabets already say the two sides are offering | ||
| 1537 | + transform-type sets of DIFFERENT SIZES for the same block, which is | ||
| 1538 | + a set-content or set-selection defect rather than a value one. | ||
| 1539 | + | ||
| 1540 | +Not pinned, no gate, refusal untouched. | ||
| 1541 | + | ||
| 1542 | +## Round 26 — coverage attempted, and it is NOT achieved: the gap is bigger than var-tx | ||
| 1543 | + | ||
| 1544 | +Oracle rung added and snapshotted (`79e2986`): an `EC_VARTX` print on the | ||
| 1545 | +`txfm_partition` read at `decodeframe.c:1058`, carrying mi, row, col, ctx, | ||
| 1546 | +alphabet size, selected value and bit position. Validated at 1384 firings | ||
| 1547 | +on a1.obu. This decoder's `read_var_tx_size` already printed | ||
| 1548 | +`EC_ISTEP name=txfm_split`, so both sides now cover the var-tx phase. | ||
| 1549 | + | ||
| 1550 | +**And the coverage check FAILS, which is the result.** Enumerating every | ||
| 1551 | +rung of any kind on both sides across reads 107495-107770: | ||
| 1552 | + | ||
| 1553 | +``` | ||
| 1554 | +OURS (9 rungs) first at 107533: EC_MM mi_row=32 mi_col=0 w=64 h=64 ... | ||
| 1555 | + 107537 txfm_split mi(32,0) ctx=0 | ||
| 1556 | + 107539 txfm_split mi(32,8) ctx=3 | ||
| 1557 | + 107762 EC_MM mi_row=48 mi_col=0 | ||
| 1558 | +ORACLE (1 rung) 107751 EC_VARTX mi=(38,14) row=0 col=0 ctx=18 n=2 s=0 bitpos=3314 | ||
| 1559 | +``` | ||
| 1560 | + | ||
| 1561 | +So reads **107493-107532 on ours and 107493-107751 on the oracle's are | ||
| 1562 | +untagged on BOTH sides** — the `n=8` (ours) and the `n=2, n=2` (the | ||
| 1563 | +oracle) that diverge at 107517 all sit inside that gap. It is not the | ||
| 1564 | +transform-type read: the var-tx rung fires 1384 times on the oracle's and | ||
| 1565 | +still nowhere near 107517. By the shape of the gap it is the | ||
| 1566 | +**inter-block mode-info and MV read path**, which neither side tags. | ||
| 1567 | + | ||
| 1568 | +**The one thing this does establish about the divergence's direction:** | ||
| 1569 | +by read 107751 the oracle is at `mi(38,14)` while this decoder is at | ||
| 1570 | +`mi(32,0)`, and the oracle's bit position there is 3314 against our | ||
| 1571 | +3129 at the divergence — the oracle is roughly 230 reads and 185 bits | ||
| 1572 | +AHEAD. So this is not "one side reads an extra symbol"; the two decoders | ||
| 1573 | +are in **different blocks** by then, and the untagged gap is where they | ||
| 1574 | +part company. | ||
| 1575 | + | ||
| 1576 | +**Not claimed:** any symbol name for 107517-107519, and any tx-set | ||
| 1577 | +comparison. Main's step 1 made coverage a precondition for step 2, and | ||
| 1578 | +the precondition is not met, so step 2 is not attempted. | ||
| 1579 | + | ||
| 1580 | +**Handoff — the next instrument is the inter-mode/MV path, on both | ||
| 1581 | +sides**: tag the per-block inter mode-info reads (libaom | ||
| 1582 | +`read_inter_block_mode_info`: `is_inter`-dependent `y_mode`, | ||
| 1583 | +`uv_mode`, `skip_mode`, `interintra`, `comp_mode`, `motion_mode`) and | ||
| 1584 | +`read_mv_component`. With those, reads 107493-107532 stop being a gap | ||
| 1585 | +and the `n=8` / `n=2,n=2` get names; the `n=8` alphabet on our side is | ||
| 1586 | +the size a `y_mode` CDF would carry and the oracle's two `n=2` are | ||
| 1587 | +partition-sized, which is what makes "different block" the reading to | ||
| 1588 | +test first. Note the mi label will need the same treatment there — the | ||
| 1589 | +inter path's mi is not published by the intra mode reader. | ||
| 1590 | + | ||
| 1591 | +Not pinned, no gate, refusal untouched. | ||
| 1592 | + | ||
| 1593 | +## Round 27 — the inter path is tagged, and a wrong mi label of mine is fixed | ||
| 1594 | + | ||
| 1595 | +Instrument `7f55d054` (phase + corrected inter mi, no behaviour change; | ||
| 1596 | +identity re-proved: 4:2:0 byte-exact, 4:4:4 byte-identical to the | ||
| 1597 | +pre-lane build, both pinned 422 witnesses pixel-exact) and oracle | ||
| 1598 | +snapshot `ec_symr_phase`. | ||
| 1599 | + | ||
| 1600 | +### A label error of mine, found and fixed at the source | ||
| 1601 | + | ||
| 1602 | +Round 27 first published the mi from `decode_inter_block`'s entry `at`. | ||
| 1603 | +That labels a **different block**: it reported mi(28,52) for reads this | ||
| 1604 | +decoder makes for mi(30,62). Our own `EC_MODE_VAL8` rung — printed by | ||
| 1605 | +the function that actually reads the mode — reports mi(30,62). The | ||
| 1606 | +phase/mi are now also published from `decode_inter_block8` at the | ||
| 1607 | +block's own `leaf_mi`. | ||
| 1608 | + | ||
| 1609 | +This is round 22's misattribution class exactly, and it is now closed at | ||
| 1610 | +the source rather than worked around: with the label correct the two | ||
| 1611 | +sides are demonstrably in the SAME block. | ||
| 1612 | + | ||
| 1613 | +### The divergence, correctly attributed | ||
| 1614 | + | ||
| 1615 | +``` | ||
| 1616 | +oracle ph=inter mi=(30,62) n=2 s=1 107517 <-- the two missing reads | ||
| 1617 | + ph=inter mi=(30,62) n=2 s=1 107518 | ||
| 1618 | + ph=inter mi=(30,62) n=8 s=3 107519 | ||
| 1619 | +ours ph=inter8 mi=(30,62) n=8 s=3 107517 <-- identical to the oracle's 107519 | ||
| 1620 | + ph=inter8 mi=(30,62) n=10 s=0 107518 | ||
| 1621 | + ph=inter mi=(32,0) n=2 s=0 107519 | ||
| 1622 | +``` | ||
| 1623 | + | ||
| 1624 | +Reads 107514-107516 pair at mi(30,62) on both sides. Then **this decoder | ||
| 1625 | +omits two 2-symbol inter-mode reads that libaom makes**, and its n=8 at | ||
| 1626 | +107519 is bit-identical to our n=8 at 107517 — a clean **two-symbol | ||
| 1627 | +shift, same block, same coder state** (pre `val=45039, rng=61960`). | ||
| 1628 | + | ||
| 1629 | +**Not claimed: which two symbols.** libaom's 2-symbol reads in this | ||
| 1630 | +region are `interintra_cdf[bsize_group]` (decodemv.c:1628) and, after a | ||
| 1631 | +compound block, `comp_group_idx` / `compound_idx` (:1677, :1685); the | ||
| 1632 | +`n=3` pair just before (107514-107515) is in the MV/dmv region, which | ||
| 1633 | +this decoder's own path labels `inter8`. Pinning WHICH two requires | ||
| 1634 | +matching the read to its CDF context, and the `EC_SYMR` line carries the | ||
| 1635 | +`cdf0` pre-value but not the table identity — so the next step is to | ||
| 1636 | +extend the print with the CDF pointer (or the `bsize_group`) and pair on | ||
| 1637 | +that. I am not going to name them from alphabet size alone; that is the | ||
| 1638 | +same shortcut that produced rounds 8, 11 and 15. | ||
| 1639 | + | ||
| 1640 | +### Handoff | ||
| 1641 | + | ||
| 1642 | +Extend `EC_SYMR` on both sides with the CDF table IDENTITY (pointer or | ||
| 1643 | +`bsize_group`/`size_group` index) alongside `cdf0`. That is the last | ||
| 1644 | +thing `cdf0` alone cannot tell you — two rows can share a first entry — | ||
| 1645 | +and it converts "two 2-symbol reads" into the named pair. With that, the | ||
| 1646 | +gate that decides whether this decoder reads them is one comparison away | ||
| 1647 | +in the source. | ||
| 1648 | + | ||
| 1649 | +Not pinned, no gate, refusal untouched. | ||
| 1650 | + | ||
| 1651 | +## Round 28 — table identity added; the attribution is NOT closed | ||
| 1652 | + | ||
| 1653 | +Instrument `05770240` (no behaviour change; identity re-proved: 4:2:0 | ||
| 1654 | +byte-exact, 4:4:4 byte-identical to the pre-lane build, both pinned 422 | ||
| 1655 | +witnesses pixel-exact) and oracle snapshot for the table names. | ||
| 1656 | + | ||
| 1657 | +`cdf0` alone cannot identify a table — two rows can share a first entry | ||
| 1658 | +— which is exactly what stopped round 27. `EC_SYMR` now prints `cdf=`, | ||
| 1659 | +set at the read sites in this window on both sides: `interintra`, | ||
| 1660 | +`comp_group_idx`, `compound_idx`. | ||
| 1661 | + | ||
| 1662 | +**What the oracle's tag says:** read 107517 at mi(30,62) carries | ||
| 1663 | +`cdf=interintra`, and the two reads this decoder omits sit either side | ||
| 1664 | +of it. The oracle's `interintra` value there is 1, so it then reads the | ||
| 1665 | +wedge follow-up as well. | ||
| 1666 | + | ||
| 1667 | +**Why that is still not an attribution.** The matching gate on our side | ||
| 1668 | +(`enable_interintra_compound && !skip_mode`, decode.rs:41506) is **TRUE | ||
| 1669 | +on every one of its 451 firings** — `enable_interintra_compound=true, | ||
| 1670 | +skip_mode=false` — so this decoder is **not** skipping the interintra | ||
| 1671 | +read there. The obvious reading ("the two missing reads are interintra") | ||
| 1672 | +therefore does NOT hold, and I am not going to ship it. Two things are | ||
| 1673 | +unverified and both must be settled first: | ||
| 1674 | + | ||
| 1675 | +1. **Our `cdf` tag has not been checked against a known read.** The | ||
| 1676 | + printed field parsed oddly in the diff (it showed `inter8`, a value | ||
| 1677 | + `set_symr_cdf` is never given), so either the tag is not being set on | ||
| 1678 | + the path the reads are on, or my parse of the field is wrong. Until | ||
| 1679 | + one known read is confirmed tagged correctly on our side, our half of | ||
| 1680 | + the window is unlabelled. | ||
| 1681 | +2. **libaom's gate is a strict superset of ours** — `decodemv.c:1625` is | ||
| 1682 | + `enable_interintra_compound && !skip_mode && is_interintra_allowed(mbmi)` | ||
| 1683 | + and we implement the first two only. That makes libaom MORE restrictive, so | ||
| 1684 | + it cannot explain libaom reading and us skipping; but it is a real | ||
| 1685 | + divergence from source and should be reconciled on its own. | ||
| 1686 | + | ||
| 1687 | +**Handoff.** Verify our `cdf` tag end-to-end on a read whose table is known | ||
| 1688 | +from an existing rung (the `EC_COEFF_STEP tag=tx_type` sites and our | ||
| 1689 | +`inter_txbset_for` are the natural anchors), then re-run the window. Only | ||
| 1690 | +with our side labelled is the two-symbol shift attributable; until then the | ||
| 1691 | +only sound statement is the one above — the oracle reads an `interintra` | ||
| 1692 | +symbol at mi(30,62) that this decoder does not read at that point, our | ||
| 1693 | +interintra gate is open there, and the two cannot both be true without a | ||
| 1694 | +label we have not verified. | ||
| 1695 | + | ||
| 1696 | +Not pinned, no gate, refusal untouched. | ||
| 1697 | + | ||
| 1698 | +## Round 29 — our tag was printing the PHASE; fixed, and the window is now labelled | ||
| 1699 | + | ||
| 1700 | +`a4a1fcdb`: the `cdf=` slot of `EC_SYMR` was passing `SYMR_PHASE` a second | ||
| 1701 | +time — an off-by-one from adding the phase argument in round 27 and the cdf | ||
| 1702 | +one in round 28. **Every read reported the phase in the cdf field.** That is | ||
| 1703 | +precisely the `inter8` round 28 saw where no code path ever sets that value, | ||
| 1704 | +and it is why this lane could not label its own half of the window. With it | ||
| 1705 | +fixed the tag is live and verified against three distinct tables on a1.obu: | ||
| 1706 | +`interintra` 72533, `compound_idx` 33655, `comp_group_idx` 13744. No behaviour | ||
| 1707 | +change; identity re-proved (4:2:0 byte-exact, 4:4:4 byte-identical to | ||
| 1708 | +pre-lane, both pinned 422 witnesses pixel-exact). | ||
| 1709 | + | ||
| 1710 | +### The window, both sides now labelled | ||
| 1711 | + | ||
| 1712 | +``` | ||
| 1713 | + [107516] O cdf=interintra mi=(30,62) n=2 s=1 | M cdf=interintra mi=(30,62) n=2 s=1 pair | ||
| 1714 | + [107517] O cdf=interintra mi=(30,62) n=2 s=1 | M cdf=interintra mi=(30,62) n=8 s=3 <-- DIVERGES | ||
| 1715 | + [107518] O cdf=interintra mi=(30,62) n=2 s=1 | M cdf=interintra mi=(30,62) n=10 s=0 | ||
| 1716 | + [107519] O cdf=interintra mi=(30,62) n=8 s=3 | M cdf=interintra mi=(32,0) n=2 s=0 | ||
| 1717 | +``` | ||
| 1718 | + | ||
| 1719 | +Our `n=8` at 107517 is bit-identical to the oracle's at 107519, and the `n=10` | ||
| 1720 | +that follows matches too — so the oracle performs **two extra 2-symbol reads** | ||
| 1721 | +at mi(30,62) that this decoder does not, and the oracle's `interintra` value | ||
| 1722 | +there is **1**, so libaom then reads the wedge follow-up | ||
| 1723 | +(`decodemv.c:1639/1642`) as well. | ||
| 1724 | + | ||
| 1725 | +### What is still NOT closed, precisely | ||
| 1726 | + | ||
| 1727 | +Our `interintra` gate (`decode.rs:41506`, `enable_interintra_compound && | ||
| 1728 | +!skip_mode`) is TRUE on all 451 of its firings and we do read `interintra` | ||
| 1729 | +(72533 tagged reads) — so this decoder is **not** skipping the symbol | ||
| 1730 | +globally. The two missing reads are therefore not "our gate is wrong"; our | ||
| 1731 | +block at mi(30,62) reaches the `interintra` read at a different point in the | ||
| 1732 | +sequence than libaom's does. The two reads are NAMED | ||
| 1733 | +(`interintra` + its wedge follow-up, by the oracle's tag and its value of 1) | ||
| 1734 | +but the reason our path differs at that block is not yet established, and I am | ||
| 1735 | +not shipping a gate change on an unestablished reason. | ||
| 1736 | + | ||
| 1737 | +### Not done from this round's charter | ||
| 1738 | + | ||
| 1739 | +Step 3 — reconciling the missing `is_interintra_allowed(mbmi)` term | ||
| 1740 | +(`decodemv.c:1625` is a strict superset of ours) — is **not** done. libaom's | ||
| 1741 | +extra term can only make libaom read FEWER interintra symbols, so it cannot be | ||
| 1742 | +the cause of the two extra reads observed here, and landing it blind would | ||
| 1743 | +change a gate on a stream I cannot yet explain. It stays open. | ||
| 1744 | + | ||
| 1745 | +**Handoff.** With the tag live, the next step is to find which read this | ||
| 1746 | +decoder performs at mi(30,62) where the oracle performs `interintra` — i.e. | ||
| 1747 | +to tag the remaining inter-path reads (`y_mode`, `uv_mode`, `motion_mode`, | ||
| 1748 | +`skip`, and the `dmv`/MV reads) so the pair before 107517 is fully labelled. | ||
| 1749 | +Everything needed is now in place and verified. | ||
| 1750 | + | ||
| 1751 | +Not pinned, no gate, refusal untouched. | ||
| 1752 | + | ||
| 1753 | +## Round 30 — the tag WAS sticky; Main's suspicion confirmed, and round 28's attribution is retracted | ||
| 1754 | + | ||
| 1755 | +`37656c2f` (instrument, no behaviour change; identity re-proved) and oracle | ||
| 1756 | +snapshot `662b6f0`. | ||
| 1757 | + | ||
| 1758 | +### Sticky-tag verdict: CONFIRMED, and it invalidates round 28 | ||
| 1759 | + | ||
| 1760 | +The `cdf` tag was set at a read site and **carried by every later read**. | ||
| 1761 | +That is exactly how an 8-symbol read came to be labelled `interintra`, a | ||
| 1762 | +2-symbol table — the anomaly round 28 saw and could not explain. The tag is | ||
| 1763 | +now **one-shot**: `SymbolDecoder::symbol` consumes it, so an empty `cdf=` | ||
| 1764 | +means "no table set for this read", never the previous read's table. | ||
| 1765 | + | ||
| 1766 | +**Consequence: round 28's "the two missing reads are interintra" is | ||
| 1767 | +RETRACTED.** It rested entirely on the sticky label. | ||
| 1768 | + | ||
| 1769 | +### Remaining inter reads tagged, both sides | ||
| 1770 | + | ||
| 1771 | +`y_mode`, `uv_mode`, `motion_mode`, `skip_mode`, `comp_group_idx`, | ||
| 1772 | +`compound_idx`, `interintra` (plus `mv_sign`, `mv_class` on the oracle). | ||
| 1773 | +Verified sparse, which is the check that matters: comp_group_idx 947, | ||
| 1774 | +interintra 945, uv_mode 895, motion_mode 736, compound_idx 726, y_mode 293, | ||
| 1775 | +everything else empty. A sticky tag would have inflated these. | ||
| 1776 | + | ||
| 1777 | +### The window, with the label now trustworthy | ||
| 1778 | + | ||
| 1779 | +``` | ||
| 1780 | + [107512] O - n= 4 s=1 | M - n= 4 s=1 | ||
| 1781 | + [107513] O - n= 2 s=0 | M - n= 2 s=0 | ||
| 1782 | + [107514] O - n= 3 s=1 | M - n= 3 s=1 | ||
| 1783 | + [107515] O - n= 3 s=0 | M - n= 3 s=0 | ||
| 1784 | + [107516] O - n= 2 s=1 | M - n= 2 s=1 pair | ||
| 1785 | +->[107517] O - n= 2 s=1 | M - n= 8 s=3 DIVERGES | ||
| 1786 | + [107518] O - n= 2 s=1 | M - n=10 s=0 | ||
| 1787 | + [107519] O - n= 8 s=3 | M - n= 2 s=0 | ||
| 1788 | +``` | ||
| 1789 | + | ||
| 1790 | +**What this now says.** The two extra 2-symbol reads are at sites that | ||
| 1791 | +carry NO table tag on either side — and the neighbouring `n=3` pair is | ||
| 1792 | +`mv_class` (MV_CLASSES is 3) with the `n=10` matching `class0_cdf` | ||
| 1793 | +(CLASS0_SIZE is 10). So the window is inside libaom's | ||
| 1794 | +**`read_mv_component`**, not the mode-info reads: the oracle reads two extra | ||
| 1795 | +2-symbol MV sub-reads per component that this decoder does not, and the | ||
| 1796 | +`n=8`/`n=10` pair that follows is the matching `y_mode`/`class0` read. | ||
| 1797 | + | ||
| 1798 | +That is a real narrowing — from "two unnamed reads somewhere in the | ||
| 1799 | +inter path" to "two extra sub-reads inside the MV-component read" — and it | ||
| 1800 | +moves the defect OUT of the mode-info path that rounds 27-29 were chasing, | ||
| 1801 | +including the `interintra` gate theory, which is now irrelevant to this | ||
| 1802 | +window. | ||
| 1803 | + | ||
| 1804 | +### Not closed | ||
| 1805 | + | ||
| 1806 | +Which two MV sub-reads. `read_mv_component` (`decodemv.c:1000`) reads, in | ||
| 1807 | +order: `sign_cdf` (2), `classes_cdf` (MV_CLASSES), then under `class0` | ||
| 1808 | +`class0_cdf` (CLASS0_SIZE), else `class0_to_fr`/`hp`/`bits`. The two extra | ||
| 1809 | +n=2 reads are consistent with a `bit`/`hp`/`fr` sub-read this decoder skips | ||
| 1810 | +under a condition libaom does not take at this block — but naming WHICH | ||
| 1811 | +needs the sub-read sites tagged at their own granularity, not the | ||
| 1812 | +component. | ||
| 1813 | + | ||
| 1814 | +**Handoff.** Tag `read_mv_component`'s sub-reads individually on both sides | ||
| 1815 | +(`mv_sign`, `mv_class`, `mv_class0`, `mv_fr`, `mv_hp`, `mv_bit`). With the | ||
| 1816 | +tag now one-shot, the two extra reads name themselves on the next pass. | ||
| 1817 | + | ||
| 1818 | +Not pinned, no gate, refusal untouched. | ||
| 1819 | + | ||
| 1820 | +## Round 31 — the two reads are NAMED: `decodeframe.c:1722`, `wiener_restore_cdf` | ||
| 1821 | + | ||
| 1822 | +`37656c2f` (round 30's instrument, still current) and oracle snapshots | ||
| 1823 | +`662b6f0` / `9bb526a`. No behaviour change; identity re-proved. | ||
| 1824 | + | ||
| 1825 | +### The instrument that finally worked | ||
| 1826 | + | ||
| 1827 | +Two candidates were tried and **rejected on evidence**: | ||
| 1828 | +`__builtin_return_address(0)` is defeated by inlining and identical-code | ||
| 1829 | +folding — five distinct reads resolved to ONE address, and rebuilding | ||
| 1830 | +with `-fno-ipa-icf` did **not** separate them — and `addr2line` without | ||
| 1831 | +`-g` has no line info at all. | ||
| 1832 | + | ||
| 1833 | +What works is a **macro capturing `__FILE__`/`__LINE__` at the expansion**, | ||
| 1834 | +which is exact by construction and survives both. `aom_read_symbol` now | ||
| 1835 | +reports `site=file:line` for every read. This is the instrument nine | ||
| 1836 | +rounds of pairing needed and did not have. | ||
| 1837 | + | ||
| 1838 | +### The named reads | ||
| 1839 | + | ||
| 1840 | +``` | ||
| 1841 | +decodemv.c:1031 n=4 mv_fr | ||
| 1842 | +decodemv.c:1642 n=2 (interintra follow-up) | ||
| 1843 | +decodemv.c:172 n=4 | ||
| 1844 | +decodemv.c:1654 n=2 wedge_interintra | ||
| 1845 | +decodemv.c:1232 n=3 | ||
| 1846 | +decodemv.c:1232 n=3 | ||
| 1847 | +decodeframe.c:1722 n=2 s=1 pairs | ||
| 1848 | +decodeframe.c:1722 n=2 s=1 <-- MISSING | ||
| 1849 | +decodeframe.c:1722 n=2 s=1 <-- MISSING | ||
| 1850 | +decodeframe.c:1268 n=8 / n=10 the next block's modes | ||
| 1851 | +``` | ||
| 1852 | + | ||
| 1853 | +`decodeframe.c:1722` is `wiener_restore_cdf` inside `read_restoration_type` | ||
| 1854 | +— the per-plane loop-restoration read-back. **The oracle reads it three | ||
| 1855 | +times at this superblock; this decoder reads it once.** That is the whole | ||
| 1856 | +divergence: this decoder is missing two loop-restoration unit reads. | ||
| 1857 | + | ||
| 1858 | +### Two candidates checked and RULED OUT against libaom | ||
| 1859 | + | ||
| 1860 | +1. **Chroma LR unit size.** `decodeframe.c:1584-1593` uses | ||
| 1861 | + `s = AOMMIN(subsampling_x, subsampling_y)` and shifts by | ||
| 1862 | + `aom_rb_read_bit(rb) * s` only when `s && !chroma_none`. At 4:2:2 | ||
| 1863 | + `s == 0`, so chroma takes the luma size unshifted — which is exactly | ||
| 1864 | + what `ec-av1-syntax/src/frame.rs:1636` does. **Our code matches.** A | ||
| 1865 | + plausible-looking "fix" here (`>> (subsampling_x + subsampling_y)`, | ||
| 1866 | + the reading I started from) would break 4:2:0 and 4:4:4. | ||
| 1867 | +2. **`count_units`.** `restoration.rs:467` is character-for-character | ||
| 1868 | + `av1_lr_count_units` (`restoration.c:63`): same half-up rounding, same | ||
| 1869 | + `.max(1)`. **Matches.** | ||
| 1870 | + | ||
| 1871 | +### What is left, and it is small | ||
| 1872 | + | ||
| 1873 | +`restoration.rs:519-524` — the per-superblock unit range: | ||
| 1874 | + | ||
| 1875 | +```rust | ||
| 1876 | +let mi_size = if plane == 0 { 4 } else { 4 >> ss_x(fctx) }; | ||
| 1877 | +let rcol0 = ceil_div(mi_col * num_x, denom_x); | ||
| 1878 | +let rrow0 = ceil_div(mi_row * mi_size, unit_size); | ||
| 1879 | +``` | ||
| 1880 | + | ||
| 1881 | +`mi_size` is the only 4:2:2-sensitive term (2 at 4:2:2, 2 at 4:2:0, 4 at | ||
| 1882 | +4:4:4), and this range is what decides how many `read_lr_unit` calls a | ||
| 1883 | +superblock makes per plane. libaom's equivalent bounds come from | ||
| 1884 | +`av1_loop_restoration_corners_in_sb`, which mixes the superres `denom_x` | ||
| 1885 | +path differently for the row axis than this does. **That is the next | ||
| 1886 | +thing to check, and it is a read, not a rewrite.** | ||
| 1887 | + | ||
| 1888 | +**Handoff:** compare `restoration.rs:519-524` line by line against | ||
| 1889 | +`av1_loop_restoration_corners_in_sb` (`restoration.c`), with the 4:2:2 | ||
| 1890 | +`ss_y == 0` case in view. The oracle now names every read, so a correct | ||
| 1891 | +fix is provable in one run: the sequence diff must go flat. | ||
| 1892 | + | ||
| 1893 | +Not pinned, no gate, refusal untouched. | ||
| 1894 | + | ||
| 1895 | +## Round 32 — FIXED. The stream pairs bit-for-bit; the witness is pinned | ||
| 1896 | + | ||
| 1897 | +`af3285d5`. The 4:2:2 header refusal is **unchanged and unconditional**. | ||
| 1898 | + | ||
| 1899 | +### Round 31's hand-off was one of two errors, and they cancelled | ||
| 1900 | + | ||
| 1901 | +Round 31 pointed at `restoration.rs:519-524`. It was right that the row | ||
| 1902 | +term was wrong, and it was **half** the story. | ||
| 1903 | + | ||
| 1904 | +1. **`read_lr` derived the ROW corners from the COLUMN axis.** libaom's | ||
| 1905 | + `av1_loop_restoration_corners_in_sb` (`restoration.c:1303-1338`) steps | ||
| 1906 | + rows by `MI_SIZE >> subsampling_y` and columns by | ||
| 1907 | + `MI_SIZE >> subsampling_x` — the axes are not symmetric. This decoder | ||
| 1908 | + had one `mi_size = 4 >> subsampling_x` for both, on a base of 4 where | ||
| 1909 | + libaom's `MI_SIZE` is 8. At 4:2:2 (`ss_x` 1, `ss_y` 0) the row range | ||
| 1910 | + came out 4x too small, so `rrow0 == rrow1`: an empty range, zero | ||
| 1911 | + `read_lr_unit` calls, wherever libaom reads a chroma unit. **Those were | ||
| 1912 | + the two missing `wiener_restore_cdf` reads.** | ||
| 1913 | + | ||
| 1914 | +2. **The superblock extent was 2x too large.** `read_sb128_root` passed | ||
| 1915 | + `SB_MI * 2` for the 128x128 superblock, and the two 64px call sites | ||
| 1916 | + carried the same half-mi convention (`sb_r * SB_MI`, extent `SB_MI`). | ||
| 1917 | + | ||
| 1918 | +**`4 * 32 == 8 * 16`: the two errors cancelled exactly at 4:2:0.** That is | ||
| 1919 | +why 4:2:0 and 4:4:4 decoded byte-exact while carrying the bug, and why | ||
| 1920 | +the 4:2:0 evidence was never evidence of correctness here. At 4:2:2 the | ||
| 1921 | +cancellation breaks, because the row term stops following the column axis. | ||
| 1922 | +No amount of 4:2:0 testing could have found this. | ||
| 1923 | + | ||
| 1924 | +A third, smaller correction: the `read_lr` call is the **one** consumer | ||
| 1925 | +that turns a superblock's mode-info origin into *absolute* frame space | ||
| 1926 | +(it divides by the restoration-unit size, a real pixel count), and it was | ||
| 1927 | +handed `(sb_r & !1) * SB_MI` — twice the true mi row, since `sb_r` indexes | ||
| 1928 | +64px superblocks. The partition decode is self-consistent with that value | ||
| 1929 | +(relative offsets only), which is why the 128 path decoded correctly | ||
| 1930 | +everywhere else. The origin is corrected **only** where it is converted | ||
| 1931 | +to absolute frame space; the partition path is untouched. | ||
| 1932 | + | ||
| 1933 | +### Evidence | ||
| 1934 | + | ||
| 1935 | +| check | result | | ||
| 1936 | +|---|---| | ||
| 1937 | +| entropy pairing vs instrumented oracle | **246735 reads each side, no divergence anywhere** | | ||
| 1938 | +| 16 frames vs `aomdec --rawvideo` | **pixel-exact**, 2359296 bytes, sha256 `4bfc2395…aeb203` both sides | | ||
| 1939 | +| 4:2:0 control | byte-exact | | ||
| 1940 | +| 4:4:4 LR witness | byte-identical to its pre-lane decode | | ||
| 1941 | +| both previously pinned 4:2:2 witnesses | pixel-exact | | ||
| 1942 | +| LR gate family | 12/12 | | ||
| 1943 | +| battery: 420/444/inter/superres/cdef | 118 passed, 0 failed, 7 ignored | | ||
| 1944 | + | ||
| 1945 | +The pairing result is the strong one: not "past the window", but **no | ||
| 1946 | +divergence in the whole stream**. | ||
| 1947 | + | ||
| 1948 | +After the first two edits, two committed 4:2:0/4:4:4 LR gates **failed**. | ||
| 1949 | +That is how the 64px call sites' half-mi convention surfaced; fixing them | ||
| 1950 | +is part of this change, not a follow-up. | ||
| 1951 | + | ||
| 1952 | +### Pinned witness and gate | ||
| 1953 | + | ||
| 1954 | +`crates/ec-av1/fixtures/422_residual_compound_warp_16f.obu` — 38845 bytes, | ||
| 1955 | +sha256 `d78e2afb43ce311d3d82335a945c6f80f62db4537966d881c1349a68b3aecb95`, | ||
| 1956 | +fnv1a64 `0x0e73a51e2cc0c424`. Gate | ||
| 1957 | +`the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name`. | ||
| 1958 | + | ||
| 1959 | +The gate is **pin + refuse-by-name**, the established 4:2:2 pattern: with | ||
| 1960 | +the header refusal standing, no committed test *can* decode a 4:2:2 | ||
| 1961 | +stream, because the bypass that would allow it must never be committed. | ||
| 1962 | +The exactness and engagement figures live in the gate's doc comment with | ||
| 1963 | +the encode recipe. Mutation-proven both ways: a flipped fixture byte | ||
| 1964 | +panics `bytes drifted`; a wrong refusal string panics `must refuse by | ||
| 1965 | +name`. | ||
| 1966 | + | ||
| 1967 | +### Engagement, above the vertical midpoint | ||
| 1968 | + | ||
| 1969 | +Every pre-existing warp counter is frame-global, so this adds | ||
| 1970 | +`top_half_warp_hits` and `top_half_compound_hits` (permanent gate | ||
| 1971 | +counters; the throwaway dump and its example wiring were removed): | ||
| 1972 | + | ||
| 1973 | +- **top-half warp 248**, **top-half compound 3** | ||
| 1974 | +- frame-globally: compound_warp 25, compound_warp_8 18, rotzoom_gm_warp | ||
| 1975 | + 84, lr_wiener 22, lr_sgrproj 10, cdef_idx 53, part128_split 95 | ||
| 1976 | + | ||
| 1977 | +The loop-restoration numbers are load-bearing twice: decoding this stream | ||
| 1978 | +is what exposed the corner bug, and the fix is what made the sequence | ||
| 1979 | +pair. | ||
| 1980 | + | ||
| 1981 | +### Refusal-lift assessment — exactness bar MET, coverage NOT yet | ||
| 1982 | + | ||
| 1983 | +Not lifting, and here is the honest gap rather than a clean bill: | ||
| 1984 | + | ||
| 1985 | +- 16 frames of **one** 256x288 stream from **one** encoder recipe; | ||
| 1986 | +- top-half **compound is 3 blocks** — thin, even though top-half warp is | ||
| 1987 | + ample at 248; | ||
| 1988 | +- the code path whose bug we just fixed is *128x128 SB + loop restoration | ||
| 1989 | + + non-4:2:0*. **4:2:2 with loop restoration OFF is still untested**, | ||
| 1990 | + and it is a different range computation again (`av1_lr_count_units` over | ||
| 1991 | + a full-height chroma plane with no units to place). | ||
| 1992 | + | ||
| 1993 | +The old lift-blocker asked for a second 4:2:2 fixture with real residuals, | ||
| 1994 | +compound and warped motion above the vertical midpoint. This is that | ||
| 1995 | +fixture and it is exact. But one more exact stream is not the same as the | ||
| 1996 | +format being covered. **Recommendation: keep the refusal; charter the | ||
| 1997 | +LR-off 4:2:2 witness next**, then re-assess. | ||
| 1998 | + | ||
| 1999 | +Not lifting. Refusal untouched. Nothing pushed. | ||
| 2000 | + | ||