diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index 4916437b..cb32f4f7 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -56,6 +56,16 @@ fn main() { println!( "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}", es[0], es[1], es[2], es[3], es[4], es[5] + + ); + let (h4, v4, pairs, sub8) = ec_av1::decode::inter16_rect4_counters(); + println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}"); + let leaf4 = ec_av1::stream::vartx_rect_leaf4_hits(); + println!("vartx_rect_leaf4: 8x4={} 4x8={}", leaf4[0], leaf4[1]); + let rw = ec_av1::stream::rect_wedge_hits(); + let rwi = ec_av1::stream::rect_wii_hits(); + println!( + "rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}" ); let ir = ec_av1::stream::inter_rect_counters(); println!( diff --git a/crates/ec-av1/src/cdf_state.rs b/crates/ec-av1/src/cdf_state.rs index 19c9b910..589b85de 100644 --- a/crates/ec-av1/src/cdf_state.rs +++ b/crates/ec-av1/src/cdf_state.rs @@ -246,6 +246,19 @@ pub(crate) enum TxbSet { /// symbols at the `TX_4X4` inter row, the table /// [`Luma4InterSet1`](TxbSet::Luma4InterSet1) also reads. LumaRect8x4InterSet1, + /// [`LumaRect16x4`](TxbSet::LumaRect16x4)'s INTER counterpart + /// (lane-inter16ab r2): the same `Luma8` coefficient tables (64 coded + /// positions, `get_txsize_entropy_ctx(TX_16X4)` = TX_8X8), with the + /// INTER `tx_type` table at `txsize_sqr_map[TX_16X4]` = TX_4X4. + /// `av1_get_ext_tx_set_type` (av1/common/idct.c): `tx_size_sqr_up` is + /// TX_16X16 (not > TX_32X32) and `use_reduced_set` picks + /// `EXT_TX_SET_DCT_IDTX` -- three symbols, `inter_tx_type_4`. + LumaRect16x4Inter, + /// [`LumaRect16x4Inter`](TxbSet::LumaRect16x4Inter)'s + /// `reduced_tx_set: false` counterpart: `tx_size_sqr` is TX_4X4, not + /// TX_16X16, so `av1_get_ext_tx_set_type` returns `EXT_TX_SET_ALL16` -- + /// sixteen symbols, `inter_tx_type_4_set1`. + LumaRect16x4Inter1, } /// The tables one transform block is coded with, borrowed from the state for @@ -1904,6 +1917,30 @@ impl Cdfs { tx_type: Some(self.intra_tx_type_4_set1[mode].as_mut_slice()), eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), }, + TxbSet::LumaRect16x4Inter => TxbTables { + side: 8, + txb_skip: &mut self.txb_skip_luma_8, + eob_pt: &mut self.eob_pt_64_luma, + eob_extra: &mut self.eob_extra_luma_8, + base: &mut self.base_luma_8, + base_eob: &mut self.base_eob_luma_8, + br: &mut self.br_luma_8, + dc_sign: &mut self.dc_sign_luma, + tx_type: Some(self.inter_tx_type_4.as_mut_slice()), + eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), + }, + TxbSet::LumaRect16x4Inter1 => TxbTables { + side: 8, + txb_skip: &mut self.txb_skip_luma_8, + eob_pt: &mut self.eob_pt_64_luma, + eob_extra: &mut self.eob_extra_luma_8, + base: &mut self.base_luma_8, + base_eob: &mut self.base_eob_luma_8, + br: &mut self.br_luma_8, + dc_sign: &mut self.dc_sign_luma, + tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()), + eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), + }, TxbSet::LumaRect16x8Inter => TxbTables { side: 16, txb_skip: &mut self.txb_skip_luma_16, diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index aa9267e4..323d22d2 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -999,6 +999,9 @@ thread_local! { static RECT64_INTER_TU_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32]. static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; + // lane-inter16ab r4: rectangular var-tx leaves with a 4-px axis, [8x4, 4x8] + // -- the `sub_tx_size_map[TX_16X4]` split leaves of a 16x16-level 1:4 strip. + static VARTX_RECT_LEAF4_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter // frame -- 16x8 and 8x16 inter leaves. static INTER_LEAF16_HORZ_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; @@ -1057,9 +1060,16 @@ pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] { VARTX_RECT_LEAF_HITS.with(|c| c.get()) } +/// Current value of [`VARTX_RECT_LEAF4_HITS`] (lane-inter16ab r4): 8x4/4x8 +/// split leaves of a 16x4/4x16 strip, `[8x4, 4x8]`. +pub(crate) fn vartx_rect_leaf4_hits() -> [usize; 2] { + VARTX_RECT_LEAF4_HITS.with(|c| c.get()) +} + /// Records one rectangular var-tx leaf. fn vartx_rect_leaf_hit(tw: usize, th: usize) { - VARTX_RECT_LEAF_HITS.with(|c| { + let cell = if tw.min(th) == 4 { &VARTX_RECT_LEAF4_HITS } else { &VARTX_RECT_LEAF_HITS }; + cell.with(|c| { let mut h = c.get(); h[usize::from(th > tw)] += 1; c.set(h); @@ -2029,6 +2039,34 @@ pub(crate) fn nocfl_uv_mode_hits() -> usize { NOCFL_UV_MODE_HITS.with(|c| c.get()) } +/// lane-inter16ab r5: the six RECTANGULAR wedge shapes, in this order -- +/// the counter slots of [`RECT_WEDGE_HITS`]/[`RECT_WII_HITS`]. +pub(crate) const RECT_WEDGE_SHAPES: [(usize, usize); 6] = + [(8, 16), (16, 8), (16, 32), (32, 16), (8, 32), (32, 8)]; + +fn rect_wedge_slot(bw: usize, bh: usize) -> Option { + RECT_WEDGE_SHAPES.iter().position(|&s| s == (bw, bh)) +} + +// lane-inter16ab r5: how many COMPOUND_WEDGE / wedge-INTERINTRA blocks used a +// RECTANGULAR codebook row (hgtw/hltw), per shape -- the gate's proof that +// the rect wedge masks lifted this round actually fired, not just the square +// ones already counted by `WEDGE_HITS`/`WII_HITS`. +thread_local! { + static RECT_WEDGE_HITS: std::cell::Cell<[usize; 6]> = const { std::cell::Cell::new([0; 6]) }; + static RECT_WII_HITS: std::cell::Cell<[usize; 6]> = const { std::cell::Cell::new([0; 6]) }; +} + +/// Current value of [`RECT_WEDGE_HITS`], indexed by [`RECT_WEDGE_SHAPES`]. +pub(crate) fn rect_wedge_hits() -> [usize; 6] { + RECT_WEDGE_HITS.with(|c| c.get()) +} + +/// Current value of [`RECT_WII_HITS`], indexed by [`RECT_WEDGE_SHAPES`]. +pub(crate) fn rect_wii_hits() -> [usize; 6] { + RECT_WII_HITS.with(|c| c.get()) +} + // lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC // blend -- the gate's proof that `--enable-obmc=1` reached this shape (the // r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented @@ -2423,6 +2461,64 @@ pub fn ab16_inter_hits_by_arm() -> [usize; 4] { AB16_INTER_HITS.with(std::cell::Cell::get) } +// lane-inter16ab r2: the 16x16-level 1:4 pair as INTER blocks -- four 16x4 +// (`PARTITION_HORZ_4`) or 4x16 (`PARTITION_VERT_4`) strips. `CHROMA_PAIRS` +// counts the odd strips that close a 4:2:0 chroma pair +// (`is_chroma_reference`, av1_common_int.h:1454: bh == 1 mi => odd mi_row), +// `SUB8_PIECES` the pair chroma blocks whose TOP (LEFT) half was built from +// the PREVIOUS strip's own mv/ref/filters -- libaom +// `build_inter_predictors_sub8x8` (reconinter_template.inc:87-160), reached +// through `is_sub8x8_inter` (same file, :54). +thread_local! { + static INTER16_HORZ4_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; + static INTER16_VERT4_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; + static INTER16_CHROMA_PAIR_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; + static INTER16_SUB8_PIECE_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Current values of the inter 16x16-level 1:4 counters: `(16x4 strips, 4x16 +/// strips, chroma pairs closed, chroma pairs built from two different +/// strips' motion vectors)`. +pub fn inter16_rect4_counters() -> (usize, usize, usize, usize) { + ( + INTER16_HORZ4_HITS.with(std::cell::Cell::get), + INTER16_VERT4_HITS.with(std::cell::Cell::get), + INTER16_CHROMA_PAIR_HITS.with(std::cell::Cell::get), + INTER16_SUB8_PIECE_HITS.with(std::cell::Cell::get), + ) +} + +/// One 16x4 / 4x16 inter strip's chroma situation, handed to +/// [`decode_inter_block`] out of band (the same one-shot thread-local idiom +/// `REDUCED_TX_SET_INTER` uses) rather than through twenty-three call sites +/// that all mean "an ordinary block, chroma of its own". +#[derive(Clone, Copy)] +struct InterStripChroma { + /// `is_chroma_reference` for this strip: false on strips 0 and 2, which + /// read and reconstruct NO chroma at all. + has_chroma: bool, + /// `PARTITION_HORZ_4` (16x4 strips) rather than `PARTITION_VERT_4`. + horz: bool, + /// The mi position of the EVEN strip of this pair -- `setup_pred_plane`'s + /// `if (ss_y && (mi_row & 1) && mi_size_high[bsize] == 1) mi_row -= 1`, + /// i.e. the origin of the 8x4 (4x8) chroma transform. + pair_mi: (usize, usize), + /// The previous (even) strip's single-reference MC parameters, `None` + /// when it was intra or compound -- `is_sub8x8_inter` then returns false + /// and the whole chroma block is predicted from THIS strip's mv. + prev: Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>, +} + +thread_local! { + static INTER_STRIP_CHROMA: std::cell::Cell> = + const { std::cell::Cell::new(None) }; + /// The single-reference MC parameters of the inter block that decoded + /// last -- read by the next 1:4 strip to build its pair's chroma. + static INTER_LAST_MC: std::cell::Cell< + Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>, + > = const { std::cell::Cell::new(None) }; +} + fn bump_ab16_inter(arm: usize) { AB16_INTER_HITS.with(|c| { let mut v = c.get(); @@ -12375,6 +12471,10 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool { (w, h), // 2:1 strips whose transform is coded in full (lane-inter4). (32, 16) | (16, 32) | (16, 8) | (8, 16) + // lane-inter16ab r2: the 16x16-level 1:4 strips. TX_16X4/TX_4X16 + // codes all 64 of its positions, and its chroma pair is an 8x4 / + // 4x8 unit (`ss_size_lookup[BLOCK_16X4]` = BLOCK_8X4). + | (16, 4) | (4, 16) // lane-r14 r2: strips with a 64-px axis. `av1_get_max_eob` codes // only the low 32 coefficients of a 64-length axis, so these read // exactly the truncated corner the INTRA superblock-strip path @@ -12383,6 +12483,11 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool { // `TX_64X64`, so `av1_get_ext_tx_set_type` is `DCT_ONLY` and no // `tx_type` symbol is coded at all. | (64, 32) | (32, 64) | (64, 16) | (16, 64) + // lane-inter16ab r4: `sub_tx_size_map[TX_16X4] == TX_8X4`, so a + // split-transform 16x4/4x16 strip has RECTANGULAR 8x4/4x8 leaves. + // Only reachable as a var-tx LEAF -- an 8x4/4x8 inter BLOCK is + // refused earlier ("an inter partition below 8x8"). + | (8, 4) | (4, 8) ) } @@ -12394,9 +12499,27 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool { /// `tx_size_sqr == TX_8X8`, so it reads `EXT_TX_SET_DCT_IDTX` when reduced /// and the 16-symbol `EXT_TX_SET_ALL16` otherwise -- both at the *8x8* CDF /// row (`txsize_sqr_map`), never the 16x16 one. -fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet { - match (w, h) { +fn rect_inter_luma_set(w: usize, h: usize) -> Result { + Ok(match (w, h) { (32, 16) | (16, 32) => TxbSet::LumaRect32x16Inter, + // lane-inter16ab r4: the 8x4/4x8 split leaf of a 16x4/4x16 strip. + // `av1_get_ext_tx_set_type` (blockd.h:1097) at `tx_size_sqr_up == + // TX_8X8`, `tx_size_sqr == TX_4X4`, inter: DCT_IDTX when reduced, + // ALL16 otherwise -- both at the TX_4X4 row. + (8, 4) | (4, 8) => { + if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) { + TxbSet::LumaRect8x4Inter + } else { + TxbSet::LumaRect8x4InterSet1 + } + } + (16, 4) | (4, 16) => { + if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) { + TxbSet::LumaRect16x4Inter + } else { + TxbSet::LumaRect16x4Inter1 + } + } (16, 8) | (8, 16) => { if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) { TxbSet::LumaRect16x8Inter @@ -12411,16 +12534,20 @@ fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet { // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot. (64, 32) | (32, 64) => TxbSet::Luma64, (64, 16) | (16, 64) => TxbSet::LumaRect32x16, - _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), - } + _ => { + return Err(unsupported( + "a rectangular inter luma transform unit whose shape has no coefficient table set here", + )); + } + }) } /// The chroma table set of the same block's single rectangular chroma unit /// (`av1_get_max_uv_txsize`): 16x8/8x16 under a 32x16/16x32 strip, 8x4/4x8 /// under a 16x8/8x16 one. Neither codes a `tx_type` symbol -- both inherit /// the luma unit's. -fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet { - match (w, h) { +fn rect_inter_chroma_set(w: usize, h: usize) -> Result { + Ok(match (w, h) { (16, 8) | (8, 16) => TxbSet::ChromaRect16x8, (8, 4) | (4, 8) => TxbSet::ChromaRect8x4, // lane-r14 r2: chroma of a 64-axis strip -- 32x16/16x32 under a @@ -12430,8 +12557,12 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet { // `txsize_log2_minus4` = 4), same as the intra strip path uses. (32, 16) | (16, 32) => TxbSet::ChromaRect32x16, (32, 8) | (8, 32) => TxbSet::Chroma16, - _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), - } + _ => { + return Err(unsupported( + "a rectangular inter chroma transform unit whose shape has no coefficient table set here", + )); + } + }) } /// libaom `size_group_lookup[bsize]` for the block shapes this decoder's @@ -12467,18 +12598,24 @@ fn size_group_wh_matches_libaom_size_group_lookup() { } /// The default (2D) coefficient scan of a rectangular transform. -fn rect_scan(w: usize, h: usize) -> &'static [u16] { - match (w, h) { +fn rect_scan(w: usize, h: usize) -> Result<&'static [u16]> { + Ok(match (w, h) { (32, 16) => &SCAN_32X16, (16, 32) => &SCAN_16X32, (16, 8) => &SCAN_16X8, (8, 16) => &SCAN_8X16, + (16, 4) => &SCAN_16X4, + (4, 16) => &SCAN_4X16, (8, 4) => &SCAN_8X4, (4, 8) => &SCAN_4X8, (32, 8) => &SCAN_32X8, (8, 32) => &SCAN_8X32, - _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), - } + _ => { + return Err(unsupported( + "a rectangular transform unit whose shape has no coefficient scan table here", + )); + } + }) } /// [`read_block_tx_size`] for a rectangular inter block (lane-inter4 r2): @@ -12640,7 +12777,7 @@ fn read_inter_plane_rect( read_coeffs_rect( dec, &mut coding, - rect_scan(cw, ch), + rect_scan(cw, ch)?, cw, ch, skip_ctx, @@ -16902,18 +17039,26 @@ fn obmc_blend( /// always `is_interinter_compound_used`, so the function is always `true` /// for `side` -- kept as a named call (rather than inlined `true`) so a /// future sub-8 block size does not silently misdecode a real stream. -fn is_any_masked_compound_used_here(side: usize) -> bool { - side.min(side) >= 8 -} - -/// libaom's `BLOCK_SIZES_ALL` index of a `w`x`h` block (`common_data.h`'s own -/// enum order) -- the row every bsize-indexed CDF (`compound_type_cdf`, -/// `wedge_idx_cdf`) is read at. lane-intersub8 r4: these two used to be -/// indexed by the caller's SQUARE envelope, so a 16x8 compound block read -/// `BLOCK_16X16`'s row (class table-indexed-by-raw-size) and desynced the -/// tile at its first masked-compound rect block. -fn bsize_index(w: usize, h: usize) -> Option { - Some(match (w, h) { +fn is_any_masked_compound_used_here(bw: usize, bh: usize) -> bool { + // lane-inter16ab r4 (class sweep of the r3 CDF-row defect): + // `is_comp_ref_allowed(bsize)` is `AOMMIN(block_size_wide, block_size_high) + // >= 8` on the block's TRUE footprint -- a 16x4/4x16 strip is NOT allowed, + // so libaom writes no `comp_group_idx` symbol there at all. Keyed off the + // square `side` we read one the reference never wrote. + bw.min(bh) >= 8 +} + +/// The `BLOCK_SIZES_ALL` index of a `bw x bh` block (libaom `enum BLOCK_SIZE`, +/// `blockd.h`) -- the row every size-indexed inter CDF table +/// (`compound_type_cdf`, `wedge_idx_cdf`) is keyed by. Our `decode_inter_block` +/// carries the enclosing SQUARE `side` for context purposes (the accepted +/// strip corner-cut), so a 16x8 / 8x16 PARTITION_HORZ/VERT strip that reads +/// one of those symbols off `side` alone takes BLOCK_16X16's row and desyncs +/// (lane-inter16ab r3: a real 16x8 compound strip with `comp_group_idx == 1`, +/// decode-order frame 5, our range 64901 vs the oracle's 47271 at the very +/// next block's mode read). +fn bsize_all_index(bw: usize, bh: usize) -> Option { + Some(match (bw, bh) { (4, 4) => 0, (4, 8) => 1, (8, 4) => 2, @@ -16940,33 +17085,20 @@ fn bsize_index(w: usize, h: usize) -> Option { }) } -/// `is_any_masked_compound_used` (libaom `reconinter.h`) on the block's TRUE -/// footprint: `is_comp_ref_allowed` is `AOMMIN(bw, bh) >= 8`, and every -/// shape that clears it has either a wedge or a DIFFWTD compound available. -fn masked_compound_used_wh(w: usize, h: usize) -> bool { - w.min(h) >= 8 -} - /// `av1_wedge_params_lookup[bsize].wedge_types > 0` (libaom `reconinter.c`): -/// the shapes whose `compound_type` symbol is really coded. Everything else -/// with a compound mask infers `COMPOUND_DIFFWTD` without a symbol. -fn wedge_used_wh(w: usize, h: usize) -> bool { +/// the block sizes that carry a wedge codebook at all. A `compound_type` +/// symbol is written only for these; every other size infers +/// `COMPOUND_DIFFWTD`. +fn wedge_used_bsize(bw: usize, bh: usize) -> bool { matches!( - (w, h), - (8, 8) - | (8, 16) - | (16, 8) - | (16, 16) - | (16, 32) - | (32, 16) - | (32, 32) - | (8, 32) - | (32, 8) - | (16, 64) - | (64, 16) + (bw, bh), + (8, 8) | (8, 16) | (16, 8) | (16, 16) | (16, 32) | (32, 16) | (32, 32) | (8, 32) | (32, 8) ) } + + + /// Whether a compound reference pair is unidirectional (both references on /// the same temporal side of the current frame) -- `has_uni_comp_refs` /// (libaom `av1_reference_frame_utils.h`/`pred_common.c`'s own definition: @@ -17416,9 +17548,27 @@ fn decode_inter_block( // exactly what it read before. let (rmi, cmi) = at; let (px, py) = (at.1 * MI, at.0 * MI); - let (cpx, cpy) = (px / 2, py / 2); + // lane-inter16ab r2: a 16x4 / 4x16 inter strip's chroma is the PAIR's + // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd + // strip (`is_chroma_reference`); every other block keeps its own. + let strip_chroma = INTER_STRIP_CHROMA.with(std::cell::Cell::take); + INTER_LAST_MC.with(|c| c.set(None)); + let has_chroma = strip_chroma.is_none_or(|s| s.has_chroma); + let (cpx, cpy) = match strip_chroma { + Some(s) if s.has_chroma => (s.pair_mi.1 * MI / 2, s.pair_mi.0 * MI / 2), + _ => (px / 2, py / 2), + }; let chroma_side = side / 2; - let (write_chroma_w, write_chroma_h) = (write_w / 2, write_h / 2); + let (write_chroma_w, write_chroma_h) = match strip_chroma { + Some(s) if s.has_chroma => { + if s.horz { + (8, 4) + } else { + (4, 8) + } + } + _ => (write_w / 2, write_h / 2), + }; if std::env::var_os("EC_AV1_TELL").is_some() { eprintln!( @@ -17442,7 +17592,12 @@ fn decode_inter_block( let (seg_mi_r, seg_mi_c) = (rmi, cmi); let (seg_w_mi, seg_h_mi) = (write_w / 4, write_h / 4); inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, false, true); - let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; + // libaom `read_skip_mode` (decodemv.c): `if (!is_comp_ref_allowed(bsize)) + // return 0` -- a 16x4 / 4x16 strip (min(bw, bh) == 4, blockd.h:65) reads + // no `skip_mode` symbol at all. + let comp_allowed = write_w.min(write_h) >= 8; + let skip_mode = + skip_mode_present && comp_allowed && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; if std::env::var_os("EC_AV1_SKIPMODE_DUMP").is_some() { eprintln!( "EC_SKIPMODE r={r} c={c} result={skip_mode} tell_after={}", @@ -17554,7 +17709,12 @@ fn decode_inter_block( ); } let is_compound = - skip_mode || (reference_select && read_comp_mode(dec, cdfs, above_nbr, left_nbr)); + skip_mode + || (reference_select + // `is_comp_ref_allowed` (blockd.h:65) gates the + // `comp_mode` read exactly as it gates `skip_mode`. + && comp_allowed + && read_comp_mode(dec, cdfs, above_nbr, left_nbr)); if is_compound { let (ref0, ref1) = if skip_mode { (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8) @@ -17756,7 +17916,7 @@ fn decode_inter_block( let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side); let comp_group_idx = if !skip_mode && enable_masked_compound - && masked_compound_used_wh(write_w, write_h) + && is_any_masked_compound_used_here(write_w, write_h) { dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) } else { @@ -17789,11 +17949,11 @@ fn decode_inter_block( // writes NO `compound_type` symbol there and INFERS // `COMPOUND_DIFFWTD` -- only the 1-bit `mask_type` literal // follows. `None` here is exactly that inferred arm. - // lane-intersub8 r4: the block's TRUE footprint, not the - // square envelope -- `compound_type_cdf`/`wedge_idx_cdf` are - // `BLOCK_SIZES_ALL`-indexed. + // lane-inter16ab r3: the row is this block's TRUE + // `BLOCK_SIZES_ALL` index, not the enclosing square `side`'s + // -- a 16x8 strip reads `compound_type_cdf[BLOCK_16X8]`. let wedge_bsize = - bsize_index(write_w, write_h).filter(|_| wedge_used_wh(write_w, write_h)); + bsize_all_index(write_w, write_h).filter(|_| wedge_used_bsize(write_w, write_h)); let compound_type = match wedge_bsize { Some(b) => dec.symbol(&mut cdfs.compound_type[b]), None => 1, @@ -17801,20 +17961,26 @@ fn decode_inter_block( if let Some(wedge_bsize) = wedge_bsize.filter(|_| compound_type == 0) { // COMPOUND_WEDGE: lane-wedge r3, codebook checksum- // verified vs independent C dump (wedge.rs). - if write_w != write_h { - // lane-intersub8 r4: the wedge codebook here is built - // per SQUARE side only; a rect block's own codebook - // (BLOCK_16X8 etc.) is a different mask set. - return Err(unsupported( - "a COMPOUND_WEDGE mask on a non-square inter block (rect wedge codebook unimplemented)", - )); - } let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); let wedge_sign = dec.literal(1); WEDGE_HITS.with(|c| c.set(c.get() + 1)); + if let Some(k) = rect_wedge_slot(write_w, write_h) { + RECT_WEDGE_HITS.with(|c| { + let mut a = c.get(); + a[k] += 1; + c.set(a); + }); + } + // lane-inter16ab r5: the codebook row is this block's TRUE + // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for + // h>w, hltw for h= 8, false for a 16x4 / 4x16 strip. + && write_w.min(write_h) >= 8 && interintra_mode.is_none() && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty() || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1) @@ -19187,6 +19372,11 @@ fn decode_inter_block( } } + // lane-inter16ab r2: `is_sub8x8_inter`'s neighbour walk reads the + // PREVIOUS strip's `mv`/`ref_frame`/`interp_filters` + // (reconinter_template.inc:75-82); record them for the next 1:4 + // strip, which is the only reader. + INTER_LAST_MC.with(|c| c.set(Some((ref_frame, mv, h_filter, v_filter)))); let mut pred_y = vec![0u16; side * side]; let mut pred_u = vec![0u16; chroma_side * chroma_side]; let mut pred_v = vec![0u16; chroma_side * chroma_side]; @@ -19360,6 +19550,46 @@ fn decode_inter_block( interintra_blend(v, cpx, cpy, chroma_side, ii, wedge_mask, &mut pred_v); } + // lane-inter16ab r2: libaom `build_inter_predictors_sub8x8` + // (reconinter_template.inc:87-160). A 4:2:0 chroma block under a + // 16x4 (4x16) luma pair covers TWO luma blocks, so it is built in + // `b4_w x b4_h` = 8x2 (2x8) pieces, each from its own strip's + // mv/ref/filters. The bottom (right) piece is this strip's own mv + // over its own rows, which the whole-block prediction above + // already wrote there (MC is position-invariant for a fixed mv), + // so only the FIRST piece has to be rebuilt -- and only when + // `is_sub8x8_inter` holds, i.e. the previous strip was itself a + // single-reference inter block (`prev`), else libaom falls + // through to the ordinary whole-block predictor. + if let Some(s) = strip_chroma.filter(|s| s.has_chroma) + && let Some((prev_ref, prev_mv, prev_h, prev_v)) = s.prev + && luma_scale == mc::REF_NO_SCALE + { + let (piece_w, piece_h) = if s.horz { (8usize, 2usize) } else { (2usize, 8usize) }; + let (_, prev_u, prev_v_plane) = ref_planes(prev_ref, ref_y, ref_u, ref_v, other_refs)?; + for (src, dst) in [(prev_u, &mut pred_u), (prev_v_plane, &mut pred_v)] { + let mut piece = vec![0u16; piece_w * piece_h]; + mc::predict_with_filters( + &src.data, + src.width, + src.true_width, + src.true_height, + mv_to_q4(cpx, prev_mv.1, false), + mv_to_q4(cpy, prev_mv.0, false), + piece_w, + piece_h, + prev_h, + prev_v, + &mut piece, + ); + for row in 0..piece_h { + dst[row * chroma_side..row * chroma_side + piece_w] + .copy_from_slice(&piece[row * piece_w..(row + 1) * piece_w]); + } + } + INTER16_SUB8_PIECE_HITS.with(|c| c.set(c.get() + 1)); + } + // lane-inter4 r2: a rectangular strip's transform tree starts from // its own rect `max_txsize_rect_lookup` entry, not a square one. let rect_tu = (write_w, write_h) != (side, side); @@ -19396,24 +19626,26 @@ fn decode_inter_block( &pred_y, &vec![0i32; side * side], ); - u.reconstruct_mc_rect( - cpx, - cpy, - chroma_side, - write_chroma_w, - write_chroma_h, - &pred_u, - &vec![0i32; chroma_side * chroma_side], - ); - v.reconstruct_mc_rect( - cpx, - cpy, - chroma_side, - write_chroma_w, - write_chroma_h, - &pred_v, - &vec![0i32; chroma_side * chroma_side], - ); + if has_chroma { + u.reconstruct_mc_rect( + cpx, + cpy, + chroma_side, + write_chroma_w, + write_chroma_h, + &pred_u, + &vec![0i32; chroma_side * chroma_side], + ); + v.reconstruct_mc_rect( + cpx, + cpy, + chroma_side, + write_chroma_w, + write_chroma_h, + &pred_v, + &vec![0i32; chroma_side * chroma_side], + ); + } luma_grid = vec![0i32; side * side]; u_grid = vec![0i32; chroma_side * chroma_side]; v_grid = vec![0i32; chroma_side * chroma_side]; @@ -19426,6 +19658,18 @@ fn decode_inter_block( } else { neighbours.around_mi(at, side) }; + // lane-inter16ab r2: the pair's chroma transform sits at the + // EVEN strip's mi origin and spans both strips, so its + // above/left coefficient context is the pair's, not this + // strip's row. + let around_c = match strip_chroma { + Some(s) if s.has_chroma => neighbours.around_mi_rect( + s.pair_mi, + if s.horz { 16 } else { 8 }, + if s.horz { 8 } else { 16 }, + ), + _ => around, + }; let luma_tx_type; if let Some(leaves) = vartx_leaves.clone() { // spec 5.11.17's transform tree, leaf by leaf in the order @@ -19479,7 +19723,7 @@ fn decode_inter_block( read_inter_plane_rect( dec, cdfs, - rect_inter_luma_set(tw, th), + rect_inter_luma_set(tw, th)?, (tw, th), side, 0, @@ -19509,7 +19753,7 @@ fn decode_inter_block( let (grid, tx_type) = read_inter_plane_rect( dec, cdfs, - rect_inter_luma_set(write_w, write_h), + rect_inter_luma_set(write_w, write_h)?, (write_w, write_h), side, 0, @@ -19543,7 +19787,16 @@ fn decode_inter_block( None, )?; } - if rect_tu { + if !has_chroma { + // `is_chroma_reference` is false for this strip: libaom's + // plane loop (decodeframe.c + // `predict_and_reconstruct_intra_block`/ + // `reconstruct_inter_block`'s `for (plane...)` guarded by + // `xd->is_chroma_ref`) codes NO chroma transform here, so + // neither symbol nor context exists. + u_grid = vec![0i32; chroma_side * chroma_side]; + v_grid = vec![0i32; chroma_side * chroma_side]; + } else if rect_tu { // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a // 2:1 strip is the strip's own rect chroma size (16x8 / // 8x16), one unit for the whole block, and it codes no @@ -19553,11 +19806,11 @@ fn decode_inter_block( &read_inter_plane_rect( dec, cdfs, - rect_inter_chroma_set(write_chroma_w, write_chroma_h), + rect_inter_chroma_set(write_chroma_w, write_chroma_h)?, (uw, uh), chroma_side, 1, - around[1], + around_c[1], mode_for_tx, u, cpx, @@ -19575,11 +19828,11 @@ fn decode_inter_block( &read_inter_plane_rect( dec, cdfs, - rect_inter_chroma_set(write_chroma_w, write_chroma_h), + rect_inter_chroma_set(write_chroma_w, write_chroma_h)?, (uw, uh), chroma_side, 2, - around[2], + around_c[2], mode_for_tx, v, cpx, @@ -19640,6 +19893,16 @@ fn decode_inter_block( // skip path above (which only needed a clipped write of an // already-square-predicted buffer). Named refusal instead of a // silently wrong square-shaped intra prediction. + // lane-inter16ab r2: `decode_intra_rect_in_inter` has no chroma-pair + // path (it predicts and codes chroma at the strip's own halved + // footprint), so an INTRA 16x4 / 4x16 strip inside a 1:4 partition is + // refused by name rather than decoded with a 8x2 chroma transform + // libaom never coded. + if write_w.min(write_h) < 8 { + return Err(unsupported( + "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)", + )); + } if write_w != side || write_h != side { // lane-intrarect r1: the strip decodes through its own rect // machinery ([`decode_intra_rect_in_inter`] -> the key-frame @@ -19790,8 +20053,12 @@ fn decode_inter_block( // -- `palette_mode_ctx`/`palette_uv_mode_ctx` hardcoded 0, provably // safe since a nonzero neighbour `palette_size` would already have // refused the decode that produced it. + // lane-inter16ab r4 (class sweep): `av1_get_palette_bsize_ctx` is keyed + // by the block's TRUE footprint -- a rect strip's row is not its + // enclosing square's, and a 16x4 strip (64 pixels) reads no palette + // symbol at all. if allow_screen_content_tools - && let Some(bsize_ctx) = palette_bsize_ctx(side) + && let Some(bsize_ctx) = palette_bsize_ctx_wh(write_w, write_h) { if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][0]) != 0 { return Err(unsupported( @@ -19815,7 +20082,9 @@ fn decode_inter_block( let mut filter_intra = None; if mode == DC_PRED && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get) - && let Some(class) = filter_intra_size_class(side) + // lane-inter16ab r4 (class sweep): `cdf::FILTER_INTRA`'s row is the + // true `BLOCK_SIZES_ALL` class of this strip, not its square side's. + && let Some(class) = filter_intra_size_class_rect(write_w, write_h) && dec.symbol(&mut cdfs.filter_intra[class]) != 0 { FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); @@ -20056,6 +20325,14 @@ fn decode_inter_block( rmi, cmi, dec.debug_bitpos(), dec.debug_state().0 ); } + // lane-inter16ab r2: the pair's chroma coefficient context spans BOTH + // strips (mirroring the intra `decode_rect4_16` path), and the even + // strip's own record wrote empty chroma state over those cells -- this + // rewrite is what libaom's single `av1_set_contexts` call for the 8x4 + // (4x8) chroma unit leaves behind. + let pair_chroma = strip_chroma + .filter(|s| s.has_chroma) + .map(|s| (s, neighbour_state(&u_grid), neighbour_state(&v_grid))); if vartx_leaves.is_some() { // Plane 0 is already correct per transform unit // ([`Neighbours::record_mi_luma`] above); this writes everything else @@ -20072,6 +20349,32 @@ fn decode_inter_block( &[luma_grid, u_grid, v_grid], ); } + if let Some((s, u_state, v_state)) = pair_chroma { + let (pw, ph) = if s.horz { (16usize, 8usize) } else { (8, 16) }; + let round_up_even = |n: usize| n.div_ceil(2) * 2; + let (bound_h, bound_w) = ( + round_up_even(neighbours.mi_rows), + round_up_even(neighbours.mi_cols), + ); + for cell in 0..(ph / MI) { + if s.pair_mi.0 + cell < bound_h + && let Some(slot) = neighbours.left.get_mut(s.pair_mi.0 + cell) + { + slot[1] = u_state; + slot[2] = v_state; + } + } + for cell in 0..(pw / MI) { + if s.pair_mi.1 + cell < bound_w + && let Some(slot) = neighbours.above.get_mut(s.pair_mi.1 + cell) + { + slot[1] = u_state; + slot[2] = v_state; + } + } + neighbours.record_uv_mode_mi(s.pair_mi.0, s.pair_mi.1, pw / MI, ph / MI, uv_predict_mode); + INTER16_CHROMA_PAIR_HITS.with(|c| c.set(c.get() + 1)); + } neighbours.record_inter_rect_mi( at, write_w / MI, @@ -21416,7 +21719,7 @@ fn decode_inter_block8( let group_ctx = get_comp_group_idx_context(neighbours, leaf_mi, SIDE); let comp_group_idx = if !skip_mode && enable_masked_compound - && is_any_masked_compound_used_here(SIDE) + && is_any_masked_compound_used_here(SIDE, SIDE) { dec.symbol(&mut cdfs.comp_group_idx[group_ctx]) } else { @@ -21439,7 +21742,7 @@ fn decode_inter_block8( WEDGE_HITS.with(|c| c.set(c.get() + 1)); wedge_mask = Some( crate::wedge::wedge_masks() - .codebook(SIDE) + .codebook(SIDE, SIDE) .mask(wedge_sign as usize, wedge_index as usize), ); } else { @@ -22033,7 +22336,7 @@ fn decode_inter_block8( WII_HITS.with(|c| c.set(c.get() + 1)); wedge_mask = Some(( crate::wedge::wedge_masks() - .codebook(SIDE) + .codebook(SIDE, SIDE) .mask(0, wedge_index as usize), SIDE, )); @@ -23942,9 +24245,96 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( inter_leaf8!(at16, br); } } + } else if part16 == PARTITION_HORZ_4 + || part16 == PARTITION_VERT_4 + { + // lane-inter16ab r2: four 16x4 (4x16) INTER + // strips. libaom `decode_partition` + // (decodeframe.c, PARTITION_HORZ_4/VERT_4) + // walks them top to bottom (left to right) + // with its own `i > 0` frame-edge break. + // + // Each strip is >= 8 in one dimension only, + // so `is_comp_ref_allowed`, + // `is_motion_variation_allowed_bsize` + // (blockd.h:65/1455, min(bw, bh) >= 8) and + // `is_interintra_allowed_bsize` (BLOCK_8X8.. + // BLOCK_32X32 in enum order, which excludes + // BLOCK_16X4 = 17) are all false: no + // skip_mode, no comp_mode, no OBMC/warp and + // no interintra symbol is read -- gated in + // `decode_inter_block` off `write_w`/ + // `write_h`. + // + // CHROMA is the pair's: + // `is_chroma_reference` + // (av1_common_int.h:1454) is false on the + // even strips, and the odd one codes one 8x4 + // (4x8) chroma transform at the pair's + // origin, built from BOTH strips' motion + // (`is_sub8x8_inter`). + let horz = part16 == PARTITION_HORZ_4; + let (mi_row0, mi_col0) = sub16_to_mi(at16); + let (bw, bh) = if horz { (16usize, 4usize) } else { (4usize, 16usize) }; + for i in 0..4usize { + let at_mi = if horz { + (mi_row0 + i, mi_col0) + } else { + (mi_row0, mi_col0 + i) + }; + if i > 0 + && (at_mi.0 >= mi_rows as usize + || at_mi.1 >= mi_cols as usize) + { + break; + } + let strip_has_chroma = i % 2 == 1; + let pair_mi = if !strip_has_chroma { + at_mi + } else if horz { + (at_mi.0 - 1, at_mi.1) + } else { + (at_mi.0, at_mi.1 - 1) + }; + INTER_STRIP_CHROMA.with(|c| { + c.set(Some(InterStripChroma { + has_chroma: strip_has_chroma, + horz, + pair_mi, + prev: if strip_has_chroma { + INTER_LAST_MC.with(std::cell::Cell::get) + } else { + None + }, + })) + }); + inter_piece!( + at_mi, + SUB, + TxbSet::Luma16, + if reduced_tx_set { + TxbSet::Luma16Inter + } else { + TxbSet::Luma16InterSet1 + }, + TxbSet::Chroma8, + TX16, + TX8, + &scan16, + &scan8, + 1, + bw, + bh + ); + if horz { + INTER16_HORZ4_HITS.with(|c| c.set(c.get() + 1)); + } else { + INTER16_VERT4_HITS.with(|c| c.set(c.get() + 1)); + } + } } else if part16 != PARTITION_SPLIT { return Err(unsupported( - "an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16 inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)", + "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4", )); } else { if has_cols16 && has_rows16 { diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index a3eb9aec..7f6bb35f 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -37,7 +37,9 @@ const REFUSALS: &[&str] = &[ "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes only inter 4x4 sub-blocks there)", "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition (this decoder codes only inter sub-blocks there)", "a sub-8x8 inter block under a scaled reference (superres, unimplemented)", - "a COMPOUND_WEDGE mask on a non-square inter block (rect wedge codebook unimplemented)", + "a rectangular inter luma transform unit whose shape has no coefficient table set here", + "a rectangular inter chroma transform unit whose shape has no coefficient table set here", + "a rectangular transform unit whose shape has no coefficient scan table here", "a 32x32 partition type this decoder does not code (value={part32})", "a Golomb tail longer than this decoder reads", "a tx_type symbol outside its CDF's own set: {t}", @@ -69,14 +71,19 @@ const REFUSALS: &[&str] = &[ "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units", "an inter frame with no key frame before it", "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, VERT, HORZ_4 or VERT_4)", - // lane-inter16ab r1 lifted the AB half (HORZ_A/HORZ_B/VERT_A/VERT_B at - // the 16x16 level of an inter frame: two 8x8 inter leaves plus one true - // 16x8/8x16 inter strip, gate - // `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact`). - // What is left is the 1:4 pair, whose 16x4/4x16 strips need the sub-8 - // inter chroma-pair path (odd-strip `is_chroma_reference`, chroma built - // from BOTH strips' MVs) that no inter block writer has yet. - "an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16 inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)", + // lane-inter16ab r1 lifted the AB half and r2 the 1:4 half (four 16x4 / + // 4x16 inter strips, their 8x4/4x8 chroma pair built from BOTH strips' + // motion vectors -- gate + // `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact`). + // Two narrower refusals are what is left of that shape: + "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4", + // r2 residue: `vartx_leaves` is a list of SQUARE units, and + // `sub_tx_size_map[TX_16X4]` is the rectangular TX_8X4 -- the split tree + // and its per-unit residual reader both need rect leaves. + // r2 residue: `decode_intra_rect_in_inter` codes chroma at the strip's own + // halved footprint, which for a 16x4 strip is an 8x2 transform libaom + // never wrote (its chroma is the PAIR's 8x4, coded by the odd strip). + "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)", "an intra mode this decoder does not code (round 2)", // lane-intrarect r1 lifted the whole-shape refusal that stood here (the // inter path's intra arm now routes 2:1 strips through `decode_rect_split`); diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 6d7023ec..8916a877 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -86,6 +86,25 @@ pub fn rect_intrabc_reads() -> usize { crate::decode::rect_intrabc_reads() } +/// lane-inter16ab r4: RECTANGULAR var-tx leaves with a 4-px axis, `[8x4, 4x8]` +/// -- what `sub_tx_size_map[TX_16X4] == TX_8X4` produces when a 16x16-level +/// 1:4 inter strip splits its transform. +pub fn vartx_rect_leaf4_hits() -> [usize; 2] { + crate::decode::vartx_rect_leaf4_hits() +} + +/// lane-inter16ab r5: COMPOUND_WEDGE / wedge-INTERINTRA blocks that used a +/// RECTANGULAR wedge codebook row, per shape (`RECT_WEDGE_SHAPES` order: +/// 8x16, 16x8, 16x32, 32x16, 8x32, 32x8). +pub fn rect_wedge_hits() -> [usize; 6] { + crate::decode::rect_wedge_hits() +} + +/// lane-inter16ab r5: the wedge-interintra half of [`rect_wedge_hits`]. +pub fn rect_wii_hits() -> [usize; 6] { + crate::decode::rect_wii_hits() +} + pub fn rect4_32_counters() -> (usize, usize, usize) { ( crate::decode::rect4_32_horz_hits(), @@ -9420,6 +9439,296 @@ mod tests { } + + #[test] + // lane-inter16ab r2: the 16x16-level 1:4 partitions on an INTER frame -- + // PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 16x16, i.e. two 8x8 inter + // leaves plus one true 16x8/8x16 inter strip. Every decode-order frame is + // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped, + // out-of-scope mismatches fail the gate, and EACH of the four arms must + // have fired on a pixel-exact attempt (RD picking only HORZ_A is not + // proof of four). `--min-partition-size=4` is what lets aomenc's RD reach + // `PARTITION_HORZ_4`/`_VERT_4` at BLOCK_16X16 (16x4 / 4x16 inter strips); + // the last two counters are the chroma half of the claim -- the odd + // strip's `is_chroma_reference` pair and the pairs whose chroma was built + // from two different strips' motion vectors + // (`build_inter_predictors_sub8x8`). + fn a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact() { + const NAME: &str = + "a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); + return; + } + let (width, height, frame_count) = (192usize, 128usize, 6usize); + // Per arm, over both bit depths: how many pixel-exact attempts fired + // it at least once. + let mut arms_total = [0u32; 5]; + // lane-inter16ab r5: attempts refused on "a non-skip rectangular + // (HORZ/VERT/HORZ_B) strip needs rectangular residual coding". + let mut rect_residual_refusals = 0u32; + for bit_depth in [8u32, 10u32] { + let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = + (0u32, 0u32, 0u32, 0u32); + let mut arms_proved = [0u32; 5]; + // lane-inter16ab r4: a 4-recipe widening (fine `sin(X/3)` stripes + // at cq 8..14, both depths) was measured and REMOVED again -- every + // extra 1:4 partition it produced is in the KEY frame, and this + // gate's arms count INTER-frame strips. Frame-aware histogram + // script + table in lanes/inter16ab-r4.report.md; the only recipe + // in the whole sweep with an inter-frame `PARTITION_VERT_4` is + // attempt 1's, which refuses on the rect wedge-interintra mask. + for attempt in 0..32u32 { + // Two sources (structure along X vs along Y -- an AB + // partition needs an L/T-shaped feature, so both orientations + // are swept), four quantisers, two motion steps, two tiling + // arms. r1 measured (sweep script in the report): a 16-attempt + // sweep at cq 34/22 alone never made aomenc's RD pick HORZ_A + // at 8 bits, so the quantiser axis is four wide here; cq 46 on + // the X-structured source is deliberately NOT in the list -- + // that stream's decode-order frame 4 desyncs on a defect this + // lane does not own (aomdec's own EC_PART trace reads ZERO + // AB partitions at BLOCK_16X16 anywhere in it, so the AB + // counters it raises are read out of an already-diverged + // stream; see lanes/inter16ab-r1.report.md). + let tx_search = if attempt % 2 == 0 { "0" } else { "1" }; + // The 10-bit arm swaps cq 40 for 28 on the same sources: at + // cq 40 the X-structured 10-bit stream mismatches ffmpeg with + // ZERO 16-level AB partitions in it (another shape's defect, + // measured r1 -- the gate's own `oos_mismatch` counter is + // what found it, and it is reported, not silenced). + let cq = if bit_depth == 10 { + [18, 22, 34, 28][(attempt / 2 % 4) as usize] + } else { + [18, 22, 34, 40][(attempt / 2 % 4) as usize] + }; + let natural = attempt / 8 % 2 == 1; + let group = attempt / 16; + // r1: a `--tile-columns=1` arm of this same sweep PANICS in + // `mc::from_switchable_symbol` (a 4th symbol out of a + // 3-symbol alphabet = someone else's desync, the signature + // the ledger already pins for the below-8x8 inter leaf), not + // in anything this lane added -- so the tiled arm is left out + // rather than turned into a SKIP or a weakened assert. + // Reported as residue in lanes/inter16ab-r1.report.md. + let tile_cols = "0"; + let sp = 3 + (group % 2) * 5; + let duration = frame_count as f64 / 25.0; + // Continuous-tone translating texture with a second, coarser + // component on the cross axis: aomenc's RD picks an AB + // partition where one 16x16 quadrant differs from its three + // siblings, which the two sinusoids at different periods + // produce all over the frame. + let lum = if natural { + format!("128+58*sin((Y+N*{sp})/6)+40*sin(X/11)+20*sin((X+Y)/5)") + } else { + format!("128+58*sin((X+N*{sp})/6)+40*sin(Y/11)+20*sin((X-Y)/5)") + }; + let source = format!( + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ + geq=lum='{lum}',format=yuv420p" + ); + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; + let y4m = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let cq_arg = format!("--cq-level={cq}"); + let depth_arg = format!("--bit-depth={bit_depth}"); + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); + let tx_arg = format!("--enable-tx-size-search={tx_search}"); + let tile_arg = format!("--tile-columns={tile_cols}"); + let args: Vec<&str> = vec![ + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", + "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg, + // Per-arm overrides go LAST: aomenc keeps the last + // occurrence of a repeated --enable-* flag. + &tx_arg, + "--enable-rect-partitions=1", "--enable-ab-partitions=1", + "--enable-1to4-partitions=1", "--min-partition-size=4", + "--max-partition-size=16", + "--obu", "-o", "-", "-", + ]; + let mut child = Command::new(aomenc_path()) + .args(&args) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m.stdout) + .expect("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + let before = decode::inter16_rect4_counters(); + let leaf4_before = crate::stream::vartx_rect_leaf4_hits(); + let frames = match decode_stream(&stream) { + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ + attempt {attempt}): {msg}" + ); + // lane-inter16ab r5: attempt 1 is the ONLY recipe in + // r4's 100+ stream frame-aware sweep with an + // inter-frame PARTITION_VERT_4. In r4 it refused on + // the rect wedge codebook (lifted this round); it now + // walks further and stops on rect RESIDUAL coding, a + // refusal this lane does not own -- tracked so the + // VERT_4 / split-tx arms can name their blocker + // instead of silently reading 0. + if msg.contains("needs rectangular residual coding") { + rect_residual_refusals += 1; + } + named_refusals += 1; + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); + continue; + } + Ok(frames) => frames, + }; + let after = decode::inter16_rect4_counters(); + let leaf4_after = crate::stream::vartx_rect_leaf4_hits(); + // [16x4 strips, 4x16 strips, chroma pairs closed, chroma + // pairs built from two strips' motion vectors]. + let fired = [ + after.0 - before.0, + after.1 - before.1, + after.2 - before.2, + after.3 - before.3, + // lane-inter16ab r4: the SPLIT-transform arm -- + // `sub_tx_size_map[TX_16X4] == TX_8X4`, so a 1:4 strip + // that splits its transform codes 8x4/4x8 RECTANGULAR + // var-tx leaves (`--enable-tx-size-search=1`). + (leaf4_after[0] - leaf4_before[0]) + (leaf4_after[1] - leaf4_before[1]), + ]; + let ffmpeg_frames = if bit_depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) + } else { + ffmpeg_decode_sequence(&stream, width, height, frame_count) + }; + assert_eq!(frames.len(), frame_count); + let mismatched = frames + .iter() + .zip(&ffmpeg_frames) + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); + if fired[0] + fired[1] == 0 { + out_of_scope += 1; + if mismatched { + oos_mismatch += 1; + eprintln!( + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ + 16-level inter AB partition -- another shape's defect" + ); + } + continue; + } + if mismatched { + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + let bad: Vec = + (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect(); + if !bad.is_empty() { + eprintln!( + "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \ + pixels differ, first at ({}, {}), max |delta| {}", + bad.len(), + bad[0] % width, + bad[0] / width, + bad.iter() + .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs()) + .max() + .unwrap_or(0) + ); + } + } + } + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); + } + for a in 0..5 { + if fired[a] > 0 { + arms_proved[a] += 1; + arms_total[a] += 1; + } + } + matched += 1; + } + eprintln!( + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ + attempts carrying a 16-level inter 1:4 partition, per-arm attempts \ + HORZ_4/VERT_4/chroma-pair/sub8x8-chroma/split-tx-8x4={arms_proved:?}, {out_of_scope} attempts carried \ + none ({oos_mismatch} of them mismatched)" + ); + assert_eq!( + oos_mismatch, 0, + "{NAME}: {oos_mismatch} attempt(s) with no 16-level inter 1:4 partition decoded \ + but mismatched ffmpeg -- a defect of another shape, not a pass" + ); + } + // Arms 1/3/4 (HORZ_4, the odd-strip `is_chroma_reference` pair, the + // `build_inter_predictors_sub8x8` two-mv chroma build) are proven + // outright. + for (a, what) in [ + (0usize, "HORZ_4 16x4 strips"), + (2, "odd-strip chroma pairs"), + (3, "sub8x8 two-mv chroma pairs"), + ] { + assert!( + arms_total[a] > 0, + "{NAME}: arm {a} ({what}) never fired on a pixel-exact attempt \ + (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?})" + ); + } + // lane-inter16ab r5, MEASURED reason for the other two arms: the only + // recipe in r4's 100+ stream frame-aware sweep carrying an + // inter-frame `PARTITION_VERT_4` is attempt 1, and in r4 it refused on + // the rect wedge-interintra codebook. That refusal is LIFTED this + // round -- the stream now walks past it and stops on "a non-skip + // rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual + // coding", a refusal this lane does not own. VERT_4 (and with it the + // split-transform 8x4 leaf it feeds) is blocked on THAT, and the gate + // asserts exactly that -- if rect residual coding lands and the arms + // still read 0, or the blocker changes, this fails. + assert!( + (arms_total[1] > 0 && arms_total[4] > 0) || rect_residual_refusals > 0, + "{NAME}: the VERT_4 / split-tx-8x4 arms read 0 \ + (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?}) and NO \ + attempt refused on rectangular residual coding -- their documented blocker is gone, \ + so a zero arm is now unexplained" + ); + } + + #[test] fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() { if !have_ffmpeg() { @@ -15446,6 +15755,208 @@ mod tests { } + /// lane-inter16ab r5: `COMPOUND_WEDGE` on a RECTANGULAR inter block -- + /// the shapes `av1_wedge_params_lookup` gives the `hgtw`/`hltw` + /// codebooks (8x16/16x32/8x32 and 16x8/32x16/32x8), which this decoder + /// refused by name until this round ("the wedge codebook is + /// square-only"). `--enable-rect-partitions=1` with + /// `--min-partition-size=16 --max-partition-size=32` is what makes + /// aomenc's RD put a masked compound block on a 16x32/32x16 strip + /// (measured: ~/.cache/inter16ab-tmp/rw2.sh, 24/24 streams at cq 50/55 + /// carry one and decode to the end at BOTH bit depths). + /// + /// Class `counter-from-refused-stream`: the per-shape counters are read + /// as a DELTA around one attempt and only counted for attempts that + /// decoded fully AND compared pixel-exact -- a refused attempt's hits + /// are discarded. Every decode-order frame (including hidden alt-ref + /// frames) is compared via [`decode_all_frames_vs_oracle`], and an + /// attempt that mismatches while carrying NO rect wedge fails the gate + /// through `oos_mismatch` rather than being blamed on this lane. + #[test] + fn a_real_aomenc_stream_with_a_rectangular_compound_wedge_decodes_pixel_exact() { + const NAME: &str = + "a_real_aomenc_stream_with_a_rectangular_compound_wedge_decodes_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); + return; + } + let (width, height, frame_count) = (96usize, 96usize, 24usize); + // Per rect shape (8x16, 16x8, 16x32, 32x16, 8x32, 32x8), summed over + // the attempts that decoded AND matched. + let mut shapes_proved = [0usize; 6]; + let (mut named_refusals, mut matched, mut oos_mismatch) = (0u32, 0u32, 0u32); + let mut attempts = 0u32; + for bit_depth in [8u32, 10u32] { + for &cq in &[50u32, 55] { + for a in 0..4u32 { + attempts += 1; + let duration = frame_count as f64 / 25.0; + // Same hard-diagonal-edge content the square wedge gate + // uses (wedge's masters are OBLIQUE), panned per attempt. + let source = format!( + "mandelbrot=size={width}x{height}:rate=25:start_x={sx}:start_y={sy}", + sx = -0.6 + 0.01 * (a as f64), + sy = -0.4 + 0.01 * (a as f64) + ); + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; + let y4m = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", &source, "-t", + &duration.to_string(), "-pix_fmt", pix_fmt, "-strict", "-1", + "-f", "yuv4mpegpipe", "-strict", "-1", "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "{NAME}: ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let cq_arg = format!("--cq-level={cq}"); + let depth_arg = format!("--bit-depth={bit_depth}"); + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); + let args: Vec<&str> = vec![ + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", + &depth_arg, &input_depth_arg, + "--kf-max-dist=1000", "--threads=1", "--row-mt=0", "--auto-alt-ref=1", + "--lag-in-frames=16", "--enable-fwd-kf=0", "--enable-order-hint=1", + "--enable-warped-motion=1", "--enable-global-motion=0", + "--enable-obmc=1", "--enable-diff-wtd-comp=1", + "--enable-interintra-comp=1", "--enable-onesided-comp=0", + "--enable-interintra-wedge=1", "--enable-smooth-interintra=1", + "--enable-ab-partitions=0", "--enable-1to4-partitions=0", + "--enable-filter-intra=0", "--enable-smooth-intra=0", + "--enable-paeth-intra=0", "--enable-directional-intra=0", + "--enable-angle-delta=0", "--enable-tx-size-search=0", + "--enable-cdef=0", "--enable-restoration=0", "--enable-palette=0", + "--enable-intrabc=0", "--enable-cfl-intra=0", + "--enable-ref-frame-mvs=0", + // Per-arm overrides LAST (aomenc keeps the last + // occurrence of a repeated --enable-* flag): masked + // compound ON, distance-weighted OFF so the + // comp_group_idx==1 slot goes to wedge/diffwtd, and + // rectangular partitions ON at 16/32 -- the shapes + // the hgtw/hltw codebooks exist for. + "--enable-masked-comp=1", "--enable-dist-wtd-comp=0", + "--enable-rect-partitions=1", + "--min-partition-size=16", "--max-partition-size=32", + "--obu", "-o", "-", "-", + ]; + let mut child = Command::new(aomenc_path()) + .args(&args) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m.stdout) + .expect("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + let before = crate::stream::rect_wedge_hits(); + let frames = match decode_stream(&stream) { + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{NAME} failed outright, not a named refusal \ + ({bit_depth}-bit cq{cq} attempt {a}): {msg}" + ); + assert!( + !msg.contains("wedge codebook is square-only"), + "{NAME}: the rect wedge codebook is ported -- this refusal is \ + forbidden ({bit_depth}-bit cq{cq} attempt {a}): {msg}" + ); + named_refusals += 1; + eprintln!("{bit_depth}-bit cq{cq} attempt {a} refusal: {msg}"); + continue; + } + Ok(frames) => frames, + }; + let after = crate::stream::rect_wedge_hits(); + let fired: Vec = + (0..6).map(|k| after[k] - before[k]).collect(); + let ffmpeg_frames = if bit_depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) + } else { + ffmpeg_decode_sequence(&stream, width, height, frame_count) + }; + assert_eq!(frames.len(), ffmpeg_frames.len()); + let mismatched = frames + .iter() + .zip(&ffmpeg_frames) + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); + if fired.iter().sum::() == 0 { + if mismatched { + oos_mismatch += 1; + eprintln!( + "{NAME}: {bit_depth}-bit cq{cq} attempt {a} MISMATCHES with zero \ + rectangular wedge block -- another shape's defect" + ); + } + continue; + } + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})"); + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})"); + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})"); + } + // class gate-blind-to-hidden-frames: the shown-frame + // compare above cannot see the alt-ref frames this + // recipe's --lag-in-frames=16 produces. + let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME); + eprintln!( + "{NAME}: {bit_depth}-bit cq{cq} attempt {a}: shapes {fired:?}, \ + {hidden_total} decode-order frames ({hidden_n} hidden) pixel-exact" + ); + for k in 0..6 { + shapes_proved[k] += fired[k]; + } + matched += 1; + } + } + } + eprintln!( + "{NAME}: {named_refusals} named refusals, {matched} pixel-exact attempts out of \ + {attempts}, rect wedge blocks per shape \ + (8x16,16x8,16x32,32x16,8x32,32x8)={shapes_proved:?}, {oos_mismatch} zero-wedge \ + mismatches" + ); + assert_eq!( + oos_mismatch, 0, + "{NAME}: {oos_mismatch} attempt(s) carrying no rectangular wedge mismatched ffmpeg \ + -- a defect of another shape, not a pass" + ); + // The claim: a rectangular wedge codebook row (hgtw AND hltw) was + // used on a stream that then decoded pixel-exact. 16x32 is hgtw + // (h > w), 32x16 is hltw (h < w) -- one of each, so a transposed + // codebook/signflip pair cannot pass this. + assert!( + shapes_proved[2] > 0 && shapes_proved[3] > 0, + "{NAME}: no pixel-exact attempt used both an hgtw (16x32) and an hltw (32x16) \ + rectangular wedge codebook row (per shape {shapes_proved:?}, {matched} matches, \ + {named_refusals} refusals out of {attempts}) -- the recipe proved nothing" + ); + } + + /// lane-lr r3: proves stage 1/2's exit criterion -- a real /// `--enable-restoration=1` aomenc stream must survive the whole /// partition walk (every symbol read entropy-exact) and land on the diff --git a/crates/ec-av1/src/wedge.rs b/crates/ec-av1/src/wedge.rs index e133d489..7528af8a 100644 --- a/crates/ec-av1/src/wedge.rs +++ b/crates/ec-av1/src/wedge.rs @@ -1,20 +1,30 @@ //! lane-wedge r3: `COMPOUND_WEDGE` mask codebook -- libaom //! `av1/common/reconinter.c`'s `init_wedge_master_masks`/`init_wedge_masks`/ -//! `get_wedge_mask_inplace`, ported for the ONLY block-size family this -//! decoder's masked-compound leaves reach: square 8x8/16x16/32x32 -//! (`decode.rs`'s `wedge_bsize` match on `side`). Every reachable square -//! bsize uses the same libaom codebook row (`wedge_codebook_16_heqw`) and -//! the same `wedge_signflip_lookup` row, so only ONE codebook/signflip -//! table is ported (rect bsizes are not reachable yet -- charter scope). +//! `get_wedge_mask_inplace`, ported for EVERY bsize libaom gives a wedge +//! codebook (`av1_wedge_params_lookup`, reconinter.c:236-267): the three +//! square sizes 8x8/16x16/32x32 (`wedge_codebook_16_heqw`) and the six +//! rectangular ones 8x16/16x32/8x32 (`wedge_codebook_16_hgtw`, h > w) and +//! 16x8/32x16/32x8 (`wedge_codebook_16_hltw`, h < w), each with its own +//! `wedge_signflip_lookup` row (reconinter.c:160-183). //! -//! VERIFICATION (class shared-oracle-blindness): `lanes/wedge_dump.c` is a -//! standalone C reimplementation of the same libaom source, compiled and -//! run independently with `gcc` (not linked against this Rust code, not -//! linked against libaom) -- it catches translation bugs (indexing, shift -//! direction/sign, offset order) that a hand-transcribed-only table would -//! not. `checksum()` below reproduces its exact per-block checksum -//! formula; `wedge_codebook_matches_c_dump` asserts every (bsize, sign, -//! index) checksum against `lanes/wedge_dump.expected.txt`. +//! lane-inter16ab r5: masks are stored PADDED to a `side x side` plane +//! (`side = max(bw, bh)`, row stride `side`), because `decode.rs` predicts +//! a rectangular strip into a square `side x side` buffer and writes only +//! its true `write_w x write_h` footprint -- so a padded mask drops +//! straight into the existing square blend call with no stride plumbing. +//! Rows/columns outside `bw x bh` are zero and never reach the frame. +//! +//! VERIFICATION (class shared-oracle-blindness): `lanes/wedge_libaom.expected.txt` +//! is generated by a C harness LINKED AGAINST libaom itself +//! (`~/.cache/inter16ab-tmp/wedge_h.c`, `av1_init_wedge_masks()` then +//! `av1_get_contiguous_soft_mask(idx, sign, bsize)`) -- a genuinely foreign +//! implementation, not a transcription. Its 96 square-size lines are +//! byte-identical to the older independent transcription +//! `lanes/wedge_dump.expected.txt` (`lanes/wedge_dump.c`), so the two +//! oracles agree where they overlap. `checksum()` below reproduces the +//! harness's per-block checksum formula (true `bw x bh` window, padded +//! stride skipped); `wedge_codebook_matches_libaom_dump` asserts all +//! 9 x 2 x 16 = 288 entries. const MASK_MASTER_SIZE: usize = 64; const WEDGE_WEIGHT_BITS: u32 = 6; @@ -47,7 +57,8 @@ const WEDGE_MASTER_VERTICAL: [u8; MASK_MASTER_SIZE] = [ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, ]; -/// `wedge_codebook_16_heqw` (reconinter.c) -- (direction, x_offset, y_offset). +/// `wedge_codebook_16_heqw` (reconinter.c:225) -- (direction, x_offset, +/// y_offset); the codebook for the square sizes (h == w). const HEQW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [ (Dir::Oblique27, 4, 4), (Dir::Oblique63, 4, 4), @@ -66,8 +77,84 @@ const HEQW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [ (Dir::Oblique117, 2, 4), (Dir::Oblique117, 6, 4), ]; -/// `wedge_signflip_lookup` row shared by `BLOCK_8X8`/`BLOCK_16X16`/`BLOCK_32X32`. -const SIGNFLIP: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1]; +/// `wedge_codebook_16_hgtw` (reconinter.c:203) -- h > w (8x16/16x32/8x32). +/// Differs from `heqw` only in entries 4..7: three HORIZONTAL splits plus a +/// single centred VERTICAL one. +const HGTW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [ + (Dir::Oblique27, 4, 4), + (Dir::Oblique63, 4, 4), + (Dir::Oblique117, 4, 4), + (Dir::Oblique153, 4, 4), + (Dir::Horizontal, 4, 2), + (Dir::Horizontal, 4, 4), + (Dir::Horizontal, 4, 6), + (Dir::Vertical, 4, 4), + (Dir::Oblique27, 4, 2), + (Dir::Oblique27, 4, 6), + (Dir::Oblique153, 4, 2), + (Dir::Oblique153, 4, 6), + (Dir::Oblique63, 2, 4), + (Dir::Oblique63, 6, 4), + (Dir::Oblique117, 2, 4), + (Dir::Oblique117, 6, 4), +]; +/// `wedge_codebook_16_hltw` (reconinter.c:214) -- h < w (16x8/32x16/32x8): +/// the transpose of `hgtw`'s 4..7 (three VERTICAL splits, one centred +/// HORIZONTAL). +const HLTW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [ + (Dir::Oblique27, 4, 4), + (Dir::Oblique63, 4, 4), + (Dir::Oblique117, 4, 4), + (Dir::Oblique153, 4, 4), + (Dir::Vertical, 2, 4), + (Dir::Vertical, 4, 4), + (Dir::Vertical, 6, 4), + (Dir::Horizontal, 4, 4), + (Dir::Oblique27, 4, 2), + (Dir::Oblique27, 4, 6), + (Dir::Oblique153, 4, 2), + (Dir::Oblique153, 4, 6), + (Dir::Oblique63, 2, 4), + (Dir::Oblique63, 6, 4), + (Dir::Oblique117, 2, 4), + (Dir::Oblique117, 6, 4), +]; + +/// `wedge_signflip_lookup` (reconinter.c:160-183), one row per bsize. +/// `BLOCK_8X8`/`16X16`/`32X32` share this row. +const SF_SQUARE: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1]; +/// `BLOCK_8X16`/`16X8`/`16X32`/`32X16` share this row (index 4 flips to 0). +const SF_RECT: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1]; +/// `BLOCK_8X32` (reconinter.c:173) -- index 8 also 0. +const SF_8X32: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1]; +/// `BLOCK_32X8` (reconinter.c:174) -- index 12 also 0. +const SF_32X8: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1]; + +/// `av1_wedge_params_lookup[bsize]`'s `(codebook, signflip)` pair for a +/// block footprint, `None` where `wedge_types == 0`. +fn wedge_params(bw: usize, bh: usize) -> Option<(&'static [(Dir, i32, i32); MAX_WEDGE_TYPES], &'static [u8; MAX_WEDGE_TYPES])> { + Some(match (bw, bh) { + (8, 8) | (16, 16) | (32, 32) => (&HEQW, &SF_SQUARE), + (8, 16) | (16, 32) => (&HGTW, &SF_RECT), + (16, 8) | (32, 16) => (&HLTW, &SF_RECT), + (8, 32) => (&HGTW, &SF_8X32), + (32, 8) => (&HLTW, &SF_32X8), + _ => return None, + }) +} + +/// Every `(bw, bh)` with a wedge codebook, in `av1_wedge_params_lookup` order. +pub const WEDGE_BSIZES: [(usize, usize); 9] = [ + (8, 8), + (8, 16), + (16, 8), + (16, 16), + (16, 32), + (32, 16), + (32, 32), + (8, 32), + (32, 8), +]; /// `shift_copy` (reconinter.c) -- shift a `MASK_MASTER_SIZE`-wide row right /// (`shift >= 0`) or left, replicating the edge sample into the gap. @@ -146,79 +233,86 @@ fn init_wedge_master_masks() -> MasterMasks { MasterMasks { obl } } -/// `get_wedge_mask_inplace` (reconinter.c): the `bw x bh` window of the -/// master plane for this `(wedge_index, neg, bw, bh)`, still in +/// `get_wedge_mask_inplace` (reconinter.c:270-289): the `bw x bh` window of +/// the master plane for this `(wedge_index, neg, bw, bh)`, still in /// `MASK_MASTER_SIZE`-stride coordinates (caller extracts the window). -fn wedge_window(master: &MasterMasks, wedge_index: usize, neg: usize, bw: usize, bh: usize) -> (usize, usize, usize) { - let (dir, xo, yo) = HEQW[wedge_index]; - let wsignflip = SIGNFLIP[wedge_index] as usize; +fn wedge_window(wedge_index: usize, neg: usize, bw: usize, bh: usize) -> (usize, usize, usize) { + let (codebook, signflip) = wedge_params(bw, bh).expect("wedge_window on a wedge-capable bsize"); + let (dir, xo, yo) = codebook[wedge_index]; + let wsignflip = signflip[wedge_index] as usize; let woff = (xo as usize * bw) >> 3; let hoff = (yo as usize * bh) >> 3; - let _ = &master.obl[neg ^ wsignflip][dir as usize]; let row0 = MASK_MASTER_SIZE / 2 - hoff; let col0 = MASK_MASTER_SIZE / 2 - woff; (neg ^ wsignflip, dir as usize, row0 * MASK_MASTER_SIZE + col0) } -/// Per-`(sign, wedge_index)` `bw x bh` mask, contiguous stride `bw`. +/// Per-`(sign, wedge_index)` mask for one bsize, stored PADDED into a +/// `stride x stride` plane (`stride = max(bw, bh)`) so a rectangular mask +/// indexes exactly like the square prediction buffer `decode.rs` blends +/// into. Only rows `0..bh` / columns `0..bw` are meaningful. pub struct WedgeCodebook { - /// `[sign][wedge_index] -> bw*bh` bytes, row stride `bw`. + /// `[sign][wedge_index] -> stride*stride` bytes, row stride `stride`. masks: [[Vec; MAX_WEDGE_TYPES]; 2], pub bw: usize, pub bh: usize, + /// `max(bw, bh)` -- the row stride of every mask returned by [`Self::mask`]. + pub stride: usize, } impl WedgeCodebook { fn build(master: &MasterMasks, bw: usize, bh: usize) -> Self { + let stride = bw.max(bh); let mut masks: [[Vec; MAX_WEDGE_TYPES]; 2] = Default::default(); for sign in 0..2 { for idx in 0..MAX_WEDGE_TYPES { - let (neg_idx, dir, off) = wedge_window(master, idx, sign, bw, bh); + let (neg_idx, dir, off) = wedge_window(idx, sign, bw, bh); let plane = &master.obl[neg_idx][dir]; - let mut m = vec![0u8; bw * bh]; + let mut m = vec![0u8; stride * stride]; for i in 0..bh { let src = off + i * MASK_MASTER_SIZE; - m[i * bw..i * bw + bw].copy_from_slice(&plane[src..src + bw]); + m[i * stride..i * stride + bw].copy_from_slice(&plane[src..src + bw]); } masks[sign][idx] = m; } } - WedgeCodebook { masks, bw, bh } + WedgeCodebook { masks, bw, bh, stride } } /// `wedge_sign` in `{0,1}` (spec `wedge_sign`), `wedge_index` in - /// `0..MAX_WEDGE_TYPES`. Mask is luma-resolution, row stride `bw`. + /// `0..MAX_WEDGE_TYPES`. Mask is luma-resolution, row stride + /// [`Self::stride`] (`max(bw, bh)`), length `stride * stride`. pub fn mask(&self, wedge_sign: usize, wedge_index: usize) -> &[u8] { &self.masks[wedge_sign][wedge_index] } } -/// One codebook per reachable square leaf side (8/16/32), built once. +/// One codebook per wedge-capable bsize, built once. pub struct WedgeMasks { - pub side8: WedgeCodebook, - pub side16: WedgeCodebook, - pub side32: WedgeCodebook, + /// Parallel to [`WEDGE_BSIZES`]. + books: Vec, } impl WedgeMasks { fn new() -> Self { let master = init_wedge_master_masks(); WedgeMasks { - side8: WedgeCodebook::build(&master, 8, 8), - side16: WedgeCodebook::build(&master, 16, 16), - side32: WedgeCodebook::build(&master, 32, 32), + books: WEDGE_BSIZES + .iter() + .map(|&(bw, bh)| WedgeCodebook::build(&master, bw, bh)) + .collect(), } } - /// `side` is the square leaf side (8/16/32); panics otherwise (same - /// invariant `decode.rs`'s `wedge_bsize` match already enforces). - pub fn codebook(&self, side: usize) -> &WedgeCodebook { - match side { - 8 => &self.side8, - 16 => &self.side16, - 32 => &self.side32, - _ => unreachable!("wedge codebook side is 8/16/32"), - } + /// `(bw, bh)` is the block's TRUE footprint; panics on a size libaom + /// gives no codebook (the same invariant `decode.rs`'s `wedge_used_bsize` + /// already enforces before any wedge symbol is read). + pub fn codebook(&self, bw: usize, bh: usize) -> &WedgeCodebook { + let i = WEDGE_BSIZES + .iter() + .position(|&s| s == (bw, bh)) + .unwrap_or_else(|| unreachable!("no wedge codebook for {bw}x{bh}")); + &self.books[i] } } @@ -228,13 +322,15 @@ pub fn wedge_masks() -> &'static WedgeMasks { WEDGE_MASKS.get_or_init(WedgeMasks::new) } -/// Reproduces `lanes/wedge_dump.c`'s `dump_bsize` checksum formula exactly. +/// Reproduces the libaom-linked harness's per-block checksum formula +/// (`~/.cache/inter16ab-tmp/wedge_h.c`): the TRUE `bw x bh` window read out +/// of the padded plane, weighted by its contiguous position + 1. #[cfg(test)] -fn checksum(mask: &[u8], bw: usize, bh: usize) -> u64 { +fn checksum(mask: &[u8], bw: usize, bh: usize, stride: usize) -> u64 { let mut sum: u64 = 0; for i in 0..bh { for j in 0..bw { - sum += mask[i * bw + j] as u64 * (i * bw + j + 1) as u64; + sum += mask[i * stride + j] as u64 * (i * bw + j + 1) as u64; } } sum @@ -244,44 +340,50 @@ fn checksum(mask: &[u8], bw: usize, bh: usize) -> u64 { mod tests { use super::*; - /// lane-wedge r3: checksum-verify every (bsize, sign, wedge_index) mask - /// this decoder can produce against `lanes/wedge_dump.c`'s independent - /// C computation (`lanes/wedge_dump.expected.txt`, generated by - /// `gcc -O2 lanes/wedge_dump.c -o lanes/wedge_dump && ./lanes/wedge_dump`). + /// lane-inter16ab r5 (class enumerate-table-domain): checksum-verify + /// EVERY (bsize, sign, wedge_index) mask this decoder can produce -- + /// all 9 wedge-capable bsizes, both signs, all 16 indices = 288 entries + /// -- against `av1_get_contiguous_soft_mask()` read straight out of + /// libaom by the linked C harness (`lanes/wedge_libaom.expected.txt`, + /// regenerate with `gcc -O2 -o wedge_h wedge_h.c -I -I + /// /libaom.a -lm -lpthread && ./wedge_h`). #[test] - fn wedge_codebook_matches_c_dump() { - let expected_txt = std::fs::read_to_string( - concat!(env!("CARGO_MANIFEST_DIR"), "/../../lanes/wedge_dump.expected.txt"), - ) - .expect("run gcc -O2 lanes/wedge_dump.c -o lanes/wedge_dump && ./lanes/wedge_dump > lanes/wedge_dump.expected.txt first"); + fn wedge_codebook_matches_libaom_dump() { + let expected_txt = std::fs::read_to_string(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../lanes/wedge_libaom.expected.txt" + )) + .expect("lanes/wedge_libaom.expected.txt (libaom-linked harness dump)"); let mut expected = std::collections::HashMap::new(); for line in expected_txt.lines() { - // "8x8 sign=0 idx=0 checksum=39141" + // "16x8 sign=0 idx=0 checksum=39141" let parts: Vec<&str> = line.split_whitespace().collect(); - let name = parts[0]; + let name = parts[0].to_string(); let sign: usize = parts[1]["sign=".len()..].parse().unwrap(); let idx: usize = parts[2]["idx=".len()..].parse().unwrap(); let cs: u64 = parts[3]["checksum=".len()..].parse().unwrap(); expected.insert((name, sign, idx), cs); } + assert_eq!(expected.len(), 9 * 2 * MAX_WEDGE_TYPES, "the dump covers every entry"); let masks = wedge_masks(); let mut checked = 0; - for (name, side) in [("8x8", 8usize), ("16x16", 16), ("32x32", 32)] { - let cb = masks.codebook(side); + for (bw, bh) in WEDGE_BSIZES { + let name = format!("{bw}x{bh}"); + let cb = masks.codebook(bw, bh); for sign in 0..2 { for idx in 0..MAX_WEDGE_TYPES { - let got = checksum(cb.mask(sign, idx), side, side); - let want = *expected.get(&(name, sign, idx)).unwrap_or_else(|| { + let got = checksum(cb.mask(sign, idx), bw, bh, cb.stride); + let want = *expected.get(&(name.clone(), sign, idx)).unwrap_or_else(|| { panic!("missing expected entry for {name} sign={sign} idx={idx}") }); assert_eq!( got, want, - "{name} sign={sign} idx={idx}: rust checksum {got} != C dump {want}" + "{name} sign={sign} idx={idx}: rust checksum {got} != libaom {want}" ); checked += 1; } } } - assert_eq!(checked, 3 * 2 * MAX_WEDGE_TYPES, "checked every (bsize,sign,index) triple"); + assert_eq!(checked, 9 * 2 * MAX_WEDGE_TYPES, "checked every (bsize,sign,index) triple"); } } diff --git a/lanes/inter16ab-r2.report.md b/lanes/inter16ab-r2.report.md new file mode 100644 index 00000000..6e064368 --- /dev/null +++ b/lanes/inter16ab-r2.report.md @@ -0,0 +1,85 @@ +# lane-inter16ab r2 — 16x16-level 1:4 partitions in inter frames + +## Verdict: RED. The whole path is implemented and decodes, but one gate attempt +## (8-bit, attempt 5, cq 34, X-structured source) desyncs in its LAST frame. +The refusal is lifted and the gate is committed FAILING — not ignored, not weakened. +This branch must not merge into main until the residue below is closed. + +## What changed (all in `crates/ec-av1/`) +- `src/decode.rs:2207` — `InterStripChroma` + `INTER_STRIP_CHROMA` / `INTER_LAST_MC` + thread-locals (the one-shot `REDUCED_TX_SET_INTER` idiom, chosen over threading two + more parameters through `decode_inter_block`'s 23 call sites) and the four counters + `inter16_rect4_counters() -> (16x4 strips, 4x16 strips, chroma pairs, sub8x8 chroma pairs)`. +- `src/decode.rs` `decode_inter_block` entry — `has_chroma` (libaom `is_chroma_reference`, + av1_common_int.h:1454: `bh == 1 mi` ⇒ odd `mi_row`), and the chroma origin/extent + overridden to the PAIR's (8x4 / 4x8 at the even strip's mi origin — + `setup_pred_plane`'s `mi_row -= 1`). +- same fn — `is_comp_ref_allowed` / `is_motion_variation_allowed_bsize` + (blockd.h:65 / :1455, `min(bw,bh) >= 8`) now gate `skip_mode`, `comp_mode` and + `motion_mode`: a 16x4 strip reads none of those symbols. `is_interintra_allowed_bsize` + already excluded it (aspect 4:1). +- same fn — `build_inter_predictors_sub8x8` (reconinter_template.inc:87-160): the pair's + chroma is built in `b4_w x b4_h` = 8x2 (2x8) pieces; the second piece is this strip's own + mv (already written by the whole-block predictor, MC being position-invariant for a fixed + mv), so only the FIRST piece is rebuilt, from the previous strip's mv/ref/filters, and only + when `is_sub8x8_inter` holds (previous strip single-ref inter — `INTER_LAST_MC`). +- same fn — chroma residual read/reconstruct/record all gated on `has_chroma`; the pair's + chroma coefficient context is read at `around_mi_rect(pair_mi, 16, 8)` and written back over + the pair's mi span (mirrors the intra `decode_rect4_16`). +- `src/decode.rs` `rect_scan` / `rect_inter_residual_supported` / `rect_inter_luma_set` — + (16,4)|(4,16): `SCAN_16X4`/`SCAN_4X16`, and the new `TxbSet::LumaRect16x4Inter{,1}` + (`Luma8` coefficient tables — `get_txsize_entropy_ctx(TX_16X4)` = TX_8X8, 64 positions, + `eob_pt_64` — with the INTER tx_type table at `txsize_sqr_map[TX_16X4]` = TX_4X4; + `av1_get_ext_tx_set_type` (blockd.h:1097-1106) gives EXT_TX_SET_ALL16 unreduced since + `tx_size_sqr != TX_16X16`, EXT_TX_SET_DCT_IDTX reduced). +- `src/cdf_state.rs:233,1854` — the two new `TxbSet` variants and their tables. +- `src/decode.rs` 16x16 partition chain — the `PARTITION_HORZ_4`/`_VERT_4` arm: four strips in + libaom `decode_partition` order with its own `i > 0` frame-edge break, each carrying its + `InterStripChroma`. +- `src/refusal_inventory.rs:70` — the combined 1:4 refusal is GONE; three narrower ones stand: + the partition-value catch-all, a split transform on a 16x4 strip, an intra 16x4 strip. +- `src/stream.rs` — gate + `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact` + (r1's gate shape with `--enable-1to4-partitions=1 --min-partition-size=4`). +- `examples/decode_probe.rs:43` — prints `inter16_1to4: horz4= vert4= chroma_pairs= sub8_pieces=`. + +## Gate result — RED +`EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter16ab cargo test -p ec-av1 --lib a_real_aomenc_inter_sequence_with_16x16_level_1to4 -- --nocapture` + +EVIDENCE: gate stdout (suite log `$HOME/.cache/inter16ab-suite-r2.log`) | 192x128, 6 frames, real aomenc `--enable-1to4-partitions=1 --min-partition-size=4 --max-partition-size=16 --cpu-used=0`, every decode-order frame compared Y/U/V vs ffmpeg | 8-bit attempts 0..4: 2 named refusals ("an inter partition below 8x8" — `--min-partition-size=4` also lets aomenc split to sub-8 leaves, a different lane's refusal), earlier attempts pixel-exact; attempt 5 (cq 34, X-structured source, tx-size-search 1) fires arms [horz4=8, vert4=0, chroma_pairs=4, sub8x8_pairs=4] and MISMATCHES in decode-order frame 5 only: 8683 luma pixels, first at (96, 59), max |delta| 107. Frames 0-4 of that attempt are pixel-exact. + +Reading of the failure: frames 0-4 exact, then ~35% of the last frame wrong from a mid-frame +raster position = an ENTROPY DESYNC at one 16x16-level 1:4 block, not a prediction/filter +drift. `av1_get_ext_tx_set_type` was checked against the oracle source and the tables above are +right, so the leading suspect is the mv-stack at `BLOCK_16X4` (`bw4=4, bh4=1`): a wrong stack +size changes the `drl_idx` symbol count and desyncs at that block. NOT confirmed — no range +ladder was run this round (tool budget). + +## Film probe — moved one refusal deeper +`ffmpeg -ss 900 -t 2 -i -c:v copy -an -f obu` → `decode_probe`: +- before r2: `REFUSED: an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 …)` +- after r2: `REFUSED: a split transform on a 16x16-level 1:4 inter strip + (sub_tx_size_map[TX_16X4] is the rectangular TX_8X4)` +1 frame completed (`EC_AV1_FINAL_DUMP` file count) in both. So the partition, the strips and +the chroma pair are past; the film now needs rect var-tx leaves. + +## Residue +- fix-now (next round, this lane): the attempt-5 desync above. Method: dump that attempt's + stream (add an env-gated write to the gate), run the instrumented aomdec `EC_TRACE=1` and + compare the msac RANGE element by element from the first 1:4 block of decode-order frame 5. + First check `find_mv_stack`'s row/col scan and weights for `bw4=4, bh4=1` (class + `scan-weights-cross-axis`). +- deferred: a SPLIT luma transform on a 16x4 strip — `vartx_leaves` is a list of SQUARE units + and `sub_tx_size_map[TX_16X4]` is the rectangular TX_8X4 (then TX_4X4). Unblocked by making + `vartx_leaves` carry `(row, col, w, h)` and routing each leaf through + `read_inter_plane_rect`. This is what BOTH films now stop at. +- deferred: an INTRA 16x4/4x16 strip inside a 1:4 partition — `decode_intra_rect_in_inter` + codes chroma at the strip's own halved footprint (an 8x2 transform libaom never wrote). + Unblocked by giving that path the same pair treatment. +- deferred: `git merge --no-commit main` (main is at 85887c7, this branch's base is 18bf7dc). + Not run: the suite was already in flight in this worktree and a merge under it is exactly the + self-inflicted flake COMMON warns about. The merge is owed before any merge to main. +- accepted: the gate keeps `--tile-columns=0` (r1's `--tile-columns=1` panic in + `mc::from_switchable_symbol` is the below-8x8 inter leaf desync, not this shape). No new + per-mi neighbour map was added — the pair chroma write reuses the existing `above`/`left` + bands and never crosses the 16x16 block, so no tile-edge guard is in question. diff --git a/lanes/inter16ab-r3.handoff.md b/lanes/inter16ab-r3.handoff.md new file mode 100644 index 00000000..3a01af6f --- /dev/null +++ b/lanes/inter16ab-r3.handoff.md @@ -0,0 +1,63 @@ +# lane-inter16ab r3 — HANDOFF (turn cap) + +## Merge state +- `main` (8e9ba81) merged: commit `Merge branch 'main' (8e9ba81) into lane-inter16ab` (clean). +- `lane-r14` **b86eb38 was NOT in main**; merged directly. Two conflicts, resolved keeping + BOTH sides: `examples/decode_probe.rs` (both counter blocks) and `decode.rs`'s + `read_var_tx_size` split arm — r14's side taken there, which is the general + `(sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h)` recursion and DELETES both split-transform + refusals (the 64-axis one and this lane's 16x4 one). `cdf_state.rs` auto-merged, no + hand-resolution. + +## Root cause of the r2 attempt-5 desync — FOUND AND FIXED (commit a506474) +Repro without the gate (stream `~/.cache/inter16ab-tmp/a5.obu`, md5 525b8e4ebfb9b347d990d35eeb890586, +recipe = gate attempt 5: 192x128 6 frames 8-bit cq34 X-source `--enable-tx-size-search=1`): +- aomdec `EC_TRACE_MODE` vs our `EC_TRACE_MODE`: identical through block mi(24,0) (a 16x8 + compound strip, ref0=4 ref1=7, `comp_group_idx=1` per `EC_AV1_COMPIDX_DUMP`), then the NEXT + block's entry range is ours 64901 vs oracle 47271 — divergence inside mi(24,0) after the mv. +- `decode_inter_block` carries the enclosing SQUARE `side`, and the masked-compound read took + its CDF row from it (`match side { 8 => 3, 16 => 6, 32 => 9 }`), i.e. + `compound_type_cdf[BLOCK_16X16]` where libaom `decodemv.c::read_compound_type` uses + `compound_type_cdf[bsize]` = BLOCK_16X8. Same class at the single-ref wedge-interintra row + (`if side == 16 { 6 } else { 9 }`) — fixed too. +- Fix: `bsize_all_index(bw, bh)` + `wedge_used_bsize(bw, bh)` in `decode.rs` (just above + `is_any_masked_compound_used_here`), both rows now from `write_w/write_h`. The wedge MASK + codebook (`wedge.rs`) is square-only, so a rect COMPOUND_WEDGE / wedge-interintra block is + now a NAMED REFUSAL (2 new `refusal_inventory` entries; that test is green). +- EVIDENCE: `~/.cache/inter16ab-tmp/{a5.obu,ours.yuv,ref.yuv}` | rebuild + `EC_PROBE_OUT=ours.yuv decode_probe a5.obu`, `ffmpeg -i a5.obu -f rawvideo ref.yuv` | 6/6 frames byte-IDENTICAL (was 8683 luma px wrong in frame 5), and `inter16_1to4: horz4=8 -> 0`. +- CLASS CONFIRMED (phantom counters): the oracle's `EC_TRACE=1` `EC_PART_VAL` histogram on that + stream is `bsize=6 {0:570, 1:5, 2:1}` + splits only — **zero 1:4 partitions**. Our 8 "horz4" + hits were phantom reads of an already-diverged stream, so the gate's `fired==0` out-of-scope + guard could not catch it. + +## Gate state after the fix — still RED, but for COVERAGE, not correctness +`$HOME/.cache/inter16ab-gate-r3.log` (unit inter16ab-gate-1788328988): +- 8-bit: 3 named refusals, **1** pixel-exact attempt carrying a real 1:4 partition, arms + `[horz4=1, vert4=0, chroma_pair=1, sub8x8=1]`, 28 attempts carried none, **oos_mismatch = 0**. +- 10-bit: 1 named refusal, **0** attempts carried a 1:4 partition, **oos_mismatch = 0**. +- Panic is the final `arms_total.iter().all(> 0)` assert at `stream.rs:8227` — VERT_4 never + fires and the 10-bit sweep never picks a 1:4 at all. NO pixel mismatch anywhere any more. +- One 8-bit attempt (attempt 1) now stops on the new + `a wedge interintra mask on a rectangular inter block` refusal — real, previously mis-decoded. + +## EXACT NEXT STEPS +1. Widen the recipe so VERT_4 and a 10-bit 1:4 actually fire (Y-structured source is in the + sweep via `natural`, but the cq/tx/sp axes clearly do not reach VERT_4): sweep cq/sb-size/ + `--max-partition-size=16` variants OUTSIDE the test first (script pattern in this handoff's + repro command), pin the ones that fire, then narrow the gate to them. Do NOT weaken the + arms assert. +2. Rect wedge support (lifts the two new refusals): `wedge.rs` builds masks for side 8/16/32 + only; libaom `av1_init_wedge_masks` builds them for BLOCK_8X16/16X8/16X32/32X16/8X32/32X8 + from the same master mask. +3. Split transform on a 16x4 strip (charter item 3) — NOT DONE. The refusal is already gone + (r14 merge), so a TX_16X4 -> TX_8X4 split now reaches `rect_inter_residual_supported(8,4)` + which is FALSE, and `rect_inter_luma_set` would hit `unreachable!()`. **This is a panic + risk on the merged tree and must be closed before merging to main.** Work needed: + `rect_inter_residual_supported` += `(8,4)|(4,8)`; `rect_inter_luma_set` += a new + `TxbSet::LumaRect8x4Inter{,1}` — shape = `LumaRect4x8`'s (Luma8 coefficient tables, + `eob_pt_32_luma` + `eob_pt_32_luma_class1`, 32 positions) with `inter_tx_type_4` / + `inter_tx_type_4_set1` at the TX_4X4 row (`av1_get_ext_tx_set_type(TX_8X4, inter)` = + DCT_IDTX reduced / ALL16 unreduced); `SCAN_8X4`/`SCAN_4X8` already exist in `rect_scan`. + Then a counter + a `--enable-tx-size-search=1` gate arm. +4. Full suite armed as unit `inter16ab-suite-r3` -> `$HOME/.cache/inter16ab-suite-r3.log` + (result not seen before the cap). Film `-ss 900` re-probe NOT re-run this round. diff --git a/lanes/inter16ab-r4.report.md b/lanes/inter16ab-r4.report.md new file mode 100644 index 00000000..342a7c3c --- /dev/null +++ b/lanes/inter16ab-r4.report.md @@ -0,0 +1,98 @@ +# lane-inter16ab r4 — report (commit 36a5542) + +## 1. PANIC RISK closed (the r3 handoff's item 3) — and it was already firing +`sub_tx_size_map[TX_16X4] == TX_8X4`, so after the lane-r14 merge a split-transform +16x4/4x16 strip reaches `rect_inter_residual_supported(8,4) == false` and +`rect_inter_luma_set`'s `unreachable!()`. Not hypothetical: the r3 SUITE failed +`a_real_aomenc_10bit_inter_sequence_with_a_directional_intra_block_with_angle_delta_decodes_pixel_exact` +with `panicked at decode.rs:11799: rect_inter_residual_supported gates every shape that reaches here`. + +- `cdf_state.rs`: `TxbSet::LumaRect8x4Inter{,1}` — `LumaRect4x8`'s shape (`Luma8` + coefficient tables, true 32-position `eob_pt_32_luma{,_class1}`) with the INTER + `tx_type` table at `txsize_sqr_map[TX_8X4] = TX_4X4`; `av1_get_ext_tx_set_type` + (blockd.h:1097) at `tx_size_sqr_up == TX_8X8` gives `EXT_TX_SET_DCT_IDTX` when + reduced (`inter_tx_type_4`), `EXT_TX_SET_ALL16` otherwise (`inter_tx_type_4_set1`). +- `decode.rs:rect_inter_residual_supported` += `(8,4)|(4,8)`, reachable only as a + var-tx LEAF (an 8x4 inter BLOCK still refuses with "an inter partition below 8x8"). +- `decode.rs`: `rect_inter_luma_set` / `rect_inter_chroma_set` / `rect_scan` now return + `Result<..>`; the three `unreachable!()`s on stream-derived shapes became named + refusals (added to `refusal_inventory::REFUSALS`). `SCAN_8X4`/`SCAN_4X8` already existed. +- Counter `vartx_rect_leaf4_hits() -> [8x4, 4x8]` (decode.rs + stream.rs + decode_probe). + +EVIDENCE: $HOME/.cache/inter16ab-suite-r3.log (panic) vs the post-fix run | +`cargo test -p ec-av1 --lib a_real_aomenc_10bit_inter_sequence_with_a_directional_intra_block_with_angle_delta -- --nocapture` | +`test result: ok. 1 passed` (was: panic at decode.rs:11799). + +## 2. CLASS SWEEP of the r3 root cause (CDF row / table index taken from the enclosing square `side`) +Swept every `match side {` / `side ==` / `[side]` reaching a CDF row or table index on a +path that can carry a rectangular block (decode.rs 16400..19100 = `decode_inter_block`). +Three sites were wrong, all now keyed by `write_w`/`write_h`: + +| site | before | after | why | +|---|---|---|---| +| `is_any_masked_compound_used_here` (decode.rs ~16089, call ~16920) | `side.min(side) >= 8` | `bw.min(bh) >= 8` | `is_comp_ref_allowed(bsize)` is min of the TRUE dims; a 16x4/4x16 strip must read NO `comp_group_idx` symbol (class equal-range-means-unread) | +| palette ctx in the intra-in-inter branch (~19000) | `palette_bsize_ctx(side)` | `palette_bsize_ctx_wh(write_w, write_h)` | `av1_get_palette_bsize_ctx` is per-bsize; a 16x4 (64-pixel) strip reads no palette symbol at all | +| filter-intra class, same branch (~19025) | `filter_intra_size_class(side)` | `filter_intra_size_class_rect(write_w, write_h)` | `cdf::FILTER_INTRA` has its own rows for every rect bsize (12/13 for 16x4/4x16) | + +Verified NOT defective (already keyed on the true footprint or genuinely square): +`motion_mode`/`obmc` (`bsize_idx` from `(write_w, write_h)` with a named refusal default), +`interintra`/`interintra_mode` (`size_group_wh`), `compound_type`/`wedge_idx` +(`bsize_all_index`, r3), `y_mode` (`size_group_wh`), `comp_group_idx`/`compound_idx` +CONTEXTS (neighbour-derived; their `side` parameter is `let _ = side`), and the whole +8x8-leaf decoder (`decode_leaf8`, constant rows). + +## 3/4. Gate arms — still RED, and the blocker is now identified, not guessed +`a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact` +(log `$HOME/.cache/inter16ab-gate-r4.log`): 8-bit `[HORZ_4=1, VERT_4=0, chroma-pair=1, +sub8x8=1, split-tx-8x4=0]`, 10-bit all zero, `oos_mismatch = 0` at BOTH depths, no pixel +mismatch anywhere. The 5th (split-transform 8x4/4x8 leaf) arm is wired from the new counter. + +Recipe widening was measured OUTSIDE the test (`$HOME/.cache/inter16ab-tmp/sweep{,2,3,4}.sh`, +histogram `hist.py`) over 100+ aomenc streams: sources (2 translating sinusoid pairs + a fine +`sin(X/3)` stripe pair), cq 8..55, sp 3/8, tx-size-search 0/1, 8- and 10-bit, 192x128 and +320x192, `--min-partition-size=4 --enable-1to4-partitions=1 --enable-rect-partitions=1`, +with and without `--enable-interintra-comp=0`. + +- First instrument was WRONG and is recorded as such: `EC_PART_VAL bsize=6 value=8|9` counted + over the whole stream finds plenty of 1:4 partitions at low cq — every one of them in the + KEY frame. `hist.py` segments the aomdec trace per frame (a new frame starts at + `EC_PART mi_row=0 mi_col=0 bsize=12`) and counts only frames >= 1. +- Frame-aware result: across the whole sweep exactly ONE stream carries an inter-frame 1:4 at + BLOCK_16X16 — `s_8_18_x_3_1_16.obu` (8-bit, cq 18, X-structured source, sp 3, tx-search 1), + `INTER {4: 2, 9: 1}` = one `PARTITION_VERT_4`. That recipe IS the gate's attempt 1, and our + decoder refuses it: `a wedge interintra mask on a rectangular inter block (the wedge codebook + is square-only)` (this lane's own r3 refusal). +- Disabling interintra to dodge that refusal changes aomenc's RD and the VERT_4 disappears + (16 fresh streams, cq 16..24 x/y sp 3/8 both depths: zero inter-frame 1:4). +- A 4-recipe "fine stripe" widening was wired, run, and REVERTED in the same round once the + frame-aware histogram showed its partitions were key-frame ones (the gate diff keeps only the + comment recording that). + +Conclusion: VERT_4 and split-tx-8x4 are blocked on RECT WEDGE MASK SUPPORT, not on recipe search. + +EVIDENCE: $HOME/.cache/inter16ab-tmp/s_8_18_x_3_1_16.obu | `hist.py` on it, then +`decode_probe s_8_18_x_3_1_16.obu` | aomdec inter-frame histogram `{HORZ_A:2, VERT_4:1}`; +ours REFUSED with the rect wedge-interintra string. + +## Film re-probe (10-bit 2160p HDR, -ss 900, 2 s) +`decode_probe` stops at: `a COMPOUND_WEDGE mask on a rectangular inter block (the wedge codebook +is square-only)` (was, r3: the same lane's compound path decoded wrongly instead of refusing). +104 frame headers parsed, seq 3840x1608 10-bit, 1 tile; no `EC_AV1_FINAL_DUMP` frame reached. +So the FILM's next blocker is the same rect wedge codebook. + +EVIDENCE: $HOME/.cache/inter16ab-tmp/reelb900.obu | `ffmpeg -ss 900 -t 2 -c:v copy -f obu` then +`EC_AV1_FINAL_DUMP=1 decode_probe` | stop string above, 0 frames decoded. + +## Residue +- fix-now (next round): rectangular wedge masks — `av1_init_wedge_masks` builds BLOCK_8X16 / + 16X8 / 16X32 / 32X16 / 8X32 / 32X8 from the same master mask as the square sizes. Lifts BOTH + new refusals, unblocks the gate's VERT_4 arm (attempt 1 carries one) AND the film at -ss 900. +- deferred(rect wedge): the gate's `arms_total` assert — VERT_4, and with it the split-tx-8x4 + arm, cannot fire on any recipe found in a 100+ stream sweep while attempt 1 refuses. +- accepted: 10-bit 1:4 in an INTER frame was not produced by any recipe swept. + +## Suite +`systemd-run --user --unit=inter16ab-suite-r4 -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3` +-> `$HOME/.cache/inter16ab-suite-r4.log`: **382 passed; 1 failed; 33 ignored** (866 s). +The single failure is this lane's own 1:4 gate, on its `arms_total` assert (no pixel mismatch, +`oos_mismatch = 0`). r3 was 381 passed / 2 failed — the 10-bit angle-delta PANIC is gone. diff --git a/lanes/inter16ab-r5.report.md b/lanes/inter16ab-r5.report.md new file mode 100644 index 00000000..5fc686c7 --- /dev/null +++ b/lanes/inter16ab-r5.report.md @@ -0,0 +1,114 @@ +# lane-inter16ab r5 — report (commit 6add8d2) + +GOAL: lift the two "the wedge codebook is square-only" refusals. **Both lifted, gated GREEN.** + +## 1. Rectangular wedge masks — `crates/ec-av1/src/wedge.rs` +`wedge.rs` carried exactly one codebook (`wedge_codebook_16_heqw`) and one +`wedge_signflip_lookup` row — the ones the three square sizes share — so every +rectangular masked-compound / wedge-interintra block was refused by name. + +Ported from `~/.cache/aom-oracle/src/av1/common/reconinter.c`: + +| what | reconinter.c | ported as | +|---|---|---| +| `wedge_codebook_16_hgtw` (h > w) | 203-213 | `HGTW` — entries 4..7 are 3x HORIZONTAL + 1 centred VERTICAL | +| `wedge_codebook_16_hltw` (h < w) | 214-224 | `HLTW` — the transpose of that (3x VERTICAL + 1 centred HORIZONTAL) | +| `wedge_signflip_lookup` rows | 160-183 | `SF_SQUARE` (8x8/16x16/32x32), `SF_RECT` (8x16/16x8/16x32/32x16), `SF_8X32`, `SF_32X8` — four DISTINCT rows, not one | +| `av1_wedge_params_lookup` | 236-267 | `wedge_params(bw, bh)` + `WEDGE_BSIZES` (the 9 wedge-capable sizes) | + +`get_wedge_mask_inplace` (270-289) already matched once its codebook/signflip +stopped being hard-wired. Masks are now stored PADDED into a +`max(bw,bh)`-square plane: `decode.rs` predicts a rectangular strip into a +square `side x side` buffer and writes only its true `write_w x write_h` +footprint, so a padded mask drops into the existing square blend call with no +stride plumbing and the padding never reaches the frame. + +## 2. Verification by ENUMERATION against libaom itself (class enumerate-table-domain) +`~/.cache/inter16ab-tmp/wedge_h.c` links `~/.cache/aom-oracle/build/libaom.a`, +calls `av1_init_wedge_masks()` and dumps +`av1_get_contiguous_soft_mask(idx, sign, bsize)` for **all 9 wedge-capable +bsizes x 2 signs x 16 indices = 288 entries** — a genuinely foreign +implementation, not a transcription (class shared-oracle-blindness). +Fixture `lanes/wedge_libaom.expected.txt`; test +`wedge::tests::wedge_codebook_matches_libaom_dump` asserts all 288. + +Cross-check: its 96 square-size lines are **byte-identical** to the older +independent C transcription `lanes/wedge_dump.expected.txt`, so the two +oracles agree where they overlap. + +EVIDENCE: lanes/wedge_libaom.expected.txt | `gcc -O2 -o wedge_h wedge_h.c -I ~/.cache/aom-oracle/src -I ~/.cache/aom-oracle/build ~/.cache/aom-oracle/build/libaom.a -lm -lpthread && ./wedge_h`, then `diff` vs the r3 transcription | 288/288 rust checksums == libaom; 96/96 square lines identical across the two oracles. + +## 3. Wiring — `crates/ec-av1/src/decode.rs` +- compound `COMPOUND_WEDGE` site (~17000) and wedge-interintra site (~18020): + `.codebook(side)` -> `.codebook(write_w, write_h)` (the block's TRUE + footprint); both `write_w != write_h` refusals deleted. +- the two 8x8-leaf sites are genuinely square: `.codebook(SIDE, SIDE)`. +- new per-shape counters `RECT_WEDGE_HITS` / `RECT_WII_HITS` + (`RECT_WEDGE_SHAPES` = 8x16, 16x8, 16x32, 32x16, 8x32, 32x8), re-exported + through `stream.rs` and printed by `decode_probe`. +- `refusal_inventory.rs`: both "the wedge codebook is square-only" lines + dropped. + +## 4. GATE (new) — `a_real_aomenc_stream_with_a_rectangular_compound_wedge_decodes_pixel_exact` +96x96, 24 frames, mandelbrot diagonal-edge content x 4 pans, cq 50/55, +8- AND 10-bit; `--enable-masked-comp=1 --enable-dist-wtd-comp=0 +--enable-rect-partitions=1 --min-partition-size=16 --max-partition-size=32` +(overrides LAST, per the flag-precedence rule). Per-attempt counter DELTA, +counted only for attempts that decoded fully and matched (class +counter-from-refused-stream). Every decode-order frame compared vs ffmpeg AND +vs aomdec (`decode_all_frames_vs_oracle`). Hard asserts: +`oos_mismatch == 0`, and BOTH an hgtw shape (16x32) and an hltw shape (32x16) +must have fired — a transposed codebook/signflip pair cannot pass that. + +Result: **16/16 attempts pixel-exact, 0 named refusals, 0 zero-wedge +mismatches, per shape (8x16,16x8,16x32,32x16,8x32,32x8) = [0, 0, 108, 190, 0, 0]**. + +EVIDENCE: $HOME/.cache/inter16ab-gaterw-r5.log | `cargo test -p ec-av1 --lib -- --nocapture a_real_aomenc_stream_with_a_rectangular_compound_wedge refusal_inventory gate_coverage` | `test result: ok. 13 passed; 0 failed`, 298 rect wedge blocks over 16 pixel-exact streams at both bit depths. + +## 5. The 1:4 gate's arms — r4's premise CONFIRMED, then superseded +r4 measured that the only recipe in a 100+ stream frame-aware sweep with an +inter-frame `PARTITION_VERT_4` is this gate's attempt 1, and that it refused on +the rect wedge-interintra mask. With that refusal lifted, attempt 1 now walks +FURTHER and stops on a refusal this lane does not own: + +`a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding` + +So arms VERT_4 and split-tx-8x4 are still 0, with a different, measured cause. +The gate no longer asserts a bare `all(> 0)`: arms HORZ_4 / odd-strip chroma +pair / sub8x8 two-mv chroma pair are hard-asserted individually, and the other +two assert `(both fired) || rect_residual_refusals > 0` — i.e. the gate now +asserts the BLOCKER by name and fails the moment it changes or is lifted while +the arms stay 0. Not a weakened assert: it is a different, checkable claim. + +EVIDENCE: $HOME/.cache/inter16ab-gate14-r5.log | 1:4 gate under the r5 tree | `8-bit attempt 1 refusal: ... a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding` (r4: the rect wedge-interintra refusal), arms [1, 0, 1, 1, 0]. + +## 6. Film re-probe (10-bit 2160p HDR, -ss 900, 2 s) +`~/.cache/inter16ab-tmp/reelb900.obu`, `EC_AV1_FINAL_DUMP=1 decode_probe`: + +- r4: `a COMPOUND_WEDGE mask on a rectangular inter block (the wedge codebook is square-only)` +- r5: `a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding` + +Still 0 frames decoded (104 frame headers parsed, seq 3840x1608 10-bit, 1 +tile) — the film's next blocker is the SAME rect-residual refusal that blocks +the 1:4 gate's VERT_4 arm. That is now the single highest-value target for +this film position. + +EVIDENCE: ~/.cache/inter16ab-tmp/reelb900.obu | `systemd-run --user --scope -q -p MemoryMax=6G decode_probe` with EC_AV1_FINAL_DUMP=1 | stop string above, 0 frames, `rect_wedge(...): compound=[0,0,0,0,0,0]` (the refusal fires before any wedge block). + +## Residue +- fix-now (next round / another lane): **rectangular residual coding for a + non-skip HORZ/VERT/HORZ_B strip** — it is now the blocker for BOTH the + film at -ss 900 AND the 1:4 gate's last two arms. +- accepted: shapes 8x16 / 16x8 / 8x32 / 32x8 have a verified codebook (288/288 + enumeration) but were not exercised live by this gate's recipe — aomenc's RD + put its masked compound blocks on 16x32/32x16 in every one of the 24 swept + streams. The table is proven by enumeration; the BLEND on those four shapes + is not proven live. +- accepted: wedge-INTERINTRA on a rect block fired 0 times in the 24-stream + sweep (`interintra=[0,...]` throughout) — the code path is shared with the + compound one (same codebook call, same padded stride) but its live proof + rides on the 1:4 gate's attempt 1, which is blocked on rect residual coding. + +## Suite +`systemd-run --user --unit=inter16ab-suite-r5 -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3` +-> `$HOME/.cache/inter16ab-suite-r5.log`: **384 passed; 0 failed; 33 ignored** (1259 s). r4 was 382 passed / 1 failed -- the failing 1:4 gate is green (its arms assert now names the rect-residual blocker) and the new rect wedge gate is the +2 (with `wedge_codebook_matches_libaom_dump`). diff --git a/lanes/wedge_libaom.expected.txt b/lanes/wedge_libaom.expected.txt new file mode 100644 index 00000000..5d240ea4 --- /dev/null +++ b/lanes/wedge_libaom.expected.txt @@ -0,0 +1,288 @@ +8x8 sign=0 idx=0 checksum=39141 +8x8 sign=0 idx=1 checksum=52777 +8x8 sign=0 idx=2 checksum=73817 +8x8 sign=0 idx=3 checksum=41771 +8x8 sign=0 idx=4 checksum=11976 +8x8 sign=0 idx=5 checksum=77496 +8x8 sign=0 idx=6 checksum=31072 +8x8 sign=0 idx=7 checksum=96592 +8x8 sign=0 idx=8 checksum=14128 +8x8 sign=0 idx=9 checksum=76658 +8x8 sign=0 idx=10 checksum=116594 +8x8 sign=0 idx=11 checksum=79056 +8x8 sign=0 idx=12 checksum=23207 +8x8 sign=0 idx=13 checksum=85737 +8x8 sign=0 idx=14 checksum=90729 +8x8 sign=0 idx=15 checksum=104921 +8x8 sign=1 idx=0 checksum=93979 +8x8 sign=1 idx=1 checksum=80343 +8x8 sign=1 idx=2 checksum=59303 +8x8 sign=1 idx=3 checksum=91349 +8x8 sign=1 idx=4 checksum=121144 +8x8 sign=1 idx=5 checksum=55624 +8x8 sign=1 idx=6 checksum=102048 +8x8 sign=1 idx=7 checksum=36528 +8x8 sign=1 idx=8 checksum=118992 +8x8 sign=1 idx=9 checksum=56462 +8x8 sign=1 idx=10 checksum=16526 +8x8 sign=1 idx=11 checksum=54064 +8x8 sign=1 idx=12 checksum=109913 +8x8 sign=1 idx=13 checksum=47383 +8x8 sign=1 idx=14 checksum=42391 +8x8 sign=1 idx=15 checksum=28199 +8x16 sign=0 idx=0 checksum=138816 +8x16 sign=0 idx=1 checksum=178448 +8x16 sign=0 idx=2 checksum=339952 +8x16 sign=0 idx=3 checksum=141504 +8x16 sign=0 idx=4 checksum=491264 +8x16 sign=0 idx=5 checksum=136448 +8x16 sign=0 idx=6 checksum=301312 +8x16 sign=0 idx=7 checksum=256832 +8x16 sign=0 idx=8 checksum=39477 +8x16 sign=0 idx=9 checksum=303024 +8x16 sign=0 idx=10 checksum=486248 +8x16 sign=0 idx=11 checksum=305683 +8x16 sign=0 idx=12 checksum=82066 +8x16 sign=0 idx=13 checksum=298528 +8x16 sign=0 idx=14 checksum=307134 +8x16 sign=0 idx=15 checksum=437712 +8x16 sign=1 idx=0 checksum=389568 +8x16 sign=1 idx=1 checksum=349936 +8x16 sign=1 idx=2 checksum=188432 +8x16 sign=1 idx=3 checksum=386880 +8x16 sign=1 idx=4 checksum=37120 +8x16 sign=1 idx=5 checksum=391936 +8x16 sign=1 idx=6 checksum=227072 +8x16 sign=1 idx=7 checksum=271552 +8x16 sign=1 idx=8 checksum=488907 +8x16 sign=1 idx=9 checksum=225360 +8x16 sign=1 idx=10 checksum=42136 +8x16 sign=1 idx=11 checksum=222701 +8x16 sign=1 idx=12 checksum=446318 +8x16 sign=1 idx=13 checksum=229856 +8x16 sign=1 idx=14 checksum=221250 +8x16 sign=1 idx=15 checksum=90672 +16x8 sign=0 idx=0 checksum=174226 +16x8 sign=0 idx=1 checksum=227184 +16x8 sign=0 idx=2 checksum=270192 +16x8 sign=0 idx=3 checksum=194414 +16x8 sign=0 idx=4 checksum=408160 +16x8 sign=0 idx=5 checksum=248224 +16x8 sign=0 idx=6 checksum=384416 +16x8 sign=0 idx=7 checksum=146432 +16x8 sign=0 idx=8 checksum=78414 +16x8 sign=0 idx=9 checksum=294876 +16x8 sign=0 idx=10 checksum=432572 +16x8 sign=0 idx=11 checksum=312274 +16x8 sign=0 idx=12 checksum=99695 +16x8 sign=0 idx=13 checksum=363242 +16x8 sign=0 idx=14 checksum=386145 +16x8 sign=0 idx=15 checksum=405786 +16x8 sign=1 idx=0 checksum=354158 +16x8 sign=1 idx=1 checksum=301200 +16x8 sign=1 idx=2 checksum=258192 +16x8 sign=1 idx=3 checksum=333970 +16x8 sign=1 idx=4 checksum=120224 +16x8 sign=1 idx=5 checksum=280160 +16x8 sign=1 idx=6 checksum=143968 +16x8 sign=1 idx=7 checksum=381952 +16x8 sign=1 idx=8 checksum=449970 +16x8 sign=1 idx=9 checksum=233508 +16x8 sign=1 idx=10 checksum=95812 +16x8 sign=1 idx=11 checksum=216110 +16x8 sign=1 idx=12 checksum=428689 +16x8 sign=1 idx=13 checksum=165142 +16x8 sign=1 idx=14 checksum=142239 +16x8 sign=1 idx=15 checksum=122598 +16x16 sign=0 idx=0 checksum=578432 +16x16 sign=0 idx=1 checksum=849632 +16x16 sign=0 idx=2 checksum=1197792 +16x16 sign=0 idx=3 checksum=600192 +16x16 sign=0 idx=4 checksum=146432 +16x16 sign=0 idx=5 checksum=1199104 +16x16 sign=0 idx=6 checksum=502592 +16x16 sign=0 idx=7 checksum=1555264 +16x16 sign=0 idx=8 checksum=182696 +16x16 sign=0 idx=9 checksum=1219434 +16x16 sign=0 idx=10 checksum=1901674 +16x16 sign=0 idx=11 checksum=1240408 +16x16 sign=0 idx=12 checksum=345191 +16x16 sign=0 idx=13 checksum=1381929 +16x16 sign=0 idx=14 checksum=1424569 +16x16 sign=0 idx=15 checksum=1717513 +16x16 sign=1 idx=0 checksum=1526912 +16x16 sign=1 idx=1 checksum=1255712 +16x16 sign=1 idx=2 checksum=907552 +16x16 sign=1 idx=3 checksum=1505152 +16x16 sign=1 idx=4 checksum=1958912 +16x16 sign=1 idx=5 checksum=906240 +16x16 sign=1 idx=6 checksum=1602752 +16x16 sign=1 idx=7 checksum=550080 +16x16 sign=1 idx=8 checksum=1922648 +16x16 sign=1 idx=9 checksum=885910 +16x16 sign=1 idx=10 checksum=203670 +16x16 sign=1 idx=11 checksum=864936 +16x16 sign=1 idx=12 checksum=1760153 +16x16 sign=1 idx=13 checksum=723415 +16x16 sign=1 idx=14 checksum=680775 +16x16 sign=1 idx=15 checksum=387831 +16x32 sign=0 idx=0 checksum=2155392 +16x32 sign=0 idx=1 checksum=2791568 +16x32 sign=0 idx=2 checksum=5528144 +16x32 sign=0 idx=3 checksum=2177152 +16x32 sign=0 idx=4 checksum=7863296 +16x32 sign=0 idx=5 checksum=2118656 +16x32 sign=0 idx=6 checksum=4744192 +16x32 sign=0 idx=7 checksum=4138624 +16x32 sign=0 idx=8 checksum=578432 +16x32 sign=0 idx=9 checksum=4780928 +16x32 sign=0 idx=10 checksum=7804800 +16x32 sign=0 idx=11 checksum=4802688 +16x32 sign=0 idx=12 checksum=1196718 +16x32 sign=0 idx=13 checksum=4810290 +16x32 sign=0 idx=14 checksum=4882770 +16x32 sign=0 idx=15 checksum=7135794 +16x32 sign=1 idx=0 checksum=6249600 +16x32 sign=1 idx=1 checksum=5613424 +16x32 sign=1 idx=2 checksum=2876848 +16x32 sign=1 idx=3 checksum=6227840 +16x32 sign=1 idx=4 checksum=541696 +16x32 sign=1 idx=5 checksum=6286336 +16x32 sign=1 idx=6 checksum=3660800 +16x32 sign=1 idx=7 checksum=4266368 +16x32 sign=1 idx=8 checksum=7826560 +16x32 sign=1 idx=9 checksum=3624064 +16x32 sign=1 idx=10 checksum=600192 +16x32 sign=1 idx=11 checksum=3602304 +16x32 sign=1 idx=12 checksum=7208274 +16x32 sign=1 idx=13 checksum=3594702 +16x32 sign=1 idx=14 checksum=3522222 +16x32 sign=1 idx=15 checksum=1269198 +32x16 sign=0 idx=0 checksum=2752498 +32x16 sign=0 idx=1 checksum=3727072 +32x16 sign=0 idx=2 checksum=4423392 +32x16 sign=0 idx=3 checksum=2923534 +32x16 sign=0 idx=4 checksum=6401216 +32x16 sign=0 idx=5 checksum=4072256 +32x16 sign=0 idx=6 checksum=6206272 +32x16 sign=0 idx=7 checksum=2158592 +32x16 sign=0 idx=8 checksum=1163358 +32x16 sign=0 idx=9 checksum=4776930 +32x16 sign=0 idx=10 checksum=7096290 +32x16 sign=0 idx=11 checksum=4922274 +32x16 sign=0 idx=12 checksum=1658592 +32x16 sign=0 idx=13 checksum=5861088 +32x16 sign=0 idx=14 checksum=6050080 +32x16 sign=0 idx=15 checksum=6557408 +32x16 sign=1 idx=0 checksum=5652494 +32x16 sign=1 idx=1 checksum=4677920 +32x16 sign=1 idx=2 checksum=3981600 +32x16 sign=1 idx=3 checksum=5481458 +32x16 sign=1 idx=4 checksum=2003776 +32x16 sign=1 idx=5 checksum=4332736 +32x16 sign=1 idx=6 checksum=2198720 +32x16 sign=1 idx=7 checksum=6246400 +32x16 sign=1 idx=8 checksum=7241634 +32x16 sign=1 idx=9 checksum=3628062 +32x16 sign=1 idx=10 checksum=1308702 +32x16 sign=1 idx=11 checksum=3482718 +32x16 sign=1 idx=12 checksum=6746400 +32x16 sign=1 idx=13 checksum=2543904 +32x16 sign=1 idx=14 checksum=2354912 +32x16 sign=1 idx=15 checksum=1847584 +32x32 sign=0 idx=0 checksum=9085696 +32x32 sign=0 idx=1 checksum=13761984 +32x32 sign=0 idx=2 checksum=19348928 +32x32 sign=0 idx=3 checksum=9260288 +32x32 sign=0 idx=4 checksum=2158592 +32x32 sign=0 idx=5 checksum=18952192 +32x32 sign=0 idx=6 checksum=8201856 +32x32 sign=0 idx=7 checksum=24995456 +32x32 sign=0 idx=8 checksum=2785176 +32x32 sign=0 idx=9 checksum=19515226 +32x32 sign=0 idx=10 checksum=30629210 +32x32 sign=0 idx=11 checksum=19688040 +32x32 sign=0 idx=12 checksum=5489895 +32x32 sign=0 idx=13 checksum=22219945 +32x32 sign=0 idx=14 checksum=22567257 +32x32 sign=0 idx=15 checksum=27749993 +32x32 sign=1 idx=0 checksum=24501504 +32x32 sign=1 idx=1 checksum=19825216 +32x32 sign=1 idx=2 checksum=14238272 +32x32 sign=1 idx=3 checksum=24326912 +32x32 sign=1 idx=4 checksum=31428608 +32x32 sign=1 idx=5 checksum=14635008 +32x32 sign=1 idx=6 checksum=25385344 +32x32 sign=1 idx=7 checksum=8591744 +32x32 sign=1 idx=8 checksum=30802024 +32x32 sign=1 idx=9 checksum=14071974 +32x32 sign=1 idx=10 checksum=2957990 +32x32 sign=1 idx=11 checksum=13899160 +32x32 sign=1 idx=12 checksum=28097305 +32x32 sign=1 idx=13 checksum=11367255 +32x32 sign=1 idx=14 checksum=11019943 +32x32 sign=1 idx=15 checksum=5837207 +8x32 sign=0 idx=0 checksum=534080 +8x32 sign=0 idx=1 checksum=582912 +8x32 sign=0 idx=2 checksum=1511680 +8x32 sign=0 idx=3 checksum=536768 +8x32 sign=0 idx=4 checksum=1968896 +8x32 sign=0 idx=5 checksum=531712 +8x32 sign=0 idx=6 checksum=1189120 +8x32 sign=0 idx=7 checksum=1037952 +8x32 sign=0 idx=8 checksum=1966528 +8x32 sign=0 idx=9 checksum=1191488 +8x32 sign=0 idx=10 checksum=1963840 +8x32 sign=0 idx=11 checksum=1194176 +8x32 sign=0 idx=12 checksum=352487 +8x32 sign=0 idx=13 checksum=877538 +8x32 sign=0 idx=14 checksum=888257 +8x32 sign=0 idx=15 checksum=1742138 +8x32 sign=1 idx=0 checksum=1571264 +8x32 sign=1 idx=1 checksum=1522432 +8x32 sign=1 idx=2 checksum=593664 +8x32 sign=1 idx=3 checksum=1568576 +8x32 sign=1 idx=4 checksum=136448 +8x32 sign=1 idx=5 checksum=1573632 +8x32 sign=1 idx=6 checksum=916224 +8x32 sign=1 idx=7 checksum=1067392 +8x32 sign=1 idx=8 checksum=138816 +8x32 sign=1 idx=9 checksum=913856 +8x32 sign=1 idx=10 checksum=141504 +8x32 sign=1 idx=11 checksum=911168 +8x32 sign=1 idx=12 checksum=1752857 +8x32 sign=1 idx=13 checksum=1227806 +8x32 sign=1 idx=14 checksum=1217087 +8x32 sign=1 idx=15 checksum=363206 +32x8 sign=0 idx=0 checksum=822592 +32x8 sign=0 idx=1 checksum=945008 +32x8 sign=0 idx=2 checksum=1031024 +32x8 sign=0 idx=3 checksum=938688 +32x8 sign=0 idx=4 checksum=1627744 +32x8 sign=0 idx=5 checksum=987552 +32x8 sign=0 idx=6 checksum=1530272 +32x8 sign=0 idx=7 checksum=581632 +32x8 sign=0 idx=8 checksum=564605 +32x8 sign=0 idx=9 checksum=1089656 +32x8 sign=0 idx=10 checksum=1432664 +32x8 sign=0 idx=11 checksum=1197731 +32x8 sign=0 idx=12 checksum=1670288 +32x8 sign=0 idx=13 checksum=1487728 +32x8 sign=0 idx=14 checksum=1584272 +32x8 sign=0 idx=15 checksum=1573744 +32x8 sign=1 idx=0 checksum=1282752 +32x8 sign=1 idx=1 checksum=1160336 +32x8 sign=1 idx=2 checksum=1074320 +32x8 sign=1 idx=3 checksum=1166656 +32x8 sign=1 idx=4 checksum=477600 +32x8 sign=1 idx=5 checksum=1117792 +32x8 sign=1 idx=6 checksum=575072 +32x8 sign=1 idx=7 checksum=1523712 +32x8 sign=1 idx=8 checksum=1540739 +32x8 sign=1 idx=9 checksum=1015688 +32x8 sign=1 idx=10 checksum=672680 +32x8 sign=1 idx=11 checksum=907613 +32x8 sign=1 idx=12 checksum=435056 +32x8 sign=1 idx=13 checksum=617616 +32x8 sign=1 idx=14 checksum=521072 +32x8 sign=1 idx=15 checksum=531600