Merge commit '434ac12c' into lane-t900: rect chroma warp guard deduped, rect interintra gate arm kept
Browse files at this commit5 changed files +361 -2
- crates/ec-av1/src/decode.rs +33 -1
- crates/ec-av1/src/stream.rs +66 -1
- lanes/midcut-r1.handoff.md +76 -0
- lanes/midcut-r2.handoff.md +71 -0
- lanes/midcut-r3.handoff.md +115 -0
crates/ec-av1/src/decode.rsmodified+33 -1
| @@ -2442,6 +2442,19 @@ pub(crate) fn intra_rect_in_inter_split_tx_hits() -> [usize; 3] { | |||
| 2442 | INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get) | 2442 | INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get) |
| 2443 | } | 2443 | } |
| 2444 | 2444 | ||
| 2445 | +// lane-midcut r2: rect intra blocks inside an inter frame whose `tx_depth` CDF | ||
| 2446 | +// ROW moved when libaom's inter-neighbour override was applied -- i.e. exactly | ||
| 2447 | +// the blocks the key frame's deblock-grid approximation used to mis-read. | ||
| 2448 | +thread_local! { | ||
| 2449 | + static INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS: std::cell::Cell<usize> = | ||
| 2450 | + const { std::cell::Cell::new(0) }; | ||
| 2451 | +} | ||
| 2452 | + | ||
| 2453 | +/// Current value of [`INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS`]. | ||
| 2454 | +pub(crate) fn intra_rect_in_inter_txctx_override_hits() -> usize { | ||
| 2455 | + INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS.with(std::cell::Cell::get) | ||
| 2456 | +} | ||
| 2457 | + | ||
| 2445 | // lane-intra14 r1: how many intra-coded 1:4 strips decoded on the INTER | 2458 | // lane-intra14 r1: how many intra-coded 1:4 strips decoded on the INTER |
| 2446 | // block path, per shape -- [0] 64x16, [1] 16x64, [2] 32x8, [3] 8x32. Every | 2459 | // block path, per shape -- [0] 64x16, [1] 16x64, [2] 32x8, [3] 8x32. Every |
| 2447 | // one of them was the named refusal "an intra-coded 1:4 (or other non-2:1) | 2460 | // one of them was the named refusal "an intra-coded 1:4 (or other non-2:1) |
| @@ -13804,12 +13817,26 @@ fn tx_size_context_txfm_rect( | |||
| 13804 | n.left_side_mi[mi_r], | 13817 | n.left_side_mi[mi_r], |
| 13805 | ); | 13818 | ); |
| 13806 | } | 13819 | } |
| 13807 | - match (has_above, has_left) { | 13820 | + let ctx = match (has_above, has_left) { |
| 13808 | (true, true) => usize::from(above) + usize::from(left), | 13821 | (true, true) => usize::from(above) + usize::from(left), |
| 13809 | (true, false) => usize::from(above), | 13822 | (true, false) => usize::from(above), |
| 13810 | (false, true) => usize::from(left), | 13823 | (false, true) => usize::from(left), |
| 13811 | (false, false) => 0, | 13824 | (false, false) => 0, |
| 13825 | + }; | ||
| 13826 | + // lane-midcut r3: count only the blocks the KEY FRAME deblock-grid | ||
| 13827 | + // approximation ([`tx_size_context_rect`]) would have read off a DIFFERENT | ||
| 13828 | + // CDF row, i.e. exactly the blocks this band read fixes -- a plain "rect | ||
| 13829 | + // intra in an inter frame" tally is green on the buggy code too (class | ||
| 13830 | + // gate-blind-to-feature). | ||
| 13831 | + if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() { | ||
| 13832 | + let (cw, ch) = (own_w.min(64), own_h.min(64)); | ||
| 13833 | + let stale = usize::from(has_above && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= cw) | ||
| 13834 | + + usize::from(has_left && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= ch); | ||
| 13835 | + if ctx != stale { | ||
| 13836 | + INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 13837 | + } | ||
| 13812 | } | 13838 | } |
| 13839 | + ctx | ||
| 13813 | } | 13840 | } |
| 13814 | 13841 | ||
| 13815 | /// lane-intrasplit r3: `above_inter`/`left_inter` are mi-granular bands (they | 13842 | /// lane-intrasplit r3: `above_inter`/`left_inter` are mi-granular bands (they |
| @@ -19938,6 +19965,11 @@ fn decode_inter_block( | |||
| 19938 | } | 19965 | } |
| 19939 | _ => (write_w / 2, write_h / 2), | 19966 | _ => (write_w / 2, write_h / 2), |
| 19940 | }; | 19967 | }; |
| 19968 | + // lane-midcut r3 (same rule as lane-t900 r5's `warp_plane_allowed`, one | ||
| 19969 | + // copy kept at the merge): `av1_init_warp_params` (libaom reconinter.c) | ||
| 19970 | + // bails per PLANE at `block_width < 8 || block_height < 8` -- on the | ||
| 19971 | + // block's own dims, never on the square prediction buffer this reader | ||
| 19972 | + // allocates. | ||
| 19941 | if std::env::var_os("EC_MC_TRACE").is_some() { | 19973 | if std::env::var_os("EC_MC_TRACE").is_some() { |
| 19942 | eprintln!("EC_IB px={px} py={py} side={side} w={write_w} h={write_h}"); | 19974 | eprintln!("EC_IB px={px} py={py} side={side} w={write_w} h={write_h}"); |
| 19943 | } | 19975 | } |
crates/ec-av1/src/stream.rsmodified+66 -1
| @@ -14001,6 +14001,10 @@ mod tests { | |||
| 14001 | return; | 14001 | return; |
| 14002 | } | 14002 | } |
| 14003 | let (width, height, frame_count) = (64usize, 64usize, 24usize); | 14003 | let (width, height, frame_count) = (64usize, 64usize, 24usize); |
| 14004 | + // lane-midcut r1: rect interintra (`write_w != write_h`) built its | ||
| 14005 | + // intra predictor at the square `side`; this gate passed with that | ||
| 14006 | + // bug, so the shape gets its own delta-counted assert below. | ||
| 14007 | + let rect_before = crate::decode::interintra_rect_hits(); | ||
| 14004 | let mut named_refusals = 0u32; | 14008 | let mut named_refusals = 0u32; |
| 14005 | let mut matched = 0u32; | 14009 | let mut matched = 0u32; |
| 14006 | let n_attempts: u32 = std::env::var("EC_INTERINTRA_GATE_ATTEMPTS") | 14010 | let n_attempts: u32 = std::env::var("EC_INTERINTRA_GATE_ATTEMPTS") |
| @@ -14156,6 +14160,61 @@ mod tests { | |||
| 14156 | decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle" | 14160 | decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle" |
| 14157 | ); | 14161 | ); |
| 14158 | } | 14162 | } |
| 14163 | + // lane-midcut r3 RECT ARM: the recipe above spells | ||
| 14164 | + // `--enable-rect-partitions=0 --min-partition-size=32`, so it can | ||
| 14165 | + // never produce a RECT interintra block -- the delta assert at the | ||
| 14166 | + // end of this gate was unsatisfiable on it (the gate disabled the | ||
| 14167 | + // very shape it claims to prove). Re-encode the SAME source with | ||
| 14168 | + // the rect overrides APPENDED (aomenc keeps the LAST occurrence of | ||
| 14169 | + // a repeated flag) and compare every decode-order frame of that | ||
| 14170 | + // stream against aomdec, until a rect interintra block fires. | ||
| 14171 | + if crate::decode::interintra_rect_hits() == rect_before { | ||
| 14172 | + let mut rect_args = args.clone(); | ||
| 14173 | + rect_args.extend_from_slice(&[ | ||
| 14174 | + "--enable-rect-partitions=1", | ||
| 14175 | + "--min-partition-size=8", | ||
| 14176 | + "--max-partition-size=64", | ||
| 14177 | + ]); | ||
| 14178 | + let mut child = Command::new(aomenc_path()) | ||
| 14179 | + .args(&rect_args) | ||
| 14180 | + .stdin(Stdio::piped()) | ||
| 14181 | + .stdout(Stdio::piped()) | ||
| 14182 | + .stderr(Stdio::piped()) | ||
| 14183 | + .spawn() | ||
| 14184 | + .expect("aomenc failed to start"); | ||
| 14185 | + child | ||
| 14186 | + .stdin | ||
| 14187 | + .take() | ||
| 14188 | + .expect("aomenc stdin") | ||
| 14189 | + .write_all(&y4m.stdout) | ||
| 14190 | + .expect("writing y4m to aomenc"); | ||
| 14191 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 14192 | + assert!( | ||
| 14193 | + out.status.success(), | ||
| 14194 | + "{NAME} RECT-ARM: aomenc refused its own recipe plus the rect overrides: {}", | ||
| 14195 | + String::from_utf8_lossy(&out.stderr) | ||
| 14196 | + ); | ||
| 14197 | + let rect_stream = out.stdout; | ||
| 14198 | + match decode_stream(&rect_stream) { | ||
| 14199 | + Err(e) => { | ||
| 14200 | + let msg = e.to_string(); | ||
| 14201 | + assert!( | ||
| 14202 | + msg.contains("unsupported"), | ||
| 14203 | + "{NAME} RECT-ARM failed outright, not a named refusal (seed {seed}): {msg}" | ||
| 14204 | + ); | ||
| 14205 | + eprintln!("{NAME} RECT-ARM: skipped on a named refusal: {msg}"); | ||
| 14206 | + } | ||
| 14207 | + Ok(_) => { | ||
| 14208 | + let (total, hidden) = | ||
| 14209 | + decode_all_frames_vs_oracle(&rect_stream, &format!("{NAME}-rect")); | ||
| 14210 | + eprintln!( | ||
| 14211 | + "{NAME} RECT-ARM: seed {seed}: {total} decode-order frames, {hidden} \ | ||
| 14212 | + hidden, all pixel-exact vs the oracle, interintra_rect_hits={}", | ||
| 14213 | + crate::decode::interintra_rect_hits() - rect_before | ||
| 14214 | + ); | ||
| 14215 | + } | ||
| 14216 | + } | ||
| 14217 | + } | ||
| 14159 | matched += 1; | 14218 | matched += 1; |
| 14160 | } | 14219 | } |
| 14161 | assert!( | 14220 | assert!( |
| @@ -14175,9 +14234,15 @@ mod tests { | |||
| 14175 | "{NAME}: {matched} matches but zero UNIDIR_COMP_REFERENCE pairs read -- \ | 14234 | "{NAME}: {matched} matches but zero UNIDIR_COMP_REFERENCE pairs read -- \ |
| 14176 | --enable-onesided-comp=1 never reached the uni_comp_ref alphabet" | 14235 | --enable-onesided-comp=1 never reached the uni_comp_ref alphabet" |
| 14177 | ); | 14236 | ); |
| 14237 | + assert!( | ||
| 14238 | + crate::decode::interintra_rect_hits() > rect_before, | ||
| 14239 | + "{NAME}: {matched} matches but zero RECTANGULAR interintra blocks fired -- the \ | ||
| 14240 | + square-only blend defect (lane-midcut r1) would pass this gate unseen" | ||
| 14241 | + ); | ||
| 14178 | eprintln!( | 14242 | eprintln!( |
| 14179 | - "{NAME}: {named_refusals} other-capability refusals, {matched} pixel-exact matches out of {n_attempts}, interintra_hits={} uni_comp_hits={}", | 14243 | + "{NAME}: {named_refusals} other-capability refusals, {matched} pixel-exact matches out of {n_attempts}, interintra_hits={} interintra_rect_hits={} uni_comp_hits={}", |
| 14180 | crate::decode::interintra_hits(), | 14244 | crate::decode::interintra_hits(), |
| 14245 | + crate::decode::interintra_rect_hits() - rect_before, | ||
| 14181 | crate::decode::uni_comp_hits() | 14246 | crate::decode::uni_comp_hits() |
| 14182 | ); | 14247 | ); |
| 14183 | } | 14248 | } |
lanes/midcut-r1.handoff.mdadded+76 -0
| @@ -0,0 +1,76 @@ | |||
| 1 | +# lane-midcut r1 handoff (turn cap) | ||
| 2 | + | ||
| 3 | +## Verdict: (C) real reconstruction desync. NOT (A) alignment, NOT (B) film grain. | ||
| 4 | + | ||
| 5 | +Reproducer, hashed twice, 325 KB: `~/.cache/midcut-tmp/h2400.t2.obu` | ||
| 6 | += `ffmpeg -ss 2400 -t 2 -c:v copy -f obu` on the 10-bit 3840x1608 stream | ||
| 7 | +(sha256 2f62dd1f74bffe10973494404ee4d1a695d2d327b88fb1891c63452b5d47c895 for the | ||
| 8 | +full 2 s cut) truncated to its first 2 frame OBUs (census7 `trunc.py`). | ||
| 9 | +It holds the whole defect: key frame + first hidden alt-ref. | ||
| 10 | + | ||
| 11 | +### Measurements that separated A/B/C | ||
| 12 | +1. (A) ruled out. ffmpeg decodes 261 frames from the 2 s cut; our OUT16 frames | ||
| 13 | + are in display order and monotone in `order_hint` (HDR dump: 114 key, then | ||
| 14 | + 115,116(show_existing 7),117,118(se 6),119,120,121...). An 8x8 cross-compare | ||
| 15 | + of our 8 shown frames vs ffmpeg's 8 (grain off both sides) has NO near-zero | ||
| 16 | + off-diagonal: every ours[i] is 13-16 MB from every ffmpeg[j]. Frames are | ||
| 17 | + aligned; the census tool was measuring the truth. | ||
| 18 | +2. (B) ruled out. `EC_AV1_NO_GRAIN=1` (added this round, `stream.rs`) vs | ||
| 19 | + `ffmpeg -c:v libdav1d -filmgrain 0`: first_diff_frame=1, 13450726 bytes -- | ||
| 20 | + the same mismatch as grain-on/grain-on (13458423). Grain is not it. | ||
| 21 | +3. (C) located. Decode-order compare of `EC_AV1_PREFILT_DUMP16` ours vs the | ||
| 22 | + instrumented aomdec: f0 (key) EXACT, f1 (hidden ARF) 4386319 luma px wrong, | ||
| 23 | + confined to superblocks (0,17) and (0,58) at first, then spreading. | ||
| 24 | + Pre-deblock and post-deblock diffs are identical -> reconstruction, not filters. | ||
| 25 | + | ||
| 26 | +### Root cause found and FIXED (commit 43e9909) | ||
| 27 | +First bad pixel (17,1088) sat in the block aomdec reports as | ||
| 28 | +`EC_MODE_VAL mi_row=4 mi_col=272 mode=13 ref0=1 ref1=0` -- ref1=0 is INTRA_FRAME, | ||
| 29 | +i.e. an INTERINTRA block, and its footprint is 32x16. | ||
| 30 | +`decode.rs interintra_blend` took ONE `side` and used it for the edge fetch, the | ||
| 31 | +intra predictor's (bw,bh), `ii_size_scales` and the blend bounds. On a rect block | ||
| 32 | +`side` is the LONGER dimension, so a 32x16 block got a 32x32 SMOOTH/DC predictor | ||
| 33 | +built off 32 rows of left edge (16 of them not yet decoded). The error signature | ||
| 34 | +matches exactly: rank-1 (sv 90 vs 18), exactly 0 on the block's first row, growing | ||
| 35 | +downward -- the `sm_weights_h` divergence between height-32 and height-16 SMOOTH_PRED. | ||
| 36 | +Fix: `interintra_blend(plane, x, y, bw, bh, stride, ..)` -- `edges_rect`/`predict` | ||
| 37 | +at the true footprint, mask scale `128 / max(bw,bh)`, loop `bh x bw`, `pred` | ||
| 38 | +indexed at the buffer stride. New `interintra_rect_hits()` counter + `decode_probe` | ||
| 39 | +line + a delta-counted hard assert in | ||
| 40 | +`a_real_aomenc_stream_with_interintra_decodes_pixel_exact` (NOT yet run: turn cap). | ||
| 41 | +Result: superblock (0,17) is now exact; f1's first mismatch moves to (448,1152). | ||
| 42 | + | ||
| 43 | +### The NEXT defect (this is the exact next step) | ||
| 44 | +Same 2-frame reproducer, frame 1, block mi_row=112 mi_col=288, a 32x16 NEARMV | ||
| 45 | +block (`TRACE_RECT_SPLIT mi_row=108 mi_col=288 bw=32 bh=16`): | ||
| 46 | + aomdec `EC_MODE_VAL mi_row=112 mi_col=288 mode=14 ref0=1 ref1=-1 mv0=(-32,-350) stack=4` | ||
| 47 | + ours `EC_TRACE mi_row=112 mi_col=288 mv=(-40,-340) is_new_mv=false bsize=32` | ||
| 48 | +Entropy stays in sync (later blocks' rng match; the frame does not refuse), so it | ||
| 49 | +is the mv STACK content/order, not a symbol. Suspect the same class as the fix | ||
| 50 | +above: an mv-stack scan taking the square `side` instead of the block's true | ||
| 51 | +`write_w`/`write_h` (`find_mv_stack` call sites decode.rs:18005 and :30091 -- | ||
| 52 | +check the bw4/bh4 arguments there first). Ladder: aomdec `EC_TRACE_MODE=1` | ||
| 53 | +(`EC_MODE_MV` lines) vs ours for that mi; artifacts already on disk: | ||
| 54 | +`~/.cache/midcut-tmp/am.txt` (aomdec, 2-frame cut) and `tr2.txt` (ours). | ||
| 55 | + | ||
| 56 | +### Re-measured table (24 offsets, 2 s cut truncated to 4 frame OBUs, | ||
| 57 | +### decode-order bytes vs instrumented aomdec, AFTER the fix) | ||
| 58 | +`~/.cache/midcut-tmp/cen/after.tsv`. f0 is exact at EVERY offset. ss=0 is fully | ||
| 59 | +exact (0,0,0,0) -- and is the ONLY offset with `interintra_rect: 0`, which is why | ||
| 60 | +the head cut never saw this bug. Every other offset still diverges at f1 or f2 | ||
| 61 | +because of the NEARMV defect above; rect-interintra blocks per 4-frame prefix run | ||
| 62 | +1..645. Sample: 0 -> 0,0,0,0 | 300 -> 0,2362684,5576522,10902022 | | ||
| 63 | +2400 -> 0,11010633,7316581,15127483 | 4200 -> 0,607935,837,586 | | ||
| 64 | +4800 -> 0,537,5724744,14232841 | 6000 -> 0,806,6192253,13728776. | ||
| 65 | + | ||
| 66 | +### Owed / not done (turn cap) | ||
| 67 | +- deferred: run `a_real_aomenc_stream_with_interintra_decodes_pixel_exact` with the | ||
| 68 | + new rect assert (`cargo test -p ec-av1 --lib interintra`) -- unblocked by a free | ||
| 69 | + turn; `cargo check -p ec-av1 --lib` is CLEAN on this tree. | ||
| 70 | +- deferred: full suite. A run was started under unit `midcut-suite-r1-1788371174` | ||
| 71 | + on commit 43e9909 (log `$HOME/.cache/midcut-suite.log`) and had not reached | ||
| 72 | + `test result` at the cap. | ||
| 73 | +- deferred: no fixture pinned. The film prefix is NOT pixel-exact yet (the NEARMV | ||
| 74 | + defect), so a hard-counter gate on it would have to assert a mismatch; pin it | ||
| 75 | + once the mv-stack defect is fixed. | ||
| 76 | +- no refusal was lifted or moved; refusal_inventory/gate_coverage untouched. | ||
lanes/midcut-r2.handoff.mdadded+71 -0
| @@ -0,0 +1,71 @@ | |||
| 1 | +# lane-midcut r2 handoff (coordinator turn cap) | ||
| 2 | + | ||
| 3 | +Tip: lane-midcut, merged main (243f125) cleanly at STEP 0 (decode.rs/stream.rs auto-merged, `cargo check -p ec-av1` clean). | ||
| 4 | + | ||
| 5 | +## r1's named defect was STALE on both counts | ||
| 6 | +1. `find_mv_stack` call sites decode.rs:20959 and :23046 ALREADY pass | ||
| 7 | + `bw4 = write_w/4`, `bh4 = write_h/4` (lane-rect r2 did that). No `side, side` | ||
| 8 | + remains at any single-ref/compound mv-stack site; the sub-8 leaf sites pass | ||
| 9 | + the literal `1,1` / `2,2` libaom uses. Nothing to fix there. | ||
| 10 | +2. The mv stack at mi(112,288) is IDENTICAL to aomdec's, entry for entry: | ||
| 11 | + i0 (-24,-352) w=700 | i1 (-32,-350) w=664 | i2 (-40,-340) w=644 | i3 (-20,-360) w=4 | ||
| 12 | + (both decoders, both stack=4). Only the DRL index differed, because the | ||
| 13 | + entropy state at that block already differed (aomdec EC_MODE rng=56215 vs | ||
| 14 | + ours 41892) -- r1's "entropy in sync" premise was wrong. It was a downstream | ||
| 15 | + symptom, never a defect. | ||
| 16 | + | ||
| 17 | +## Root cause found and FIXED (commit cde8893) | ||
| 18 | +Reproducing this cut now needs `EC_INTRA16X4_DECODE=1` (main re-added the | ||
| 19 | +16x4-in-inter refusal); without it the probe refuses and every trace truncates. | ||
| 20 | + | ||
| 21 | +First real divergence in frame 1 (2-frame cut, decode order): the 32x8 INTRA | ||
| 22 | +strip at mi(118,280), inside an inter frame, reading its `tx_depth` symbol. | ||
| 23 | + aomdec: `EC_ISTEP mi_row=118 mi_col=280 name=tx_depth val=0 ctx=2 cat=2 rng=63652` | ||
| 24 | + ours : `EC_TXCTX mi_row=118 mi_col=280 w=32 h=8 above_px=16 left_px=16 ctx=1` | ||
| 25 | +Both entered at rng 42394 (the `use_filter_intra` rung matches exactly), so the | ||
| 26 | +ROW of `tx_size_cat2` is the whole defect (class wrong-alphabet-same-value: the | ||
| 27 | +value is 0 in both, only the range moves). | ||
| 28 | + | ||
| 29 | +`tx_size_context_rect` is the KEY FRAME approximation of libaom | ||
| 30 | +`get_tx_size_context` (`pred_common.h:342`): it reads the deblock tx grid and | ||
| 31 | +never applies "an INTER neighbour contributes its BLOCK size, not its transform | ||
| 32 | +size". The above neighbour here is the inter 32x8 at mi(116,280) whose var-tx | ||
| 33 | +tree had split to 16-wide TUs, so libaom sees 32 >= 32 (above=1) while we saw | ||
| 34 | +16 >= 32 (above=0). The 1:4 16x4 strip already branched to | ||
| 35 | +`tx_size_context_txfm_rect` at its own call site (decode.rs:9116); the other six | ||
| 36 | +rect intra readers did not. Fix = one branch inside `tx_size_context_rect` | ||
| 37 | +itself (decode.rs:6737) keyed on `INTRA_IN_INTER_MODE`, so every call site | ||
| 38 | +inherits it. | ||
| 39 | + | ||
| 40 | +### Measured effect (EVIDENCE lines) | ||
| 41 | +EVIDENCE: ~/.cache/midcut-tmp/{m_am.txt,m_o2.txt} | greedy in-order match of every | ||
| 42 | +`EC_MODE mi_row= mi_col= rng=` line, aomdec vs ours, 2-frame cut | first mismatch | ||
| 43 | +moved from aom idx 1998 (mi 120,272) to ALL MATCH 6871/6871 inter blocks. | ||
| 44 | +EVIDENCE: ~/.cache/midcut-tmp/d/{our,aom}.f{0,1} (EC_AV1_PREFILT_DUMP16, both | ||
| 45 | +decoders, regenerated this round) | numpy plane compare | f0 EXACT; f1 luma | ||
| 46 | +4386319 -> 115 wrong samples, U 342, V 860, every delta |1|, luma bbox rows | ||
| 47 | +552..1552 cols 488..969. | ||
| 48 | + | ||
| 49 | +## Also added (compiles, NOT yet gated -- next agent's first job) | ||
| 50 | +`decode::intra_rect_in_inter_txctx_override_hits()` (decode.rs, next to | ||
| 51 | +`intra_rect_in_inter_split_tx_hits`): counts ONLY the rect-intra-in-inter blocks | ||
| 52 | +whose ctx actually MOVED under the override, i.e. the blocks the bug mis-read -- | ||
| 53 | +a plain "rect intra in inter" tally is green on the buggy code too | ||
| 54 | +(class gate-blind-to-feature). | ||
| 55 | + | ||
| 56 | +## Exact next steps | ||
| 57 | +1. Print the new counter in `crates/ec-av1/examples/decode_probe.rs` (model: | ||
| 58 | + the `interintra_rect:` line at :46) and hard-assert a positive delta in | ||
| 59 | + `intra_rect_in_inter_split_tx_gate` / `intra_rect_in_inter_gate` | ||
| 60 | + (stream.rs:5639 / :29785, both bit depths). If neither arm fires the counter, | ||
| 61 | + add an aomenc arm with rect partitions + tx-size search on (the override only | ||
| 62 | + moves the row once a neighbour's var-tx tree splits). | ||
| 63 | +2. Chase the 115/342/860 |1| residue in frame 1 (entropy is now provably exact, | ||
| 64 | + so it is pure reconstruction: MC rounding or an intra edge, luma bbox above). | ||
| 65 | +3. Re-run the 24-offset decode-order table (`~/.cache/midcut-tmp/cen/`, r1's | ||
| 66 | + scripts; the r1 table `cen/after.tsv` is now stale) and report how many | ||
| 67 | + offsets have frame 1 exact. | ||
| 68 | +4. Then the named gates (mv_stack, interintra, rect, hidden_arf, | ||
| 69 | + refusal_inventory, gate_coverage) and the suite unit. None was run this round. | ||
| 70 | +5. No fixture pinned: frame 1 is not exact yet (residue above). | ||
| 71 | +6. No refusal lifted or moved; refusal_inventory/gate_coverage untouched. | ||
lanes/midcut-r3.handoff.mdadded+115 -0
| @@ -0,0 +1,115 @@ | |||
| 1 | +# lane-midcut r3 handoff -- dedup done, the rect chroma WARP guard was the residue's bulk | ||
| 2 | + | ||
| 3 | +Branch `lane-midcut`, worktree `edith_codecs-midcut`, | ||
| 4 | +`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-midcut`. Tip: `d93a149b`. | ||
| 5 | +Reproduction of every cut here needs `EC_INTRA16X4_DECODE=1`. | ||
| 6 | + | ||
| 7 | +## STEP 0 -- merge + DEDUP VERDICT: my override was redundant, dropped | ||
| 8 | + | ||
| 9 | +`git merge 75b3a1d` (lane-t900 r3 tip, already containing main `243f125`): | ||
| 10 | +clean auto-merge (decode.rs / stream.rs / decode_probe.rs). | ||
| 11 | + | ||
| 12 | +lane-t900 r2 switched EVERY rect intra reader's own call site to | ||
| 13 | +`tx_size_context_txfm_rect` under `INTRA_IN_INTER_MODE`, so after the merge my | ||
| 14 | +`cde8893` branch INSIDE `tx_size_context_rect` was unreachable: all seven | ||
| 15 | +remaining `tx_size_context_rect` calls sit in the `else` arm of exactly that | ||
| 16 | +condition (grep `tx_size_context_txfm_rect|tx_size_context_rect` in decode.rs). | ||
| 17 | +Removed it (`d41cbc51`); kept the counter by moving | ||
| 18 | +`intra_rect_in_inter_txctx_override_hits` INTO `tx_size_context_txfm_rect`, | ||
| 19 | +where it still counts only blocks whose CDF row the deblock-grid approximation | ||
| 20 | +would have read differently. Kept the r1 interintra rect blend (`43e9909`). | ||
| 21 | + | ||
| 22 | +Verification with t900's fix alone (no override anywhere): the 2-frame cut | ||
| 23 | +`~/.cache/midcut-tmp/h2400.t2.obu`, decode-order PREFILT16 compare vs | ||
| 24 | +instrumented aomdec -- frame 0 EXACT, frame 1 wrong-sample count 1317 | ||
| 25 | +(Y 115, U 342, V 860), i.e. bit-identical to what my own override produced. | ||
| 26 | +No site needs both. | ||
| 27 | + | ||
| 28 | +## STEP 1 -- ROOT CAUSE of the chroma residue (fixed, `8043ad54`) | ||
| 29 | + | ||
| 30 | +`decode_inter_block` allocates a SQUARE prediction buffer and gated the warp | ||
| 31 | +per plane on `chroma_side >= 8` -- the BUFFER's side. libaom | ||
| 32 | +`av1_init_warp_params` bails per PLANE at `block_width < 8 || block_height < 8` | ||
| 33 | +on the BLOCK's dims, so the 8x4 / 4x8 chroma of a 16x8 / 8x16 luma block keeps | ||
| 34 | +the translational prediction. Every rect block with a local or global warp | ||
| 35 | +warped its chroma where libaom does not. Guards are now `warp_chroma_ok = | ||
| 36 | +write_chroma_w >= 8 && write_chroma_h >= 8` (5 sites: 4 compound + 1 | ||
| 37 | +single-ref) and `warp_luma_ok = write_w >= 8 && write_h >= 8` (3 luma sites). | ||
| 38 | +Class: rectchroma2 / narrow-block-sharp-kernel (dims read off the enclosing | ||
| 39 | +square buffer). The 8x8-leaf reader (`CHROMA_SIDE >= 8`, const-generic) was | ||
| 40 | +already correct and is untouched. | ||
| 41 | + | ||
| 42 | +Frame 1 of the 2-frame cut: **1317 -> 126 wrong samples (Y 115, U 11, V 0)**. | ||
| 43 | + | ||
| 44 | +## RESIDUE STATE (126 samples, exact coordinates -- do not re-bisect) | ||
| 45 | + | ||
| 46 | +Three luma clusters + one chroma cluster, all in decode-order frame 1 of | ||
| 47 | +`~/.cache/midcut-tmp/h2400.t2.obu` (dumps kept at `~/.cache/midcut-tmp/d2/`): | ||
| 48 | + | ||
| 49 | +| cluster | px | n | shape | | ||
| 50 | +|---|---|---|---| | ||
| 51 | +| SB(8,15) | y 552..559, x 960..969 | 18 | dithered +-1 | | ||
| 52 | +| SB(9,7) | y 576..607, x 484..500 | 79 | a DIAGONAL +-1/+-2 band | | ||
| 53 | +| SB(24,10) | y 1549..1552, x 647..658 | 18 | +1/+2 wedge | | ||
| 54 | +| U | rows 800..803, cols 1216..1219 | 11 | -1..-2 | | ||
| 55 | + | ||
| 56 | +Every one of those blocks is an INTRA block inside the INTER frame, and every | ||
| 57 | +one is RECT (`EC_TRACE_MODE_STEP` at those mi): | ||
| 58 | +* SB(8,15) -> mi(136,240) `fn=rect bw=16 bh=32`, `mode=9` (SMOOTH), tx_depth 0. | ||
| 59 | +* SB(9,7) -> mi(144,120) `fn=rect bw=8 bh=16` mode=4 angle_y=+2 (directional), | ||
| 60 | + mi(144,122) `bw=8 bh=16` filter-intra, mi(144,124) `fn=sq side=16` mode=6 | ||
| 61 | + angle_y=-2. | ||
| 62 | +The diagonal band under a directional mode plus a dithered edge under SMOOTH is | ||
| 63 | +the signature of ONE wrong edge sample, not a wrong predictor: suspect the | ||
| 64 | +edge availability / reach for a RECT intra block inside an inter frame | ||
| 65 | +(`n_top`/`n_left`, has-top-right, or the intra edge filter strength/upsample | ||
| 66 | +computed from the square side rather than `bw x bh` -- `intra.rs:483 | ||
| 67 | +directional`, `intra_edge_filter_strength`, `use_intra_edge_upsample`). | ||
| 68 | +Classes to check first: reach-is-per-transform-unit, visit-order-changes- | ||
| 69 | +availability, context-read-from-one-cell. | ||
| 70 | + | ||
| 71 | +## STEP 2 -- gate/counter wiring state | ||
| 72 | + | ||
| 73 | +* `intra_rect_in_inter_txctx_override_hits` compiles and counts in | ||
| 74 | + `tx_size_context_txfm_rect`; it is **not yet printed by decode_probe and not | ||
| 75 | + yet asserted by any gate** (turn cap). Next: print it next to | ||
| 76 | + `interintra_rect:` in `crates/ec-av1/examples/decode_probe.rs:46` and assert a | ||
| 77 | + positive delta in `intra_rect_in_inter_split_tx_gate` / `intra_rect_in_inter_gate`. | ||
| 78 | +* `a_real_aomenc_stream_with_interintra_decodes_pixel_exact` was RED on this | ||
| 79 | + branch: its recipe spells `--enable-rect-partitions=0 --min-partition-size=32`, | ||
| 80 | + so r1's `interintra_rect_hits` delta assert was UNSATISFIABLE (40 pixel-exact | ||
| 81 | + matches, counter 0). Fixed with a RECT ARM (`d93a149b`) that re-encodes the | ||
| 82 | + same source with `--enable-rect-partitions=1 --min-partition-size=8 | ||
| 83 | + --max-partition-size=64` APPENDED (last flag wins) and compares every | ||
| 84 | + decode-order frame vs aomdec; seed 46's arm fires 4 rect interintra blocks. | ||
| 85 | + Gate green (1 passed, 11.7 s). | ||
| 86 | +* NO fixture pinned: frame 1 is still 126 samples off, so | ||
| 87 | + `crates/ec-av1/fixtures/reelb_midcut_arf_witness.obu` and its decode-order gate | ||
| 88 | + must wait for exactness. No refusal lifted; `refusal_inventory.rs` / | ||
| 89 | + `gate_coverage.rs` untouched. | ||
| 90 | + | ||
| 91 | +## Gates run this round (per-name, systemd units) | ||
| 92 | + | ||
| 93 | +`$HOME/.cache/midcut-gates-r3.log` (at `d41cbc51`): `hidden_arf` 1 passed; | ||
| 94 | +`rect64_corner_tus` 1 passed; `interintra` FAILED (the vacuous assert above, | ||
| 95 | +now fixed); `1to4` / `refusal_inventory` / `gate_coverage` were still running at | ||
| 96 | +the cap -- RE-RUN THEM at the tip. Full suite NOT run (coordinator: no suite). | ||
| 97 | + | ||
| 98 | +## 24-offset decode-order table (`~/.cache/midcut-tmp/cen/after_r3.tsv`) | ||
| 99 | + | ||
| 100 | +Written by `~/.cache/midcut-tmp/cen/run_r3.sh` (adds `EC_INTRA16X4_DECODE=1`, | ||
| 101 | +which the r2 script lacked). FINISHED: 24 offsets, frame 0 EXACT at all 24, | ||
| 102 | +frame 1 EXACT at **2** (0 s and 5100 s -- 5100 s went 2300495 -> 0), 12 of 24 | ||
| 103 | +offsets improved on frame 1, the rest unchanged (their frame-1 defect is not | ||
| 104 | +warp-shaped). Best movers: 1800 s 11612125 -> 1151, 2400 s 11010633 -> 126, | ||
| 105 | +3300 s 10663109 -> 27, 3900 s 4665360 -> 522 (its frame 3 is now 0). One offset | ||
| 106 | +(1500 s) still REFUSES on the Golomb tail. Nine offsets still carry a | ||
| 107 | +multi-million-sample frame among f1..f3 (300/900/2100/6000/6300/6600 ...), i.e. | ||
| 108 | +at least one more entropy-level defect remains off this cut. | ||
| 109 | + | ||
| 110 | +## Artifacts | ||
| 111 | + | ||
| 112 | +`~/.cache/midcut-tmp/`: `h2400.t2.obu` (2-frame cut, 4K 10-bit), | ||
| 113 | +`d2/{aom,our}.f{0,1}` (PREFILT16 dumps both decoders, at the tip), | ||
| 114 | +`m5.txt`/`m6.txt` (our `EC_TRACE_MODE`+`EC_TRACE_MODE_STEP` at the residue mi), | ||
| 115 | +`cen/run_r3.sh`, `cen/after_r3.tsv`. | ||