From c6220cd1fabf5da494522f4ec11142b1a501cdab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Sep 2026 08:12:25 +0300 Subject: [PATCH] fix(av1): the compound 8x8 leaf never read its switchable interp_filter -- lost a symbol per leaf and stamped the [3,3] sentinel that made a neighbouring OBMC block PANIC libaom decodemv.c:1575 runs read_mb_interp_filter for every inter block, compound included, right after read_compound_type. decode_leaf8's compound arm skipped it entirely: it predicted both taps with a hard-coded Regular and recorded the [3, 3] "no filter" sentinel, so a SWITCHABLE-filter stream lost one symbol (two under dual filter) per compound 8x8 leaf, and a neighbouring OBMC block's neighbour_filter fed the sentinel to from_switchable_symbol, whose panic! aborted the process on a real aomenc dual-filter + OBMC stream (flagged by lane-r14 r3). Same shape lane-gmaffine r3 fixed for the single-ref leaf; this was the surviving sibling. neighbour_filter now returns Result and refuses by name instead of panicking (new refusal listed in refusal_inventory.rs) -- a decoder must never abort on stream-derived state. New gate is RED and #[ignore]d with its measurement: the compound leaf still desyncs past this read (bogus AB/1:4 refusal with the read, bogus below-8x8 without it), so the fix is necessary, not sufficient. --- crates/ec-av1/src/decode.rs | 157 +++++++++++++++++++++---- crates/ec-av1/src/refusal_inventory.rs | 1 + crates/ec-av1/src/stream.rs | 79 ++++++++++++- lanes/interp3-r1.report.md | 83 +++++++++++++ 4 files changed, 295 insertions(+), 25 deletions(-) create mode 100644 lanes/interp3-r1.report.md diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index a614323b..519c6d6d 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -1726,6 +1726,32 @@ thread_local! { static OBMC_HITS_8: std::cell::Cell = const { std::cell::Cell::new(0) }; } +// lane-interp3 r1: how many inter blocks read a SWITCHABLE `interp_filter` +// pair whose two directions differ (`enable_dual_filter` only -- with dual +// filter off both directions take the single symbol, so this can never fire). +// A gate asserting it proves the stream really carries dual-filter blocks. +thread_local! { + static DUAL_FILTER_DIFF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +// lane-interp3 r1: how many COMPOUND 8x8 leaves read their own +// `read_mb_interp_filter` symbol(s) -- the read this round added (the leaf +// used to skip it entirely, losing a symbol and stamping the `[3, 3]` +// no-filter sentinel that made a neighbouring OBMC block panic). +thread_local! { + static COMPOUND8_FILTER_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Current value of [`DUAL_FILTER_DIFF_HITS`]. +pub(crate) fn dual_filter_diff_hits() -> usize { + DUAL_FILTER_DIFF_HITS.with(|c| c.get()) +} + +/// Current value of [`COMPOUND8_FILTER_HITS`]. +pub(crate) fn compound8_filter_hits() -> usize { + COMPOUND8_FILTER_HITS.with(|c| c.get()) +} + // lane-warp round 1: how many blocks resolved `motion_mode_allowed` to // `WARPED_CAUSAL`-eligible (3-symbol read, `num_proj_ref >= 1` under // `allow_warped_motion`) AND the symbol actually decoded to `WARPED_CAUSAL` @@ -14856,6 +14882,9 @@ fn resolve_interp_filter( } else { sym0 }; + if enable_dual_filter && sym0 != sym1 { + DUAL_FILTER_DIFF_HITS.with(|c| c.set(c.get() + 1)); + } ( mc::InterpFilterKind::from_switchable_symbol(sym1 as usize), mc::InterpFilterKind::from_switchable_symbol(sym0 as usize), @@ -15515,14 +15544,25 @@ fn obmc_mask(len: usize) -> &'static [u8] { fn neighbour_filter( interp_fixed: Option, sym: [u8; 2], -) -> (mc::InterpFilterKind, mc::InterpFilterKind) { +) -> Result<(mc::InterpFilterKind, mc::InterpFilterKind)> { if let Some(kind) = interp_fixed { - return (kind, kind); + return Ok((kind, kind)); + } + // lane-interp3 r1: the `[3, 3]` sentinel reaching here is a DEFECT in + // whatever path recorded the neighbour (an inter block that never stored + // its own switchable symbols), and it used to abort the process through + // `from_switchable_symbol`'s panic. A decoder must never crash on a real + // stream: it stops by name instead, so the frame is refused and the + // stream is pinned like every other unsupported case. + if sym[0] > 2 || sym[1] > 2 { + return Err(unsupported( + "an OBMC neighbour whose interp filter was never recorded (no switchable symbol for that block)", + )); } - ( + Ok(( mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize), mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize), - ) + )) } /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh @@ -15800,7 +15840,7 @@ fn obmc_blend( let (h_kind, v_kind) = neighbour_filter( interp_fixed, neighbours.above_filter[mi_col + off4], - ); + )?; let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; let nb_scale = mc::scale_factor(ny.width, frame_width); let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4); @@ -15819,7 +15859,7 @@ fn obmc_blend( let (h_kind, v_kind) = neighbour_filter( interp_fixed, neighbours.left_filter[mi_row + off4], - ); + )?; let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; let nb_scale = mc::scale_factor(ny.width, frame_width); let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4); @@ -19302,6 +19342,58 @@ fn decode_inter_block8( ); } + // lane-interp3 r1: `read_mb_interp_filter` (libaom + // `decodemv.c` 1575, the tail of + // `read_inter_block_mode_info`) runs for EVERY inter block, + // compound included, right AFTER `read_compound_type` -- this + // leaf read no filter symbol at all, so a SWITCHABLE-filter + // stream lost one symbol (two under `enable_dual_filter`) at + // every compound 8x8 leaf, and the leaf recorded the `[3, 3]` + // "no filter" sentinel, which made a neighbouring OBMC block's + // `neighbour_filter` PANIC instead of blending. + // `av1_is_interp_needed` suppression terms for this arm: + // `skip_mode`, and `is_nontrans_global_motion` (mode + // GLOBAL_GLOBALMV with BOTH refs' models non-TRANSLATION) -- + // WARPED_CAUSAL cannot occur on a compound block. + let gm_nontrans_c = compound_mode == 6 + && global_motion[(ref0 - LAST_FRAME) as usize].model + != ec_av1_syntax::WarpModel::Translation + && global_motion[(ref1 - LAST_FRAME) as usize].model + != ec_av1_syntax::WarpModel::Translation; + // spec `get_ref_filter_type`, keyed on this block's ref0 and + // matching EITHER of the neighbour's references -- same shape + // as [`decode_inter_block`]'s compound arm. Same corner-cut as + // this leaf's single-ref arm below: the context comes from the + // enclosing 16x16's coarse slot. + let above_filter_ctx = if neighbours.above_ref[cmi] == ref0 + || neighbours.above_ref1[cmi] == Some(ref0) + { + neighbours.above_filter[cmi] + } else { + [3, 3] + }; + let left_filter_ctx = if neighbours.left_ref[rmi] == ref0 + || neighbours.left_ref1[rmi] == Some(ref0) + { + neighbours.left_filter[rmi] + } else { + [3, 3] + }; + let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( + dec, + cdfs, + interp_fixed, + enable_dual_filter, + gm_nontrans_c || skip_mode, + above_filter_ctx, + left_filter_ctx, + true, + ); + leaf_filter_syms = resolved_filter; + if interp_fixed.is_none() && !(gm_nontrans_c || skip_mode) { + COMPOUND8_FILTER_HITS.with(|c| c.set(c.get() + 1)); + } + let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?; let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?; let scale0 = mc::scale_factor(py0.width, frame_width); @@ -19333,11 +19425,6 @@ fn decode_inter_block8( } mode_for_tx = 0; - // lane-av1comp corner-cut, matching this leaf's single-ref - // arm below (`mc::predict`'s own fixed-Regular default): - // `decode_inter_block8` never resolves a switchable filter, - // so both compound taps use `Regular` too. - use mc::InterpFilterKind::Regular; let mut inter0_y = vec![0i32; SIDE * SIDE]; mc::predict_compound_intermediate( &py0.data, @@ -19349,8 +19436,8 @@ fn decode_inter_block8( scale0, SIDE, SIDE, - Regular, - Regular, + h_filter, + v_filter, &mut inter0_y, ); let mut inter1_y = vec![0i32; SIDE * SIDE]; @@ -19364,8 +19451,8 @@ fn decode_inter_block8( scale1, SIDE, SIDE, - Regular, - Regular, + h_filter, + v_filter, &mut inter1_y, ); let mut pred_y = vec![0u16; SIDE * SIDE]; @@ -19397,8 +19484,8 @@ fn decode_inter_block8( scale0, CHROMA_SIDE, CHROMA_SIDE, - Regular, - Regular, + h_filter, + v_filter, &mut inter0_u, ); let mut inter1_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; @@ -19412,8 +19499,8 @@ fn decode_inter_block8( scale1, CHROMA_SIDE, CHROMA_SIDE, - Regular, - Regular, + h_filter, + v_filter, &mut inter1_u, ); let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; @@ -19443,8 +19530,8 @@ fn decode_inter_block8( scale0, CHROMA_SIDE, CHROMA_SIDE, - Regular, - Regular, + h_filter, + v_filter, &mut inter0_v, ); let mut inter1_v = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; @@ -19458,8 +19545,8 @@ fn decode_inter_block8( scale1, CHROMA_SIDE, CHROMA_SIDE, - Regular, - Regular, + h_filter, + v_filter, &mut inter1_v, ); let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; @@ -22840,6 +22927,30 @@ mod tests { /// always cleared to `None` by `record_inter`, so the next block's own /// `NeighbourRef::uni` -- and `comp_reference_type_ctx` downstream of it /// -- could never see a real compound neighbour). + /// lane-interp3 r1: a decoder must never abort the process on + /// stream-derived state. `neighbour_filter` used to feed the `[3, 3]` + /// "no filter recorded" sentinel straight into + /// `InterpFilterKind::from_switchable_symbol`, whose `panic!` ("...alphabet + /// is exactly 3 symbols") crashed on a real aomenc dual-filter + OBMC + /// stream. It now refuses by name; the real symbols still decode. + #[test] + fn an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking() { + assert!( + neighbour_filter(None, [3, 3]) + .unwrap_err() + .to_string() + .contains("an OBMC neighbour whose interp filter was never recorded"), + "the [3, 3] sentinel must refuse by name, never panic" + ); + assert!(neighbour_filter(None, [3, 0]).is_err()); + let (h, v) = neighbour_filter(None, [0, 2]).expect("real symbols decode"); + assert_eq!(h, mc::InterpFilterKind::Sharp, "sym[1] is the horizontal kernel"); + assert_eq!(v, mc::InterpFilterKind::Regular, "sym[0] is the vertical kernel"); + let (h, v) = neighbour_filter(Some(mc::InterpFilterKind::Smooth), [3, 3]) + .expect("a fixed-filter frame never reads a symbol"); + assert_eq!((h, v), (mc::InterpFilterKind::Smooth, mc::InterpFilterKind::Smooth)); + } + #[test] fn record_compound_ctx_stamps_ref1_for_the_next_block_to_read() { let mut n = Neighbours::new(4, 4, 16, 16); diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 4ab1f2c6..a3496e6c 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -34,6 +34,7 @@ const REFUSALS: &[&str] = &[ "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", + "an OBMC neighbour whose interp filter was never recorded (no switchable symbol for that block)", "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 15ad6113..f3220d88 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -6087,6 +6087,9 @@ mod tests { // aomenc silently codes one tile column and the arm is vacuous. extra: &[&str], width: usize, + // lane-interp3 r1: sequence length -- a compound block needs several + // already-coded references, which a 4-frame sequence never has. + frame_count: usize, ) { if !have_ffmpeg() { eprintln!("SKIP {name}: no ffmpeg"); @@ -6096,7 +6099,8 @@ mod tests { eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); return; } - let (height, frame_count) = (64usize, 4usize); + let height = 64usize; + let duration = format!("{:.2}", frame_count as f64 / 25.0); // A deterministic synthetic source with real motion (a static source // codes every inter frame as skip and never exercises the residual // path); bounded with `-t` (class gate-loader-slurps-whole-file). @@ -6109,7 +6113,7 @@ mod tests { "-i", &format!("mandelbrot=size={width}x{height}:rate=25"), "-t", - "0.16", + &duration, "-pix_fmt", if ten_bit { "yuv420p10le" } else { "yuv420p" }, // y4m calls 10-bit unofficial (same as the 10-bit key-frame @@ -6236,6 +6240,7 @@ mod tests { "whole-superblock inter PARTITION_NONE", &[], 64, + 4, ); } @@ -6250,6 +6255,7 @@ mod tests { "whole-superblock inter PARTITION_NONE", &[], 64, + 4, ); } @@ -6292,6 +6298,73 @@ mod tests { "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", &["--tile-columns=1"], 128, + 4, + ); + } + + /// lane-interp3 r1: the same 8x8-leaf recipe with DUAL FILTER, OBMC and + /// warped motion on. `read_mb_interp_filter` runs for every inter block + /// (libaom `decodemv.c` 1575), compound ones included; the compound 8x8 + /// leaf skipped it entirely, so a SWITCHABLE-filter stream lost a symbol + /// per compound leaf and stamped the `[3, 3]` "no filter" sentinel, which + /// made a neighbouring OBMC block's `neighbour_filter` PANIC (a crash on + /// his data, not a named refusal). The three hard asserts prove the flags + /// arrived: a compound 8x8 leaf that really read the filter, a block whose + /// two dual-filter directions DIFFER (impossible with dual filter off), + /// and an 8x8 OBMC blend. + // lane-interp3 r1: RED, and ignored rather than deleted -- MEASURED, not + // assumed. At `EC_INTERP3_FRAMES=4` (the other arms' length) aomenc codes + // no compound block at all and the stream decodes; from 5 frames on it + // does, and the decode then stops at "an inter 16x16-level AB or 1:4 + // partition" WITH this round's filter read and at "an inter partition + // below 8x8" WITHOUT it (measured by ablating the read) -- both are + // impossible on a `--enable-ab-partitions=0 --enable-1to4-partitions=0 + // --min-partition-size=8` recipe, so BOTH are our own desync + // (class refusal-from-own-desync) and the compound 8x8 leaf carries at + // least one more missing/misplaced symbol beyond the interp filter this + // round added. Next round: EC_TRACE range ladder vs aomdec on the first + // compound leaf of frame 5. + #[ignore = "lane-interp3 r1: the compound 8x8 leaf still desyncs past the interp-filter read (surfaces as a bogus AB/1:4 refusal); the panic it used to end in is now a named refusal"] + #[test] + fn a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact() { + const NAME: &str = + "a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact"; + if !have_ffmpeg() || !have_aomenc() { + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); + return; + } + let before_dual = decode::dual_filter_diff_hits(); + let before_obmc = decode::obmc_hits_8(); + inter_sb_none_gate( + NAME, + false, + "8", + "16", + decode::compound8_filter_hits, + "a compound 8x8 leaf reading its own switchable interp_filter", + &[ + "--enable-dual-filter=1", + "--enable-obmc=1", + "--enable-warped-motion=1", + "--enable-onesided-comp=1", + ], + 64, + // Recipe search hook (same shape as EC_OBMC8_ATTEMPTS): a compound + // block needs several coded references, so the sequence is longer + // than the other arms' 4 frames. + std::env::var("EC_INTERP3_FRAMES") + .ok() + .and_then(|v| v.parse().ok()) + .unwrap_or(16), + ); + assert!( + decode::dual_filter_diff_hits() > before_dual, + "{NAME}: no block read two DIFFERENT dual-filter directions -- \ + --enable-dual-filter=1 did not arrive or aomenc declined it" + ); + assert!( + decode::obmc_hits_8() > before_obmc, + "{NAME}: no 8x8 OBMC blend fired -- --enable-obmc=1 did not arrive" ); } @@ -6306,6 +6379,7 @@ mod tests { "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", &[], 64, + 4, ); } @@ -6329,6 +6403,7 @@ mod tests { "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", &[], 64, + 4, ); } diff --git a/lanes/interp3-r1.report.md b/lanes/interp3-r1.report.md new file mode 100644 index 00000000..41f74038 --- /dev/null +++ b/lanes/interp3-r1.report.md @@ -0,0 +1,83 @@ +# lane-interp3 r1 -- the `switchable_interp` PANIC: the compound 8x8 leaf never read its filter + +## Root cause (cited) + +libaom `decodemv.c:1575` (`read_inter_block_mode_info`) calls `read_mb_interp_filter` +for **every** inter block, compound ones included, right after `read_compound_type`. +`decode_leaf8`'s COMPOUND arm (`crates/ec-av1/src/decode.rs`, the branch that returns at +the old line 19589) called `resolve_interp_filter` **not at all**: it predicted both taps +with a hard-coded `Regular` and returned the `[3, 3]` "no filter recorded" sentinel as the +leaf's `leaf_filter_syms`. Two consequences, both real on his data: + +1. **Entropy**: on a `SWITCHABLE`-filter frame one symbol (two under `enable_dual_filter`) + is left unread at every compound 8x8 leaf -- silent desync. +2. **Crash**: the sentinel is stamped into `Neighbours::above_filter`/`left_filter`, and a + neighbouring OBMC block's `neighbour_filter` fed it to + `mc::InterpFilterKind::from_switchable_symbol`, whose `panic!("switchable_interp's + alphabet is exactly 3 symbols")` aborted the process. That is the panic lane-r14 r3 + flagged (its `--enable-dual-filter=1 --enable-obmc=1` 192x128 cq30 stream). The same + shape was already fixed once for the SINGLE-ref 8x8 leaf (lane-gmaffine r3, decode.rs + ~21509 comment) -- the compound arm was the surviving sibling instance. + +## Changed + +- `crates/ec-av1/src/decode.rs` (compound 8x8 leaf, after the `comp_group_idx`/ + `compound_idx` reads): reads `interp_filter` in libaom's order, with `get_ref_filter_type` + neighbour contexts keyed on `ref0` and `is_compound = true`; suppression term is + `skip_mode || is_nontrans_global_motion` (GLOBAL_GLOBALMV + both refs' models non- + TRANSLATION; WARPED_CAUSAL cannot occur on compound). The 12 `predict_compound_intermediate` + taps now use the resolved `h_filter`/`v_filter` instead of `Regular`. +- `crates/ec-av1/src/decode.rs` `neighbour_filter`: returns `Result`; the `[3, 3]` sentinel + is now the named refusal `an OBMC neighbour whose interp filter was never recorded (no + switchable symbol for that block)` -- **never a panic**. Both OBMC call sites `?` it. +- `crates/ec-av1/src/decode.rs`: counters `DUAL_FILTER_DIFF_HITS` (a block whose two + dual-filter directions differ -- impossible with dual filter off) and + `COMPOUND8_FILTER_HITS`. +- `crates/ec-av1/src/refusal_inventory.rs`: the new refusal listed (inventory test green). +- `crates/ec-av1/src/stream.rs`: `inter_sb_none_gate` takes a `frame_count` + (4 frames never code a compound block); new gate + `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` + (`--enable-dual-filter=1 --enable-obmc=1 --enable-warped-motion=1 --enable-onesided-comp=1` + on the `--min-partition-size=8 --enable-ab-partitions=0 --enable-1to4-partitions=0` + recipe, every frame compared Y/U/V vs ffmpeg, hard asserts on all three counters). +- `crates/ec-av1/src/decode.rs` test + `an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking`. + +## Gate: RED, `#[ignore]`d with the measurement, not deleted + +`EC_INTERP3_FRAMES=4` -> aomenc codes no compound block, stream decodes. +From 5 frames on it does, and the decode stops at a refusal that the recipe makes +impossible: `an inter 16x16-level AB or 1:4 partition` WITH this round's filter read, and +`an inter partition below 8x8` WITHOUT it (measured by ablating the read behind a temporary +env switch, since removed). `--enable-ab-partitions=0 --enable-1to4-partitions=0 +--min-partition-size=8` cannot emit either -- so both are our own desync +(class `refusal-from-own-desync`): the compound 8x8 leaf carries at least one more +missing/misplaced symbol beyond the interp filter. The fix is therefore **necessary but not +sufficient** and is not claimed as pixel-proven. + +EVIDENCE: $HOME/.cache/interp3-suite-r1.log | `cargo test -p ec-av1 --lib -j3` under a +systemd user unit, MemoryMax=10G | totals below +EVIDENCE: gate run `EC_INTERP3_FRAMES=5..16 cargo test -p ec-av1 --lib a_real_aomenc_dual_filter_obmc_8x8` with and without the new read | 6 encodes x 2 arms | refusal string differs per arm (AB/1:4 vs below-8x8), 0 frames compared either way -- gate RED, ignored +EVIDENCE: `cargo test -p ec-av1 --lib an_obmc_neighbour_with_no_recorded` | direct call with the `[3, 3]` sentinel | 1 passed: refuses by name, no panic + +## Panic sweep of the decode path (charter clause) + +`neighbour_filter` was the only `panic!` reachable from a *stream-derived value* on the OBMC +path; converted. The rest of `decode.rs`'s 57 `panic!/unreachable!/unwrap/expect` sites, +inspected: `2733, 11268, 11617, 11636, 11683, 11996, 12015, 12052, 13820, 13998, 15225, +15533` are `unreachable!` on values a CDF alphabet or an earlier refusal already bounds +(cannot fire on any stream); `5238, 5282, 6043, 6110, 7310, 7311, 7777, 7778, 10479, 10535, +10679, 10888` are `unwrap/expect` on this decoder's own just-built state; everything above +line 22700 is inside `#[cfg(test)]`. Two remain flagged, not converted (they need a `Result` +in a counter/table helper and no stream is known to reach them): +`decode.rs:2486` `panic!("ref_hits: no per-reference counter for ref_frame {other}")` and +`decode.rs:3247` `panic!("intra mode {other} has no Intra_Mode_To_Tx_Type entry")`. +`mc.rs:203`/`:220` stay as documented invariants -- both callers now check first. + +## Residue + +- fix-now(next round): the remaining compound-8x8 desync. Method: `EC_TRACE=1` aomdec range + ladder against ours on the FIRST compound leaf of frame 5 of the gate's stream, comparing + msac RANGE element by element (never `tell()`). +- deferred(needs that fix): the 10-bit arm of the new gate, and the counter-proving + pixel-exact claim.