Merge branch 'lane-interp3' (10b801a): compound 8x8 leaf interp read, ref ctx bands, per-ref global warp
Browse files at this commit7 changed files +818 -31
- crates/ec-av1/src/decode.rs +300 -29
- 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+300 -29
| @@ -1809,6 +1809,32 @@ thread_local! { | |||
| 1809 | static OBMC_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 1809 | static OBMC_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1810 | } | 1810 | } |
| 1811 | 1811 | ||
| 1812 | +// lane-interp3 r1: how many inter blocks read a SWITCHABLE `interp_filter` | ||
| 1813 | +// pair whose two directions differ (`enable_dual_filter` only -- with dual | ||
| 1814 | +// filter off both directions take the single symbol, so this can never fire). | ||
| 1815 | +// A gate asserting it proves the stream really carries dual-filter blocks. | ||
| 1816 | +thread_local! { | ||
| 1817 | + static DUAL_FILTER_DIFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1818 | +} | ||
| 1819 | + | ||
| 1820 | +// lane-interp3 r1: how many COMPOUND 8x8 leaves read their own | ||
| 1821 | +// `read_mb_interp_filter` symbol(s) -- the read this round added (the leaf | ||
| 1822 | +// used to skip it entirely, losing a symbol and stamping the `[3, 3]` | ||
| 1823 | +// no-filter sentinel that made a neighbouring OBMC block panic). | ||
| 1824 | +thread_local! { | ||
| 1825 | + static COMPOUND8_FILTER_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1826 | +} | ||
| 1827 | + | ||
| 1828 | +/// Current value of [`DUAL_FILTER_DIFF_HITS`]. | ||
| 1829 | +pub(crate) fn dual_filter_diff_hits() -> usize { | ||
| 1830 | + DUAL_FILTER_DIFF_HITS.with(|c| c.get()) | ||
| 1831 | +} | ||
| 1832 | + | ||
| 1833 | +/// Current value of [`COMPOUND8_FILTER_HITS`]. | ||
| 1834 | +pub(crate) fn compound8_filter_hits() -> usize { | ||
| 1835 | + COMPOUND8_FILTER_HITS.with(|c| c.get()) | ||
| 1836 | +} | ||
| 1837 | + | ||
| 1812 | // lane-warp round 1: how many blocks resolved `motion_mode_allowed` to | 1838 | // lane-warp round 1: how many blocks resolved `motion_mode_allowed` to |
| 1813 | // `WARPED_CAUSAL`-eligible (3-symbol read, `num_proj_ref >= 1` under | 1839 | // `WARPED_CAUSAL`-eligible (3-symbol read, `num_proj_ref >= 1` under |
| 1814 | // `allow_warped_motion`) AND the symbol actually decoded to `WARPED_CAUSAL` | 1840 | // `allow_warped_motion`) AND the symbol actually decoded to `WARPED_CAUSAL` |
| @@ -1840,6 +1866,20 @@ pub(crate) fn compound_warp_hits() -> usize { | |||
| 1840 | COMPOUND_WARP_HITS.with(|c| c.get()) | 1866 | COMPOUND_WARP_HITS.with(|c| c.get()) |
| 1841 | } | 1867 | } |
| 1842 | 1868 | ||
| 1869 | +// lane-interp3 r3: the same proof narrowed to the 8x8 LEAF's own compound | ||
| 1870 | +// arm ([`decode_inter_block8`]) -- that arm predicted both taps | ||
| 1871 | +// translationally until r3, so a gate needs to tell a warped 8x8 compound | ||
| 1872 | +// leaf apart from a warped 16x16+ one (both bump [`COMPOUND_WARP_HITS`]). | ||
| 1873 | +thread_local! { | ||
| 1874 | + static COMPOUND_WARP_HITS_8: std::cell::Cell<usize> = | ||
| 1875 | + const { std::cell::Cell::new(0) }; | ||
| 1876 | +} | ||
| 1877 | + | ||
| 1878 | +/// Current value of [`COMPOUND_WARP_HITS_8`]. | ||
| 1879 | +pub(crate) fn compound_warp_hits_8() -> usize { | ||
| 1880 | + COMPOUND_WARP_HITS_8.with(|c| c.get()) | ||
| 1881 | +} | ||
| 1882 | + | ||
| 1843 | // lane-gmaffine r1: how many blocks built their prediction from a | 1883 | // lane-gmaffine r1: how many blocks built their prediction from a |
| 1844 | // SIX-parameter (`AFFINE`) global-motion model through | 1884 | // SIX-parameter (`AFFINE`) global-motion model through |
| 1845 | // `crate::warp::global_warp_params` -- the gate's proof that a stream really | 1885 | // `crate::warp::global_warp_params` -- the gate's proof that a stream really |
| @@ -15490,6 +15530,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 15490 | // that isolate whether a decode-order frame's mismatch already exists | 15530 | // that isolate whether a decode-order frame's mismatch already exists |
| 15491 | // in reconstruction (this dump) vs is introduced by the loop filter | 15531 | // in reconstruction (this dump) vs is introduced by the loop filter |
| 15492 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). | 15532 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). |
| 15533 | + // Decode-order frame marker for the EC_OBMC / EC_TRACE_MODE ladders. | ||
| 15534 | + if std::env::var_os("EC_OBMC").is_some() || std::env::var_os("EC_TRACE_MODE").is_some() { | ||
| 15535 | + eprintln!( | ||
| 15536 | + "EC_PICT idx={}", | ||
| 15537 | + PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) | ||
| 15538 | + ); | ||
| 15539 | + } | ||
| 15493 | dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | 15540 | dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 15494 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { | 15541 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { |
| 15495 | use std::io::Write; | 15542 | use std::io::Write; |
| @@ -15704,6 +15751,9 @@ fn resolve_interp_filter( | |||
| 15704 | } else { | 15751 | } else { |
| 15705 | sym0 | 15752 | sym0 |
| 15706 | }; | 15753 | }; |
| 15754 | + if enable_dual_filter && sym0 != sym1 { | ||
| 15755 | + DUAL_FILTER_DIFF_HITS.with(|c| c.set(c.get() + 1)); | ||
| 15756 | + } | ||
| 15707 | ( | 15757 | ( |
| 15708 | mc::InterpFilterKind::from_switchable_symbol(sym1 as usize), | 15758 | mc::InterpFilterKind::from_switchable_symbol(sym1 as usize), |
| 15709 | mc::InterpFilterKind::from_switchable_symbol(sym0 as usize), | 15759 | mc::InterpFilterKind::from_switchable_symbol(sym0 as usize), |
| @@ -16560,6 +16610,71 @@ fn obmc_blend_h(dst: &mut [u16], stride: usize, ox: usize, oy: usize, w: usize, | |||
| 16560 | } | 16610 | } |
| 16561 | } | 16611 | } |
| 16562 | 16612 | ||
| 16613 | +/// libaom's own `BLOCK_SIZE` enum index for a `w4`x`h4` (mi-unit) block -- | ||
| 16614 | +/// only for the `EC_OBMC` trace rung below, so it reads byte-identical to | ||
| 16615 | +/// the instrumented aomdec's `backup_mbmi.bsize`. | ||
| 16616 | +fn ec_obmc_bsize(w4: usize, h4: usize) -> i32 { | ||
| 16617 | + match (w4, h4) { | ||
| 16618 | + (1, 1) => 0, | ||
| 16619 | + (1, 2) => 1, | ||
| 16620 | + (2, 1) => 2, | ||
| 16621 | + (2, 2) => 3, | ||
| 16622 | + (2, 4) => 4, | ||
| 16623 | + (4, 2) => 5, | ||
| 16624 | + (4, 4) => 6, | ||
| 16625 | + (4, 8) => 7, | ||
| 16626 | + (8, 4) => 8, | ||
| 16627 | + (8, 8) => 9, | ||
| 16628 | + (8, 16) => 10, | ||
| 16629 | + (16, 8) => 11, | ||
| 16630 | + (16, 16) => 12, | ||
| 16631 | + (1, 4) => 16, | ||
| 16632 | + (4, 1) => 17, | ||
| 16633 | + (2, 8) => 18, | ||
| 16634 | + (8, 2) => 19, | ||
| 16635 | + (4, 16) => 20, | ||
| 16636 | + (16, 4) => 21, | ||
| 16637 | + _ => -1, | ||
| 16638 | + } | ||
| 16639 | +} | ||
| 16640 | + | ||
| 16641 | +/// The `EC_OBMC` rung: one line per blended neighbour, in the instrumented | ||
| 16642 | +/// aomdec's own byte format (`decodeframe.c` | ||
| 16643 | +/// `dec_build_prediction_by_{above,left}_pred`), so the two decoders' OBMC | ||
| 16644 | +/// neighbour lists diff line for line. `filt` is libaom's packed | ||
| 16645 | +/// `interp_filters.as_int` = `y_filter | (x_filter << 16)`. | ||
| 16646 | +#[allow(clippy::too_many_arguments)] | ||
| 16647 | +fn ec_obmc_trace( | ||
| 16648 | + dir: &str, | ||
| 16649 | + mi_row: usize, | ||
| 16650 | + mi_col: usize, | ||
| 16651 | + write_w: usize, | ||
| 16652 | + write_h: usize, | ||
| 16653 | + rel: usize, | ||
| 16654 | + op: usize, | ||
| 16655 | + nb: &MiInfo, | ||
| 16656 | + h_kind: mc::InterpFilterKind, | ||
| 16657 | + v_kind: mc::InterpFilterKind, | ||
| 16658 | +) { | ||
| 16659 | + if std::env::var_os("EC_OBMC").is_none() { | ||
| 16660 | + return; | ||
| 16661 | + } | ||
| 16662 | + let sym = |k: mc::InterpFilterKind| match k { | ||
| 16663 | + mc::InterpFilterKind::Smooth => 1u32, | ||
| 16664 | + mc::InterpFilterKind::Sharp => 2, | ||
| 16665 | + _ => 0, | ||
| 16666 | + }; | ||
| 16667 | + eprintln!( | ||
| 16668 | + "EC_OBMC {dir} mi=({mi_row},{mi_col}) wh=({write_w}x{write_h}) rel={rel} op={op} \ | ||
| 16669 | +nbmv=({},{}) nbref={} nbbsize={} filt={}", | ||
| 16670 | + nb.mv.0, | ||
| 16671 | + nb.mv.1, | ||
| 16672 | + nb.ref_frame, | ||
| 16673 | + ec_obmc_bsize(nb.size, nb.size_h), | ||
| 16674 | + sym(v_kind) | (sym(h_kind) << 16), | ||
| 16675 | + ); | ||
| 16676 | +} | ||
| 16677 | + | ||
| 16563 | /// `av1_build_obmc_inter_prediction` (libaom `reconinter.c`): re-predicts | 16678 | /// `av1_build_obmc_inter_prediction` (libaom `reconinter.c`): re-predicts |
| 16564 | /// the overlap strip against each bordering above/left inter neighbour's own | 16679 | /// the overlap strip against each bordering above/left inter neighbour's own |
| 16565 | /// mv/ref/filter and blends it into this block's just-built single-reference | 16680 | /// mv/ref/filter and blends it into this block's just-built single-reference |
| @@ -16659,6 +16774,7 @@ fn obmc_blend( | |||
| 16659 | interp_fixed, | 16774 | interp_fixed, |
| 16660 | neighbours.above_filter[mi_col + off4], | 16775 | neighbours.above_filter[mi_col + off4], |
| 16661 | )?; | 16776 | )?; |
| 16777 | + ec_obmc_trace("above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); | ||
| 16662 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; | 16778 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; |
| 16663 | let nb_scale = mc::scale_factor(ny.width, frame_width); | 16779 | let nb_scale = mc::scale_factor(ny.width, frame_width); |
| 16664 | let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4); | 16780 | let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4); |
| @@ -16678,6 +16794,7 @@ fn obmc_blend( | |||
| 16678 | interp_fixed, | 16794 | interp_fixed, |
| 16679 | neighbours.left_filter[mi_row + off4], | 16795 | neighbours.left_filter[mi_row + off4], |
| 16680 | )?; | 16796 | )?; |
| 16797 | + ec_obmc_trace("left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); | ||
| 16681 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; | 16798 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; |
| 16682 | let nb_scale = mc::scale_factor(ny.width, frame_width); | 16799 | let nb_scale = mc::scale_factor(ny.width, frame_width); |
| 16683 | let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4); | 16800 | let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4); |
| @@ -20077,21 +20194,24 @@ fn decode_inter_block8( | |||
| 20077 | let (ref0, ref1) = if skip_mode { | 20194 | let (ref0, ref1) = if skip_mode { |
| 20078 | (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8) | 20195 | (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8) |
| 20079 | } else { | 20196 | } else { |
| 20197 | + // lane-interp3 r2 (class twin-functions-drift): this leaf | ||
| 20198 | + // passed a hard-coded `LAST_FRAME` for every inter | ||
| 20199 | + // neighbour -- the old "coarse LAST_FRAME-or-intra" | ||
| 20200 | + // approximation -- while the side bands have carried the | ||
| 20201 | + // neighbour's REAL reference per mi since lane-inter8 r2. | ||
| 20202 | + // Every `av1_collect_neighbors_ref_counts` vote below | ||
| 20203 | + // (`uni_comp_ref_p1`, `comp_ref`, `comp_bwdref`, ...) was | ||
| 20204 | + // therefore taken off the wrong CDF row. Same two args | ||
| 20205 | + // [`decode_inter_block`]'s own compound arm passes | ||
| 20206 | + // (`-1` when the band is unavailable is start_tile's / | ||
| 20207 | + // start_row's own reset value, so no `has_above` guard). | ||
| 20080 | read_compound_ref_frames( | 20208 | read_compound_ref_frames( |
| 20081 | dec, | 20209 | dec, |
| 20082 | cdfs, | 20210 | cdfs, |
| 20083 | above_nbr, | 20211 | above_nbr, |
| 20084 | left_nbr, | 20212 | left_nbr, |
| 20085 | - if has_above && above_inter { | 20213 | + above_ref0, |
| 20086 | - LAST_FRAME | 20214 | + left_ref0, |
| 20087 | - } else { | ||
| 20088 | - -1 | ||
| 20089 | - }, | ||
| 20090 | - if has_left && left_inter { | ||
| 20091 | - LAST_FRAME | ||
| 20092 | - } else { | ||
| 20093 | - -1 | ||
| 20094 | - }, | ||
| 20095 | ) | 20215 | ) |
| 20096 | }; | 20216 | }; |
| 20097 | leaf_refs = (ref0, Some(ref1)); | 20217 | leaf_refs = (ref0, Some(ref1)); |
| @@ -20272,6 +20392,58 @@ fn decode_inter_block8( | |||
| 20272 | ); | 20392 | ); |
| 20273 | } | 20393 | } |
| 20274 | 20394 | ||
| 20395 | + // lane-interp3 r1: `read_mb_interp_filter` (libaom | ||
| 20396 | + // `decodemv.c` 1575, the tail of | ||
| 20397 | + // `read_inter_block_mode_info`) runs for EVERY inter block, | ||
| 20398 | + // compound included, right AFTER `read_compound_type` -- this | ||
| 20399 | + // leaf read no filter symbol at all, so a SWITCHABLE-filter | ||
| 20400 | + // stream lost one symbol (two under `enable_dual_filter`) at | ||
| 20401 | + // every compound 8x8 leaf, and the leaf recorded the `[3, 3]` | ||
| 20402 | + // "no filter" sentinel, which made a neighbouring OBMC block's | ||
| 20403 | + // `neighbour_filter` PANIC instead of blending. | ||
| 20404 | + // `av1_is_interp_needed` suppression terms for this arm: | ||
| 20405 | + // `skip_mode`, and `is_nontrans_global_motion` (mode | ||
| 20406 | + // GLOBAL_GLOBALMV with BOTH refs' models non-TRANSLATION) -- | ||
| 20407 | + // WARPED_CAUSAL cannot occur on a compound block. | ||
| 20408 | + let gm_nontrans_c = compound_mode == 6 | ||
| 20409 | + && global_motion[(ref0 - LAST_FRAME) as usize].model | ||
| 20410 | + != ec_av1_syntax::WarpModel::Translation | ||
| 20411 | + && global_motion[(ref1 - LAST_FRAME) as usize].model | ||
| 20412 | + != ec_av1_syntax::WarpModel::Translation; | ||
| 20413 | + // spec `get_ref_filter_type`, keyed on this block's ref0 and | ||
| 20414 | + // matching EITHER of the neighbour's references -- same shape | ||
| 20415 | + // as [`decode_inter_block`]'s compound arm. Same corner-cut as | ||
| 20416 | + // this leaf's single-ref arm below: the context comes from the | ||
| 20417 | + // enclosing 16x16's coarse slot. | ||
| 20418 | + let above_filter_ctx = if neighbours.above_ref[cmi] == ref0 | ||
| 20419 | + || neighbours.above_ref1[cmi] == Some(ref0) | ||
| 20420 | + { | ||
| 20421 | + neighbours.above_filter[cmi] | ||
| 20422 | + } else { | ||
| 20423 | + [3, 3] | ||
| 20424 | + }; | ||
| 20425 | + let left_filter_ctx = if neighbours.left_ref[rmi] == ref0 | ||
| 20426 | + || neighbours.left_ref1[rmi] == Some(ref0) | ||
| 20427 | + { | ||
| 20428 | + neighbours.left_filter[rmi] | ||
| 20429 | + } else { | ||
| 20430 | + [3, 3] | ||
| 20431 | + }; | ||
| 20432 | + let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( | ||
| 20433 | + dec, | ||
| 20434 | + cdfs, | ||
| 20435 | + interp_fixed, | ||
| 20436 | + enable_dual_filter, | ||
| 20437 | + gm_nontrans_c || skip_mode, | ||
| 20438 | + above_filter_ctx, | ||
| 20439 | + left_filter_ctx, | ||
| 20440 | + true, | ||
| 20441 | + ); | ||
| 20442 | + leaf_filter_syms = resolved_filter; | ||
| 20443 | + if interp_fixed.is_none() && !(gm_nontrans_c || skip_mode) { | ||
| 20444 | + COMPOUND8_FILTER_HITS.with(|c| c.set(c.get() + 1)); | ||
| 20445 | + } | ||
| 20446 | + | ||
| 20275 | let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?; | 20447 | let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?; |
| 20276 | let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?; | 20448 | let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?; |
| 20277 | let scale0 = mc::scale_factor(py0.width, frame_width); | 20449 | let scale0 = mc::scale_factor(py0.width, frame_width); |
| @@ -20281,6 +20453,54 @@ fn decode_inter_block8( | |||
| 20281 | SCALED_BLOCK8_HITS.with(|c| c.set(c.get() + 1)); | 20453 | SCALED_BLOCK8_HITS.with(|c| c.set(c.get() + 1)); |
| 20282 | } | 20454 | } |
| 20283 | 20455 | ||
| 20456 | + // lane-interp3 r2 (class twin-functions-drift): both slots | ||
| 20457 | + // used to be stamped `false`, while [`decode_inter_block`]'s | ||
| 20458 | + // compound arm computes libaom's PER-SLOT `is_global_mv_block` | ||
| 20459 | + // (blockd.h:421-429 -- mode GLOBAL_GLOBALMV, block >= 8x8 | ||
| 20460 | + // (always true for this leaf) and THAT slot's own gm model > | ||
| 20461 | + // TRANSLATION). A neighbour carrying the flag makes | ||
| 20462 | + // `setup_ref_mv_list` substitute the READER's global mv for | ||
| 20463 | + // the neighbour's stored one, so a cleared flag fed the next | ||
| 20464 | + // block's stack a stored mv where libaom has the global | ||
| 20465 | + // candidate -- a wrong mv stack, wrong mode contexts, and a | ||
| 20466 | + // desync one block later. | ||
| 20467 | + let is_globalmv_c = compound_mode == 6; | ||
| 20468 | + let is_global_mv0_c = is_globalmv_c | ||
| 20469 | + && global_motion[(ref0 - LAST_FRAME) as usize].model as u8 > 1; | ||
| 20470 | + let is_global_mv1_c = is_globalmv_c | ||
| 20471 | + && global_motion[(ref1 - LAST_FRAME) as usize].model as u8 > 1; | ||
| 20472 | + // lane-interp3 r3 (class twin-functions-drift, second | ||
| 20473 | + // instance): libaom applies `allow_warp`'s GLOBAL branch | ||
| 20474 | + // (`reconinter.c:33-55`, reached from `av1_init_warp_params` | ||
| 20475 | + // inside `build_inter_predictors_8x8_and_bigger`'s per-`ref` | ||
| 20476 | + // loop) to EVERY `is_global_mv_block` slot, compound | ||
| 20477 | + // included and independently of `motion_mode` -- the 16x16+ | ||
| 20478 | + // compound arm has done this since lane-cwarp r1, this leaf | ||
| 20479 | + // predicted both taps translationally, so a GLOBAL_GLOBALMV | ||
| 20480 | + // 8x8 compound leaf under a non-TRANSLATION model drifted by | ||
| 20481 | + // a few luma levels, growing away from the block origin. | ||
| 20482 | + // `force_integer_mv` short-circuits `av1_init_warp_params` | ||
| 20483 | + // before `allow_warp`; chroma is 4x4 here, below | ||
| 20484 | + // `av1_init_warp_params`'s own 8px per-plane bound, so only | ||
| 20485 | + // luma warps (same rule as this leaf's single-ref arm). | ||
| 20486 | + let leaf_compound_warp = |ref_frame: i8, eligible: bool| { | ||
| 20487 | + if eligible | ||
| 20488 | + && !force_integer_mv | ||
| 20489 | + && !global_motion[(ref_frame - LAST_FRAME) as usize].invalid | ||
| 20490 | + { | ||
| 20491 | + crate::warp::global_warp_params( | ||
| 20492 | + global_motion[(ref_frame - LAST_FRAME) as usize].params, | ||
| 20493 | + ) | ||
| 20494 | + } else { | ||
| 20495 | + None | ||
| 20496 | + } | ||
| 20497 | + }; | ||
| 20498 | + let warp0_c = leaf_compound_warp(ref0, is_global_mv0_c); | ||
| 20499 | + let warp1_c = leaf_compound_warp(ref1, is_global_mv1_c); | ||
| 20500 | + if warp0_c.is_some() || warp1_c.is_some() { | ||
| 20501 | + COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1)); | ||
| 20502 | + COMPOUND_WARP_HITS_8.with(|c| c.set(c.get() + 1)); | ||
| 20503 | + } | ||
| 20284 | for dr in 0..2 { | 20504 | for dr in 0..2 { |
| 20285 | for dc in 0..2 { | 20505 | for dc in 0..2 { |
| 20286 | grid.set( | 20506 | grid.set( |
| @@ -20295,19 +20515,14 @@ fn decode_inter_block8( | |||
| 20295 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), | 20515 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), |
| 20296 | size: 2, | 20516 | size: 2, |
| 20297 | size_h: 2, | 20517 | size_h: 2, |
| 20298 | - is_global_mv0: false, | 20518 | + is_global_mv0: is_global_mv0_c, |
| 20299 | - is_global_mv1: false, | 20519 | + is_global_mv1: is_global_mv1_c, |
| 20300 | }, | 20520 | }, |
| 20301 | ); | 20521 | ); |
| 20302 | } | 20522 | } |
| 20303 | } | 20523 | } |
| 20304 | mode_for_tx = 0; | 20524 | mode_for_tx = 0; |
| 20305 | 20525 | ||
| 20306 | - // lane-av1comp corner-cut, matching this leaf's single-ref | ||
| 20307 | - // arm below (`mc::predict`'s own fixed-Regular default): | ||
| 20308 | - // `decode_inter_block8` never resolves a switchable filter, | ||
| 20309 | - // so both compound taps use `Regular` too. | ||
| 20310 | - use mc::InterpFilterKind::Regular; | ||
| 20311 | let mut inter0_y = vec![0i32; SIDE * SIDE]; | 20526 | let mut inter0_y = vec![0i32; SIDE * SIDE]; |
| 20312 | mc::predict_compound_intermediate( | 20527 | mc::predict_compound_intermediate( |
| 20313 | &py0.data, | 20528 | &py0.data, |
| @@ -20319,10 +20534,17 @@ fn decode_inter_block8( | |||
| 20319 | scale0, | 20534 | scale0, |
| 20320 | SIDE, | 20535 | SIDE, |
| 20321 | SIDE, | 20536 | SIDE, |
| 20322 | - Regular, | 20537 | + h_filter, |
| 20323 | - Regular, | 20538 | + v_filter, |
| 20324 | &mut inter0_y, | 20539 | &mut inter0_y, |
| 20325 | ); | 20540 | ); |
| 20541 | + if let Some(wp) = &warp0_c { | ||
| 20542 | + crate::warp::warp_affine_compound( | ||
| 20543 | + wp, &py0.data, py0.true_width as i32, py0.true_height as i32, | ||
| 20544 | + py0.width as i32, &mut inter0_y, px as i32, py as i32, SIDE as i32, | ||
| 20545 | + SIDE as i32, SIDE as i32, 0, 0, | ||
| 20546 | + ); | ||
| 20547 | + } | ||
| 20326 | let mut inter1_y = vec![0i32; SIDE * SIDE]; | 20548 | let mut inter1_y = vec![0i32; SIDE * SIDE]; |
| 20327 | mc::predict_compound_intermediate( | 20549 | mc::predict_compound_intermediate( |
| 20328 | &py1.data, | 20550 | &py1.data, |
| @@ -20334,10 +20556,17 @@ fn decode_inter_block8( | |||
| 20334 | scale1, | 20556 | scale1, |
| 20335 | SIDE, | 20557 | SIDE, |
| 20336 | SIDE, | 20558 | SIDE, |
| 20337 | - Regular, | 20559 | + h_filter, |
| 20338 | - Regular, | 20560 | + v_filter, |
| 20339 | &mut inter1_y, | 20561 | &mut inter1_y, |
| 20340 | ); | 20562 | ); |
| 20563 | + if let Some(wp) = &warp1_c { | ||
| 20564 | + crate::warp::warp_affine_compound( | ||
| 20565 | + wp, &py1.data, py1.true_width as i32, py1.true_height as i32, | ||
| 20566 | + py1.width as i32, &mut inter1_y, px as i32, py as i32, SIDE as i32, | ||
| 20567 | + SIDE as i32, SIDE as i32, 0, 0, | ||
| 20568 | + ); | ||
| 20569 | + } | ||
| 20341 | let mut pred_y = vec![0u16; SIDE * SIDE]; | 20570 | let mut pred_y = vec![0u16; SIDE * SIDE]; |
| 20342 | let mut diffwtd_mask_y = Vec::new(); | 20571 | let mut diffwtd_mask_y = Vec::new(); |
| 20343 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { | 20572 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { |
| @@ -20367,8 +20596,8 @@ fn decode_inter_block8( | |||
| 20367 | scale0, | 20596 | scale0, |
| 20368 | CHROMA_SIDE, | 20597 | CHROMA_SIDE, |
| 20369 | CHROMA_SIDE, | 20598 | CHROMA_SIDE, |
| 20370 | - Regular, | 20599 | + h_filter, |
| 20371 | - Regular, | 20600 | + v_filter, |
| 20372 | &mut inter0_u, | 20601 | &mut inter0_u, |
| 20373 | ); | 20602 | ); |
| 20374 | let mut inter1_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; | 20603 | let mut inter1_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -20382,8 +20611,8 @@ fn decode_inter_block8( | |||
| 20382 | scale1, | 20611 | scale1, |
| 20383 | CHROMA_SIDE, | 20612 | CHROMA_SIDE, |
| 20384 | CHROMA_SIDE, | 20613 | CHROMA_SIDE, |
| 20385 | - Regular, | 20614 | + h_filter, |
| 20386 | - Regular, | 20615 | + v_filter, |
| 20387 | &mut inter1_u, | 20616 | &mut inter1_u, |
| 20388 | ); | 20617 | ); |
| 20389 | let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; | 20618 | let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -20413,8 +20642,8 @@ fn decode_inter_block8( | |||
| 20413 | scale0, | 20642 | scale0, |
| 20414 | CHROMA_SIDE, | 20643 | CHROMA_SIDE, |
| 20415 | CHROMA_SIDE, | 20644 | CHROMA_SIDE, |
| 20416 | - Regular, | 20645 | + h_filter, |
| 20417 | - Regular, | 20646 | + v_filter, |
| 20418 | &mut inter0_v, | 20647 | &mut inter0_v, |
| 20419 | ); | 20648 | ); |
| 20420 | let mut inter1_v = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; | 20649 | let mut inter1_v = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -20428,8 +20657,8 @@ fn decode_inter_block8( | |||
| 20428 | scale1, | 20657 | scale1, |
| 20429 | CHROMA_SIDE, | 20658 | CHROMA_SIDE, |
| 20430 | CHROMA_SIDE, | 20659 | CHROMA_SIDE, |
| 20431 | - Regular, | 20660 | + h_filter, |
| 20432 | - Regular, | 20661 | + v_filter, |
| 20433 | &mut inter1_v, | 20662 | &mut inter1_v, |
| 20434 | ); | 20663 | ); |
| 20435 | let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; | 20664 | let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -20611,6 +20840,17 @@ fn decode_inter_block8( | |||
| 20611 | &gm_table, | 20840 | &gm_table, |
| 20612 | tpl, | 20841 | tpl, |
| 20613 | ); | 20842 | ); |
| 20843 | + // lane-interp3 r2: same per-entry EC_STACK ladder | ||
| 20844 | + // [`decode_inter_block`]'s single-ref arm prints, so this leaf's stack | ||
| 20845 | + // diffs line for line against the oracle's. | ||
| 20846 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | ||
| 20847 | + for (i, e) in stack.entries.iter().enumerate() { | ||
| 20848 | + eprintln!( | ||
| 20849 | + "EC_STACK mi_row={mi_row} mi_col={mi_col} ref={ref_frame} i={i} this=({},{}) comp=(0,0) w={}", | ||
| 20850 | + e.mv.0, e.mv.1, e.weight | ||
| 20851 | + ); | ||
| 20852 | + } | ||
| 20853 | + } | ||
| 20614 | 20854 | ||
| 20615 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; | 20855 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| 20616 | let mut is_globalmv = false; | 20856 | let mut is_globalmv = false; |
| @@ -23674,6 +23914,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 23674 | // that isolate whether a decode-order frame's mismatch already exists | 23914 | // that isolate whether a decode-order frame's mismatch already exists |
| 23675 | // in reconstruction (this dump) vs is introduced by the loop filter | 23915 | // in reconstruction (this dump) vs is introduced by the loop filter |
| 23676 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). | 23916 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). |
| 23917 | + // Decode-order frame marker for the EC_OBMC / EC_TRACE_MODE ladders. | ||
| 23918 | + if std::env::var_os("EC_OBMC").is_some() || std::env::var_os("EC_TRACE_MODE").is_some() { | ||
| 23919 | + eprintln!( | ||
| 23920 | + "EC_PICT idx={}", | ||
| 23921 | + PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) | ||
| 23922 | + ); | ||
| 23923 | + } | ||
| 23677 | dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | 23924 | dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 23678 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { | 23925 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { |
| 23679 | use std::io::Write; | 23926 | use std::io::Write; |
| @@ -24084,6 +24331,30 @@ mod tests { | |||
| 24084 | /// always cleared to `None` by `record_inter`, so the next block's own | 24331 | /// always cleared to `None` by `record_inter`, so the next block's own |
| 24085 | /// `NeighbourRef::uni` -- and `comp_reference_type_ctx` downstream of it | 24332 | /// `NeighbourRef::uni` -- and `comp_reference_type_ctx` downstream of it |
| 24086 | /// -- could never see a real compound neighbour). | 24333 | /// -- could never see a real compound neighbour). |
| 24334 | + /// lane-interp3 r1: a decoder must never abort the process on | ||
| 24335 | + /// stream-derived state. `neighbour_filter` used to feed the `[3, 3]` | ||
| 24336 | + /// "no filter recorded" sentinel straight into | ||
| 24337 | + /// `InterpFilterKind::from_switchable_symbol`, whose `panic!` ("...alphabet | ||
| 24338 | + /// is exactly 3 symbols") crashed on a real aomenc dual-filter + OBMC | ||
| 24339 | + /// stream. It now refuses by name; the real symbols still decode. | ||
| 24340 | + #[test] | ||
| 24341 | + fn an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking() { | ||
| 24342 | + assert!( | ||
| 24343 | + neighbour_filter(None, [3, 3]) | ||
| 24344 | + .unwrap_err() | ||
| 24345 | + .to_string() | ||
| 24346 | + .contains("an OBMC neighbour whose switchable interp filter was never recorded"), | ||
| 24347 | + "the [3, 3] sentinel must refuse by name, never panic" | ||
| 24348 | + ); | ||
| 24349 | + assert!(neighbour_filter(None, [3, 0]).is_err()); | ||
| 24350 | + let (h, v) = neighbour_filter(None, [0, 2]).expect("real symbols decode"); | ||
| 24351 | + assert_eq!(h, mc::InterpFilterKind::Sharp, "sym[1] is the horizontal kernel"); | ||
| 24352 | + assert_eq!(v, mc::InterpFilterKind::Regular, "sym[0] is the vertical kernel"); | ||
| 24353 | + let (h, v) = neighbour_filter(Some(mc::InterpFilterKind::Smooth), [3, 3]) | ||
| 24354 | + .expect("a fixed-filter frame never reads a symbol"); | ||
| 24355 | + assert_eq!((h, v), (mc::InterpFilterKind::Smooth, mc::InterpFilterKind::Smooth)); | ||
| 24356 | + } | ||
| 24357 | + | ||
| 24087 | #[test] | 24358 | #[test] |
| 24088 | fn record_compound_ctx_stamps_ref1_for_the_next_block_to_read() { | 24359 | fn record_compound_ctx_stamps_ref1_for_the_next_block_to_read() { |
| 24089 | let mut n = Neighbours::new(4, 4, 16, 16); | 24360 | let mut n = Neighbours::new(4, 4, 16, 16); |
crates/ec-av1/src/stream.rsmodified+92 -2
| @@ -6900,6 +6900,9 @@ mod tests { | |||
| 6900 | // aomenc silently codes one tile column and the arm is vacuous. | 6900 | // aomenc silently codes one tile column and the arm is vacuous. |
| 6901 | extra: &[&str], | 6901 | extra: &[&str], |
| 6902 | width: usize, | 6902 | width: usize, |
| 6903 | + // lane-interp3 r1: sequence length -- a compound block needs several | ||
| 6904 | + // already-coded references, which a 4-frame sequence never has. | ||
| 6905 | + frame_count: usize, | ||
| 6903 | ) { | 6906 | ) { |
| 6904 | if !have_ffmpeg() { | 6907 | if !have_ffmpeg() { |
| 6905 | eprintln!("SKIP {name}: no ffmpeg"); | 6908 | eprintln!("SKIP {name}: no ffmpeg"); |
| @@ -6909,7 +6912,8 @@ mod tests { | |||
| 6909 | eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); | 6912 | eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); |
| 6910 | return; | 6913 | return; |
| 6911 | } | 6914 | } |
| 6912 | - let (height, frame_count) = (64usize, 4usize); | 6915 | + let height = 64usize; |
| 6916 | + let duration = format!("{:.2}", frame_count as f64 / 25.0); | ||
| 6913 | // A deterministic synthetic source with real motion (a static source | 6917 | // A deterministic synthetic source with real motion (a static source |
| 6914 | // codes every inter frame as skip and never exercises the residual | 6918 | // codes every inter frame as skip and never exercises the residual |
| 6915 | // path); bounded with `-t` (class gate-loader-slurps-whole-file). | 6919 | // path); bounded with `-t` (class gate-loader-slurps-whole-file). |
| @@ -6922,7 +6926,7 @@ mod tests { | |||
| 6922 | "-i", | 6926 | "-i", |
| 6923 | &format!("mandelbrot=size={width}x{height}:rate=25"), | 6927 | &format!("mandelbrot=size={width}x{height}:rate=25"), |
| 6924 | "-t", | 6928 | "-t", |
| 6925 | - "0.16", | 6929 | + &duration, |
| 6926 | "-pix_fmt", | 6930 | "-pix_fmt", |
| 6927 | if ten_bit { "yuv420p10le" } else { "yuv420p" }, | 6931 | if ten_bit { "yuv420p10le" } else { "yuv420p" }, |
| 6928 | // y4m calls 10-bit unofficial (same as the 10-bit key-frame | 6932 | // y4m calls 10-bit unofficial (same as the 10-bit key-frame |
| @@ -7049,6 +7053,7 @@ mod tests { | |||
| 7049 | "whole-superblock inter PARTITION_NONE", | 7053 | "whole-superblock inter PARTITION_NONE", |
| 7050 | &[], | 7054 | &[], |
| 7051 | 64, | 7055 | 64, |
| 7056 | + 4, | ||
| 7052 | ); | 7057 | ); |
| 7053 | } | 7058 | } |
| 7054 | 7059 | ||
| @@ -7063,6 +7068,7 @@ mod tests { | |||
| 7063 | "whole-superblock inter PARTITION_NONE", | 7068 | "whole-superblock inter PARTITION_NONE", |
| 7064 | &[], | 7069 | &[], |
| 7065 | 64, | 7070 | 64, |
| 7071 | + 4, | ||
| 7066 | ); | 7072 | ); |
| 7067 | } | 7073 | } |
| 7068 | 7074 | ||
| @@ -7105,6 +7111,88 @@ mod tests { | |||
| 7105 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", | 7111 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", |
| 7106 | &["--tile-columns=1"], | 7112 | &["--tile-columns=1"], |
| 7107 | 128, | 7113 | 128, |
| 7114 | + 4, | ||
| 7115 | + ); | ||
| 7116 | + } | ||
| 7117 | + | ||
| 7118 | + /// lane-interp3 r1: the same 8x8-leaf recipe with DUAL FILTER, OBMC and | ||
| 7119 | + /// warped motion on. `read_mb_interp_filter` runs for every inter block | ||
| 7120 | + /// (libaom `decodemv.c` 1575), compound ones included; the compound 8x8 | ||
| 7121 | + /// leaf skipped it entirely, so a SWITCHABLE-filter stream lost a symbol | ||
| 7122 | + /// per compound leaf and stamped the `[3, 3]` "no filter" sentinel, which | ||
| 7123 | + /// made a neighbouring OBMC block's `neighbour_filter` PANIC (a crash on | ||
| 7124 | + /// his data, not a named refusal). The three hard asserts prove the flags | ||
| 7125 | + /// arrived: a compound 8x8 leaf that really read the filter, a block whose | ||
| 7126 | + /// two dual-filter directions DIFFER (impossible with dual filter off), | ||
| 7127 | + /// and an 8x8 OBMC blend. | ||
| 7128 | + // lane-interp3 r2: the ENTROPY desync r1 measured is CLOSED -- the full | ||
| 7129 | + // 16-frame stream now parses end to end and every `EC_MODE`/`EC_MODE_VAL` | ||
| 7130 | + // element's msac RANGE matches the instrumented aomdec's line for line | ||
| 7131 | + // (570/570 mode elements, 0 diff). Two twin-drift root causes, both in | ||
| 7132 | + // `decode_inter_block8`'s compound arm: `read_compound_ref_frames` was | ||
| 7133 | + // passed a hard-coded `LAST_FRAME` for every inter neighbour instead of | ||
| 7134 | + // the real per-mi band, and the grid stamp cleared both per-slot | ||
| 7135 | + // `is_global_mv_block` flags. | ||
| 7136 | + // lane-interp3 r3: the luma reconstruction residue r2 left open is CLOSED | ||
| 7137 | + // and this gate is GREEN. Third instance of the same twin-drift class: | ||
| 7138 | + // libaom applies `allow_warp`'s GLOBAL branch to every | ||
| 7139 | + // `is_global_mv_block` reference slot, compound included and independent | ||
| 7140 | + // of `motion_mode` (`av1_init_warp_params` inside | ||
| 7141 | + // `build_inter_predictors_8x8_and_bigger`'s per-`ref` loop) -- the 16x16+ | ||
| 7142 | + // compound arm has warped since lane-cwarp r1, the 8x8 leaf's compound arm | ||
| 7143 | + // predicted BOTH taps translationally, so a GLOBAL_GLOBALMV 8x8 compound | ||
| 7144 | + // leaf under a non-TRANSLATION model drifted a few luma levels, growing | ||
| 7145 | + // away from the block origin. It was NOT OBMC: the `EC_OBMC` emitter this | ||
| 7146 | + // round added to `decode.rs` diffs 325/325 lines against the instrumented | ||
| 7147 | + // aomdec's own rung (position, span, neighbour mv/ref/bsize/filter) with | ||
| 7148 | + // zero differences. | ||
| 7149 | + #[test] | ||
| 7150 | + fn a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact() { | ||
| 7151 | + const NAME: &str = | ||
| 7152 | + "a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact"; | ||
| 7153 | + if !have_ffmpeg() || !have_aomenc() { | ||
| 7154 | + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); | ||
| 7155 | + return; | ||
| 7156 | + } | ||
| 7157 | + let before_dual = decode::dual_filter_diff_hits(); | ||
| 7158 | + let before_obmc = decode::obmc_hits_8(); | ||
| 7159 | + let before_cwarp8 = decode::compound_warp_hits_8(); | ||
| 7160 | + inter_sb_none_gate( | ||
| 7161 | + NAME, | ||
| 7162 | + false, | ||
| 7163 | + "8", | ||
| 7164 | + "16", | ||
| 7165 | + decode::compound8_filter_hits, | ||
| 7166 | + "a compound 8x8 leaf reading its own switchable interp_filter", | ||
| 7167 | + &[ | ||
| 7168 | + "--enable-dual-filter=1", | ||
| 7169 | + "--enable-obmc=1", | ||
| 7170 | + "--enable-warped-motion=1", | ||
| 7171 | + "--enable-onesided-comp=1", | ||
| 7172 | + ], | ||
| 7173 | + 64, | ||
| 7174 | + // Recipe search hook (same shape as EC_OBMC8_ATTEMPTS): a compound | ||
| 7175 | + // block needs several coded references, so the sequence is longer | ||
| 7176 | + // than the other arms' 4 frames. | ||
| 7177 | + std::env::var("EC_INTERP3_FRAMES") | ||
| 7178 | + .ok() | ||
| 7179 | + .and_then(|v| v.parse().ok()) | ||
| 7180 | + .unwrap_or(16), | ||
| 7181 | + ); | ||
| 7182 | + assert!( | ||
| 7183 | + decode::dual_filter_diff_hits() > before_dual, | ||
| 7184 | + "{NAME}: no block read two DIFFERENT dual-filter directions -- \ | ||
| 7185 | + --enable-dual-filter=1 did not arrive or aomenc declined it" | ||
| 7186 | + ); | ||
| 7187 | + assert!( | ||
| 7188 | + decode::obmc_hits_8() > before_obmc, | ||
| 7189 | + "{NAME}: no 8x8 OBMC blend fired -- --enable-obmc=1 did not arrive" | ||
| 7190 | + ); | ||
| 7191 | + assert!( | ||
| 7192 | + decode::compound_warp_hits_8() > before_cwarp8, | ||
| 7193 | + "{NAME}: no 8x8 COMPOUND leaf was predicted through the per-ref GLOBAL \ | ||
| 7194 | + warp -- the r3 root-cause path never fired, so this stream no longer \ | ||
| 7195 | + proves it" | ||
| 7108 | ); | 7196 | ); |
| 7109 | } | 7197 | } |
| 7110 | 7198 | ||
| @@ -7119,6 +7207,7 @@ mod tests { | |||
| 7119 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", | 7207 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", |
| 7120 | &[], | 7208 | &[], |
| 7121 | 64, | 7209 | 64, |
| 7210 | + 4, | ||
| 7122 | ); | 7211 | ); |
| 7123 | } | 7212 | } |
| 7124 | 7213 | ||
| @@ -7142,6 +7231,7 @@ mod tests { | |||
| 7142 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", | 7231 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", |
| 7143 | &[], | 7232 | &[], |
| 7144 | 64, | 7233 | 64, |
| 7234 | + 4, | ||
| 7145 | ); | 7235 | ); |
| 7146 | } | 7236 | } |
| 7147 | 7237 | ||
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. | ||