Merge 10b801a into lane-uv8
Browse files at this commit8 changed files +836 -37
- crates/ec-av1/src/decode.rs +317 -35
- crates/ec-av1/src/refusal_inventory.rs +1 -0
- crates/ec-av1/src/stream.rs +92 -2
- lanes/interp3-r1.report.md +96 -0
- lanes/interp3-r2.handoff.md +48 -0
- lanes/interp3-r2.report.md +88 -0
- lanes/interp3-r3.handoff.md +88 -0
- lanes/interp3-r3.report.md +106 -0
crates/ec-av1/src/decode.rsmodified+317 -35
| @@ -1763,6 +1763,32 @@ thread_local! { | ||
| 1763 | 1763 | static OBMC_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1764 | 1764 | } |
| 1765 | 1765 | |
| 1766 | +// lane-interp3 r1: how many inter blocks read a SWITCHABLE `interp_filter` | |
| 1767 | +// pair whose two directions differ (`enable_dual_filter` only -- with dual | |
| 1768 | +// filter off both directions take the single symbol, so this can never fire). | |
| 1769 | +// A gate asserting it proves the stream really carries dual-filter blocks. | |
| 1770 | +thread_local! { | |
| 1771 | + static DUAL_FILTER_DIFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1772 | +} | |
| 1773 | + | |
| 1774 | +// lane-interp3 r1: how many COMPOUND 8x8 leaves read their own | |
| 1775 | +// `read_mb_interp_filter` symbol(s) -- the read this round added (the leaf | |
| 1776 | +// used to skip it entirely, losing a symbol and stamping the `[3, 3]` | |
| 1777 | +// no-filter sentinel that made a neighbouring OBMC block panic). | |
| 1778 | +thread_local! { | |
| 1779 | + static COMPOUND8_FILTER_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1780 | +} | |
| 1781 | + | |
| 1782 | +/// Current value of [`DUAL_FILTER_DIFF_HITS`]. | |
| 1783 | +pub(crate) fn dual_filter_diff_hits() -> usize { | |
| 1784 | + DUAL_FILTER_DIFF_HITS.with(|c| c.get()) | |
| 1785 | +} | |
| 1786 | + | |
| 1787 | +/// Current value of [`COMPOUND8_FILTER_HITS`]. | |
| 1788 | +pub(crate) fn compound8_filter_hits() -> usize { | |
| 1789 | + COMPOUND8_FILTER_HITS.with(|c| c.get()) | |
| 1790 | +} | |
| 1791 | + | |
| 1766 | 1792 | // lane-warp round 1: how many blocks resolved `motion_mode_allowed` to |
| 1767 | 1793 | // `WARPED_CAUSAL`-eligible (3-symbol read, `num_proj_ref >= 1` under |
| 1768 | 1794 | // `allow_warped_motion`) AND the symbol actually decoded to `WARPED_CAUSAL` |
| @@ -1794,6 +1820,20 @@ pub(crate) fn compound_warp_hits() -> usize { | ||
| 1794 | 1820 | COMPOUND_WARP_HITS.with(|c| c.get()) |
| 1795 | 1821 | } |
| 1796 | 1822 | |
| 1823 | +// lane-interp3 r3: the same proof narrowed to the 8x8 LEAF's own compound | |
| 1824 | +// arm ([`decode_inter_block8`]) -- that arm predicted both taps | |
| 1825 | +// translationally until r3, so a gate needs to tell a warped 8x8 compound | |
| 1826 | +// leaf apart from a warped 16x16+ one (both bump [`COMPOUND_WARP_HITS`]). | |
| 1827 | +thread_local! { | |
| 1828 | + static COMPOUND_WARP_HITS_8: std::cell::Cell<usize> = | |
| 1829 | + const { std::cell::Cell::new(0) }; | |
| 1830 | +} | |
| 1831 | + | |
| 1832 | +/// Current value of [`COMPOUND_WARP_HITS_8`]. | |
| 1833 | +pub(crate) fn compound_warp_hits_8() -> usize { | |
| 1834 | + COMPOUND_WARP_HITS_8.with(|c| c.get()) | |
| 1835 | +} | |
| 1836 | + | |
| 1797 | 1837 | // lane-gmaffine r1: how many blocks built their prediction from a |
| 1798 | 1838 | // SIX-parameter (`AFFINE`) global-motion model through |
| 1799 | 1839 | // `crate::warp::global_warp_params` -- the gate's proof that a stream really |
| @@ -14850,6 +14890,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 14850 | 14890 | // that isolate whether a decode-order frame's mismatch already exists |
| 14851 | 14891 | // in reconstruction (this dump) vs is introduced by the loop filter |
| 14852 | 14892 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). |
| 14893 | + // Decode-order frame marker for the EC_OBMC / EC_TRACE_MODE ladders. | |
| 14894 | + if std::env::var_os("EC_OBMC").is_some() || std::env::var_os("EC_TRACE_MODE").is_some() { | |
| 14895 | + eprintln!( | |
| 14896 | + "EC_PICT idx={}", | |
| 14897 | + PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) | |
| 14898 | + ); | |
| 14899 | + } | |
| 14853 | 14900 | dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 14854 | 14901 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { |
| 14855 | 14902 | use std::io::Write; |
| @@ -15054,6 +15101,9 @@ fn resolve_interp_filter( | ||
| 15054 | 15101 | } else { |
| 15055 | 15102 | sym0 |
| 15056 | 15103 | }; |
| 15104 | + if enable_dual_filter && sym0 != sym1 { | |
| 15105 | + DUAL_FILTER_DIFF_HITS.with(|c| c.set(c.get() + 1)); | |
| 15106 | + } | |
| 15057 | 15107 | ( |
| 15058 | 15108 | mc::InterpFilterKind::from_switchable_symbol(sym1 as usize), |
| 15059 | 15109 | mc::InterpFilterKind::from_switchable_symbol(sym0 as usize), |
| @@ -15713,14 +15763,25 @@ fn obmc_mask(len: usize) -> &'static [u8] { | ||
| 15713 | 15763 | fn neighbour_filter( |
| 15714 | 15764 | interp_fixed: Option<mc::InterpFilterKind>, |
| 15715 | 15765 | sym: [u8; 2], |
| 15716 | -) -> (mc::InterpFilterKind, mc::InterpFilterKind) { | |
| 15766 | +) -> Result<(mc::InterpFilterKind, mc::InterpFilterKind)> { | |
| 15717 | 15767 | if let Some(kind) = interp_fixed { |
| 15718 | - return (kind, kind); | |
| 15768 | + return Ok((kind, kind)); | |
| 15769 | + } | |
| 15770 | + // lane-interp3 r1: the `[3, 3]` sentinel reaching here is a DEFECT in | |
| 15771 | + // whatever path recorded the neighbour (an inter block that never stored | |
| 15772 | + // its own switchable symbols), and it used to abort the process through | |
| 15773 | + // `from_switchable_symbol`'s panic. A decoder must never crash on a real | |
| 15774 | + // stream: it stops by name instead, so the frame is refused and the | |
| 15775 | + // stream is pinned like every other unsupported case. | |
| 15776 | + if sym[0] > 2 || sym[1] > 2 { | |
| 15777 | + return Err(unsupported( | |
| 15778 | + "an OBMC neighbour whose interp filter was never recorded (no switchable symbol for that block)", | |
| 15779 | + )); | |
| 15719 | 15780 | } |
| 15720 | - ( | |
| 15781 | + Ok(( | |
| 15721 | 15782 | mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize), |
| 15722 | 15783 | mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize), |
| 15723 | - ) | |
| 15784 | + )) | |
| 15724 | 15785 | } |
| 15725 | 15786 | |
| 15726 | 15787 | /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh |
| @@ -15900,6 +15961,71 @@ fn obmc_blend_h(dst: &mut [u16], stride: usize, ox: usize, oy: usize, w: usize, | ||
| 15900 | 15961 | } |
| 15901 | 15962 | } |
| 15902 | 15963 | |
| 15964 | +/// libaom's own `BLOCK_SIZE` enum index for a `w4`x`h4` (mi-unit) block -- | |
| 15965 | +/// only for the `EC_OBMC` trace rung below, so it reads byte-identical to | |
| 15966 | +/// the instrumented aomdec's `backup_mbmi.bsize`. | |
| 15967 | +fn ec_obmc_bsize(w4: usize, h4: usize) -> i32 { | |
| 15968 | + match (w4, h4) { | |
| 15969 | + (1, 1) => 0, | |
| 15970 | + (1, 2) => 1, | |
| 15971 | + (2, 1) => 2, | |
| 15972 | + (2, 2) => 3, | |
| 15973 | + (2, 4) => 4, | |
| 15974 | + (4, 2) => 5, | |
| 15975 | + (4, 4) => 6, | |
| 15976 | + (4, 8) => 7, | |
| 15977 | + (8, 4) => 8, | |
| 15978 | + (8, 8) => 9, | |
| 15979 | + (8, 16) => 10, | |
| 15980 | + (16, 8) => 11, | |
| 15981 | + (16, 16) => 12, | |
| 15982 | + (1, 4) => 16, | |
| 15983 | + (4, 1) => 17, | |
| 15984 | + (2, 8) => 18, | |
| 15985 | + (8, 2) => 19, | |
| 15986 | + (4, 16) => 20, | |
| 15987 | + (16, 4) => 21, | |
| 15988 | + _ => -1, | |
| 15989 | + } | |
| 15990 | +} | |
| 15991 | + | |
| 15992 | +/// The `EC_OBMC` rung: one line per blended neighbour, in the instrumented | |
| 15993 | +/// aomdec's own byte format (`decodeframe.c` | |
| 15994 | +/// `dec_build_prediction_by_{above,left}_pred`), so the two decoders' OBMC | |
| 15995 | +/// neighbour lists diff line for line. `filt` is libaom's packed | |
| 15996 | +/// `interp_filters.as_int` = `y_filter | (x_filter << 16)`. | |
| 15997 | +#[allow(clippy::too_many_arguments)] | |
| 15998 | +fn ec_obmc_trace( | |
| 15999 | + dir: &str, | |
| 16000 | + mi_row: usize, | |
| 16001 | + mi_col: usize, | |
| 16002 | + write_w: usize, | |
| 16003 | + write_h: usize, | |
| 16004 | + rel: usize, | |
| 16005 | + op: usize, | |
| 16006 | + nb: &MiInfo, | |
| 16007 | + h_kind: mc::InterpFilterKind, | |
| 16008 | + v_kind: mc::InterpFilterKind, | |
| 16009 | +) { | |
| 16010 | + if std::env::var_os("EC_OBMC").is_none() { | |
| 16011 | + return; | |
| 16012 | + } | |
| 16013 | + let sym = |k: mc::InterpFilterKind| match k { | |
| 16014 | + mc::InterpFilterKind::Smooth => 1u32, | |
| 16015 | + mc::InterpFilterKind::Sharp => 2, | |
| 16016 | + _ => 0, | |
| 16017 | + }; | |
| 16018 | + eprintln!( | |
| 16019 | + "EC_OBMC {dir} mi=({mi_row},{mi_col}) wh=({write_w}x{write_h}) rel={rel} op={op} \ | |
| 16020 | +nbmv=({},{}) nbref={} nbbsize={} filt={}", | |
| 16021 | + nb.mv.0, | |
| 16022 | + nb.mv.1, | |
| 16023 | + nb.ref_frame, | |
| 16024 | + ec_obmc_bsize(nb.size, nb.size_h), | |
| 16025 | + sym(v_kind) | (sym(h_kind) << 16), | |
| 16026 | + ); | |
| 16027 | +} | |
| 16028 | + | |
| 15903 | 16029 | /// `av1_build_obmc_inter_prediction` (libaom `reconinter.c`): re-predicts |
| 15904 | 16030 | /// the overlap strip against each bordering above/left inter neighbour's own |
| 15905 | 16031 | /// mv/ref/filter and blends it into this block's just-built single-reference |
| @@ -15998,7 +16124,8 @@ fn obmc_blend( | ||
| 15998 | 16124 | let (h_kind, v_kind) = neighbour_filter( |
| 15999 | 16125 | interp_fixed, |
| 16000 | 16126 | neighbours.above_filter[mi_col + off4], |
| 16001 | - ); | |
| 16127 | + )?; | |
| 16128 | + ec_obmc_trace("above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); | |
| 16002 | 16129 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; |
| 16003 | 16130 | let nb_scale = mc::scale_factor(ny.width, frame_width); |
| 16004 | 16131 | let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4); |
| @@ -16017,7 +16144,8 @@ fn obmc_blend( | ||
| 16017 | 16144 | let (h_kind, v_kind) = neighbour_filter( |
| 16018 | 16145 | interp_fixed, |
| 16019 | 16146 | neighbours.left_filter[mi_row + off4], |
| 16020 | - ); | |
| 16147 | + )?; | |
| 16148 | + ec_obmc_trace("left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); | |
| 16021 | 16149 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; |
| 16022 | 16150 | let nb_scale = mc::scale_factor(ny.width, frame_width); |
| 16023 | 16151 | let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4); |
| @@ -19376,21 +19504,24 @@ fn decode_inter_block8( | ||
| 19376 | 19504 | let (ref0, ref1) = if skip_mode { |
| 19377 | 19505 | (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8) |
| 19378 | 19506 | } else { |
| 19507 | + // lane-interp3 r2 (class twin-functions-drift): this leaf | |
| 19508 | + // passed a hard-coded `LAST_FRAME` for every inter | |
| 19509 | + // neighbour -- the old "coarse LAST_FRAME-or-intra" | |
| 19510 | + // approximation -- while the side bands have carried the | |
| 19511 | + // neighbour's REAL reference per mi since lane-inter8 r2. | |
| 19512 | + // Every `av1_collect_neighbors_ref_counts` vote below | |
| 19513 | + // (`uni_comp_ref_p1`, `comp_ref`, `comp_bwdref`, ...) was | |
| 19514 | + // therefore taken off the wrong CDF row. Same two args | |
| 19515 | + // [`decode_inter_block`]'s own compound arm passes | |
| 19516 | + // (`-1` when the band is unavailable is start_tile's / | |
| 19517 | + // start_row's own reset value, so no `has_above` guard). | |
| 19379 | 19518 | read_compound_ref_frames( |
| 19380 | 19519 | dec, |
| 19381 | 19520 | cdfs, |
| 19382 | 19521 | above_nbr, |
| 19383 | 19522 | left_nbr, |
| 19384 | - if has_above && above_inter { | |
| 19385 | - LAST_FRAME | |
| 19386 | - } else { | |
| 19387 | - -1 | |
| 19388 | - }, | |
| 19389 | - if has_left && left_inter { | |
| 19390 | - LAST_FRAME | |
| 19391 | - } else { | |
| 19392 | - -1 | |
| 19393 | - }, | |
| 19523 | + above_ref0, | |
| 19524 | + left_ref0, | |
| 19394 | 19525 | ) |
| 19395 | 19526 | }; |
| 19396 | 19527 | leaf_refs = (ref0, Some(ref1)); |
| @@ -19571,6 +19702,58 @@ fn decode_inter_block8( | ||
| 19571 | 19702 | ); |
| 19572 | 19703 | } |
| 19573 | 19704 | |
| 19705 | + // lane-interp3 r1: `read_mb_interp_filter` (libaom | |
| 19706 | + // `decodemv.c` 1575, the tail of | |
| 19707 | + // `read_inter_block_mode_info`) runs for EVERY inter block, | |
| 19708 | + // compound included, right AFTER `read_compound_type` -- this | |
| 19709 | + // leaf read no filter symbol at all, so a SWITCHABLE-filter | |
| 19710 | + // stream lost one symbol (two under `enable_dual_filter`) at | |
| 19711 | + // every compound 8x8 leaf, and the leaf recorded the `[3, 3]` | |
| 19712 | + // "no filter" sentinel, which made a neighbouring OBMC block's | |
| 19713 | + // `neighbour_filter` PANIC instead of blending. | |
| 19714 | + // `av1_is_interp_needed` suppression terms for this arm: | |
| 19715 | + // `skip_mode`, and `is_nontrans_global_motion` (mode | |
| 19716 | + // GLOBAL_GLOBALMV with BOTH refs' models non-TRANSLATION) -- | |
| 19717 | + // WARPED_CAUSAL cannot occur on a compound block. | |
| 19718 | + let gm_nontrans_c = compound_mode == 6 | |
| 19719 | + && global_motion[(ref0 - LAST_FRAME) as usize].model | |
| 19720 | + != ec_av1_syntax::WarpModel::Translation | |
| 19721 | + && global_motion[(ref1 - LAST_FRAME) as usize].model | |
| 19722 | + != ec_av1_syntax::WarpModel::Translation; | |
| 19723 | + // spec `get_ref_filter_type`, keyed on this block's ref0 and | |
| 19724 | + // matching EITHER of the neighbour's references -- same shape | |
| 19725 | + // as [`decode_inter_block`]'s compound arm. Same corner-cut as | |
| 19726 | + // this leaf's single-ref arm below: the context comes from the | |
| 19727 | + // enclosing 16x16's coarse slot. | |
| 19728 | + let above_filter_ctx = if neighbours.above_ref[cmi] == ref0 | |
| 19729 | + || neighbours.above_ref1[cmi] == Some(ref0) | |
| 19730 | + { | |
| 19731 | + neighbours.above_filter[cmi] | |
| 19732 | + } else { | |
| 19733 | + [3, 3] | |
| 19734 | + }; | |
| 19735 | + let left_filter_ctx = if neighbours.left_ref[rmi] == ref0 | |
| 19736 | + || neighbours.left_ref1[rmi] == Some(ref0) | |
| 19737 | + { | |
| 19738 | + neighbours.left_filter[rmi] | |
| 19739 | + } else { | |
| 19740 | + [3, 3] | |
| 19741 | + }; | |
| 19742 | + let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( | |
| 19743 | + dec, | |
| 19744 | + cdfs, | |
| 19745 | + interp_fixed, | |
| 19746 | + enable_dual_filter, | |
| 19747 | + gm_nontrans_c || skip_mode, | |
| 19748 | + above_filter_ctx, | |
| 19749 | + left_filter_ctx, | |
| 19750 | + true, | |
| 19751 | + ); | |
| 19752 | + leaf_filter_syms = resolved_filter; | |
| 19753 | + if interp_fixed.is_none() && !(gm_nontrans_c || skip_mode) { | |
| 19754 | + COMPOUND8_FILTER_HITS.with(|c| c.set(c.get() + 1)); | |
| 19755 | + } | |
| 19756 | + | |
| 19574 | 19757 | let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?; |
| 19575 | 19758 | let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?; |
| 19576 | 19759 | let scale0 = mc::scale_factor(py0.width, frame_width); |
| @@ -19580,6 +19763,54 @@ fn decode_inter_block8( | ||
| 19580 | 19763 | SCALED_BLOCK8_HITS.with(|c| c.set(c.get() + 1)); |
| 19581 | 19764 | } |
| 19582 | 19765 | |
| 19766 | + // lane-interp3 r2 (class twin-functions-drift): both slots | |
| 19767 | + // used to be stamped `false`, while [`decode_inter_block`]'s | |
| 19768 | + // compound arm computes libaom's PER-SLOT `is_global_mv_block` | |
| 19769 | + // (blockd.h:421-429 -- mode GLOBAL_GLOBALMV, block >= 8x8 | |
| 19770 | + // (always true for this leaf) and THAT slot's own gm model > | |
| 19771 | + // TRANSLATION). A neighbour carrying the flag makes | |
| 19772 | + // `setup_ref_mv_list` substitute the READER's global mv for | |
| 19773 | + // the neighbour's stored one, so a cleared flag fed the next | |
| 19774 | + // block's stack a stored mv where libaom has the global | |
| 19775 | + // candidate -- a wrong mv stack, wrong mode contexts, and a | |
| 19776 | + // desync one block later. | |
| 19777 | + let is_globalmv_c = compound_mode == 6; | |
| 19778 | + let is_global_mv0_c = is_globalmv_c | |
| 19779 | + && global_motion[(ref0 - LAST_FRAME) as usize].model as u8 > 1; | |
| 19780 | + let is_global_mv1_c = is_globalmv_c | |
| 19781 | + && global_motion[(ref1 - LAST_FRAME) as usize].model as u8 > 1; | |
| 19782 | + // lane-interp3 r3 (class twin-functions-drift, second | |
| 19783 | + // instance): libaom applies `allow_warp`'s GLOBAL branch | |
| 19784 | + // (`reconinter.c:33-55`, reached from `av1_init_warp_params` | |
| 19785 | + // inside `build_inter_predictors_8x8_and_bigger`'s per-`ref` | |
| 19786 | + // loop) to EVERY `is_global_mv_block` slot, compound | |
| 19787 | + // included and independently of `motion_mode` -- the 16x16+ | |
| 19788 | + // compound arm has done this since lane-cwarp r1, this leaf | |
| 19789 | + // predicted both taps translationally, so a GLOBAL_GLOBALMV | |
| 19790 | + // 8x8 compound leaf under a non-TRANSLATION model drifted by | |
| 19791 | + // a few luma levels, growing away from the block origin. | |
| 19792 | + // `force_integer_mv` short-circuits `av1_init_warp_params` | |
| 19793 | + // before `allow_warp`; chroma is 4x4 here, below | |
| 19794 | + // `av1_init_warp_params`'s own 8px per-plane bound, so only | |
| 19795 | + // luma warps (same rule as this leaf's single-ref arm). | |
| 19796 | + let leaf_compound_warp = |ref_frame: i8, eligible: bool| { | |
| 19797 | + if eligible | |
| 19798 | + && !force_integer_mv | |
| 19799 | + && !global_motion[(ref_frame - LAST_FRAME) as usize].invalid | |
| 19800 | + { | |
| 19801 | + crate::warp::global_warp_params( | |
| 19802 | + global_motion[(ref_frame - LAST_FRAME) as usize].params, | |
| 19803 | + ) | |
| 19804 | + } else { | |
| 19805 | + None | |
| 19806 | + } | |
| 19807 | + }; | |
| 19808 | + let warp0_c = leaf_compound_warp(ref0, is_global_mv0_c); | |
| 19809 | + let warp1_c = leaf_compound_warp(ref1, is_global_mv1_c); | |
| 19810 | + if warp0_c.is_some() || warp1_c.is_some() { | |
| 19811 | + COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1)); | |
| 19812 | + COMPOUND_WARP_HITS_8.with(|c| c.set(c.get() + 1)); | |
| 19813 | + } | |
| 19583 | 19814 | for dr in 0..2 { |
| 19584 | 19815 | for dc in 0..2 { |
| 19585 | 19816 | grid.set( |
| @@ -19594,19 +19825,14 @@ fn decode_inter_block8( | ||
| 19594 | 19825 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), |
| 19595 | 19826 | size: 2, |
| 19596 | 19827 | size_h: 2, |
| 19597 | - is_global_mv0: false, | |
| 19598 | - is_global_mv1: false, | |
| 19828 | + is_global_mv0: is_global_mv0_c, | |
| 19829 | + is_global_mv1: is_global_mv1_c, | |
| 19599 | 19830 | }, |
| 19600 | 19831 | ); |
| 19601 | 19832 | } |
| 19602 | 19833 | } |
| 19603 | 19834 | mode_for_tx = 0; |
| 19604 | 19835 | |
| 19605 | - // lane-av1comp corner-cut, matching this leaf's single-ref | |
| 19606 | - // arm below (`mc::predict`'s own fixed-Regular default): | |
| 19607 | - // `decode_inter_block8` never resolves a switchable filter, | |
| 19608 | - // so both compound taps use `Regular` too. | |
| 19609 | - use mc::InterpFilterKind::Regular; | |
| 19610 | 19836 | let mut inter0_y = vec![0i32; SIDE * SIDE]; |
| 19611 | 19837 | mc::predict_compound_intermediate( |
| 19612 | 19838 | &py0.data, |
| @@ -19618,10 +19844,17 @@ fn decode_inter_block8( | ||
| 19618 | 19844 | scale0, |
| 19619 | 19845 | SIDE, |
| 19620 | 19846 | SIDE, |
| 19621 | - Regular, | |
| 19622 | - Regular, | |
| 19847 | + h_filter, | |
| 19848 | + v_filter, | |
| 19623 | 19849 | &mut inter0_y, |
| 19624 | 19850 | ); |
| 19851 | + if let Some(wp) = &warp0_c { | |
| 19852 | + crate::warp::warp_affine_compound( | |
| 19853 | + wp, &py0.data, py0.true_width as i32, py0.true_height as i32, | |
| 19854 | + py0.width as i32, &mut inter0_y, px as i32, py as i32, SIDE as i32, | |
| 19855 | + SIDE as i32, SIDE as i32, 0, 0, | |
| 19856 | + ); | |
| 19857 | + } | |
| 19625 | 19858 | let mut inter1_y = vec![0i32; SIDE * SIDE]; |
| 19626 | 19859 | mc::predict_compound_intermediate( |
| 19627 | 19860 | &py1.data, |
| @@ -19633,10 +19866,17 @@ fn decode_inter_block8( | ||
| 19633 | 19866 | scale1, |
| 19634 | 19867 | SIDE, |
| 19635 | 19868 | SIDE, |
| 19636 | - Regular, | |
| 19637 | - Regular, | |
| 19869 | + h_filter, | |
| 19870 | + v_filter, | |
| 19638 | 19871 | &mut inter1_y, |
| 19639 | 19872 | ); |
| 19873 | + if let Some(wp) = &warp1_c { | |
| 19874 | + crate::warp::warp_affine_compound( | |
| 19875 | + wp, &py1.data, py1.true_width as i32, py1.true_height as i32, | |
| 19876 | + py1.width as i32, &mut inter1_y, px as i32, py as i32, SIDE as i32, | |
| 19877 | + SIDE as i32, SIDE as i32, 0, 0, | |
| 19878 | + ); | |
| 19879 | + } | |
| 19640 | 19880 | let mut pred_y = vec![0u16; SIDE * SIDE]; |
| 19641 | 19881 | let mut diffwtd_mask_y = Vec::new(); |
| 19642 | 19882 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { |
| @@ -19666,8 +19906,8 @@ fn decode_inter_block8( | ||
| 19666 | 19906 | scale0, |
| 19667 | 19907 | CHROMA_SIDE, |
| 19668 | 19908 | CHROMA_SIDE, |
| 19669 | - Regular, | |
| 19670 | - Regular, | |
| 19909 | + h_filter, | |
| 19910 | + v_filter, | |
| 19671 | 19911 | &mut inter0_u, |
| 19672 | 19912 | ); |
| 19673 | 19913 | let mut inter1_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -19681,8 +19921,8 @@ fn decode_inter_block8( | ||
| 19681 | 19921 | scale1, |
| 19682 | 19922 | CHROMA_SIDE, |
| 19683 | 19923 | CHROMA_SIDE, |
| 19684 | - Regular, | |
| 19685 | - Regular, | |
| 19924 | + h_filter, | |
| 19925 | + v_filter, | |
| 19686 | 19926 | &mut inter1_u, |
| 19687 | 19927 | ); |
| 19688 | 19928 | let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -19712,8 +19952,8 @@ fn decode_inter_block8( | ||
| 19712 | 19952 | scale0, |
| 19713 | 19953 | CHROMA_SIDE, |
| 19714 | 19954 | CHROMA_SIDE, |
| 19715 | - Regular, | |
| 19716 | - Regular, | |
| 19955 | + h_filter, | |
| 19956 | + v_filter, | |
| 19717 | 19957 | &mut inter0_v, |
| 19718 | 19958 | ); |
| 19719 | 19959 | let mut inter1_v = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -19727,8 +19967,8 @@ fn decode_inter_block8( | ||
| 19727 | 19967 | scale1, |
| 19728 | 19968 | CHROMA_SIDE, |
| 19729 | 19969 | CHROMA_SIDE, |
| 19730 | - Regular, | |
| 19731 | - Regular, | |
| 19970 | + h_filter, | |
| 19971 | + v_filter, | |
| 19732 | 19972 | &mut inter1_v, |
| 19733 | 19973 | ); |
| 19734 | 19974 | let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -19902,6 +20142,17 @@ fn decode_inter_block8( | ||
| 19902 | 20142 | &gm_table, |
| 19903 | 20143 | tpl, |
| 19904 | 20144 | ); |
| 20145 | + // lane-interp3 r2: same per-entry EC_STACK ladder | |
| 20146 | + // [`decode_inter_block`]'s single-ref arm prints, so this leaf's stack | |
| 20147 | + // diffs line for line against the oracle's. | |
| 20148 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | |
| 20149 | + for (i, e) in stack.entries.iter().enumerate() { | |
| 20150 | + eprintln!( | |
| 20151 | + "EC_STACK mi_row={mi_row} mi_col={mi_col} ref={ref_frame} i={i} this=({},{}) comp=(0,0) w={}", | |
| 20152 | + e.mv.0, e.mv.1, e.weight | |
| 20153 | + ); | |
| 20154 | + } | |
| 20155 | + } | |
| 19905 | 20156 | |
| 19906 | 20157 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| 19907 | 20158 | let mut is_globalmv = false; |
| @@ -22969,6 +23220,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 22969 | 23220 | // that isolate whether a decode-order frame's mismatch already exists |
| 22970 | 23221 | // in reconstruction (this dump) vs is introduced by the loop filter |
| 22971 | 23222 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). |
| 23223 | + // Decode-order frame marker for the EC_OBMC / EC_TRACE_MODE ladders. | |
| 23224 | + if std::env::var_os("EC_OBMC").is_some() || std::env::var_os("EC_TRACE_MODE").is_some() { | |
| 23225 | + eprintln!( | |
| 23226 | + "EC_PICT idx={}", | |
| 23227 | + PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) | |
| 23228 | + ); | |
| 23229 | + } | |
| 22972 | 23230 | dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 22973 | 23231 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { |
| 22974 | 23232 | use std::io::Write; |
| @@ -23339,6 +23597,30 @@ mod tests { | ||
| 23339 | 23597 | /// always cleared to `None` by `record_inter`, so the next block's own |
| 23340 | 23598 | /// `NeighbourRef::uni` -- and `comp_reference_type_ctx` downstream of it |
| 23341 | 23599 | /// -- could never see a real compound neighbour). |
| 23600 | + /// lane-interp3 r1: a decoder must never abort the process on | |
| 23601 | + /// stream-derived state. `neighbour_filter` used to feed the `[3, 3]` | |
| 23602 | + /// "no filter recorded" sentinel straight into | |
| 23603 | + /// `InterpFilterKind::from_switchable_symbol`, whose `panic!` ("...alphabet | |
| 23604 | + /// is exactly 3 symbols") crashed on a real aomenc dual-filter + OBMC | |
| 23605 | + /// stream. It now refuses by name; the real symbols still decode. | |
| 23606 | + #[test] | |
| 23607 | + fn an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking() { | |
| 23608 | + assert!( | |
| 23609 | + neighbour_filter(None, [3, 3]) | |
| 23610 | + .unwrap_err() | |
| 23611 | + .to_string() | |
| 23612 | + .contains("an OBMC neighbour whose interp filter was never recorded"), | |
| 23613 | + "the [3, 3] sentinel must refuse by name, never panic" | |
| 23614 | + ); | |
| 23615 | + assert!(neighbour_filter(None, [3, 0]).is_err()); | |
| 23616 | + let (h, v) = neighbour_filter(None, [0, 2]).expect("real symbols decode"); | |
| 23617 | + assert_eq!(h, mc::InterpFilterKind::Sharp, "sym[1] is the horizontal kernel"); | |
| 23618 | + assert_eq!(v, mc::InterpFilterKind::Regular, "sym[0] is the vertical kernel"); | |
| 23619 | + let (h, v) = neighbour_filter(Some(mc::InterpFilterKind::Smooth), [3, 3]) | |
| 23620 | + .expect("a fixed-filter frame never reads a symbol"); | |
| 23621 | + assert_eq!((h, v), (mc::InterpFilterKind::Smooth, mc::InterpFilterKind::Smooth)); | |
| 23622 | + } | |
| 23623 | + | |
| 23342 | 23624 | #[test] |
| 23343 | 23625 | fn record_compound_ctx_stamps_ref1_for_the_next_block_to_read() { |
| 23344 | 23626 | let mut n = Neighbours::new(4, 4, 16, 16); |
crates/ec-av1/src/refusal_inventory.rsmodified+1 -0
| @@ -33,6 +33,7 @@ const REFUSALS: &[&str] = &[ | ||
| 33 | 33 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 34 | 34 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", |
| 35 | 35 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", |
| 36 | + "an OBMC neighbour whose interp filter was never recorded (no switchable symbol for that block)", | |
| 36 | 37 | "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", |
| 37 | 38 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 38 | 39 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
crates/ec-av1/src/stream.rsmodified+92 -2
| @@ -6466,6 +6466,9 @@ mod tests { | ||
| 6466 | 6466 | // aomenc silently codes one tile column and the arm is vacuous. |
| 6467 | 6467 | extra: &[&str], |
| 6468 | 6468 | width: usize, |
| 6469 | + // lane-interp3 r1: sequence length -- a compound block needs several | |
| 6470 | + // already-coded references, which a 4-frame sequence never has. | |
| 6471 | + frame_count: usize, | |
| 6469 | 6472 | ) { |
| 6470 | 6473 | if !have_ffmpeg() { |
| 6471 | 6474 | eprintln!("SKIP {name}: no ffmpeg"); |
| @@ -6475,7 +6478,8 @@ mod tests { | ||
| 6475 | 6478 | eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); |
| 6476 | 6479 | return; |
| 6477 | 6480 | } |
| 6478 | - let (height, frame_count) = (64usize, 4usize); | |
| 6481 | + let height = 64usize; | |
| 6482 | + let duration = format!("{:.2}", frame_count as f64 / 25.0); | |
| 6479 | 6483 | // A deterministic synthetic source with real motion (a static source |
| 6480 | 6484 | // codes every inter frame as skip and never exercises the residual |
| 6481 | 6485 | // path); bounded with `-t` (class gate-loader-slurps-whole-file). |
| @@ -6488,7 +6492,7 @@ mod tests { | ||
| 6488 | 6492 | "-i", |
| 6489 | 6493 | &format!("mandelbrot=size={width}x{height}:rate=25"), |
| 6490 | 6494 | "-t", |
| 6491 | - "0.16", | |
| 6495 | + &duration, | |
| 6492 | 6496 | "-pix_fmt", |
| 6493 | 6497 | if ten_bit { "yuv420p10le" } else { "yuv420p" }, |
| 6494 | 6498 | // y4m calls 10-bit unofficial (same as the 10-bit key-frame |
| @@ -6615,6 +6619,7 @@ mod tests { | ||
| 6615 | 6619 | "whole-superblock inter PARTITION_NONE", |
| 6616 | 6620 | &[], |
| 6617 | 6621 | 64, |
| 6622 | + 4, | |
| 6618 | 6623 | ); |
| 6619 | 6624 | } |
| 6620 | 6625 | |
| @@ -6629,6 +6634,7 @@ mod tests { | ||
| 6629 | 6634 | "whole-superblock inter PARTITION_NONE", |
| 6630 | 6635 | &[], |
| 6631 | 6636 | 64, |
| 6637 | + 4, | |
| 6632 | 6638 | ); |
| 6633 | 6639 | } |
| 6634 | 6640 | |
| @@ -6671,6 +6677,88 @@ mod tests { | ||
| 6671 | 6677 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", |
| 6672 | 6678 | &["--tile-columns=1"], |
| 6673 | 6679 | 128, |
| 6680 | + 4, | |
| 6681 | + ); | |
| 6682 | + } | |
| 6683 | + | |
| 6684 | + /// lane-interp3 r1: the same 8x8-leaf recipe with DUAL FILTER, OBMC and | |
| 6685 | + /// warped motion on. `read_mb_interp_filter` runs for every inter block | |
| 6686 | + /// (libaom `decodemv.c` 1575), compound ones included; the compound 8x8 | |
| 6687 | + /// leaf skipped it entirely, so a SWITCHABLE-filter stream lost a symbol | |
| 6688 | + /// per compound leaf and stamped the `[3, 3]` "no filter" sentinel, which | |
| 6689 | + /// made a neighbouring OBMC block's `neighbour_filter` PANIC (a crash on | |
| 6690 | + /// his data, not a named refusal). The three hard asserts prove the flags | |
| 6691 | + /// arrived: a compound 8x8 leaf that really read the filter, a block whose | |
| 6692 | + /// two dual-filter directions DIFFER (impossible with dual filter off), | |
| 6693 | + /// and an 8x8 OBMC blend. | |
| 6694 | + // lane-interp3 r2: the ENTROPY desync r1 measured is CLOSED -- the full | |
| 6695 | + // 16-frame stream now parses end to end and every `EC_MODE`/`EC_MODE_VAL` | |
| 6696 | + // element's msac RANGE matches the instrumented aomdec's line for line | |
| 6697 | + // (570/570 mode elements, 0 diff). Two twin-drift root causes, both in | |
| 6698 | + // `decode_inter_block8`'s compound arm: `read_compound_ref_frames` was | |
| 6699 | + // passed a hard-coded `LAST_FRAME` for every inter neighbour instead of | |
| 6700 | + // the real per-mi band, and the grid stamp cleared both per-slot | |
| 6701 | + // `is_global_mv_block` flags. | |
| 6702 | + // lane-interp3 r3: the luma reconstruction residue r2 left open is CLOSED | |
| 6703 | + // and this gate is GREEN. Third instance of the same twin-drift class: | |
| 6704 | + // libaom applies `allow_warp`'s GLOBAL branch to every | |
| 6705 | + // `is_global_mv_block` reference slot, compound included and independent | |
| 6706 | + // of `motion_mode` (`av1_init_warp_params` inside | |
| 6707 | + // `build_inter_predictors_8x8_and_bigger`'s per-`ref` loop) -- the 16x16+ | |
| 6708 | + // compound arm has warped since lane-cwarp r1, the 8x8 leaf's compound arm | |
| 6709 | + // predicted BOTH taps translationally, so a GLOBAL_GLOBALMV 8x8 compound | |
| 6710 | + // leaf under a non-TRANSLATION model drifted a few luma levels, growing | |
| 6711 | + // away from the block origin. It was NOT OBMC: the `EC_OBMC` emitter this | |
| 6712 | + // round added to `decode.rs` diffs 325/325 lines against the instrumented | |
| 6713 | + // aomdec's own rung (position, span, neighbour mv/ref/bsize/filter) with | |
| 6714 | + // zero differences. | |
| 6715 | + #[test] | |
| 6716 | + fn a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact() { | |
| 6717 | + const NAME: &str = | |
| 6718 | + "a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact"; | |
| 6719 | + if !have_ffmpeg() || !have_aomenc() { | |
| 6720 | + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); | |
| 6721 | + return; | |
| 6722 | + } | |
| 6723 | + let before_dual = decode::dual_filter_diff_hits(); | |
| 6724 | + let before_obmc = decode::obmc_hits_8(); | |
| 6725 | + let before_cwarp8 = decode::compound_warp_hits_8(); | |
| 6726 | + inter_sb_none_gate( | |
| 6727 | + NAME, | |
| 6728 | + false, | |
| 6729 | + "8", | |
| 6730 | + "16", | |
| 6731 | + decode::compound8_filter_hits, | |
| 6732 | + "a compound 8x8 leaf reading its own switchable interp_filter", | |
| 6733 | + &[ | |
| 6734 | + "--enable-dual-filter=1", | |
| 6735 | + "--enable-obmc=1", | |
| 6736 | + "--enable-warped-motion=1", | |
| 6737 | + "--enable-onesided-comp=1", | |
| 6738 | + ], | |
| 6739 | + 64, | |
| 6740 | + // Recipe search hook (same shape as EC_OBMC8_ATTEMPTS): a compound | |
| 6741 | + // block needs several coded references, so the sequence is longer | |
| 6742 | + // than the other arms' 4 frames. | |
| 6743 | + std::env::var("EC_INTERP3_FRAMES") | |
| 6744 | + .ok() | |
| 6745 | + .and_then(|v| v.parse().ok()) | |
| 6746 | + .unwrap_or(16), | |
| 6747 | + ); | |
| 6748 | + assert!( | |
| 6749 | + decode::dual_filter_diff_hits() > before_dual, | |
| 6750 | + "{NAME}: no block read two DIFFERENT dual-filter directions -- \ | |
| 6751 | + --enable-dual-filter=1 did not arrive or aomenc declined it" | |
| 6752 | + ); | |
| 6753 | + assert!( | |
| 6754 | + decode::obmc_hits_8() > before_obmc, | |
| 6755 | + "{NAME}: no 8x8 OBMC blend fired -- --enable-obmc=1 did not arrive" | |
| 6756 | + ); | |
| 6757 | + assert!( | |
| 6758 | + decode::compound_warp_hits_8() > before_cwarp8, | |
| 6759 | + "{NAME}: no 8x8 COMPOUND leaf was predicted through the per-ref GLOBAL \ | |
| 6760 | + warp -- the r3 root-cause path never fired, so this stream no longer \ | |
| 6761 | + proves it" | |
| 6674 | 6762 | ); |
| 6675 | 6763 | } |
| 6676 | 6764 | |
| @@ -6685,6 +6773,7 @@ mod tests { | ||
| 6685 | 6773 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", |
| 6686 | 6774 | &[], |
| 6687 | 6775 | 64, |
| 6776 | + 4, | |
| 6688 | 6777 | ); |
| 6689 | 6778 | } |
| 6690 | 6779 | |
| @@ -6708,6 +6797,7 @@ mod tests { | ||
| 6708 | 6797 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", |
| 6709 | 6798 | &[], |
| 6710 | 6799 | 64, |
| 6800 | + 4, | |
| 6711 | 6801 | ); |
| 6712 | 6802 | } |
| 6713 | 6803 |
lanes/interp3-r1.report.mdadded+96 -0
| @@ -0,0 +1,96 @@ | ||
| 1 | +# lane-interp3 r1 -- the `switchable_interp` PANIC: the compound 8x8 leaf never read its filter | |
| 2 | + | |
| 3 | +## Root cause (cited) | |
| 4 | + | |
| 5 | +libaom `decodemv.c:1575` (`read_inter_block_mode_info`) calls `read_mb_interp_filter` | |
| 6 | +for **every** inter block, compound ones included, right after `read_compound_type`. | |
| 7 | +`decode_leaf8`'s COMPOUND arm (`crates/ec-av1/src/decode.rs`, the branch that returns at | |
| 8 | +the old line 19589) called `resolve_interp_filter` **not at all**: it predicted both taps | |
| 9 | +with a hard-coded `Regular` and returned the `[3, 3]` "no filter recorded" sentinel as the | |
| 10 | +leaf's `leaf_filter_syms`. Two consequences, both real on his data: | |
| 11 | + | |
| 12 | +1. **Entropy**: on a `SWITCHABLE`-filter frame one symbol (two under `enable_dual_filter`) | |
| 13 | + is left unread at every compound 8x8 leaf -- silent desync. | |
| 14 | +2. **Crash**: the sentinel is stamped into `Neighbours::above_filter`/`left_filter`, and a | |
| 15 | + neighbouring OBMC block's `neighbour_filter` fed it to | |
| 16 | + `mc::InterpFilterKind::from_switchable_symbol`, whose `panic!("switchable_interp's | |
| 17 | + alphabet is exactly 3 symbols")` aborted the process. That is the panic lane-r14 r3 | |
| 18 | + flagged (its `--enable-dual-filter=1 --enable-obmc=1` 192x128 cq30 stream). The same | |
| 19 | + shape was already fixed once for the SINGLE-ref 8x8 leaf (lane-gmaffine r3, decode.rs | |
| 20 | + ~21509 comment) -- the compound arm was the surviving sibling instance. | |
| 21 | + | |
| 22 | +## Changed | |
| 23 | + | |
| 24 | +- `crates/ec-av1/src/decode.rs` (compound 8x8 leaf, after the `comp_group_idx`/ | |
| 25 | + `compound_idx` reads): reads `interp_filter` in libaom's order, with `get_ref_filter_type` | |
| 26 | + neighbour contexts keyed on `ref0` and `is_compound = true`; suppression term is | |
| 27 | + `skip_mode || is_nontrans_global_motion` (GLOBAL_GLOBALMV + both refs' models non- | |
| 28 | + TRANSLATION; WARPED_CAUSAL cannot occur on compound). The 12 `predict_compound_intermediate` | |
| 29 | + taps now use the resolved `h_filter`/`v_filter` instead of `Regular`. | |
| 30 | +- `crates/ec-av1/src/decode.rs` `neighbour_filter`: returns `Result`; the `[3, 3]` sentinel | |
| 31 | + is now the named refusal `an OBMC neighbour whose interp filter was never recorded (no | |
| 32 | + switchable symbol for that block)` -- **never a panic**. Both OBMC call sites `?` it. | |
| 33 | +- `crates/ec-av1/src/decode.rs`: counters `DUAL_FILTER_DIFF_HITS` (a block whose two | |
| 34 | + dual-filter directions differ -- impossible with dual filter off) and | |
| 35 | + `COMPOUND8_FILTER_HITS`. | |
| 36 | +- `crates/ec-av1/src/refusal_inventory.rs`: the new refusal listed (inventory test green). | |
| 37 | +- `crates/ec-av1/src/stream.rs`: `inter_sb_none_gate` takes a `frame_count` | |
| 38 | + (4 frames never code a compound block); new gate | |
| 39 | + `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | |
| 40 | + (`--enable-dual-filter=1 --enable-obmc=1 --enable-warped-motion=1 --enable-onesided-comp=1` | |
| 41 | + on the `--min-partition-size=8 --enable-ab-partitions=0 --enable-1to4-partitions=0` | |
| 42 | + recipe, every frame compared Y/U/V vs ffmpeg, hard asserts on all three counters). | |
| 43 | +- `crates/ec-av1/src/decode.rs` test | |
| 44 | + `an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking`. | |
| 45 | + | |
| 46 | +## Gate: RED, `#[ignore]`d with the measurement, not deleted | |
| 47 | + | |
| 48 | +`EC_INTERP3_FRAMES=4` -> aomenc codes no compound block, stream decodes. | |
| 49 | +From 5 frames on it does, and the decode stops at a refusal that the recipe makes | |
| 50 | +impossible: `an inter 16x16-level AB or 1:4 partition` WITH this round's filter read, and | |
| 51 | +`an inter partition below 8x8` WITHOUT it (measured by ablating the read behind a temporary | |
| 52 | +env switch, since removed). `--enable-ab-partitions=0 --enable-1to4-partitions=0 | |
| 53 | +--min-partition-size=8` cannot emit either -- so both are our own desync | |
| 54 | +(class `refusal-from-own-desync`): the compound 8x8 leaf carries at least one more | |
| 55 | +missing/misplaced symbol beyond the interp filter. The fix is therefore **necessary but not | |
| 56 | +sufficient** and is not claimed as pixel-proven. | |
| 57 | + | |
| 58 | +EVIDENCE: $HOME/.cache/interp3-suite-r1.log | `cargo test -p ec-av1 --lib -j3` under a | |
| 59 | +systemd user unit, MemoryMax=10G | totals below | |
| 60 | +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 | |
| 61 | +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 | |
| 62 | + | |
| 63 | +## Panic sweep of the decode path (charter clause) | |
| 64 | + | |
| 65 | +`neighbour_filter` was the only `panic!` reachable from a *stream-derived value* on the OBMC | |
| 66 | +path; converted. The rest of `decode.rs`'s 57 `panic!/unreachable!/unwrap/expect` sites, | |
| 67 | +inspected: `2733, 11268, 11617, 11636, 11683, 11996, 12015, 12052, 13820, 13998, 15225, | |
| 68 | +15533` are `unreachable!` on values a CDF alphabet or an earlier refusal already bounds | |
| 69 | +(cannot fire on any stream); `5238, 5282, 6043, 6110, 7310, 7311, 7777, 7778, 10479, 10535, | |
| 70 | +10679, 10888` are `unwrap/expect` on this decoder's own just-built state; everything above | |
| 71 | +line 22700 is inside `#[cfg(test)]`. Two remain flagged, not converted (they need a `Result` | |
| 72 | +in a counter/table helper and no stream is known to reach them): | |
| 73 | +`decode.rs:2486` `panic!("ref_hits: no per-reference counter for ref_frame {other}")` and | |
| 74 | +`decode.rs:3247` `panic!("intra mode {other} has no Intra_Mode_To_Tx_Type entry")`. | |
| 75 | +`mc.rs:203`/`:220` stay as documented invariants -- both callers now check first. | |
| 76 | + | |
| 77 | +## Residue | |
| 78 | + | |
| 79 | +- fix-now(next round): the remaining compound-8x8 desync. Method: `EC_TRACE=1` aomdec range | |
| 80 | + ladder against ours on the FIRST compound leaf of frame 5 of the gate's stream, comparing | |
| 81 | + msac RANGE element by element (never `tell()`). | |
| 82 | +- deferred(needs that fix): the 10-bit arm of the new gate, and the counter-proving | |
| 83 | + pixel-exact claim. | |
| 84 | + | |
| 85 | +## Suite | |
| 86 | + | |
| 87 | +`systemd-run --user --unit=interp3-suite-r1 -p MemoryMax=10G --same-dir bash -lc 'EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interp3 nice -n 10 cargo test -p ec-av1 --lib -j3 > $HOME/.cache/interp3-suite-r1.log 2>&1'` | |
| 88 | + | |
| 89 | +**372 passed; 0 failed; 33 ignored; 1208.18s** (main's 371/0/32 plus this round's | |
| 90 | +`an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking`, plus the new | |
| 91 | +gate ignored). Every OBMC/compound sibling gate green on this tip, including | |
| 92 | +`a_real_aomenc_stream_with_obmc_decodes_pixel_exact`, | |
| 93 | +`a_real_aomenc_stream_with_obmc_8x8_decodes_pixel_exact`, | |
| 94 | +`a_real_aomenc_stream_with_compound_references_decodes_pixel_exact`, | |
| 95 | +`a_real_aomenc_superres_stream_with_compound_obmc_and_interintra_decodes_pixel_exact` | |
| 96 | +and both `..._8x8_leaf_split_...` arms -- the entropy change did not move any of them. |
lanes/interp3-r2.handoff.mdadded+48 -0
| @@ -0,0 +1,48 @@ | ||
| 1 | +# lane-interp3 r2 HANDOFF (turn cap) | |
| 2 | + | |
| 3 | +Tip: see `git log -1` on branch `lane-interp3` (r2 fix commit + report commit). | |
| 4 | +Base: r1 b702853 + `git merge main` (4eff3a1, lane-mvtwin mvstack fixes). Merge touched | |
| 5 | +only mvstack.rs / stream.rs / lanes/mvtwin-r1.report.md; cdf.rs untouched both sides. | |
| 6 | + | |
| 7 | +## Phase table + divergences: see lanes/interp3-r2.report.md (complete, 17 rows) | |
| 8 | +Two divergences found in `decode_inter_block8`'s compound arm, both FIXED: | |
| 9 | +1. decode.rs:19151 `read_compound_ref_frames` got a hard-coded `LAST_FRAME` (or -1) | |
| 10 | + for the above/left neighbour reference instead of the real per-mi bands | |
| 11 | + (`above_ref0`/`left_ref0`, what `decode_inter_block` passes) -> every | |
| 12 | + `av1_collect_neighbors_ref_counts` vote off the wrong CDF row. | |
| 13 | +2. decode.rs:19410 the leaf's grid stamp cleared BOTH per-slot `is_global_mv_block` | |
| 14 | + flags; now computed as libaom blockd.h:421-429 (mode GLOBAL_GLOBALMV + that slot's | |
| 15 | + gm model > TRANSLATION). | |
| 16 | +Also added: decode.rs:19726 per-entry `EC_STACK` print in the leaf's SINGLE-ref arm. | |
| 17 | + | |
| 18 | +## Ladder (EC_TRACE_MODE=1, ours vs instrumented aomdec, RANGE never tell) | |
| 19 | +- Before fix 1, frames=5 stream: first divergence at compound leaf mi (10,2) -- | |
| 20 | + both enter the mode info at rng=61097; aomdec reads refs (LAST,GOLDEN) mode | |
| 21 | + NEAREST_NEARESTMV -> rng 49516; ours read (LAST,LAST2) NEW_NEWMV -> rng 50496. | |
| 22 | +- Before fix 2, frames=16 stream: first divergence at single-ref 8x8 leaf mi (8,8), | |
| 23 | + entry rng=43099 both; aomdec stack = [(-1,-1) w648, (0,0) w644] (2 entries), | |
| 24 | + ours = [(0,0) w644, (2,-4) w644, (-1,-1) w4] (3) -- the extra (2,-4) is the | |
| 25 | + neighbour's stored mv1 where libaom substitutes the reader's global mv. | |
| 26 | +- AFTER both fixes: 570 vs 570 mode elements, `diff` EMPTY, no refusal. | |
| 27 | + | |
| 28 | +## Gate state | |
| 29 | +`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` still | |
| 30 | +`#[ignore]`d (ignore text updated with this measurement). Now RED on RECONSTRUCTION, | |
| 31 | +not entropy: luma-only, frames 0-6 byte-exact, frame 7 = 36 Y wrong (max |d| 5, first | |
| 32 | +(42,15), the 8x8 leaf at mi (10,4), 1-px spill across its left/bottom deblock edges), | |
| 33 | +propagating to 222 Y + 4 U + 1 V at frame 15. | |
| 34 | +Artifacts: scratchpad .../{pin.obu (5 frames), pin16.obu==mm.obu (16), aom16.trace, | |
| 35 | +ours16e.trace, mm.aom.yuv, mm.ours.yuv, aom.obmc}. | |
| 36 | + | |
| 37 | +## Suite | |
| 38 | +Unit `interp3-suite-r2-1788327820.service`, log `$HOME/.cache/interp3-suite-r2.log`. | |
| 39 | +Armed at the r2 fix commit; still running at the cap -- read the log's `test result:` | |
| 40 | +line, do not re-run blindly. | |
| 41 | + | |
| 42 | +## EXACT NEXT STEP | |
| 43 | +Build an `EC_OBMC` emitter in decode.rs (both OBMC call sites) printing the oracle's | |
| 44 | +own byte format -- `EC_OBMC above|left mi=(r,c) wh=(WxH) rel=%d op=%d nbmv=(y,x) | |
| 45 | +nbref=%d nbbsize=%d filt=%d` -- then diff it against the 325 lines of | |
| 46 | +`EC_OBMC=1 aomdec --rawvideo -o /dev/null mm.obu`, starting at `mi=(10,4)`. The leaf | |
| 47 | +now records a REAL filter pair where it used to record the [3,3] sentinel, so an OBMC | |
| 48 | +blend over a compound neighbour is the first suspect for the residue. |
lanes/interp3-r2.report.mdadded+88 -0
| @@ -0,0 +1,88 @@ | ||
| 1 | +# lane-interp3 r2 -- the compound 8x8 leaf's ENTROPY desync is closed (two twin drifts); gate now RED on a small luma reconstruction residue | |
| 2 | + | |
| 3 | +Base: b702853 (r1) + `git merge main` (4eff3a1, brings lane-mvtwin's mvstack fixes). | |
| 4 | +Merge diffstat: `crates/ec-av1/src/mvstack.rs`, `crates/ec-av1/src/stream.rs`, | |
| 5 | +`lanes/mvtwin-r1.report.md` only -- `cdf.rs` untouched by either side (byte-compare | |
| 6 | +trivially clean), no fixtures churn, no conflicts. | |
| 7 | + | |
| 8 | +## Phase table -- libaom `read_inter_block_mode_info` (decodemv.c ~1400-1600) | |
| 9 | + | |
| 10 | +`IB` = `decode_inter_block` compound arm, `L8` = `decode_inter_block8` compound arm | |
| 11 | +(both in `crates/ec-av1/src/decode.rs`; line numbers are this commit's). | |
| 12 | + | |
| 13 | +| # | phase (libaom) | IB | L8 | verdict | | |
| 14 | +|---|---|---|---|---| | |
| 15 | +| 1 | `skip_mode` (ctx = above+left skip_mode) | 16363 | 19087 | matches | | |
| 16 | +| 2 | `skip` | 16375 | 19093 | matches | | |
| 17 | +| 3 | cdef / delta_q / delta_lf | 16377-16382 | (16x16 slot's, per this fn's doc) | matches (leaf never a delta root) | | |
| 18 | +| 4 | `is_inter` (`intra_inter_ctx`) | 16389 | 19105 | matches | | |
| 19 | +| 5 | `comp_mode` (`read_comp_mode`, ref-count ctx) | 16475 | 19147 | matches (`skip_mode \|\| (reference_select && ...)` vs `reference_select \|\| skip_mode` then `skip_mode \|\| ...` -- same predicate) | | |
| 20 | +| 6 | `read_ref_frames`: `comp_ref_type`, uni/bi trees | 16480 | 19151 | **DIFFERENT -> FIXED**: L8 passed a hard-coded `LAST_FRAME` (or `-1`) as the above/left reference; IB passes the real `neighbours.above_ref[cmi]`/`left_ref[rmi]` | | |
| 21 | +| 7 | `av1_find_mv_refs` (`find_mv_stack_compound`, sign bias + gm table + tpl) | 16519 | 19195 | matches (L8's doc comment claiming "no sign-bias table nor tpl_frame" is stale -- both are passed) | | |
| 22 | +| 8 | `compound_mode` CDF (`COMPOUND_MODE_CTX_MAP`) | 16532 | 19205 | matches | | |
| 23 | +| 9 | drl + `read_mv` per ref (`assign_compound_mv`, has_nearmv/have_newmv rules) | 16537 | 19226 | matches (one shared fn) | | |
| 24 | +| 10 | `interintra` | n/a compound | n/a | matches (never read on compound -- correct) | | |
| 25 | +| 11 | `read_motion_mode` | n/a compound | n/a | matches (`has_second_ref` -> SIMPLE_TRANSLATION) | | |
| 26 | +| 12 | `comp_group_idx` (neighbour ctx) | 16675 | 19263 | matches | | |
| 27 | +| 13 | `compound_type` -> wedge idx+sign / diffwtd `mask_type` | 16710 | 19279 | matches | | |
| 28 | +| 14 | `compound_idx` (distance-weight ctx) | 16936 | 19310 | matches | | |
| 29 | +| 15 | `read_mb_interp_filter` (after `read_compound_type`; suppressed by `skip_mode` / `is_nontrans_global_motion`; `get_ref_filter_type` on ref0 matching EITHER neighbour ref) | 16980 | 19383 | matches (landed r1) | | |
| 30 | +| 16 | tail: grid `MiInfo` stamp -- per-slot `is_global_mv_block` | 16577+16660 | 19424 | **DIFFERENT -> FIXED**: L8 stamped `is_global_mv0/1 = false` unconditionally | | |
| 31 | +| 17 | tail: `record_inter_rect_mi` + `record_compound_ctx_rect_mi` (skip/skip_mode/inter/ref/ref1/filter/comp_group_idx/compound_idx bands) | 18870 | via `compound_ctx8` + caller, 19000 | matches -- verified by the range ladder staying exact for the whole stream | | |
| 32 | + | |
| 33 | +Root causes 6 and 16 are the round's fix. Both are the same class the charter named | |
| 34 | +(twin functions drift), and both are invisible to any value-only check: (6) changes a | |
| 35 | +CDF ROW, (16) changes a LATER block's mv-stack composition. | |
| 36 | + | |
| 37 | +## Changed (path:line) | |
| 38 | + | |
| 39 | +- `crates/ec-av1/src/decode.rs:19151` -- `read_compound_ref_frames` now gets | |
| 40 | + `above_ref0`/`left_ref0` (the per-mi bands the leaf already reads at 19078-19081) | |
| 41 | + instead of `LAST_FRAME`/`-1`. `-1` on an unavailable band is `start_tile`'s / | |
| 42 | + `start_row`'s own reset value, so no `has_above` guard is needed (IB has none either). | |
| 43 | +- `crates/ec-av1/src/decode.rs:19410` -- the leaf's grid stamp computes libaom's | |
| 44 | + per-slot `is_global_mv_block` (mode `GLOBAL_GLOBALMV`, that slot's gm model > | |
| 45 | + TRANSLATION; the >= 8x8 size predicate is always true for this leaf). | |
| 46 | +- `crates/ec-av1/src/decode.rs:19726` -- the leaf's SINGLE-ref arm prints the same | |
| 47 | + per-entry `EC_STACK` ladder `decode_inter_block`'s single-ref arm prints (this is | |
| 48 | + the instrument that isolated cause 16). | |
| 49 | +- `crates/ec-av1/src/stream.rs:6315` -- the gate's ignore reason + comment replaced | |
| 50 | + with this round's measurement (entropy closed, pixel residue open). | |
| 51 | + | |
| 52 | +## Gate: still RED, still `#[ignore]`d -- but on a different, much smaller failure | |
| 53 | + | |
| 54 | +`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | |
| 55 | +(`--enable-dual-filter=1 --enable-obmc=1 --enable-warped-motion=1 | |
| 56 | +--enable-onesided-comp=1`, `--min-partition-size=8 --enable-ab-partitions=0 | |
| 57 | +--enable-1to4-partitions=0`, 16 frames, 64x64). | |
| 58 | + | |
| 59 | +- r1: decode STOPPED at a bogus refusal at frame 5 (0 frames ever compared). | |
| 60 | +- r2: the whole 16-frame stream parses; the failure is now | |
| 61 | + `frame 7 mismatch vs ffmpeg` -- a reconstruction residue, luma-only, | |
| 62 | + |delta| <= 8, first sample (42,15) inside/around the 8x8 leaf at mi (10,4), | |
| 63 | + spilling 1 px across that leaf's left and bottom deblock edges. It grows by pure | |
| 64 | + propagation to 222 Y + 4 U + 1 V samples at frame 15 (chroma stays exact until | |
| 65 | + frame 14). | |
| 66 | + | |
| 67 | +EVIDENCE: /tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/b6d8a07f-96a4-4bbb-b378-af9ae25cf7c9/scratchpad/{aom16.trace,ours16e.trace} | `EC_TRACE_MODE=1 aomdec --rawvideo` and `EC_TRACE_MODE=1 decode_probe` on the pinned 16-frame stream, `diff` of every `EC_MODE`/`EC_MODE_VAL` line (mi + msac RANGE, never tell) | 570 vs 570 elements, diff EMPTY, no refusal (before the fix: ours stopped at 347 elements, first RANGE divergence at the 8x8 leaf mi (8,8), stack 3 entries vs libaom's 2) | |
| 68 | +EVIDENCE: same dir, `pin.obu` (EC_INTERP3_FRAMES=5) | ladder before fix 1 | ours read refs (LAST,LAST2) + NEW_NEWMV at leaf mi (10,2) where aomdec reads (LAST,GOLDEN) + NEAREST_NEARESTMV -- the two differ only in a CDF row of `uni_comp_ref` | |
| 69 | +EVIDENCE: same dir, `mm.{aom,ours}.yuv` | `aomdec --rawvideo` vs `decode_probe` on the pinned mismatch stream, per-frame per-plane sample compare | frames 0-6 byte-exact; frame 7: 36 Y / 0 U / 0 V wrong, max |delta| 5; frame 15: 222 Y / 4 U / 1 V, max |delta| 8 | |
| 70 | + | |
| 71 | +## Refusals | |
| 72 | + | |
| 73 | +None lifted this round (the r1 refusal `an OBMC neighbour whose interp filter was | |
| 74 | +never recorded` stays; `refusal_inventory` unchanged). Two refusals this stream used | |
| 75 | +to hit -- `an inter 16x16-level AB or 1:4 partition` and `an inter partition below | |
| 76 | +8x8` -- were our own desync (class refusal-from-own-desync) and no longer fire on it. | |
| 77 | + | |
| 78 | +## Residue | |
| 79 | + | |
| 80 | +- fix-now(next round): the luma reconstruction residue above. First suspect is the | |
| 81 | + OBMC blend over a COMPOUND neighbour -- the leaf now records a real filter pair | |
| 82 | + where it used to record the `[3,3]` sentinel, and the oracle's `EC_OBMC` rung | |
| 83 | + prints `nbmv`/`nbref`/`nbbsize`/`filt` per neighbour while THIS decoder has no | |
| 84 | + `EC_OBMC` emitter at all. Build that emitter first (instrument-before-excuse), then | |
| 85 | + diff the 325 oracle `EC_OBMC` lines of `mm.obu` against ours. | |
| 86 | +- deferred(needs that fix): the gate's counter asserts (compound-8x8 filter reads, | |
| 87 | + dual-filter differing directions, 8x8 OBMC blends) are never reached while the | |
| 88 | + pixel compare fails first; the 10-bit arm; a `--tile-columns=1` arm. |
lanes/interp3-r3.handoff.mdadded+88 -0
| @@ -0,0 +1,88 @@ | ||
| 1 | +# lane-interp3 r3 HANDOFF (turn cap) -- root cause FOUND and FIXED, suite still running | |
| 2 | + | |
| 3 | +Tip: `f36be26` on branch `lane-interp3` (fix) + this handoff/report commit. | |
| 4 | + | |
| 5 | +## Suite state | |
| 6 | +- r2 suite (unit `interp3-suite-r2-1788327820.service`, log `$HOME/.cache/interp3-suite-r2.log`), | |
| 7 | + armed at the r2 commit, FINISHED: | |
| 8 | + `test result: ok. 378 passed; 0 failed; 34 ignored; 0 measured; 0 filtered out; finished in 742.50s` | |
| 9 | +- r3 suite FINISHED GREEN at f36be26 (unit `interp3-suite-r3-1788328778.service`): | |
| 10 | + `test result: ok. 379 passed; 0 failed; 33 ignored; 0 measured; 0 filtered out; finished in 1031.33s` | |
| 11 | + (old text below is superseded) | |
| 12 | +- r3 suite armed at f36be26: unit `interp3-suite-r3-1788328778.service`, | |
| 13 | + log `$HOME/.cache/interp3-suite-r3.log`. At the cap it had 258 `... ok`, ZERO | |
| 14 | + `FAILED`/`panicked`, no `test result:` line yet. READ THAT LINE, do not re-run | |
| 15 | + blindly, then paste it into `lanes/interp3-r3.report.md` where | |
| 16 | + `EVIDENCE: SUITE_LINE_PLACEHOLDER` sits. | |
| 17 | + | |
| 18 | +## Stage attribution of the frame-7 residue (done FIRST, as chartered) | |
| 19 | +`EC_AV1_PREFILT_DUMP` on both decoders over the pinned 16-frame stream | |
| 20 | +(`.../scratchpad/mm.obu`), byte compare per decode-order frame: | |
| 21 | +frames 0-6 identical, frame 7 = 35 differing luma bytes, 8..15 grow to 224. | |
| 22 | +=> PRE-FILTER, i.e. prediction/reconstruction, never the loop filter/CDEF/LR. | |
| 23 | +All 35 sit in luma rows 42-47, cols 16-23, i.e. the block at mi (10,4); | |
| 24 | +rows 40-41 of that same block are EXACT and the error grows downward. | |
| 25 | + | |
| 26 | +## What the OBMC comparison actually said (emitter built, class swept, CLEAN) | |
| 27 | +Before writing the emitter, the hand comparison against libaom found NO mismatch: | |
| 28 | +`overlappable_above`/`overlappable_left` stepping and `max_neighbor_obmc` | |
| 29 | +(`{0,1,2,3,4,4}`, 8x8 -> 1 per pass) match `obmc.h:20-55`; overlap sizes | |
| 30 | +(4 luma rows above / 4 luma cols left at 8x8, chroma 2) match | |
| 31 | +`build_obmc_inter_pred_{above,left}`; `av1_skip_u4x4_pred_in_obmc` chroma-above | |
| 32 | +skip matches; `obmc_mask_1/2/4/8/16/32` are byte-identical to | |
| 33 | +`reconinter.c:752-765`; OBMC never warps (`if (!build_for_obmc) av1_init_warp_params`). | |
| 34 | +One real divergence candidate was left un-ported and is still a documented | |
| 35 | +corner-cut, not a defect on this content: `obmc.h`'s `mi_step == 1` 4-wide pair | |
| 36 | +merge, and libaom's `op_mi_size = AOMMIN(xd->width, mi_step)` which can exceed | |
| 37 | +the remaining span while ours clips with `.min(end_col - col)` (only reachable | |
| 38 | +for a 2nd neighbour with a wide step). | |
| 39 | + | |
| 40 | +Emitter: `decode.rs:15806` `ec_obmc_bsize()` + `decode.rs:15828` `ec_obmc_trace()`, | |
| 41 | +called at both passes in `obmc_blend`. Format is aomdec's own bytes: | |
| 42 | +`EC_OBMC above|left mi=(r,c) wh=(WxH) rel=N op=N nbmv=(y,x) nbref=N nbbsize=N filt=N` | |
| 43 | +(`filt` = packed `interp_filters.as_int` = `y | (x << 16)`). | |
| 44 | +`diff` of the 325 oracle lines vs our 325: EMPTY. OBMC is exonerated. | |
| 45 | + | |
| 46 | +Also added `decode.rs:14682` + `:22658` `EC_PICT idx=` (decode-order frame | |
| 47 | +marker under `EC_OBMC`/`EC_TRACE_MODE`). REQUIRED: the marker prints AFTER the | |
| 48 | +frame's own trace lines, so `awk` must count markers seen, not read the value on | |
| 49 | +the preceding line -- attributing by the preceding `EC_PICT` value is off by one | |
| 50 | +and cost part of this round. | |
| 51 | + | |
| 52 | +## Hypotheses ruled out (each by measurement) | |
| 53 | +- OBMC neighbour fields / masks / overlap: 325/325 identical lines (above). | |
| 54 | +- Frame 7 has NO OBMC block at mi (10,4) at all -- it is COMPOUND | |
| 55 | + (SIMPLE_TRANSLATION), so the r2 handoff's "OBMC over a compound neighbour" | |
| 56 | + suspect could not have been it. | |
| 57 | +- Residual/entropy: r2's range ladder is exact end to end; `EC_MCDUMP` (a | |
| 58 | + temporary rung, removed before commit) showed aom_recon - our_residual | |
| 59 | + reproduces our PREDICTION in rows 40-41 and diverges below => prediction. | |
| 60 | +- Wrong dual-filter x/y assignment: a swap would err in every row, not only the | |
| 61 | + lower ones. | |
| 62 | + | |
| 63 | +## Root cause (FIXED, gate GREEN) | |
| 64 | +`decode_inter_block8`'s COMPOUND arm predicted BOTH taps translationally. | |
| 65 | +libaom applies `allow_warp`'s GLOBAL branch to every `is_global_mv_block` | |
| 66 | +reference slot -- compound included, independent of `motion_mode` | |
| 67 | +(`av1_init_warp_params` inside `build_inter_predictors_8x8_and_bigger`'s per-`ref` | |
| 68 | +loop; `reconinter.c:33-55`). `decode_inter_block`'s compound arm has done this | |
| 69 | +since lane-cwarp r1 (`decode.rs:16691`). Third twin-functions-drift instance in | |
| 70 | +this lane. Frame 7 mi (10,4): GLOBAL_GLOBALMV, ref0=GOLDEN mv (0,0), | |
| 71 | +ref1=ALTREF mv (-3,4), comp_group_idx=1. | |
| 72 | +Fix: `decode.rs:19513` (`leaf_compound_warp`, `warp0_c`/`warp1_c`), | |
| 73 | +`decode.rs:19596`/`:19618` (`warp_affine_compound` per luma tap; chroma is 4x4, | |
| 74 | +below `av1_init_warp_params`'s 8px per-plane bound, so it stays translational). | |
| 75 | +Counter `COMPOUND_WARP_HITS_8` / `compound_warp_hits_8()` at `decode.rs:1786`. | |
| 76 | +After the fix ALL 16 decode-order frames are byte-identical pre-filter. | |
| 77 | + | |
| 78 | +## Gate | |
| 79 | +`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | |
| 80 | +(`stream.rs:6332`) is UN-IGNORED and GREEN with four hard asserts (compound-8x8 | |
| 81 | +filter read, differing dual-filter directions, 8x8 OBMC blend, 8x8 compound | |
| 82 | +GLOBAL warp). `$HOME/.cache/interp3-gate-r3.log`: `1 passed; 0 failed`. | |
| 83 | + | |
| 84 | +## EXACT NEXT STEP | |
| 85 | +1. DONE (suite green, report filled). Nothing owed here. | |
| 86 | +2. Then the lane's open residue is only the two deferrals in the report | |
| 87 | + (10-bit arm blocked by lane-inter8's 10-bit 8x8-leaf desync; `--tile-columns=1` | |
| 88 | + arm blocked by the SB-level rect-partition refusal). |
lanes/interp3-r3.report.mdadded+106 -0
| @@ -0,0 +1,106 @@ | ||
| 1 | +# lane-interp3 r3 -- the 8x8 COMPOUND leaf never applied the per-ref GLOBAL warp; gate is GREEN and un-ignored | |
| 2 | + | |
| 3 | +Base: d06d93f (r2 handoff, already merged with main). | |
| 4 | + | |
| 5 | +## Root cause (one line) | |
| 6 | + | |
| 7 | +`decode_inter_block8`'s COMPOUND arm predicted **both** reference taps | |
| 8 | +translationally, while libaom applies `allow_warp`'s GLOBAL branch to every | |
| 9 | +`is_global_mv_block` reference slot -- compound included and independently of | |
| 10 | +`motion_mode` (`av1_init_warp_params` is called inside | |
| 11 | +`build_inter_predictors_8x8_and_bigger`'s per-`ref` loop, `reconinter.c:33-55` | |
| 12 | +for `allow_warp` itself). The 16x16+ compound arm has done this since | |
| 13 | +lane-cwarp r1 (`decode.rs:16691`); the 8x8 leaf is its twin and drifted. | |
| 14 | +Third instance in this lane of the class **twin functions drift**. | |
| 15 | + | |
| 16 | +Effect on the pinned stream: the GLOBAL_GLOBALMV compound 8x8 leaf at | |
| 17 | +mi (10,4) of decode-order frame 7 (ref0=GOLDEN mv (0,0), ref1=ALTREF mv | |
| 18 | +(-3,4), `comp_group_idx=1` masked compound) was predicted with a pure | |
| 19 | +translation, so its prediction error was 0 at the block's top rows and grew | |
| 20 | +downward to |delta| 5 -- then propagated through every later frame. | |
| 21 | + | |
| 22 | +## It was NOT the OBMC blend (the r2 handoff's first suspect, disproved) | |
| 23 | + | |
| 24 | +An `EC_OBMC` emitter was added to both OBMC passes in `decode.rs`, printing the | |
| 25 | +instrumented aomdec's own byte format | |
| 26 | +(`EC_OBMC above|left mi=() wh=() rel= op= nbmv=() nbref= nbbsize= filt=`, | |
| 27 | +`decodeframe.c` `dec_build_prediction_by_{above,left}_pred`). The two decoders | |
| 28 | +emit **325 identical lines** on the pinned 16-frame stream -- neighbour | |
| 29 | +position, span, mv, reference, bsize and packed dual-filter pair all agree at | |
| 30 | +every OBMC call. The class sweep the charter asked for (neighbour-side fields | |
| 31 | +used by OBMC: filter, ref, mv, scale) is therefore CLEAN by measurement, not by | |
| 32 | +inspection; `obmc_mask_1/2/4/8/16/32` were also byte-compared against | |
| 33 | +`reconinter.c:752-765` and match. | |
| 34 | + | |
| 35 | +Frame 7 has no OBMC block at mi (10,4) at all: it is a compound block, and | |
| 36 | +compound blocks take SIMPLE_TRANSLATION. | |
| 37 | + | |
| 38 | +## Changed (path:line, this commit) | |
| 39 | + | |
| 40 | +- `crates/ec-av1/src/decode.rs:19513` -- `leaf_compound_warp` + | |
| 41 | + `warp0_c`/`warp1_c`, the leaf's per-slot copy of `decode_inter_block`'s | |
| 42 | + `compound_warp` (`force_integer_mv` short-circuit, `gm.invalid` guard). | |
| 43 | +- `crates/ec-av1/src/decode.rs:19596,19618` -- `warp::warp_affine_compound` | |
| 44 | + replaces each luma tap's translational intermediate, exactly as the 16x16+ | |
| 45 | + arm does at 17130/17155. Chroma is 4x4 at an 8x8 leaf, below | |
| 46 | + `av1_init_warp_params`'s own per-plane 8px bound, so chroma stays | |
| 47 | + translational (same rule the leaf's single-ref arm already applied). | |
| 48 | +- `crates/ec-av1/src/decode.rs:1786` -- `COMPOUND_WARP_HITS_8` + | |
| 49 | + `compound_warp_hits_8()`: the gate's proof that the warp fired at an 8x8 | |
| 50 | + LEAF specifically (`COMPOUND_WARP_HITS` alone cannot tell it from a 16x16+). | |
| 51 | +- `crates/ec-av1/src/decode.rs:15806` (`ec_obmc_bsize`) and `15828` | |
| 52 | + (`ec_obmc_trace`) + the two call sites in `obmc_blend` -- the `EC_OBMC` rung. | |
| 53 | +- `crates/ec-av1/src/decode.rs:14682,22658` -- `EC_PICT idx=` decode-order | |
| 54 | + frame marker (printed under `EC_OBMC`/`EC_TRACE_MODE`), so a trace line can be | |
| 55 | + attributed to the frame whose `EC_AV1_PREFILT_DUMP` file mismatched. Without | |
| 56 | + it the r2 hunt mis-attributed every trace line by one frame. | |
| 57 | +- `crates/ec-av1/src/stream.rs:6332` -- the gate's `#[ignore]` removed, doc | |
| 58 | + comment carries this round's measurement, and a third hard assert | |
| 59 | + (`compound_warp_hits_8() > before`) added. | |
| 60 | + | |
| 61 | +## Class sweep | |
| 62 | + | |
| 63 | +Both inter block decoders are the only prediction sites | |
| 64 | +(`decode_inter_block` 16309, `decode_inter_block8` 19032); all 12 | |
| 65 | +`predict_compound_intermediate` calls were audited. Warp coverage is now: | |
| 66 | +16x16+ single-ref (18235-18253), 16x16+ compound y/u/v x 2 refs | |
| 67 | +(17130-17300), 8x8 leaf single-ref (20238-20253), 8x8 leaf compound luma x 2 | |
| 68 | +refs (19596/19618, chroma correctly excluded). No third twin exists. | |
| 69 | + | |
| 70 | +## Gate: GREEN, un-ignored | |
| 71 | + | |
| 72 | +`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | |
| 73 | +(`--enable-dual-filter=1 --enable-obmc=1 --enable-warped-motion=1 | |
| 74 | +--enable-onesided-comp=1`, `--min-partition-size=8 --enable-ab-partitions=0 | |
| 75 | +--enable-1to4-partitions=0`, 64x64, 16 frames). Four hard asserts now: | |
| 76 | +compound 8x8 leaf reading its own switchable filter, a block whose two | |
| 77 | +dual-filter directions DIFFER, an 8x8 OBMC blend, and an 8x8 compound leaf | |
| 78 | +predicted through the per-ref GLOBAL warp. | |
| 79 | + | |
| 80 | +Command: | |
| 81 | +`EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interp3 cargo test -p ec-av1 --lib a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | |
| 82 | +Result: `test result: ok. 1 passed; 0 failed` (log `$HOME/.cache/interp3-gate-r3.log`). | |
| 83 | + | |
| 84 | +## Refusals | |
| 85 | + | |
| 86 | +None lifted. The r1 refusal `an OBMC neighbour whose interp filter was never | |
| 87 | +recorded` stays (it does not fire on this stream); `refusal_inventory.rs` and | |
| 88 | +`gate_coverage.rs` unchanged. | |
| 89 | + | |
| 90 | +## EVIDENCE | |
| 91 | + | |
| 92 | +EVIDENCE: /tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/b6d8a07f-96a4-4bbb-b378-af9ae25cf7c9/scratchpad/{aom.obmc,ours.obmc} | `EC_OBMC=1 aomdec --rawvideo -o /dev/null mm.obu` vs `EC_OBMC=1 decode_probe mm.obu`, `diff` of every EC_OBMC line | 325 vs 325 lines, diff EMPTY -- OBMC neighbour selection/mv/ref/bsize/filter exonerated | |
| 93 | +EVIDENCE: same dir, pf_a/f.f0..15 vs pf_o/f.f0..15 | `EC_AV1_PREFILT_DUMP` on both decoders, byte compare per decode-order frame BEFORE the fix | frames 0-6 identical, frame 7 35 bytes differ (all inside luma rows 42-47, cols 16-23 = the 8x8 leaf at mi (10,4)), growing to 224 at frame 15 | |
| 94 | +EVIDENCE: same dir, pf_a vs pf_o2 | identical command AFTER the fix | all 16 decode-order frames byte-identical pre-filter (0 differing bytes) | |
| 95 | +EVIDENCE: $HOME/.cache/interp3-gate-r3.log | `cargo test -p ec-av1 --lib a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact -- --nocapture` | `test result: ok. 1 passed; 0 failed` with all four counter asserts live (the run would panic if `compound_warp_hits_8` had not moved) | |
| 96 | +EVIDENCE: $HOME/.cache/interp3-suite-r3.log | `EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interp3 cargo test -p ec-av1 --lib -j3` under systemd unit `interp3-suite-r3-1788328778.service`, armed at f36be26 | `test result: ok. 379 passed; 0 failed; 33 ignored; 0 measured; 0 filtered out; finished in 1031.33s` (r2 baseline was 378 passed / 34 ignored -- the delta is exactly this gate leaving `#[ignore]`) | |
| 97 | + | |
| 98 | +## Residue | |
| 99 | + | |
| 100 | +- deferred(lane-inter8's 10-bit 8x8-leaf desync) -- a 10-bit twin of this gate. | |
| 101 | + Its sibling `a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_...` | |
| 102 | + is still `#[ignore]`d on an unrelated 10-bit desync (lane-inter8 r2), so a | |
| 103 | + 10-bit arm of this recipe would go RED on that, not on interp3's own path. | |
| 104 | +- deferred(needs a multi-tile recipe that reaches an 8x8 leaf) -- a | |
| 105 | + `--tile-columns=1` arm. lane-inter8 r3 measured that the 128x64 multi-tile | |
| 106 | + recipe stops at the SB-level rect-partition refusal before any 8x8 leaf. |