vp9: inter context write-back zeroes the window's tail, not bytes past it
Browse files at this commit674387075fb49dac339fe42e6db38c20ae5798f7Parent: bdf08743 changed files +345 -36
- crates/ec-vp9/src/decode.rs +62 -36
- crates/ec-vp9/tests/inter_pixels_exact.rs +27 -0
- lanes/vp9f72.report.md +256 -0
crates/ec-vp9/src/decode.rsmodified+62 -36
| @@ -1684,7 +1684,6 @@ impl Decoder { | |||
| 1684 | let maxw = (n4w as i32 + (mb_to_right.min(0) >> (5 + s))).max(0) as usize; | 1684 | let maxw = (n4w as i32 + (mb_to_right.min(0) >> (5 + s))).max(0) as usize; |
| 1685 | let maxh = (n4h as i32 + (mb_to_bottom.min(0) >> (5 + s))).max(0) as usize; | 1685 | let maxh = (n4h as i32 + (mb_to_bottom.min(0) >> (5 + s))).max(0) as usize; |
| 1686 | let nblocks = 1usize << tx_size; | 1686 | let nblocks = 1usize << tx_size; |
| 1687 | - let eob_pos = usize::from(coef.eob > 0); | ||
| 1688 | let shift_a = if maxw > 0 && nblocks + tx_col > maxw { | 1687 | let shift_a = if maxw > 0 && nblocks + tx_col > maxw { |
| 1689 | (nblocks - (maxw - tx_col)) * 8 | 1688 | (nblocks - (maxw - tx_col)) * 8 |
| 1690 | } else { | 1689 | } else { |
| @@ -1695,35 +1694,16 @@ impl Decoder { | |||
| 1695 | } else { | 1694 | } else { |
| 1696 | 0 | 1695 | 0 |
| 1697 | }; | 1696 | }; |
| 1698 | - match tx_size { | 1697 | + write_tx_context(ectx, plane, tx_size, ax, ay, coef.eob > 0, shift_a, shift_l); |
| 1699 | - TX_4X4 => { | 1698 | + if crate::tokdbg_enabled() { |
| 1700 | - ectx[plane].above[ax] = eob_pos as u8; | 1699 | + eprintln!( |
| 1701 | - ectx[plane].left[ay] = eob_pos as u8; | 1700 | + "TDW row={mi_row} col={mi_col} plane={plane} brow={tx_row} bcol={tx_col} tx={tx_size} eob={} sa={} sl={} aw={:?} lw={:?} intra=1", |
| 1702 | - } | 1701 | + coef.eob, |
| 1703 | - TX_8X8 => { | 1702 | + shift_a, |
| 1704 | - let va = ((eob_pos as u16) * 0x0101) >> shift_a; | 1703 | + shift_l, |
| 1705 | - ectx[plane].above[ax] = va as u8; | 1704 | + &ectx[plane].above[ax..ax + nblocks], |
| 1706 | - ectx[plane].above[ax + 1] = (va >> 8) as u8; | 1705 | + &ectx[plane].left[ay..ay + nblocks], |
| 1707 | - let vl = ((eob_pos as u16) * 0x0101) >> shift_l; | 1706 | + ); |
| 1708 | - ectx[plane].left[ay] = vl as u8; | ||
| 1709 | - ectx[plane].left[ay + 1] = (vl >> 8) as u8; | ||
| 1710 | - } | ||
| 1711 | - TX_16X16 => { | ||
| 1712 | - for k in 0..4 { | ||
| 1713 | - let va = ((eob_pos as u32) * 0x01010101) >> shift_a; | ||
| 1714 | - ectx[plane].above[ax + k] = (va >> (8 * k)) as u8; | ||
| 1715 | - let vl = ((eob_pos as u32) * 0x01010101) >> shift_l; | ||
| 1716 | - ectx[plane].left[ay + k] = (vl >> (8 * k)) as u8; | ||
| 1717 | - } | ||
| 1718 | - } | ||
| 1719 | - _ => { | ||
| 1720 | - for k in 0..8 { | ||
| 1721 | - let va = ((eob_pos as u64) * 0x0101010101010101) >> shift_a; | ||
| 1722 | - ectx[plane].above[ax + k] = (va >> (8 * k)) as u8; | ||
| 1723 | - let vl = ((eob_pos as u64) * 0x0101010101010101) >> shift_l; | ||
| 1724 | - ectx[plane].left[ay + k] = (vl >> (8 * k)) as u8; | ||
| 1725 | - } | ||
| 1726 | - } | ||
| 1727 | } | 1707 | } |
| 1728 | 1708 | ||
| 1729 | // 4. Residual add. | 1709 | // 4. Residual add. |
| @@ -1853,6 +1833,48 @@ fn reset_skip_context( | |||
| 1853 | ectx[plane].left[(offy + i) % lrows] = 0; | 1833 | ectx[plane].left[(offy + i) % lrows] = 0; |
| 1854 | } | 1834 | } |
| 1855 | } | 1835 | } |
| 1836 | + if crate::tokdbg_enabled() { | ||
| 1837 | + eprintln!( | ||
| 1838 | + "TDK row={row} col={col} n4w={n4w:?} n4h={n4h:?} la={:?} lc={:?}", | ||
| 1839 | + &ectx[0].left[..], | ||
| 1840 | + &ectx[1].left[..], | ||
| 1841 | + ); | ||
| 1842 | + } | ||
| 1843 | +} | ||
| 1844 | + | ||
| 1845 | +/// The entropy-context write-back of one transform block | ||
| 1846 | +/// (`vp9_decode_block_tokens`, `vp9_detokenize.c:273-323`): the block's | ||
| 1847 | +/// `eob` spreads over its `1 << tx_size` 4x4 slots, and `shift_a`/`shift_l` | ||
| 1848 | +/// (the `get_ctx_shift` frame-edge rule) zero the slots past the frame edge. | ||
| 1849 | +/// | ||
| 1850 | +/// libvpx applies the shift to a value whose WIDTH IS THE WINDOW'S — a | ||
| 1851 | +/// `(uint16_t)` for `TX_8X8`, `(uint32_t)` for `TX_16X16`, `(uint64_t)` for | ||
| 1852 | +/// `TX_32X32` — so the shift zeroes the window's TAIL. Shifting a 64-bit | ||
| 1853 | +/// spread instead only zeroes bytes past the window and leaves the in-window | ||
| 1854 | +/// tail set: the last-SB-row chroma blocks then hand a stale 1 to the next | ||
| 1855 | +/// row's context read (the frame-72 desync). | ||
| 1856 | +fn write_tx_context( | ||
| 1857 | + ectx: &mut [PlaneContexts; 3], | ||
| 1858 | + plane: usize, | ||
| 1859 | + tx_size: usize, | ||
| 1860 | + ax: usize, | ||
| 1861 | + ay: usize, | ||
| 1862 | + eob: bool, | ||
| 1863 | + shift_a: usize, | ||
| 1864 | + shift_l: usize, | ||
| 1865 | +) { | ||
| 1866 | + const ONES: u64 = 0x0101_0101_0101_0101; | ||
| 1867 | + let nblocks = 1usize << tx_size; | ||
| 1868 | + let eob_pos = u64::from(eob); | ||
| 1869 | + // Narrow to the window first (libvpx's cast), then apply the edge shift; | ||
| 1870 | + // the clamp keeps a fully-outside window (libvpx: undefined shift) total. | ||
| 1871 | + let narrow = 64 - 8 * nblocks; | ||
| 1872 | + let spread_a = ((eob_pos * ONES) >> narrow) >> shift_a.min(8 * nblocks); | ||
| 1873 | + let spread_l = ((eob_pos * ONES) >> narrow) >> shift_l.min(8 * nblocks); | ||
| 1874 | + for k in 0..nblocks { | ||
| 1875 | + ectx[plane].above[ax + k] = (spread_a >> (8 * k)) as u8; | ||
| 1876 | + ectx[plane].left[ay + k] = (spread_l >> (8 * k)) as u8; | ||
| 1877 | + } | ||
| 1856 | } | 1878 | } |
| 1857 | 1879 | ||
| 1858 | /// `mode_lf_lut` (`vp9/common/vp9_loopfilter.c:223`): | 1880 | /// `mode_lf_lut` (`vp9/common/vp9_loopfilter.c:223`): |
| @@ -1943,7 +1965,6 @@ fn decode_inter_tx_tokens( | |||
| 1943 | let n4h_s = bh * 2 >> s; | 1965 | let n4h_s = bh * 2 >> s; |
| 1944 | let maxw = (n4w_s as i32 + (mb_to_right.min(0) >> (5 + s))).max(0) as usize; | 1966 | let maxw = (n4w_s as i32 + (mb_to_right.min(0) >> (5 + s))).max(0) as usize; |
| 1945 | let maxh = (n4h_s as i32 + (mb_to_bottom.min(0) >> (5 + s))).max(0) as usize; | 1967 | let maxh = (n4h_s as i32 + (mb_to_bottom.min(0) >> (5 + s))).max(0) as usize; |
| 1946 | - let eob_pos = u64::from(coef.eob > 0); | ||
| 1947 | let shift_a = if maxw > 0 && nblocks + bcol > maxw { | 1968 | let shift_a = if maxw > 0 && nblocks + bcol > maxw { |
| 1948 | (nblocks - (maxw - bcol)) * 8 | 1969 | (nblocks - (maxw - bcol)) * 8 |
| 1949 | } else { | 1970 | } else { |
| @@ -1954,11 +1975,16 @@ fn decode_inter_tx_tokens( | |||
| 1954 | } else { | 1975 | } else { |
| 1955 | 0 | 1976 | 0 |
| 1956 | }; | 1977 | }; |
| 1957 | - let spread_a = (eob_pos * 0x0101_0101_0101_0101) >> shift_a; | 1978 | + write_tx_context(ectx, plane, tx_size, ax, ay, coef.eob > 0, shift_a, shift_l); |
| 1958 | - let spread_l = (eob_pos * 0x0101_0101_0101_0101) >> shift_l; | 1979 | + if crate::tokdbg_enabled() { |
| 1959 | - for k in 0..nblocks { | 1980 | + eprintln!( |
| 1960 | - ectx[plane].above[ax + k] = (spread_a >> (8 * k)) as u8; | 1981 | + "TDW row={row} col={col} plane={plane} brow={brow} bcol={bcol} tx={tx_size} eob={} sa={} sl={} aw={:?} lw={:?}", |
| 1961 | - ectx[plane].left[ay + k] = (spread_l >> (8 * k)) as u8; | 1982 | + coef.eob, |
| 1983 | + shift_a, | ||
| 1984 | + shift_l, | ||
| 1985 | + &ectx[plane].above[ax..ax + nblocks], | ||
| 1986 | + &ectx[plane].left[ay..ay + nblocks], | ||
| 1987 | + ); | ||
| 1962 | } | 1988 | } |
| 1963 | coef | 1989 | coef |
| 1964 | } | 1990 | } |
crates/ec-vp9/tests/inter_pixels_exact.rsmodified+27 -0
| @@ -129,3 +129,30 @@ fn inter_gop_with_tile_columns_matches_ffmpeg() { | |||
| 129 | ensure_fixture(&path, 1); | 129 | ensure_fixture(&path, 1); |
| 130 | assert!(compare(&path) >= 2); | 130 | assert!(compare(&path) >= 2); |
| 131 | } | 131 | } |
| 132 | + | ||
| 133 | +/// Real-content regression for the last-partial-SB-row context bug: this | ||
| 134 | +/// 120-frame 1080p stream used to abort at input frame 72 with | ||
| 135 | +/// `tile bool decoder desync`, because a chroma transform block whose | ||
| 136 | +/// write-back window runs past the frame bottom edge kept the window's | ||
| 137 | +/// TAIL slot set (`write_tx_context`), and the next row of blocks read it | ||
| 138 | +/// as an entropy context. Every shown frame must match ffmpeg. | ||
| 139 | +/// | ||
| 140 | +/// Media-gated: the corpus fixture is not versioned, so the witness skips | ||
| 141 | +/// when `fixtures/bitstreams/vp9-1080p-60-8bit.ivf` is absent. | ||
| 142 | +#[test] | ||
| 143 | +fn corpus_1080p_60fps_matches_ffmpeg_past_frame_72() { | ||
| 144 | + let Some(dir) = ivf::fixture_dir() else { | ||
| 145 | + println!("SKIP: fixtures/bitstreams absent (media-gated witness)"); | ||
| 146 | + return; | ||
| 147 | + }; | ||
| 148 | + let path = dir.join("vp9-1080p-60-8bit.ivf"); | ||
| 149 | + if !path.exists() { | ||
| 150 | + println!("SKIP: {} absent (media-gated witness)", path.display()); | ||
| 151 | + return; | ||
| 152 | + } | ||
| 153 | + let shown = compare(&path); | ||
| 154 | + assert!( | ||
| 155 | + shown >= 73, | ||
| 156 | + "the witness must decode past input frame 72 (got {shown} shown frames)" | ||
| 157 | + ); | ||
| 158 | +} | ||
lanes/vp9f72.report.mdadded+256 -0
| @@ -0,0 +1,256 @@ | |||
| 1 | +# Lane vp9f72: the frame-72 tile desync — entropy-context write-back width | ||
| 2 | + | ||
| 3 | +Branch `lane-vp9-f72`, base `main e910d25b`. Crate scope: `crates/ec-vp9` only. | ||
| 4 | +Worktree `/home/user/Documents/Code/Rust/edith_codecs-vp9f72`, private | ||
| 5 | +`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-vp9f72`. | ||
| 6 | + | ||
| 7 | +Deliverable: `vp9-1080p-60-8bit.ivf` (1920x1080, 120 frames) decodes **all 120 | ||
| 8 | +frames byte-identically** to the local libvpx 1.15 oracle, and the rest of the | ||
| 9 | +corpus is unchanged; every other corpus stream stays byte-identical. | ||
| 10 | + | ||
| 11 | +## Baseline (milestone 0) | ||
| 12 | + | ||
| 13 | + $ cd /home/user/Documents/Code/Rust/edith_codecs-vp9f72 | ||
| 14 | + $ CARGO_TARGET_DIR=$HOME/.cache/cargo-target-vp9f72 cargo test -p ec-vp9 | ||
| 15 | + -> 20 test binaries, 31 passed, 0 failed, 0 ignored | ||
| 16 | + $ cargo check -p ec-vp9 # warnings | ||
| 17 | + -> 5 warnings (modes.rs `partition_probs`/`x_mis`/`y_mis`, `read_partition`, | ||
| 18 | + tables `TM_PRED`) -- identical count on the base worktree | ||
| 19 | + | ||
| 20 | +## Symptom and reproduction | ||
| 21 | + | ||
| 22 | + $ $HOME/.cache/vp9pix/sweep.sh vp9-1080p-60-8bit 1920 1080 # against the vp9pix worktree | ||
| 23 | + # on THIS lane's tree (see `$HOME/.cache/vp9f72/sweep_f72.sh`, same shape): | ||
| 24 | + -> 72 shown frames, `PIXERR input=72: corrupt bitstream: vp9: tile bool decoder desync` | ||
| 25 | + | ||
| 26 | +Frames 0..71 are byte-identical; frame 72 aborts. Reproduced on this lane's | ||
| 27 | +build before any edit (72/120 shown, error at input 72). | ||
| 28 | + | ||
| 29 | +## Root cause | ||
| 30 | + | ||
| 31 | +**The entropy-context write-back of a transform block applied the frame-edge | ||
| 32 | +shift to a 64-bit spread, so it zeroed bytes BEYOND the window instead of the | ||
| 33 | +window's tail.** | ||
| 34 | + | ||
| 35 | +libvpx `vp9_detokenize.c:273-323` (`vp9_decode_block_tokens`) writes: | ||
| 36 | + | ||
| 37 | + case TX_8X8: | ||
| 38 | + get_ctx_shift(xd, &ctx_shift_a, &ctx_shift_l, x, y, 1 << TX_8X8); | ||
| 39 | + ... | ||
| 40 | + *(uint16_t *)a = ((eob > 0) * 0x0101) >> ctx_shift_a; | ||
| 41 | + *(uint16_t *)l = ((eob > 0) * 0x0101) >> ctx_shift_l; | ||
| 42 | + | ||
| 43 | +The shift is applied to a value **whose width is the written window's** (u16 | ||
| 44 | +for `TX_8X8`, u32 for `TX_16X16`, u64 for `TX_32X32`), so `>> 8` on a two-byte | ||
| 45 | +window yields `0x0001` — bytes `[1, 0]`. Our port shifted the full 64-bit | ||
| 46 | +spread (`0x0101..01 >> 8` = `0x0001_0101_0101_0101`) and then took byte `k`, | ||
| 47 | +which leaves bytes `[1, 1]`: the window's last slot keeps its old value. | ||
| 48 | + | ||
| 49 | +`get_ctx_shift` only fires when the block runs past an edge | ||
| 50 | +(`xd->max_blocks_wide/high != 0`, i.e. `mb_to_*_edge < 0`), which needs an mi | ||
| 51 | +extent that is not a multiple of the block size — for 1080 (mi_rows 135) that | ||
| 52 | +is exactly the **last, partial superblock row**. So frames 0..~71 behave and | ||
| 53 | +the defect shows up wherever a bottom-row chroma block's stale tail slot is | ||
| 54 | +later read as an entropy context. | ||
| 55 | + | ||
| 56 | +Mechanism as an equation (the written window for `nblocks` slots): | ||
| 57 | + | ||
| 58 | +| | written bytes | | ||
| 59 | +|---|---| | ||
| 60 | +| libvpx | `mask(nblocks) >> shift` | | ||
| 61 | +| our port (bug) | `(mask(8) >> shift)` truncated to `nblocks` bytes | | ||
| 62 | + | ||
| 63 | +`mask(n) = (eob>0) * 0x0101..01` over `n` bytes. The two agree only for | ||
| 64 | +`shift == 0` (every other corpus stream, every non-edge block) — hence a | ||
| 65 | +corpus-only defect. | ||
| 66 | + | ||
| 67 | +### The two-site oracle that pinned it | ||
| 68 | + | ||
| 69 | +A **fresh** instrumented libvpx 1.15.0 was built for this lane (the parse-time | ||
| 70 | +`/tmp/vp9loss` build was gone; `$HOME/.cache/vp9pix/drv_pix` is a static | ||
| 71 | +pixel-only driver and could not print contexts). Build + instruments: | ||
| 72 | + | ||
| 73 | + $HOME/.cache/vp9f72/libvpx-1.15.0 # configure --disable-unit-tests --disable-vp8 | ||
| 74 | + # --disable-vp9-encoder --disable-examples --disable-tools --enable-pic | ||
| 75 | + vp9/decoder/vp9_decodeframe.c : g_dbg_row/g_dbg_col/g_dbg_bsize set in decode_block; | ||
| 76 | + `SKIPCTX` print at the end of dec_reset_skip_context | ||
| 77 | + vp9/decoder/vp9_detokenize.c : `TXBW` print of (row, col, plane, x, y, tx, a[], l[]) before the switch; | ||
| 78 | + `TXBWC` print of (ctx, eob, shift_a, shift_l, written a[]/l[]) after it | ||
| 79 | + $HOME/.cache/vp9f72/drv_txbw # drv.c linked against that build | ||
| 80 | + | ||
| 81 | +Per-frame arming without rebuilding the driver: `$HOME/.cache/vp9f72/armtrace.c` | ||
| 82 | +is an `LD_PRELOAD` that counts IVF header/size reads (`fread`) and sets/unsets | ||
| 83 | +the instrument env vars at the requested frame (`TRACEFROM=72 TRACETO=73 | ||
| 84 | +ARMVARS="TXBW=1 SKIPCTX=1 MODEDUMP=1"`). Both sides' events are then compared | ||
| 85 | +block by block. | ||
| 86 | + | ||
| 87 | +**First divergent event (pre-fix), tile 3, decode-order index 2076:** | ||
| 88 | + | ||
| 89 | + O (132,180) plane 1 bcol=2 brow=2 tx=1 eob=3 sl=8 lw=[1, 0] | ||
| 90 | + M (132,180) plane 1 bcol=2 brow=2 tx=1 eob=3 sl=8 lw=[1, 1] | ||
| 91 | + | ||
| 92 | +Same shift (`sl=8`), different written window — the bug above, exactly. | ||
| 93 | + | ||
| 94 | +**First divergence that reads it** (same tile, block `(132,200)`): | ||
| 95 | + | ||
| 96 | + O (132,200) p=1 bcol=0 brow=2 tx=1 a=[0, 0] l=[0, 0] ctx=0 | ||
| 97 | + M (132,200) p=1 bcol=0 brow=2 tx=1 a=[0, 0] l=[0, 1] cin=1 | ||
| 98 | + | ||
| 99 | +and in the bool trace the first differing read is the first coefficient bool | ||
| 100 | +of that transform block: oracle prob **217** (band 0, ctx 0), ours prob **98** | ||
| 101 | +(band 0, ctx 1) — the "same ordinal, different question" signature of a wrong | ||
| 102 | +entropy context, 3 bools after the tile's marker read. | ||
| 103 | + | ||
| 104 | +## Fix | ||
| 105 | + | ||
| 106 | +One rule, one place: `write_tx_context` (`crates/ec-vp9/src/decode.rs`) now | ||
| 107 | +mirrors libvpx's per-tx-size casts — narrow the spread to the window width | ||
| 108 | +FIRST, then apply the edge shift: | ||
| 109 | + | ||
| 110 | + let narrow = 64 - 8 * nblocks; // libvpx's cast | ||
| 111 | + let spread_a = ((eob_pos * ONES) >> narrow) >> shift_a.min(8 * nblocks); | ||
| 112 | + let spread_l = ((eob_pos * ONES) >> narrow) >> shift_l.min(8 * nblocks); | ||
| 113 | + | ||
| 114 | +The `.min(8 * nblocks)` clamp is the only liberty taken: libvpx shifts a wider | ||
| 115 | +type by more than its own width there (undefined in C, 0 on x86); the clamp | ||
| 116 | +makes the same intent total in Rust. It is unreachable from the walk (a block | ||
| 117 | +entirely past the edge is never visited). | ||
| 118 | + | ||
| 119 | +Both call sites use it: the inter token path (`decode_inter_tx_tokens`) and | ||
| 120 | +the intra-in-inter path (`predict_and_reconstruct`). The latter already had | ||
| 121 | +per-width casts and was correct — sharing the helper keeps the class fixed in | ||
| 122 | +one place instead of two. | ||
| 123 | + | ||
| 124 | +## Evidence | ||
| 125 | + | ||
| 126 | +### 1. State-event equality with libvpx on frame 72 (post-fix) | ||
| 127 | + | ||
| 128 | +Every transform-block context write (value, edge shift and the written | ||
| 129 | +a[]/l[] window) and every skip-context reset, in decode order, per tile: | ||
| 130 | + | ||
| 131 | +| tile | writes ours | writes oracle | equals | skip resets ours | oracle | | ||
| 132 | +|---|---|---|---|---|---| | ||
| 133 | +| 0 | 705 | 705 | yes | 246 | 246 | | ||
| 134 | +| 1 | 1449 | 1449 | yes | 246 | 246 | | ||
| 135 | +| 2 | 2824 | 2824 | yes | 300 | 300 | | ||
| 136 | +| 3 | 3511 | 3511 | yes | 308 | 308 | | ||
| 137 | + | ||
| 138 | +Pre-fix, the write streams diverged by exactly one window per edge block | ||
| 139 | +(tile 3 index 2076) and the reset streams matched until the desync. | ||
| 140 | + | ||
| 141 | +### 2. Pixel byte-exactness (the acceptance gate) | ||
| 142 | + | ||
| 143 | + $ $HOME/.cache/vp9f72/sweep_f72.sh <fixture> <w> <h> # oracle drv_pix + our dump + pixcmp.py | ||
| 144 | + | ||
| 145 | +| fixture | frames | identical | | ||
| 146 | +|---|---|---| | ||
| 147 | +| `vp9-1080p-60-8bit.ivf` (1920x1080) | 120 | **120/120** (was 72) | | ||
| 148 | +| `vp9-1080p-23.976-8bit.ivf` | 48 | 48/48 | | ||
| 149 | +| `vp9-2160p-23.976-8bit.ivf` (3840x2160) | 48 | 48/48 | | ||
| 150 | +| `vp9-superframe-altref.ivf` (320x240) | 60 | 60/60 | | ||
| 151 | +| `vp9-tiles-1280.ivf` (1280x720) | 30 | 30/30 | | ||
| 152 | +| `/tmp/inter.ivf` (1080p, 2 tile cols) | 3 | 3/3 | | ||
| 153 | +| `/tmp/inter1.ivf` (1080p, 1 tile col) | 3 | 3/3 | | ||
| 154 | +| generated 1918x1080 60-frame-long GOP (even, non-multiple-of-8 width) | 120 | 120/120 | | ||
| 155 | + | ||
| 156 | +The 10-bit corpus members are refused by name as before | ||
| 157 | +(`PIXERR input=0: unsupported: vp9 profile 2`). | ||
| 158 | + | ||
| 159 | +### 3. Fail-pre-fix / pass-post-fix | ||
| 160 | + | ||
| 161 | +New media-gated witness `corpus_1080p_60fps_matches_ffmpeg_past_frame_72` | ||
| 162 | +(`tests/inter_pixels_exact.rs`, reuses the file's `compare()` against | ||
| 163 | +ffmpeg's rawvideo): | ||
| 164 | + | ||
| 165 | + # lane tree (fixed): | ||
| 166 | + $ CARGO_TARGET_DIR=$HOME/.cache/cargo-target-vp9f72 cargo test -p ec-vp9 --test inter_pixels_exact | ||
| 167 | + -> 3 passed (incl. corpus_1080p_60fps_matches_ffmpeg_past_frame_72) | ||
| 168 | + | ||
| 169 | + # base worktree at e910d25b + the same test file (throwaway, removed): | ||
| 170 | + $ ... cargo test -p ec-vp9 --test inter_pixels_exact corpus_1080p | ||
| 171 | + -> panicked at inter_pixels_exact.rs:82: frame decodes: | ||
| 172 | + Corrupt { context: "vp9: tile bool decoder desync" } | ||
| 173 | + test result: FAILED. 0 passed; 1 failed | ||
| 174 | + | ||
| 175 | +Skipped (with a `SKIP:` line) when `fixtures/bitstreams/vp9-1080p-60-8bit.ivf` | ||
| 176 | +is absent — the corpus fixtures are not versioned. | ||
| 177 | + | ||
| 178 | +### 4. Gates | ||
| 179 | + | ||
| 180 | + $ CARGO_TARGET_DIR=$HOME/.cache/cargo-target-vp9f72 cargo test -p ec-vp9 | ||
| 181 | + -> 20 test binaries, 31 passed, 0 failed, 0 ignored | ||
| 182 | + $ cargo check -p ec-vp9 | grep -c ^warning | ||
| 183 | + -> 6 (5 warnings + the summary line) -- equal to the base worktree | ||
| 184 | + $ rustfmt --edition 2021 --check crates/ec-vp9/src/decode.rs | ||
| 185 | + -> 6 diffs, exactly the pre-existing count on the base tree (import | ||
| 186 | + ordering + the repo's compact-argument style); my additions are clean | ||
| 187 | + $ rustfmt --edition 2021 --check crates/ec-vp9/tests/inter_pixels_exact.rs | ||
| 188 | + -> only ivf.rs (shared `mod ivf`) pre-existing diffs | ||
| 189 | + | ||
| 190 | +Named refusals unchanged (verified with the vp9pix scratch fixtures): | ||
| 191 | + | ||
| 192 | + refusal_odd.ivf -> "vp9 inter odd frame dimensions (321x241 ...)" | ||
| 193 | + refusal_sizechange.ivf -> "vp9 inter reference size change (...)" | ||
| 194 | + vp9-1080p-23.976-10bit -> "vp9 profile 2 ..." | ||
| 195 | + | ||
| 196 | +## Deferred / limitations (explicit) | ||
| 197 | + | ||
| 198 | +- **The horizontal half of the class has no witness.** `shift_a` follows the | ||
| 199 | + same rule and uses the same helper, but `mb_to_right_edge < 0` needs an mi | ||
| 200 | + extent that is not a multiple of the block size in the COLUMN direction | ||
| 201 | + (mi_cols odd), which no corpus stream here reaches — a 1918x1080 stream | ||
| 202 | + (`mi_cols` 240, even) decodes 120/120 identically on BOTH the base and the | ||
| 203 | + fixed trees, so it is not a witness. `deferred(<no reachable width in the | ||
| 204 | + corpus>)`: the vertical half is what real content hits. | ||
| 205 | +- **Cross-lane scope**: the odd-*coded*-extent path belongs to `lane-vp9-odd` | ||
| 206 | + (merged on main as `e8152b9b`, which does not touch the write-back). My fix | ||
| 207 | + is orthogonal — verified inert: `odd.ivf` decodes byte-identically on the | ||
| 208 | + base and this lane (460800 bytes, `cmp` equal). The odd-dims refusal is left | ||
| 209 | + in place. | ||
| 210 | +- Diagnostics kept (gated by the existing scratch hook `EC_VP9_TOKDGB`): | ||
| 211 | + `TDB` (transform-block context read, pre-existing), `TDW` (write value + | ||
| 212 | + shift + written window, both token paths) and `TDK` (skip-context reset). | ||
| 213 | + They are the instruments that isolated this defect; a next context lane can | ||
| 214 | + re-derive any of the tables above from them. | ||
| 215 | + | ||
| 216 | +## Repro (all commands a verifier can re-run) | ||
| 217 | + | ||
| 218 | + # 1. gate | ||
| 219 | + cd /home/user/Documents/Code/Rust/edith_codecs-vp9f72 | ||
| 220 | + CARGO_TARGET_DIR=$HOME/.cache/cargo-target-vp9f72 cargo test -p ec-vp9 | ||
| 221 | + | ||
| 222 | + # 2. the acceptance sweep (120/120) | ||
| 223 | + $HOME/.cache/vp9f72/sweep_f72.sh vp9-1080p-60-8bit 1920 1080 | ||
| 224 | + | ||
| 225 | + # 3. oracle state-event equality for frame 72 | ||
| 226 | + cd $HOME/.cache/vp9f72/libvpx-1.15.0 && make -j6 | ||
| 227 | + gcc -O1 -g -o $HOME/.cache/vp9f72/drv_txbw $HOME/.cache/vp9pix/drv.c -I. -Ibuild/make -L. -lvpx -lm -lpthread | ||
| 228 | + gcc -O1 -shared -fPIC -o $HOME/.cache/vp9f72/armtrace.so $HOME/.cache/vp9f72/armtrace.c -ldl | ||
| 229 | + TRACEFROM=72 TRACETO=73 ARMVARS="TXBW=1 SKIPCTX=1" \ | ||
| 230 | + LD_PRELOAD=$HOME/.cache/vp9f72/armtrace.so $HOME/.cache/vp9f72/drv_txbw \ | ||
| 231 | + <fixtures>/vp9-1080p-60-8bit.ivf 2>or.txt | ||
| 232 | + cd /home/user/Documents/Code/Rust/edith_codecs-vp9f72 | ||
| 233 | + CARGO_TARGET_DIR=$HOME/.cache/cargo-target-vp9f72 INTER_IVF=<fixtures>/vp9-1080p-60-8bit.ivf \ | ||
| 234 | + EC_VP9_PIXDUMP=/dev/null EC_VP9_TOKDGB=1 \ | ||
| 235 | + cargo test -p ec-vp9 --test scratch_pixdump -- --nocapture 2>&1 \ | ||
| 236 | + | awk '/PIXFRAME input=71 /{on=1;next} /PIXFRAME input=72 /{exit} on' > ours.txt | ||
| 237 | + # then diff the TDW/TDK event streams per tile (scripts under $HOME/.cache/vp9f72) | ||
| 238 | + | ||
| 239 | +## VERDICT | ||
| 240 | + | ||
| 241 | +- GATE 1: `cargo test -p ec-vp9` — 20 binaries, 31 passed, 0 failed, 0 ignored: **PASS** | ||
| 242 | +- GATE 2: `sweep_f72.sh vp9-1080p-60-8bit 1920 1080` — **120/120 byte-identical**: **PASS** | ||
| 243 | +- GATE 3: corpus re-sweep (48/48, 48/48, 60/60, 30/30, 3/3, 3/3, 1918-wide 120/120): **PASS** | ||
| 244 | +- GATE 4: state-event equality with libvpx (writes + skip resets, per tile): **PASS** | ||
| 245 | +- GATE 5: fail-pre-fix / pass-post-fix witness, media-gated per house style: **PASS** | ||
| 246 | +- GATE 6: warning parity (5) and scoped rustfmt parity with the base tree: **PASS** | ||
| 247 | +- GATE 7: this report; deferred items named above: **PASS** | ||
| 248 | + | ||
| 249 | +## git log | ||
| 250 | + | ||
| 251 | + cargo test / git log for this lane: | ||
| 252 | + * THIS COMMIT -- "vp9: inter context write-back zeroes the window's tail, | ||
| 253 | + not bytes past it" -- the only commit on lane-vp9-f72 above the base | ||
| 254 | + * e910d25b vp9pix: merge-side follow-ups -- ff merge verified, dependent | ||
| 255 | + sweep empty, gates re-run on main (base) | ||
| 256 | + $ git log --oneline lane-vp9-f72 ^e910d25b # -> exactly one line | ||