forge
Explore
Log in

Don't you dare go Hollow

merge: lane-inter16ab 2e711e1 into lane-intra14 -- rect wedge codebooks replace the non-square refusal, keep both counter sets

Browse files at this commit

b6c20eb7d32ca071e21d09b88685eb0fdf7d0d7eAhmet Kaan GümüşParent: 5f9e0bfd2534b6

11 changed files +1950 -146

crates/ec-av1/examples/decode_probe.rsmodified+11 -0
@@ -57,6 +57,17 @@ fn main() {
5757 // asserts -- printed here so a recipe sweep can see it fire without a
5858 // test-binary rebuild.
5959 println!("skip_split_tx: {}", ec_av1::decode::skip_split_tx_hits());
60+ let (h4, v4, pairs, sub8) = ec_av1::decode::inter16_rect4_counters();
61+ println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}");
62+ let leaf = ec_av1::stream::vartx_rect_leaf_hits();
63+ println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);
64+ let leaf4 = ec_av1::stream::vartx_rect_leaf4_hits();
65+ println!("vartx_rect_leaf4: 8x4={} 4x8={}", leaf4[0], leaf4[1]);
66+ let rw = ec_av1::stream::rect_wedge_hits();
67+ let rwi = ec_av1::stream::rect_wii_hits();
68+ println!(
69+ "rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}"
70+ );
6071 let ir = ec_av1::stream::inter_rect_counters();
6172 println!(
6273 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
crates/ec-av1/src/cdf_state.rsmodified+77 -0
@@ -246,6 +246,35 @@ pub(crate) enum TxbSet {
246246 /// symbols at the `TX_4X4` inter row, the table
247247 /// [`Luma4InterSet1`](TxbSet::Luma4InterSet1) also reads.
248248 LumaRect8x4InterSet1,
249+ /// [`LumaRect16x4`](TxbSet::LumaRect16x4)'s INTER counterpart
250+ /// (lane-inter16ab r2): the same `Luma8` coefficient tables (64 coded
251+ /// positions, `get_txsize_entropy_ctx(TX_16X4)` = TX_8X8), with the
252+ /// INTER `tx_type` table at `txsize_sqr_map[TX_16X4]` = TX_4X4.
253+ /// `av1_get_ext_tx_set_type` (av1/common/idct.c): `tx_size_sqr_up` is
254+ /// TX_16X16 (not > TX_32X32) and `use_reduced_set` picks
255+ /// `EXT_TX_SET_DCT_IDTX` -- three symbols, `inter_tx_type_4`.
256+ LumaRect16x4Inter,
257+ /// [`LumaRect16x4Inter`](TxbSet::LumaRect16x4Inter)'s
258+ /// `reduced_tx_set: false` counterpart: `tx_size_sqr` is TX_4X4, not
259+ /// TX_16X16, so `av1_get_ext_tx_set_type` returns `EXT_TX_SET_ALL16` --
260+ /// sixteen symbols, `inter_tx_type_4_set1`.
261+ LumaRect16x4Inter1,
262+ /// The luma 8x4/4x8 INTER transform of a `sub_tx_size_map` SPLIT LEAF of
263+ /// a 16x4/4x16 strip (lane-inter16ab r4): `sub_tx_size_map[TX_16X4] ==
264+ /// TX_8X4`. Shape = [`LumaRect4x8`](TxbSet::LumaRect4x8)'s --
265+ /// `get_txsize_entropy_ctx(TX_8X4)` ((`txsize_sqr_map` TX_4X4 +
266+ /// `txsize_sqr_up_map` TX_8X8 + 1) >> 1) resolves to TX_8X8 so every
267+ /// coefficient table is [`Luma8`](TxbSet::Luma8)'s, with the true
268+ /// 32-position `eob_pt` -- but the `tx_type` table is the INTER one at
269+ /// `txsize_sqr_map[TX_8X4]` = TX_4X4. `av1_get_ext_tx_set_type`
270+ /// (`blockd.h:1097`) with `tx_size_sqr_up == TX_8X8` (not > TX_32X32),
271+ /// inter and `use_reduced_set` returns `EXT_TX_SET_DCT_IDTX` --
272+ /// `inter_tx_type_4`.
273+ /// [`LumaRect8x4Inter`](TxbSet::LumaRect8x4Inter)'s `reduced_tx_set:
274+ /// false` counterpart: `tx_size_sqr` is TX_4X4, so
275+ /// `av1_get_ext_tx_set_type` returns `EXT_TX_SET_ALL16` --
276+ /// `inter_tx_type_4_set1`.
277+ LumaRect8x4Inter1,
249278 }
250279
251280 /// The tables one transform block is coded with, borrowed from the state for
@@ -1904,6 +1933,54 @@ impl Cdfs {
19041933 tx_type: Some(self.intra_tx_type_4_set1[mode].as_mut_slice()),
19051934 eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
19061935 },
1936+ TxbSet::LumaRect16x4Inter => TxbTables {
1937+ side: 8,
1938+ txb_skip: &mut self.txb_skip_luma_8,
1939+ eob_pt: &mut self.eob_pt_64_luma,
1940+ eob_extra: &mut self.eob_extra_luma_8,
1941+ base: &mut self.base_luma_8,
1942+ base_eob: &mut self.base_eob_luma_8,
1943+ br: &mut self.br_luma_8,
1944+ dc_sign: &mut self.dc_sign_luma,
1945+ tx_type: Some(self.inter_tx_type_4.as_mut_slice()),
1946+ eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
1947+ },
1948+ TxbSet::LumaRect16x4Inter1 => TxbTables {
1949+ side: 8,
1950+ txb_skip: &mut self.txb_skip_luma_8,
1951+ eob_pt: &mut self.eob_pt_64_luma,
1952+ eob_extra: &mut self.eob_extra_luma_8,
1953+ base: &mut self.base_luma_8,
1954+ base_eob: &mut self.base_eob_luma_8,
1955+ br: &mut self.br_luma_8,
1956+ dc_sign: &mut self.dc_sign_luma,
1957+ tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()),
1958+ eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
1959+ },
1960+ TxbSet::LumaRect8x4Inter => TxbTables {
1961+ side: 8,
1962+ txb_skip: &mut self.txb_skip_luma_8,
1963+ eob_pt: &mut self.eob_pt_32_luma,
1964+ eob_extra: &mut self.eob_extra_luma_8,
1965+ base: &mut self.base_luma_8,
1966+ base_eob: &mut self.base_eob_luma_8,
1967+ br: &mut self.br_luma_8,
1968+ dc_sign: &mut self.dc_sign_luma,
1969+ tx_type: Some(self.inter_tx_type_4.as_mut_slice()),
1970+ eob_pt_class1: Some(&mut self.eob_pt_32_luma_class1),
1971+ },
1972+ TxbSet::LumaRect8x4Inter1 => TxbTables {
1973+ side: 8,
1974+ txb_skip: &mut self.txb_skip_luma_8,
1975+ eob_pt: &mut self.eob_pt_32_luma,
1976+ eob_extra: &mut self.eob_extra_luma_8,
1977+ base: &mut self.base_luma_8,
1978+ base_eob: &mut self.base_eob_luma_8,
1979+ br: &mut self.br_luma_8,
1980+ dc_sign: &mut self.dc_sign_luma,
1981+ tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()),
1982+ eob_pt_class1: Some(&mut self.eob_pt_32_luma_class1),
1983+ },
19071984 TxbSet::LumaRect16x8Inter => TxbTables {
19081985 side: 16,
19091986 txb_skip: &mut self.txb_skip_luma_16,
crates/ec-av1/src/decode.rsmodified+519 -71
@@ -1019,6 +1019,9 @@ thread_local! {
10191019 static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
10201020 // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32].
10211021 static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
1022+ // lane-inter16ab r4: rectangular var-tx leaves with a 4-px axis, [8x4, 4x8]
1023+ // -- the `sub_tx_size_map[TX_16X4]` split leaves of a 16x16-level 1:4 strip.
1024+ static VARTX_RECT_LEAF4_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
10221025 // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter
10231026 // frame -- 16x8 and 8x16 inter leaves.
10241027 static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
@@ -1077,9 +1080,16 @@ pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] {
10771080 VARTX_RECT_LEAF_HITS.with(|c| c.get())
10781081 }
10791082
1083+/// Current value of [`VARTX_RECT_LEAF4_HITS`] (lane-inter16ab r4): 8x4/4x8
1084+/// split leaves of a 16x4/4x16 strip, `[8x4, 4x8]`.
1085+pub(crate) fn vartx_rect_leaf4_hits() -> [usize; 2] {
1086+ VARTX_RECT_LEAF4_HITS.with(|c| c.get())
1087+}
1088+
10801089 /// Records one rectangular var-tx leaf.
10811090 fn vartx_rect_leaf_hit(tw: usize, th: usize) {
1082- VARTX_RECT_LEAF_HITS.with(|c| {
1091+ let cell = if tw.min(th) == 4 { &VARTX_RECT_LEAF4_HITS } else { &VARTX_RECT_LEAF_HITS };
1092+ cell.with(|c| {
10831093 let mut h = c.get();
10841094 h[usize::from(th > tw)] += 1;
10851095 c.set(h);
@@ -1991,6 +2001,34 @@ pub(crate) fn nocfl_uv_mode_hits() -> usize {
19912001 NOCFL_UV_MODE_HITS.with(|c| c.get())
19922002 }
19932003
2004+/// lane-inter16ab r5: the six RECTANGULAR wedge shapes, in this order --
2005+/// the counter slots of [`RECT_WEDGE_HITS`]/[`RECT_WII_HITS`].
2006+pub(crate) const RECT_WEDGE_SHAPES: [(usize, usize); 6] =
2007+ [(8, 16), (16, 8), (16, 32), (32, 16), (8, 32), (32, 8)];
2008+
2009+fn rect_wedge_slot(bw: usize, bh: usize) -> Option<usize> {
2010+ RECT_WEDGE_SHAPES.iter().position(|&s| s == (bw, bh))
2011+}
2012+
2013+// lane-inter16ab r5: how many COMPOUND_WEDGE / wedge-INTERINTRA blocks used a
2014+// RECTANGULAR codebook row (hgtw/hltw), per shape -- the gate's proof that
2015+// the rect wedge masks lifted this round actually fired, not just the square
2016+// ones already counted by `WEDGE_HITS`/`WII_HITS`.
2017+thread_local! {
2018+ static RECT_WEDGE_HITS: std::cell::Cell<[usize; 6]> = const { std::cell::Cell::new([0; 6]) };
2019+ static RECT_WII_HITS: std::cell::Cell<[usize; 6]> = const { std::cell::Cell::new([0; 6]) };
2020+}
2021+
2022+/// Current value of [`RECT_WEDGE_HITS`], indexed by [`RECT_WEDGE_SHAPES`].
2023+pub(crate) fn rect_wedge_hits() -> [usize; 6] {
2024+ RECT_WEDGE_HITS.with(|c| c.get())
2025+}
2026+
2027+/// Current value of [`RECT_WII_HITS`], indexed by [`RECT_WEDGE_SHAPES`].
2028+pub(crate) fn rect_wii_hits() -> [usize; 6] {
2029+ RECT_WII_HITS.with(|c| c.get())
2030+}
2031+
19942032 // lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC
19952033 // blend -- the gate's proof that `--enable-obmc=1` reached this shape (the
19962034 // r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented
@@ -2412,6 +2450,64 @@ pub fn ab16_inter_hits_by_arm() -> [usize; 4] {
24122450 AB16_INTER_HITS.with(std::cell::Cell::get)
24132451 }
24142452
2453+// lane-inter16ab r2: the 16x16-level 1:4 pair as INTER blocks -- four 16x4
2454+// (`PARTITION_HORZ_4`) or 4x16 (`PARTITION_VERT_4`) strips. `CHROMA_PAIRS`
2455+// counts the odd strips that close a 4:2:0 chroma pair
2456+// (`is_chroma_reference`, av1_common_int.h:1454: bh == 1 mi => odd mi_row),
2457+// `SUB8_PIECES` the pair chroma blocks whose TOP (LEFT) half was built from
2458+// the PREVIOUS strip's own mv/ref/filters -- libaom
2459+// `build_inter_predictors_sub8x8` (reconinter_template.inc:87-160), reached
2460+// through `is_sub8x8_inter` (same file, :54).
2461+thread_local! {
2462+ static INTER16_HORZ4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2463+ static INTER16_VERT4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2464+ static INTER16_CHROMA_PAIR_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2465+ static INTER16_SUB8_PIECE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2466+}
2467+
2468+/// Current values of the inter 16x16-level 1:4 counters: `(16x4 strips, 4x16
2469+/// strips, chroma pairs closed, chroma pairs built from two different
2470+/// strips' motion vectors)`.
2471+pub fn inter16_rect4_counters() -> (usize, usize, usize, usize) {
2472+ (
2473+ INTER16_HORZ4_HITS.with(std::cell::Cell::get),
2474+ INTER16_VERT4_HITS.with(std::cell::Cell::get),
2475+ INTER16_CHROMA_PAIR_HITS.with(std::cell::Cell::get),
2476+ INTER16_SUB8_PIECE_HITS.with(std::cell::Cell::get),
2477+ )
2478+}
2479+
2480+/// One 16x4 / 4x16 inter strip's chroma situation, handed to
2481+/// [`decode_inter_block`] out of band (the same one-shot thread-local idiom
2482+/// `REDUCED_TX_SET_INTER` uses) rather than through twenty-three call sites
2483+/// that all mean "an ordinary block, chroma of its own".
2484+#[derive(Clone, Copy)]
2485+struct InterStripChroma {
2486+ /// `is_chroma_reference` for this strip: false on strips 0 and 2, which
2487+ /// read and reconstruct NO chroma at all.
2488+ has_chroma: bool,
2489+ /// `PARTITION_HORZ_4` (16x4 strips) rather than `PARTITION_VERT_4`.
2490+ horz: bool,
2491+ /// The mi position of the EVEN strip of this pair -- `setup_pred_plane`'s
2492+ /// `if (ss_y && (mi_row & 1) && mi_size_high[bsize] == 1) mi_row -= 1`,
2493+ /// i.e. the origin of the 8x4 (4x8) chroma transform.
2494+ pair_mi: (usize, usize),
2495+ /// The previous (even) strip's single-reference MC parameters, `None`
2496+ /// when it was intra or compound -- `is_sub8x8_inter` then returns false
2497+ /// and the whole chroma block is predicted from THIS strip's mv.
2498+ prev: Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>,
2499+}
2500+
2501+thread_local! {
2502+ static INTER_STRIP_CHROMA: std::cell::Cell<Option<InterStripChroma>> =
2503+ const { std::cell::Cell::new(None) };
2504+ /// The single-reference MC parameters of the inter block that decoded
2505+ /// last -- read by the next 1:4 strip to build its pair's chroma.
2506+ static INTER_LAST_MC: std::cell::Cell<
2507+ Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>,
2508+ > = const { std::cell::Cell::new(None) };
2509+}
2510+
24152511 fn bump_ab16_inter(arm: usize) {
24162512 AB16_INTER_HITS.with(|c| {
24172513 let mut v = c.get();
@@ -12455,6 +12551,10 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool {
1245512551 (w, h),
1245612552 // 2:1 strips whose transform is coded in full (lane-inter4).
1245712553 (32, 16) | (16, 32) | (16, 8) | (8, 16)
12554+ // lane-inter16ab r2: the 16x16-level 1:4 strips. TX_16X4/TX_4X16
12555+ // codes all 64 of its positions, and its chroma pair is an 8x4 /
12556+ // 4x8 unit (`ss_size_lookup[BLOCK_16X4]` = BLOCK_8X4).
12557+ | (16, 4) | (4, 16)
1245812558 // lane-r14 r2: strips with a 64-px axis. `av1_get_max_eob` codes
1245912559 // only the low 32 coefficients of a 64-length axis, so these read
1246012560 // exactly the truncated corner the INTRA superblock-strip path
@@ -12463,6 +12563,11 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool {
1246312563 // `TX_64X64`, so `av1_get_ext_tx_set_type` is `DCT_ONLY` and no
1246412564 // `tx_type` symbol is coded at all.
1246512565 | (64, 32) | (32, 64) | (64, 16) | (16, 64)
12566+ // lane-inter16ab r4: `sub_tx_size_map[TX_16X4] == TX_8X4`, so a
12567+ // split-transform 16x4/4x16 strip has RECTANGULAR 8x4/4x8 leaves.
12568+ // Only reachable as a var-tx LEAF -- an 8x4/4x8 inter BLOCK is
12569+ // refused earlier ("an inter partition below 8x8").
12570+ | (8, 4) | (4, 8)
1246612571 )
1246712572 }
1246812573
@@ -12474,9 +12579,27 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool {
1247412579 /// `tx_size_sqr == TX_8X8`, so it reads `EXT_TX_SET_DCT_IDTX` when reduced
1247512580 /// and the 16-symbol `EXT_TX_SET_ALL16` otherwise -- both at the *8x8* CDF
1247612581 /// row (`txsize_sqr_map`), never the 16x16 one.
12477-fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet {
12478- match (w, h) {
12582+fn rect_inter_luma_set(w: usize, h: usize) -> Result<TxbSet> {
12583+ Ok(match (w, h) {
1247912584 (32, 16) | (16, 32) => TxbSet::LumaRect32x16Inter,
12585+ // lane-inter16ab r4: the 8x4/4x8 split leaf of a 16x4/4x16 strip.
12586+ // `av1_get_ext_tx_set_type` (blockd.h:1097) at `tx_size_sqr_up ==
12587+ // TX_8X8`, `tx_size_sqr == TX_4X4`, inter: DCT_IDTX when reduced,
12588+ // ALL16 otherwise -- both at the TX_4X4 row.
12589+ (8, 4) | (4, 8) => {
12590+ if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) {
12591+ TxbSet::LumaRect8x4Inter
12592+ } else {
12593+ TxbSet::LumaRect8x4Inter1
12594+ }
12595+ }
12596+ (16, 4) | (4, 16) => {
12597+ if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) {
12598+ TxbSet::LumaRect16x4Inter
12599+ } else {
12600+ TxbSet::LumaRect16x4Inter1
12601+ }
12602+ }
1248012603 (16, 8) | (8, 16) => {
1248112604 if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) {
1248212605 TxbSet::LumaRect16x8Inter
@@ -12491,16 +12614,20 @@ fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet {
1249112614 // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot.
1249212615 (64, 32) | (32, 64) => TxbSet::Luma64,
1249312616 (64, 16) | (16, 64) => TxbSet::LumaRect32x16,
12494- _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),
12495- }
12617+ _ => {
12618+ return Err(unsupported(
12619+ "a rectangular inter luma transform unit whose shape has no coefficient table set here",
12620+ ));
12621+ }
12622+ })
1249612623 }
1249712624
1249812625 /// The chroma table set of the same block's single rectangular chroma unit
1249912626 /// (`av1_get_max_uv_txsize`): 16x8/8x16 under a 32x16/16x32 strip, 8x4/4x8
1250012627 /// under a 16x8/8x16 one. Neither codes a `tx_type` symbol -- both inherit
1250112628 /// the luma unit's.
12502-fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet {
12503- match (w, h) {
12629+fn rect_inter_chroma_set(w: usize, h: usize) -> Result<TxbSet> {
12630+ Ok(match (w, h) {
1250412631 (16, 8) | (8, 16) => TxbSet::ChromaRect16x8,
1250512632 (8, 4) | (4, 8) => TxbSet::ChromaRect8x4,
1250612633 // lane-r14 r2: chroma of a 64-axis strip -- 32x16/16x32 under a
@@ -12510,8 +12637,12 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet {
1251012637 // `txsize_log2_minus4` = 4), same as the intra strip path uses.
1251112638 (32, 16) | (16, 32) => TxbSet::ChromaRect32x16,
1251212639 (32, 8) | (8, 32) => TxbSet::Chroma16,
12513- _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),
12514- }
12640+ _ => {
12641+ return Err(unsupported(
12642+ "a rectangular inter chroma transform unit whose shape has no coefficient table set here",
12643+ ));
12644+ }
12645+ })
1251512646 }
1251612647
1251712648 /// libaom `size_group_lookup[bsize]` for the block shapes this decoder's
@@ -12547,18 +12678,24 @@ fn size_group_wh_matches_libaom_size_group_lookup() {
1254712678 }
1254812679
1254912680 /// The default (2D) coefficient scan of a rectangular transform.
12550-fn rect_scan(w: usize, h: usize) -> &'static [u16] {
12551- match (w, h) {
12681+fn rect_scan(w: usize, h: usize) -> Result<&'static [u16]> {
12682+ Ok(match (w, h) {
1255212683 (32, 16) => &SCAN_32X16,
1255312684 (16, 32) => &SCAN_16X32,
1255412685 (16, 8) => &SCAN_16X8,
1255512686 (8, 16) => &SCAN_8X16,
12687+ (16, 4) => &SCAN_16X4,
12688+ (4, 16) => &SCAN_4X16,
1255612689 (8, 4) => &SCAN_8X4,
1255712690 (4, 8) => &SCAN_4X8,
1255812691 (32, 8) => &SCAN_32X8,
1255912692 (8, 32) => &SCAN_8X32,
12560- _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),
12561- }
12693+ _ => {
12694+ return Err(unsupported(
12695+ "a rectangular transform unit whose shape has no coefficient scan table here",
12696+ ));
12697+ }
12698+ })
1256212699 }
1256312700
1256412701 /// [`read_block_tx_size`] for a rectangular inter block (lane-inter4 r2):
@@ -12720,7 +12857,7 @@ fn read_inter_plane_rect(
1272012857 read_coeffs_rect(
1272112858 dec,
1272212859 &mut coding,
12723- rect_scan(cw, ch),
12860+ rect_scan(cw, ch)?,
1272412861 cw,
1272512862 ch,
1272612863 skip_ctx,
@@ -16964,8 +17101,61 @@ fn obmc_blend(
1696417101 /// always `is_interinter_compound_used`, so the function is always `true`
1696517102 /// for `side` -- kept as a named call (rather than inlined `true`) so a
1696617103 /// future sub-8 block size does not silently misdecode a real stream.
16967-fn is_any_masked_compound_used_here(side: usize) -> bool {
16968- side.min(side) >= 8
17104+fn is_any_masked_compound_used_here(bw: usize, bh: usize) -> bool {
17105+ // lane-inter16ab r4 (class sweep of the r3 CDF-row defect):
17106+ // `is_comp_ref_allowed(bsize)` is `AOMMIN(block_size_wide, block_size_high)
17107+ // >= 8` on the block's TRUE footprint -- a 16x4/4x16 strip is NOT allowed,
17108+ // so libaom writes no `comp_group_idx` symbol there at all. Keyed off the
17109+ // square `side` we read one the reference never wrote.
17110+ bw.min(bh) >= 8
17111+}
17112+
17113+/// The `BLOCK_SIZES_ALL` index of a `bw x bh` block (libaom `enum BLOCK_SIZE`,
17114+/// `blockd.h`) -- the row every size-indexed inter CDF table
17115+/// (`compound_type_cdf`, `wedge_idx_cdf`) is keyed by. Our `decode_inter_block`
17116+/// carries the enclosing SQUARE `side` for context purposes (the accepted
17117+/// strip corner-cut), so a 16x8 / 8x16 PARTITION_HORZ/VERT strip that reads
17118+/// one of those symbols off `side` alone takes BLOCK_16X16's row and desyncs
17119+/// (lane-inter16ab r3: a real 16x8 compound strip with `comp_group_idx == 1`,
17120+/// decode-order frame 5, our range 64901 vs the oracle's 47271 at the very
17121+/// next block's mode read).
17122+fn bsize_all_index(bw: usize, bh: usize) -> Option<usize> {
17123+ Some(match (bw, bh) {
17124+ (4, 4) => 0,
17125+ (4, 8) => 1,
17126+ (8, 4) => 2,
17127+ (8, 8) => 3,
17128+ (8, 16) => 4,
17129+ (16, 8) => 5,
17130+ (16, 16) => 6,
17131+ (16, 32) => 7,
17132+ (32, 16) => 8,
17133+ (32, 32) => 9,
17134+ (32, 64) => 10,
17135+ (64, 32) => 11,
17136+ (64, 64) => 12,
17137+ (64, 128) => 13,
17138+ (128, 64) => 14,
17139+ (128, 128) => 15,
17140+ (4, 16) => 16,
17141+ (16, 4) => 17,
17142+ (8, 32) => 18,
17143+ (32, 8) => 19,
17144+ (16, 64) => 20,
17145+ (64, 16) => 21,
17146+ _ => return None,
17147+ })
17148+}
17149+
17150+/// `av1_wedge_params_lookup[bsize].wedge_types > 0` (libaom `reconinter.c`):
17151+/// the block sizes that carry a wedge codebook at all. A `compound_type`
17152+/// symbol is written only for these; every other size infers
17153+/// `COMPOUND_DIFFWTD`.
17154+fn wedge_used_bsize(bw: usize, bh: usize) -> bool {
17155+ matches!(
17156+ (bw, bh),
17157+ (8, 8) | (8, 16) | (16, 8) | (16, 16) | (16, 32) | (32, 16) | (32, 32) | (8, 32) | (32, 8)
17158+ )
1696917159 }
1697017160
1697117161 /// libaom's `BLOCK_SIZES_ALL` index of a `w`x`h` block (`common_data.h`'s own
@@ -17478,9 +17668,27 @@ fn decode_inter_block(
1747817668 // exactly what it read before.
1747917669 let (rmi, cmi) = at;
1748017670 let (px, py) = (at.1 * MI, at.0 * MI);
17481- let (cpx, cpy) = (px / 2, py / 2);
17671+ // lane-inter16ab r2: a 16x4 / 4x16 inter strip's chroma is the PAIR's
17672+ // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd
17673+ // strip (`is_chroma_reference`); every other block keeps its own.
17674+ let strip_chroma = INTER_STRIP_CHROMA.with(std::cell::Cell::take);
17675+ INTER_LAST_MC.with(|c| c.set(None));
17676+ let has_chroma = strip_chroma.is_none_or(|s| s.has_chroma);
17677+ let (cpx, cpy) = match strip_chroma {
17678+ Some(s) if s.has_chroma => (s.pair_mi.1 * MI / 2, s.pair_mi.0 * MI / 2),
17679+ _ => (px / 2, py / 2),
17680+ };
1748217681 let chroma_side = side / 2;
17483- let (write_chroma_w, write_chroma_h) = (write_w / 2, write_h / 2);
17682+ let (write_chroma_w, write_chroma_h) = match strip_chroma {
17683+ Some(s) if s.has_chroma => {
17684+ if s.horz {
17685+ (8, 4)
17686+ } else {
17687+ (4, 8)
17688+ }
17689+ }
17690+ _ => (write_w / 2, write_h / 2),
17691+ };
1748417692
1748517693 if std::env::var_os("EC_AV1_TELL").is_some() {
1748617694 eprintln!(
@@ -17504,7 +17712,12 @@ fn decode_inter_block(
1750417712 let (seg_mi_r, seg_mi_c) = (rmi, cmi);
1750517713 let (seg_w_mi, seg_h_mi) = (write_w / 4, write_h / 4);
1750617714 inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, false, true);
17507- let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
17715+ // libaom `read_skip_mode` (decodemv.c): `if (!is_comp_ref_allowed(bsize))
17716+ // return 0` -- a 16x4 / 4x16 strip (min(bw, bh) == 4, blockd.h:65) reads
17717+ // no `skip_mode` symbol at all.
17718+ let comp_allowed = write_w.min(write_h) >= 8;
17719+ let skip_mode =
17720+ skip_mode_present && comp_allowed && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
1750817721 if std::env::var_os("EC_AV1_SKIPMODE_DUMP").is_some() {
1750917722 eprintln!(
1751017723 "EC_SKIPMODE r={r} c={c} result={skip_mode} tell_after={}",
@@ -17616,7 +17829,12 @@ fn decode_inter_block(
1761617829 );
1761717830 }
1761817831 let is_compound =
17619- skip_mode || (reference_select && read_comp_mode(dec, cdfs, above_nbr, left_nbr));
17832+ skip_mode
17833+ || (reference_select
17834+ // `is_comp_ref_allowed` (blockd.h:65) gates the
17835+ // `comp_mode` read exactly as it gates `skip_mode`.
17836+ && comp_allowed
17837+ && read_comp_mode(dec, cdfs, above_nbr, left_nbr));
1762017838 if is_compound {
1762117839 let (ref0, ref1) = if skip_mode {
1762217840 (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8)
@@ -17818,7 +18036,7 @@ fn decode_inter_block(
1781818036 let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side);
1781918037 let comp_group_idx = if !skip_mode
1782018038 && enable_masked_compound
17821- && masked_compound_used_wh(write_w, write_h)
18039+ && is_any_masked_compound_used_here(write_w, write_h)
1782218040 {
1782318041 dec.symbol(&mut cdfs.comp_group_idx[group_ctx])
1782418042 } else {
@@ -17851,11 +18069,11 @@ fn decode_inter_block(
1785118069 // writes NO `compound_type` symbol there and INFERS
1785218070 // `COMPOUND_DIFFWTD` -- only the 1-bit `mask_type` literal
1785318071 // follows. `None` here is exactly that inferred arm.
17854- // lane-intersub8 r4: the block's TRUE footprint, not the
17855- // square envelope -- `compound_type_cdf`/`wedge_idx_cdf` are
17856- // `BLOCK_SIZES_ALL`-indexed.
18072+ // lane-inter16ab r3: the row is this block's TRUE
18073+ // `BLOCK_SIZES_ALL` index, not the enclosing square `side`'s
18074+ // -- a 16x8 strip reads `compound_type_cdf[BLOCK_16X8]`.
1785718075 let wedge_bsize =
17858- bsize_index(write_w, write_h).filter(|_| wedge_used_wh(write_w, write_h));
18076+ bsize_all_index(write_w, write_h).filter(|_| wedge_used_bsize(write_w, write_h));
1785918077 let compound_type = match wedge_bsize {
1786018078 Some(b) => dec.symbol(&mut cdfs.compound_type[b]),
1786118079 None => 1,
@@ -17863,20 +18081,26 @@ fn decode_inter_block(
1786318081 if let Some(wedge_bsize) = wedge_bsize.filter(|_| compound_type == 0) {
1786418082 // COMPOUND_WEDGE: lane-wedge r3, codebook checksum-
1786518083 // verified vs independent C dump (wedge.rs).
17866- if write_w != write_h {
17867- // lane-intersub8 r4: the wedge codebook here is built
17868- // per SQUARE side only; a rect block's own codebook
17869- // (BLOCK_16X8 etc.) is a different mask set.
17870- return Err(unsupported(
17871- "a COMPOUND_WEDGE mask on a non-square inter block (rect wedge codebook unimplemented)",
17872- ));
17873- }
1787418084 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]);
1787518085 let wedge_sign = dec.literal(1);
1787618086 WEDGE_HITS.with(|c| c.set(c.get() + 1));
18087+ if let Some(k) = rect_wedge_slot(write_w, write_h) {
18088+ RECT_WEDGE_HITS.with(|c| {
18089+ let mut a = c.get();
18090+ a[k] += 1;
18091+ c.set(a);
18092+ });
18093+ }
18094+ // lane-inter16ab r5: the codebook row is this block's TRUE
18095+ // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for
18096+ // h>w, hltw for h<w, plus that bsize's own signflip row).
18097+ // Masks are padded to stride `max(bw,bh) == side`, so the
18098+ // square blend below indexes them unchanged and the
18099+ // padding never reaches the frame (only `write_w x
18100+ // write_h` is written out).
1787718101 wedge_mask = Some(
1787818102 crate::wedge::wedge_masks()
17879- .codebook(side)
18103+ .codebook(write_w, write_h)
1788018104 .mask(wedge_sign as usize, wedge_index as usize),
1788118105 );
1788218106 } else {
@@ -18505,7 +18729,7 @@ fn decode_inter_block(
1850518729 read_inter_plane_rect(
1850618730 dec,
1850718731 cdfs,
18508- rect_inter_luma_set(tw, th),
18732+ rect_inter_luma_set(tw, th)?,
1850918733 (tw, th),
1851018734 side,
1851118735 0,
@@ -18535,7 +18759,7 @@ fn decode_inter_block(
1853518759 let (grid, tx_type) = read_inter_plane_rect(
1853618760 dec,
1853718761 cdfs,
18538- rect_inter_luma_set(write_w, write_h),
18762+ rect_inter_luma_set(write_w, write_h)?,
1853918763 (write_w, write_h),
1854018764 side,
1854118765 0,
@@ -18579,7 +18803,7 @@ fn decode_inter_block(
1857918803 &read_inter_plane_rect(
1858018804 dec,
1858118805 cdfs,
18582- rect_inter_chroma_set(write_chroma_w, write_chroma_h),
18806+ rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,
1858318807 (uw, uh),
1858418808 chroma_side,
1858518809 1,
@@ -18601,7 +18825,7 @@ fn decode_inter_block(
1860118825 &read_inter_plane_rect(
1860218826 dec,
1860318827 cdfs,
18604- rect_inter_chroma_set(write_chroma_w, write_chroma_h),
18828+ rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,
1860518829 (uw, uh),
1860618830 chroma_side,
1860718831 2,
@@ -18876,7 +19100,13 @@ fn decode_inter_block(
1887619100 // `enable_interintra_wedge` seq bit -- the wedge flag
1887719101 // (`av1_is_wedge_used(bsize)` holds for 16x16/32x32).
1887819102 let ii = dec.symbol(&mut cdfs.interintra_mode[bsize_group]) as u8;
18879- let wedge_bsize = if side == 16 { 6 } else { 9 };
19103+ // lane-inter16ab r3 (same class as the compound
19104+ // `compound_type` row below): the row is the block's TRUE
19105+ // `BLOCK_SIZES_ALL` index -- a 16x8 / 32x16 interintra
19106+ // strip is BLOCK_16X8 / BLOCK_32X16, not its square
19107+ // `side`'s BLOCK_16X16 / BLOCK_32X32.
19108+ let wedge_bsize = bsize_all_index(write_w, write_h)
19109+ .expect("interintra shape is a BLOCK_SIZES_ALL size");
1888019110 let wedge = dec.symbol(&mut cdfs.wedge_interintra[wedge_bsize]) == 1;
1888119111 if wedge {
1888219112 // lane-wii r2 (spec 5.11.25): `wedge_index` is an
@@ -18885,9 +19115,19 @@ fn decode_inter_block(
1888519115 // INTERINTRA_WEDGE_SIGN 0 (blockd.h).
1888619116 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]);
1888719117 WII_HITS.with(|c| c.set(c.get() + 1));
19118+ if let Some(k) = rect_wedge_slot(write_w, write_h) {
19119+ RECT_WII_HITS.with(|c| {
19120+ let mut a = c.get();
19121+ a[k] += 1;
19122+ c.set(a);
19123+ });
19124+ }
19125+ // lane-inter16ab r5: true-footprint codebook row,
19126+ // mask padded to stride `max(bw,bh) == side` -- see
19127+ // the compound site's own comment.
1888819128 wedge_mask = Some((
1888919129 crate::wedge::wedge_masks()
18890- .codebook(side)
19130+ .codebook(write_w, write_h)
1889119131 .mask(0, wedge_index as usize),
1889219132 side,
1889319133 ));
@@ -18929,6 +19169,9 @@ fn decode_inter_block(
1892919169 // motion_mode symbol is NOT read (SIMPLE_TRANSLATION implied).
1893019170 let motion_mode_eligible = switchable_motion_mode
1893119171 && !skip_mode
19172+ // `is_motion_variation_allowed_bsize` (blockd.h:1455):
19173+ // min(bw, bh) >= 8, false for a 16x4 / 4x16 strip.
19174+ && write_w.min(write_h) >= 8
1893219175 && interintra_mode.is_none()
1893319176 && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty()
1893419177 || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1)
@@ -19237,6 +19480,11 @@ fn decode_inter_block(
1923719480 }
1923819481 }
1923919482
19483+ // lane-inter16ab r2: `is_sub8x8_inter`'s neighbour walk reads the
19484+ // PREVIOUS strip's `mv`/`ref_frame`/`interp_filters`
19485+ // (reconinter_template.inc:75-82); record them for the next 1:4
19486+ // strip, which is the only reader.
19487+ INTER_LAST_MC.with(|c| c.set(Some((ref_frame, mv, h_filter, v_filter))));
1924019488 let mut pred_y = vec![0u16; side * side];
1924119489 let mut pred_u = vec![0u16; chroma_side * chroma_side];
1924219490 let mut pred_v = vec![0u16; chroma_side * chroma_side];
@@ -19398,6 +19646,46 @@ fn decode_inter_block(
1939819646 interintra_blend(v, cpx, cpy, chroma_side, ii, wedge_mask, &mut pred_v);
1939919647 }
1940019648
19649+ // lane-inter16ab r2: libaom `build_inter_predictors_sub8x8`
19650+ // (reconinter_template.inc:87-160). A 4:2:0 chroma block under a
19651+ // 16x4 (4x16) luma pair covers TWO luma blocks, so it is built in
19652+ // `b4_w x b4_h` = 8x2 (2x8) pieces, each from its own strip's
19653+ // mv/ref/filters. The bottom (right) piece is this strip's own mv
19654+ // over its own rows, which the whole-block prediction above
19655+ // already wrote there (MC is position-invariant for a fixed mv),
19656+ // so only the FIRST piece has to be rebuilt -- and only when
19657+ // `is_sub8x8_inter` holds, i.e. the previous strip was itself a
19658+ // single-reference inter block (`prev`), else libaom falls
19659+ // through to the ordinary whole-block predictor.
19660+ if let Some(s) = strip_chroma.filter(|s| s.has_chroma)
19661+ && let Some((prev_ref, prev_mv, prev_h, prev_v)) = s.prev
19662+ && luma_scale == mc::REF_NO_SCALE
19663+ {
19664+ let (piece_w, piece_h) = if s.horz { (8usize, 2usize) } else { (2usize, 8usize) };
19665+ let (_, prev_u, prev_v_plane) = ref_planes(prev_ref, ref_y, ref_u, ref_v, other_refs)?;
19666+ for (src, dst) in [(prev_u, &mut pred_u), (prev_v_plane, &mut pred_v)] {
19667+ let mut piece = vec![0u16; piece_w * piece_h];
19668+ mc::predict_with_filters(
19669+ &src.data,
19670+ src.width,
19671+ src.true_width,
19672+ src.true_height,
19673+ mv_to_q4(cpx, prev_mv.1, false),
19674+ mv_to_q4(cpy, prev_mv.0, false),
19675+ piece_w,
19676+ piece_h,
19677+ prev_h,
19678+ prev_v,
19679+ &mut piece,
19680+ );
19681+ for row in 0..piece_h {
19682+ dst[row * chroma_side..row * chroma_side + piece_w]
19683+ .copy_from_slice(&piece[row * piece_w..(row + 1) * piece_w]);
19684+ }
19685+ }
19686+ INTER16_SUB8_PIECE_HITS.with(|c| c.set(c.get() + 1));
19687+ }
19688+
1940119689 // lane-inter4 r2: a rectangular strip's transform tree starts from
1940219690 // its own rect `max_txsize_rect_lookup` entry, not a square one.
1940319691 let rect_tu = (write_w, write_h) != (side, side);
@@ -19434,24 +19722,26 @@ fn decode_inter_block(
1943419722 &pred_y,
1943519723 &vec![0i32; side * side],
1943619724 );
19437- u.reconstruct_mc_rect(
19438- cpx,
19439- cpy,
19440- chroma_side,
19441- write_chroma_w,
19442- write_chroma_h,
19443- &pred_u,
19444- &vec![0i32; chroma_side * chroma_side],
19445- );
19446- v.reconstruct_mc_rect(
19447- cpx,
19448- cpy,
19449- chroma_side,
19450- write_chroma_w,
19451- write_chroma_h,
19452- &pred_v,
19453- &vec![0i32; chroma_side * chroma_side],
19454- );
19725+ if has_chroma {
19726+ u.reconstruct_mc_rect(
19727+ cpx,
19728+ cpy,
19729+ chroma_side,
19730+ write_chroma_w,
19731+ write_chroma_h,
19732+ &pred_u,
19733+ &vec![0i32; chroma_side * chroma_side],
19734+ );
19735+ v.reconstruct_mc_rect(
19736+ cpx,
19737+ cpy,
19738+ chroma_side,
19739+ write_chroma_w,
19740+ write_chroma_h,
19741+ &pred_v,
19742+ &vec![0i32; chroma_side * chroma_side],
19743+ );
19744+ }
1945519745 luma_grid = vec![0i32; side * side];
1945619746 u_grid = vec![0i32; chroma_side * chroma_side];
1945719747 v_grid = vec![0i32; chroma_side * chroma_side];
@@ -19464,6 +19754,18 @@ fn decode_inter_block(
1946419754 } else {
1946519755 neighbours.around_mi(at, side)
1946619756 };
19757+ // lane-inter16ab r2: the pair's chroma transform sits at the
19758+ // EVEN strip's mi origin and spans both strips, so its
19759+ // above/left coefficient context is the pair's, not this
19760+ // strip's row.
19761+ let around_c = match strip_chroma {
19762+ Some(s) if s.has_chroma => neighbours.around_mi_rect(
19763+ s.pair_mi,
19764+ if s.horz { 16 } else { 8 },
19765+ if s.horz { 8 } else { 16 },
19766+ ),
19767+ _ => around,
19768+ };
1946719769 let luma_tx_type;
1946819770 if let Some(leaves) = vartx_leaves.clone() {
1946919771 // spec 5.11.17's transform tree, leaf by leaf in the order
@@ -19517,7 +19819,7 @@ fn decode_inter_block(
1951719819 read_inter_plane_rect(
1951819820 dec,
1951919821 cdfs,
19520- rect_inter_luma_set(tw, th),
19822+ rect_inter_luma_set(tw, th)?,
1952119823 (tw, th),
1952219824 side,
1952319825 0,
@@ -19547,7 +19849,7 @@ fn decode_inter_block(
1954719849 let (grid, tx_type) = read_inter_plane_rect(
1954819850 dec,
1954919851 cdfs,
19550- rect_inter_luma_set(write_w, write_h),
19852+ rect_inter_luma_set(write_w, write_h)?,
1955119853 (write_w, write_h),
1955219854 side,
1955319855 0,
@@ -19581,7 +19883,16 @@ fn decode_inter_block(
1958119883 None,
1958219884 )?;
1958319885 }
19584- if rect_tu {
19886+ if !has_chroma {
19887+ // `is_chroma_reference` is false for this strip: libaom's
19888+ // plane loop (decodeframe.c
19889+ // `predict_and_reconstruct_intra_block`/
19890+ // `reconstruct_inter_block`'s `for (plane...)` guarded by
19891+ // `xd->is_chroma_ref`) codes NO chroma transform here, so
19892+ // neither symbol nor context exists.
19893+ u_grid = vec![0i32; chroma_side * chroma_side];
19894+ v_grid = vec![0i32; chroma_side * chroma_side];
19895+ } else if rect_tu {
1958519896 // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a
1958619897 // 2:1 strip is the strip's own rect chroma size (16x8 /
1958719898 // 8x16), one unit for the whole block, and it codes no
@@ -19591,11 +19902,11 @@ fn decode_inter_block(
1959119902 &read_inter_plane_rect(
1959219903 dec,
1959319904 cdfs,
19594- rect_inter_chroma_set(write_chroma_w, write_chroma_h),
19905+ rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,
1959519906 (uw, uh),
1959619907 chroma_side,
1959719908 1,
19598- around[1],
19909+ around_c[1],
1959919910 mode_for_tx,
1960019911 u,
1960119912 cpx,
@@ -19613,11 +19924,11 @@ fn decode_inter_block(
1961319924 &read_inter_plane_rect(
1961419925 dec,
1961519926 cdfs,
19616- rect_inter_chroma_set(write_chroma_w, write_chroma_h),
19927+ rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,
1961719928 (uw, uh),
1961819929 chroma_side,
1961919930 2,
19620- around[2],
19931+ around_c[2],
1962119932 mode_for_tx,
1962219933 v,
1962319934 cpx,
@@ -19678,6 +19989,16 @@ fn decode_inter_block(
1967819989 // skip path above (which only needed a clipped write of an
1967919990 // already-square-predicted buffer). Named refusal instead of a
1968019991 // silently wrong square-shaped intra prediction.
19992+ // lane-inter16ab r2: `decode_intra_rect_in_inter` has no chroma-pair
19993+ // path (it predicts and codes chroma at the strip's own halved
19994+ // footprint), so an INTRA 16x4 / 4x16 strip inside a 1:4 partition is
19995+ // refused by name rather than decoded with a 8x2 chroma transform
19996+ // libaom never coded.
19997+ if write_w.min(write_h) < 8 {
19998+ return Err(unsupported(
19999+ "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)",
20000+ ));
20001+ }
1968120002 if write_w != side || write_h != side {
1968220003 // lane-intrarect r1: the strip decodes through its own rect
1968320004 // machinery ([`decode_intra_rect_in_inter`] -> the key-frame
@@ -19828,8 +20149,12 @@ fn decode_inter_block(
1982820149 // -- `palette_mode_ctx`/`palette_uv_mode_ctx` hardcoded 0, provably
1982920150 // safe since a nonzero neighbour `palette_size` would already have
1983020151 // refused the decode that produced it.
20152+ // lane-inter16ab r4 (class sweep): `av1_get_palette_bsize_ctx` is keyed
20153+ // by the block's TRUE footprint -- a rect strip's row is not its
20154+ // enclosing square's, and a 16x4 strip (64 pixels) reads no palette
20155+ // symbol at all.
1983120156 if allow_screen_content_tools
19832- && let Some(bsize_ctx) = palette_bsize_ctx(side)
20157+ && let Some(bsize_ctx) = palette_bsize_ctx_wh(write_w, write_h)
1983320158 {
1983420159 if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][0]) != 0 {
1983520160 return Err(unsupported(
@@ -19853,7 +20178,9 @@ fn decode_inter_block(
1985320178 let mut filter_intra = None;
1985420179 if mode == DC_PRED
1985520180 && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get)
19856- && let Some(class) = filter_intra_size_class(side)
20181+ // lane-inter16ab r4 (class sweep): `cdf::FILTER_INTRA`'s row is the
20182+ // true `BLOCK_SIZES_ALL` class of this strip, not its square side's.
20183+ && let Some(class) = filter_intra_size_class_rect(write_w, write_h)
1985720184 && dec.symbol(&mut cdfs.filter_intra[class]) != 0
1985820185 {
1985920186 FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));
@@ -20094,6 +20421,14 @@ fn decode_inter_block(
2009420421 rmi, cmi, dec.debug_bitpos(), dec.debug_state().0
2009520422 );
2009620423 }
20424+ // lane-inter16ab r2: the pair's chroma coefficient context spans BOTH
20425+ // strips (mirroring the intra `decode_rect4_16` path), and the even
20426+ // strip's own record wrote empty chroma state over those cells -- this
20427+ // rewrite is what libaom's single `av1_set_contexts` call for the 8x4
20428+ // (4x8) chroma unit leaves behind.
20429+ let pair_chroma = strip_chroma
20430+ .filter(|s| s.has_chroma)
20431+ .map(|s| (s, neighbour_state(&u_grid), neighbour_state(&v_grid)));
2009720432 if vartx_leaves.is_some() {
2009820433 // Plane 0 is already correct per transform unit
2009920434 // ([`Neighbours::record_mi_luma`] above); this writes everything else
@@ -20110,6 +20445,32 @@ fn decode_inter_block(
2011020445 &[luma_grid, u_grid, v_grid],
2011120446 );
2011220447 }
20448+ if let Some((s, u_state, v_state)) = pair_chroma {
20449+ let (pw, ph) = if s.horz { (16usize, 8usize) } else { (8, 16) };
20450+ let round_up_even = |n: usize| n.div_ceil(2) * 2;
20451+ let (bound_h, bound_w) = (
20452+ round_up_even(neighbours.mi_rows),
20453+ round_up_even(neighbours.mi_cols),
20454+ );
20455+ for cell in 0..(ph / MI) {
20456+ if s.pair_mi.0 + cell < bound_h
20457+ && let Some(slot) = neighbours.left.get_mut(s.pair_mi.0 + cell)
20458+ {
20459+ slot[1] = u_state;
20460+ slot[2] = v_state;
20461+ }
20462+ }
20463+ for cell in 0..(pw / MI) {
20464+ if s.pair_mi.1 + cell < bound_w
20465+ && let Some(slot) = neighbours.above.get_mut(s.pair_mi.1 + cell)
20466+ {
20467+ slot[1] = u_state;
20468+ slot[2] = v_state;
20469+ }
20470+ }
20471+ neighbours.record_uv_mode_mi(s.pair_mi.0, s.pair_mi.1, pw / MI, ph / MI, uv_predict_mode);
20472+ INTER16_CHROMA_PAIR_HITS.with(|c| c.set(c.get() + 1));
20473+ }
2011320474 neighbours.record_inter_rect_mi(
2011420475 at,
2011520476 write_w / MI,
@@ -21457,7 +21818,7 @@ fn decode_inter_block8(
2145721818 let group_ctx = get_comp_group_idx_context(neighbours, leaf_mi, SIDE);
2145821819 let comp_group_idx = if !skip_mode
2145921820 && enable_masked_compound
21460- && is_any_masked_compound_used_here(SIDE)
21821+ && is_any_masked_compound_used_here(SIDE, SIDE)
2146121822 {
2146221823 dec.symbol(&mut cdfs.comp_group_idx[group_ctx])
2146321824 } else {
@@ -21480,7 +21841,7 @@ fn decode_inter_block8(
2148021841 WEDGE_HITS.with(|c| c.set(c.get() + 1));
2148121842 wedge_mask = Some(
2148221843 crate::wedge::wedge_masks()
21483- .codebook(SIDE)
21844+ .codebook(SIDE, SIDE)
2148421845 .mask(wedge_sign as usize, wedge_index as usize),
2148521846 );
2148621847 } else {
@@ -22074,7 +22435,7 @@ fn decode_inter_block8(
2207422435 WII_HITS.with(|c| c.set(c.get() + 1));
2207522436 wedge_mask = Some((
2207622437 crate::wedge::wedge_masks()
22077- .codebook(SIDE)
22438+ .codebook(SIDE, SIDE)
2207822439 .mask(0, wedge_index as usize),
2207922440 SIDE,
2208022441 ));
@@ -24072,9 +24433,96 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2407224433 inter_leaf8!(at16, br);
2407324434 }
2407424435 }
24436+ } else if part16 == PARTITION_HORZ_4
24437+ || part16 == PARTITION_VERT_4
24438+ {
24439+ // lane-inter16ab r2: four 16x4 (4x16) INTER
24440+ // strips. libaom `decode_partition`
24441+ // (decodeframe.c, PARTITION_HORZ_4/VERT_4)
24442+ // walks them top to bottom (left to right)
24443+ // with its own `i > 0` frame-edge break.
24444+ //
24445+ // Each strip is >= 8 in one dimension only,
24446+ // so `is_comp_ref_allowed`,
24447+ // `is_motion_variation_allowed_bsize`
24448+ // (blockd.h:65/1455, min(bw, bh) >= 8) and
24449+ // `is_interintra_allowed_bsize` (BLOCK_8X8..
24450+ // BLOCK_32X32 in enum order, which excludes
24451+ // BLOCK_16X4 = 17) are all false: no
24452+ // skip_mode, no comp_mode, no OBMC/warp and
24453+ // no interintra symbol is read -- gated in
24454+ // `decode_inter_block` off `write_w`/
24455+ // `write_h`.
24456+ //
24457+ // CHROMA is the pair's:
24458+ // `is_chroma_reference`
24459+ // (av1_common_int.h:1454) is false on the
24460+ // even strips, and the odd one codes one 8x4
24461+ // (4x8) chroma transform at the pair's
24462+ // origin, built from BOTH strips' motion
24463+ // (`is_sub8x8_inter`).
24464+ let horz = part16 == PARTITION_HORZ_4;
24465+ let (mi_row0, mi_col0) = sub16_to_mi(at16);
24466+ let (bw, bh) = if horz { (16usize, 4usize) } else { (4usize, 16usize) };
24467+ for i in 0..4usize {
24468+ let at_mi = if horz {
24469+ (mi_row0 + i, mi_col0)
24470+ } else {
24471+ (mi_row0, mi_col0 + i)
24472+ };
24473+ if i > 0
24474+ && (at_mi.0 >= mi_rows as usize
24475+ || at_mi.1 >= mi_cols as usize)
24476+ {
24477+ break;
24478+ }
24479+ let strip_has_chroma = i % 2 == 1;
24480+ let pair_mi = if !strip_has_chroma {
24481+ at_mi
24482+ } else if horz {
24483+ (at_mi.0 - 1, at_mi.1)
24484+ } else {
24485+ (at_mi.0, at_mi.1 - 1)
24486+ };
24487+ INTER_STRIP_CHROMA.with(|c| {
24488+ c.set(Some(InterStripChroma {
24489+ has_chroma: strip_has_chroma,
24490+ horz,
24491+ pair_mi,
24492+ prev: if strip_has_chroma {
24493+ INTER_LAST_MC.with(std::cell::Cell::get)
24494+ } else {
24495+ None
24496+ },
24497+ }))
24498+ });
24499+ inter_piece!(
24500+ at_mi,
24501+ SUB,
24502+ TxbSet::Luma16,
24503+ if reduced_tx_set {
24504+ TxbSet::Luma16Inter
24505+ } else {
24506+ TxbSet::Luma16InterSet1
24507+ },
24508+ TxbSet::Chroma8,
24509+ TX16,
24510+ TX8,
24511+ &scan16,
24512+ &scan8,
24513+ 1,
24514+ bw,
24515+ bh
24516+ );
24517+ if horz {
24518+ INTER16_HORZ4_HITS.with(|c| c.set(c.get() + 1));
24519+ } else {
24520+ INTER16_VERT4_HITS.with(|c| c.set(c.get() + 1));
24521+ }
24522+ }
2407524523 } else if part16 != PARTITION_SPLIT {
2407624524 return Err(unsupported(
24077- "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)",
24525+ "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4",
2407824526 ));
2407924527 } else {
2408024528 if has_cols16 && has_rows16 {
crates/ec-av1/src/refusal_inventory.rsmodified+16 -9
@@ -36,7 +36,9 @@ const REFUSALS: &[&str] = &[
3636 "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes only inter 4x4 sub-blocks there)",
3737 "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition (this decoder codes only inter sub-blocks there)",
3838 "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",
39- "a COMPOUND_WEDGE mask on a non-square inter block (rect wedge codebook unimplemented)",
39+ "a rectangular inter luma transform unit whose shape has no coefficient table set here",
40+ "a rectangular inter chroma transform unit whose shape has no coefficient table set here",
41+ "a rectangular transform unit whose shape has no coefficient scan table here",
4042 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
4143 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
4244 "a 32x32 partition type this decoder does not code (value={part32})",
@@ -70,14 +72,19 @@ const REFUSALS: &[&str] = &[
7072 "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units",
7173 "an inter frame with no key frame before it",
7274 "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)",
73- // lane-inter16ab r1 lifted the AB half (HORZ_A/HORZ_B/VERT_A/VERT_B at
74- // the 16x16 level of an inter frame: two 8x8 inter leaves plus one true
75- // 16x8/8x16 inter strip, gate
76- // `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact`).
77- // What is left is the 1:4 pair, whose 16x4/4x16 strips need the sub-8
78- // inter chroma-pair path (odd-strip `is_chroma_reference`, chroma built
79- // from BOTH strips' MVs) that no inter block writer has yet.
80- "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)",
75+ // lane-inter16ab r1 lifted the AB half and r2 the 1:4 half (four 16x4 /
76+ // 4x16 inter strips, their 8x4/4x8 chroma pair built from BOTH strips'
77+ // motion vectors -- gate
78+ // `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact`).
79+ // Two narrower refusals are what is left of that shape:
80+ "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4",
81+ // r2 residue: `vartx_leaves` is a list of SQUARE units, and
82+ // `sub_tx_size_map[TX_16X4]` is the rectangular TX_8X4 -- the split tree
83+ // and its per-unit residual reader both need rect leaves.
84+ // r2 residue: `decode_intra_rect_in_inter` codes chroma at the strip's own
85+ // halved footprint, which for a 16x4 strip is an 8x2 transform libaom
86+ // never wrote (its chroma is the PAIR's 8x4, coded by the odd strip).
87+ "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)",
8188 "an intra mode this decoder does not code (round 2)",
8289 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the
8390 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);
crates/ec-av1/src/stream.rsmodified+511 -0
@@ -98,6 +98,25 @@ pub fn rect_intrabc_reads() -> usize {
9898 crate::decode::rect_intrabc_reads()
9999 }
100100
101+/// lane-inter16ab r4: RECTANGULAR var-tx leaves with a 4-px axis, `[8x4, 4x8]`
102+/// -- what `sub_tx_size_map[TX_16X4] == TX_8X4` produces when a 16x16-level
103+/// 1:4 inter strip splits its transform.
104+pub fn vartx_rect_leaf4_hits() -> [usize; 2] {
105+ crate::decode::vartx_rect_leaf4_hits()
106+}
107+
108+/// lane-inter16ab r5: COMPOUND_WEDGE / wedge-INTERINTRA blocks that used a
109+/// RECTANGULAR wedge codebook row, per shape (`RECT_WEDGE_SHAPES` order:
110+/// 8x16, 16x8, 16x32, 32x16, 8x32, 32x8).
111+pub fn rect_wedge_hits() -> [usize; 6] {
112+ crate::decode::rect_wedge_hits()
113+}
114+
115+/// lane-inter16ab r5: the wedge-interintra half of [`rect_wedge_hits`].
116+pub fn rect_wii_hits() -> [usize; 6] {
117+ crate::decode::rect_wii_hits()
118+}
119+
101120 pub fn rect4_32_counters() -> (usize, usize, usize) {
102121 (
103122 crate::decode::rect4_32_horz_hits(),
@@ -9962,6 +9981,296 @@ mod tests {
99629981 }
99639982
99649983
9984+
9985+ #[test]
9986+ // lane-inter16ab r2: the 16x16-level 1:4 partitions on an INTER frame --
9987+ // PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 16x16, i.e. two 8x8 inter
9988+ // leaves plus one true 16x8/8x16 inter strip. Every decode-order frame is
9989+ // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped,
9990+ // out-of-scope mismatches fail the gate, and EACH of the four arms must
9991+ // have fired on a pixel-exact attempt (RD picking only HORZ_A is not
9992+ // proof of four). `--min-partition-size=4` is what lets aomenc's RD reach
9993+ // `PARTITION_HORZ_4`/`_VERT_4` at BLOCK_16X16 (16x4 / 4x16 inter strips);
9994+ // the last two counters are the chroma half of the claim -- the odd
9995+ // strip's `is_chroma_reference` pair and the pairs whose chroma was built
9996+ // from two different strips' motion vectors
9997+ // (`build_inter_predictors_sub8x8`).
9998+ fn a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact() {
9999+ const NAME: &str =
10000+ "a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact";
10001+ let _gate_lock = lock_gate_counters();
10002+ if !have_ffmpeg() {
10003+ eprintln!("SKIP {NAME}: no ffmpeg");
10004+ return;
10005+ }
10006+ if !have_aomenc() {
10007+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
10008+ return;
10009+ }
10010+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
10011+ // Per arm, over both bit depths: how many pixel-exact attempts fired
10012+ // it at least once.
10013+ let mut arms_total = [0u32; 5];
10014+ // lane-inter16ab r5: attempts refused on "a non-skip rectangular
10015+ // (HORZ/VERT/HORZ_B) strip needs rectangular residual coding".
10016+ let mut rect_residual_refusals = 0u32;
10017+ for bit_depth in [8u32, 10u32] {
10018+ let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =
10019+ (0u32, 0u32, 0u32, 0u32);
10020+ let mut arms_proved = [0u32; 5];
10021+ // lane-inter16ab r4: a 4-recipe widening (fine `sin(X/3)` stripes
10022+ // at cq 8..14, both depths) was measured and REMOVED again -- every
10023+ // extra 1:4 partition it produced is in the KEY frame, and this
10024+ // gate's arms count INTER-frame strips. Frame-aware histogram
10025+ // script + table in lanes/inter16ab-r4.report.md; the only recipe
10026+ // in the whole sweep with an inter-frame `PARTITION_VERT_4` is
10027+ // attempt 1's, which refuses on the rect wedge-interintra mask.
10028+ for attempt in 0..32u32 {
10029+ // Two sources (structure along X vs along Y -- an AB
10030+ // partition needs an L/T-shaped feature, so both orientations
10031+ // are swept), four quantisers, two motion steps, two tiling
10032+ // arms. r1 measured (sweep script in the report): a 16-attempt
10033+ // sweep at cq 34/22 alone never made aomenc's RD pick HORZ_A
10034+ // at 8 bits, so the quantiser axis is four wide here; cq 46 on
10035+ // the X-structured source is deliberately NOT in the list --
10036+ // that stream's decode-order frame 4 desyncs on a defect this
10037+ // lane does not own (aomdec's own EC_PART trace reads ZERO
10038+ // AB partitions at BLOCK_16X16 anywhere in it, so the AB
10039+ // counters it raises are read out of an already-diverged
10040+ // stream; see lanes/inter16ab-r1.report.md).
10041+ let tx_search = if attempt % 2 == 0 { "0" } else { "1" };
10042+ // The 10-bit arm swaps cq 40 for 28 on the same sources: at
10043+ // cq 40 the X-structured 10-bit stream mismatches ffmpeg with
10044+ // ZERO 16-level AB partitions in it (another shape's defect,
10045+ // measured r1 -- the gate's own `oos_mismatch` counter is
10046+ // what found it, and it is reported, not silenced).
10047+ let cq = if bit_depth == 10 {
10048+ [18, 22, 34, 28][(attempt / 2 % 4) as usize]
10049+ } else {
10050+ [18, 22, 34, 40][(attempt / 2 % 4) as usize]
10051+ };
10052+ let natural = attempt / 8 % 2 == 1;
10053+ let group = attempt / 16;
10054+ // r1: a `--tile-columns=1` arm of this same sweep PANICS in
10055+ // `mc::from_switchable_symbol` (a 4th symbol out of a
10056+ // 3-symbol alphabet = someone else's desync, the signature
10057+ // the ledger already pins for the below-8x8 inter leaf), not
10058+ // in anything this lane added -- so the tiled arm is left out
10059+ // rather than turned into a SKIP or a weakened assert.
10060+ // Reported as residue in lanes/inter16ab-r1.report.md.
10061+ let tile_cols = "0";
10062+ let sp = 3 + (group % 2) * 5;
10063+ let duration = frame_count as f64 / 25.0;
10064+ // Continuous-tone translating texture with a second, coarser
10065+ // component on the cross axis: aomenc's RD picks an AB
10066+ // partition where one 16x16 quadrant differs from its three
10067+ // siblings, which the two sinusoids at different periods
10068+ // produce all over the frame.
10069+ let lum = if natural {
10070+ format!("128+58*sin((Y+N*{sp})/6)+40*sin(X/11)+20*sin((X+Y)/5)")
10071+ } else {
10072+ format!("128+58*sin((X+N*{sp})/6)+40*sin(Y/11)+20*sin((X-Y)/5)")
10073+ };
10074+ let source = format!(
10075+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
10076+ geq=lum='{lum}',format=yuv420p"
10077+ );
10078+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
10079+ let y4m = Command::new("ffmpeg")
10080+ .args([
10081+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
10082+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
10083+ ])
10084+ .stdin(Stdio::null())
10085+ .stdout(Stdio::piped())
10086+ .stderr(Stdio::piped())
10087+ .output()
10088+ .expect("ffmpeg failed to run");
10089+ assert!(
10090+ y4m.status.success(),
10091+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
10092+ String::from_utf8_lossy(&y4m.stderr)
10093+ );
10094+ let cq_arg = format!("--cq-level={cq}");
10095+ let depth_arg = format!("--bit-depth={bit_depth}");
10096+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
10097+ let tx_arg = format!("--enable-tx-size-search={tx_search}");
10098+ let tile_arg = format!("--tile-columns={tile_cols}");
10099+ let args: Vec<&str> = vec![
10100+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
10101+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
10102+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
10103+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
10104+ "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg,
10105+ // Per-arm overrides go LAST: aomenc keeps the last
10106+ // occurrence of a repeated --enable-* flag.
10107+ &tx_arg,
10108+ "--enable-rect-partitions=1", "--enable-ab-partitions=1",
10109+ "--enable-1to4-partitions=1", "--min-partition-size=4",
10110+ "--max-partition-size=16",
10111+ "--obu", "-o", "-", "-",
10112+ ];
10113+ let mut child = Command::new(aomenc_path())
10114+ .args(&args)
10115+ .stdin(Stdio::piped())
10116+ .stdout(Stdio::piped())
10117+ .stderr(Stdio::piped())
10118+ .spawn()
10119+ .expect("aomenc failed to start");
10120+ child
10121+ .stdin
10122+ .take()
10123+ .expect("aomenc stdin")
10124+ .write_all(&y4m.stdout)
10125+ .expect("writing y4m to aomenc");
10126+ let out = child.wait_with_output().expect("aomenc failed to run");
10127+ assert!(
10128+ out.status.success(),
10129+ "aomenc refused the fixture: {}",
10130+ String::from_utf8_lossy(&out.stderr)
10131+ );
10132+ let stream = out.stdout;
10133+ let before = decode::inter16_rect4_counters();
10134+ let leaf4_before = crate::stream::vartx_rect_leaf4_hits();
10135+ let frames = match decode_stream(&stream) {
10136+ Err(e) => {
10137+ let msg = e.to_string();
10138+ assert!(
10139+ msg.contains("unsupported"),
10140+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
10141+ attempt {attempt}): {msg}"
10142+ );
10143+ // lane-inter16ab r5: attempt 1 is the ONLY recipe in
10144+ // r4's 100+ stream frame-aware sweep with an
10145+ // inter-frame PARTITION_VERT_4. In r4 it refused on
10146+ // the rect wedge codebook (lifted this round); it now
10147+ // walks further and stops on rect RESIDUAL coding, a
10148+ // refusal this lane does not own -- tracked so the
10149+ // VERT_4 / split-tx arms can name their blocker
10150+ // instead of silently reading 0.
10151+ if msg.contains("needs rectangular residual coding") {
10152+ rect_residual_refusals += 1;
10153+ }
10154+ named_refusals += 1;
10155+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
10156+ continue;
10157+ }
10158+ Ok(frames) => frames,
10159+ };
10160+ let after = decode::inter16_rect4_counters();
10161+ let leaf4_after = crate::stream::vartx_rect_leaf4_hits();
10162+ // [16x4 strips, 4x16 strips, chroma pairs closed, chroma
10163+ // pairs built from two strips' motion vectors].
10164+ let fired = [
10165+ after.0 - before.0,
10166+ after.1 - before.1,
10167+ after.2 - before.2,
10168+ after.3 - before.3,
10169+ // lane-inter16ab r4: the SPLIT-transform arm --
10170+ // `sub_tx_size_map[TX_16X4] == TX_8X4`, so a 1:4 strip
10171+ // that splits its transform codes 8x4/4x8 RECTANGULAR
10172+ // var-tx leaves (`--enable-tx-size-search=1`).
10173+ (leaf4_after[0] - leaf4_before[0]) + (leaf4_after[1] - leaf4_before[1]),
10174+ ];
10175+ let ffmpeg_frames = if bit_depth == 10 {
10176+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
10177+ } else {
10178+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
10179+ };
10180+ assert_eq!(frames.len(), frame_count);
10181+ let mismatched = frames
10182+ .iter()
10183+ .zip(&ffmpeg_frames)
10184+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
10185+ if fired[0] + fired[1] == 0 {
10186+ out_of_scope += 1;
10187+ if mismatched {
10188+ oos_mismatch += 1;
10189+ eprintln!(
10190+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
10191+ 16-level inter AB partition -- another shape's defect"
10192+ );
10193+ }
10194+ continue;
10195+ }
10196+ if mismatched {
10197+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
10198+ let bad: Vec<usize> =
10199+ (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect();
10200+ if !bad.is_empty() {
10201+ eprintln!(
10202+ "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \
10203+ pixels differ, first at ({}, {}), max |delta| {}",
10204+ bad.len(),
10205+ bad[0] % width,
10206+ bad[0] / width,
10207+ bad.iter()
10208+ .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs())
10209+ .max()
10210+ .unwrap_or(0)
10211+ );
10212+ }
10213+ }
10214+ }
10215+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
10216+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
10217+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
10218+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
10219+ }
10220+ for a in 0..5 {
10221+ if fired[a] > 0 {
10222+ arms_proved[a] += 1;
10223+ arms_total[a] += 1;
10224+ }
10225+ }
10226+ matched += 1;
10227+ }
10228+ eprintln!(
10229+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
10230+ attempts carrying a 16-level inter 1:4 partition, per-arm attempts \
10231+ HORZ_4/VERT_4/chroma-pair/sub8x8-chroma/split-tx-8x4={arms_proved:?}, {out_of_scope} attempts carried \
10232+ none ({oos_mismatch} of them mismatched)"
10233+ );
10234+ assert_eq!(
10235+ oos_mismatch, 0,
10236+ "{NAME}: {oos_mismatch} attempt(s) with no 16-level inter 1:4 partition decoded \
10237+ but mismatched ffmpeg -- a defect of another shape, not a pass"
10238+ );
10239+ }
10240+ // Arms 1/3/4 (HORZ_4, the odd-strip `is_chroma_reference` pair, the
10241+ // `build_inter_predictors_sub8x8` two-mv chroma build) are proven
10242+ // outright.
10243+ for (a, what) in [
10244+ (0usize, "HORZ_4 16x4 strips"),
10245+ (2, "odd-strip chroma pairs"),
10246+ (3, "sub8x8 two-mv chroma pairs"),
10247+ ] {
10248+ assert!(
10249+ arms_total[a] > 0,
10250+ "{NAME}: arm {a} ({what}) never fired on a pixel-exact attempt \
10251+ (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?})"
10252+ );
10253+ }
10254+ // lane-inter16ab r5, MEASURED reason for the other two arms: the only
10255+ // recipe in r4's 100+ stream frame-aware sweep carrying an
10256+ // inter-frame `PARTITION_VERT_4` is attempt 1, and in r4 it refused on
10257+ // the rect wedge-interintra codebook. That refusal is LIFTED this
10258+ // round -- the stream now walks past it and stops on "a non-skip
10259+ // rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual
10260+ // coding", a refusal this lane does not own. VERT_4 (and with it the
10261+ // split-transform 8x4 leaf it feeds) is blocked on THAT, and the gate
10262+ // asserts exactly that -- if rect residual coding lands and the arms
10263+ // still read 0, or the blocker changes, this fails.
10264+ assert!(
10265+ (arms_total[1] > 0 && arms_total[4] > 0) || rect_residual_refusals > 0,
10266+ "{NAME}: the VERT_4 / split-tx-8x4 arms read 0 \
10267+ (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?}) and NO \
10268+ attempt refused on rectangular residual coding -- their documented blocker is gone, \
10269+ so a zero arm is now unexplained"
10270+ );
10271+ }
10272+
10273+
996510274 #[test]
996610275 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {
996710276 if !have_ffmpeg() {
@@ -15988,6 +16297,208 @@ mod tests {
1598816297 }
1598916298
1599016299
16300+ /// lane-inter16ab r5: `COMPOUND_WEDGE` on a RECTANGULAR inter block --
16301+ /// the shapes `av1_wedge_params_lookup` gives the `hgtw`/`hltw`
16302+ /// codebooks (8x16/16x32/8x32 and 16x8/32x16/32x8), which this decoder
16303+ /// refused by name until this round ("the wedge codebook is
16304+ /// square-only"). `--enable-rect-partitions=1` with
16305+ /// `--min-partition-size=16 --max-partition-size=32` is what makes
16306+ /// aomenc's RD put a masked compound block on a 16x32/32x16 strip
16307+ /// (measured: ~/.cache/inter16ab-tmp/rw2.sh, 24/24 streams at cq 50/55
16308+ /// carry one and decode to the end at BOTH bit depths).
16309+ ///
16310+ /// Class `counter-from-refused-stream`: the per-shape counters are read
16311+ /// as a DELTA around one attempt and only counted for attempts that
16312+ /// decoded fully AND compared pixel-exact -- a refused attempt's hits
16313+ /// are discarded. Every decode-order frame (including hidden alt-ref
16314+ /// frames) is compared via [`decode_all_frames_vs_oracle`], and an
16315+ /// attempt that mismatches while carrying NO rect wedge fails the gate
16316+ /// through `oos_mismatch` rather than being blamed on this lane.
16317+ #[test]
16318+ fn a_real_aomenc_stream_with_a_rectangular_compound_wedge_decodes_pixel_exact() {
16319+ const NAME: &str =
16320+ "a_real_aomenc_stream_with_a_rectangular_compound_wedge_decodes_pixel_exact";
16321+ let _gate_lock = lock_gate_counters();
16322+ if !have_ffmpeg() {
16323+ eprintln!("SKIP {NAME}: no ffmpeg");
16324+ return;
16325+ }
16326+ if !have_aomenc() {
16327+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
16328+ return;
16329+ }
16330+ let (width, height, frame_count) = (96usize, 96usize, 24usize);
16331+ // Per rect shape (8x16, 16x8, 16x32, 32x16, 8x32, 32x8), summed over
16332+ // the attempts that decoded AND matched.
16333+ let mut shapes_proved = [0usize; 6];
16334+ let (mut named_refusals, mut matched, mut oos_mismatch) = (0u32, 0u32, 0u32);
16335+ let mut attempts = 0u32;
16336+ for bit_depth in [8u32, 10u32] {
16337+ for &cq in &[50u32, 55] {
16338+ for a in 0..4u32 {
16339+ attempts += 1;
16340+ let duration = frame_count as f64 / 25.0;
16341+ // Same hard-diagonal-edge content the square wedge gate
16342+ // uses (wedge's masters are OBLIQUE), panned per attempt.
16343+ let source = format!(
16344+ "mandelbrot=size={width}x{height}:rate=25:start_x={sx}:start_y={sy}",
16345+ sx = -0.6 + 0.01 * (a as f64),
16346+ sy = -0.4 + 0.01 * (a as f64)
16347+ );
16348+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
16349+ let y4m = Command::new("ffmpeg")
16350+ .args([
16351+ "-v", "error", "-f", "lavfi", "-i", &source, "-t",
16352+ &duration.to_string(), "-pix_fmt", pix_fmt, "-strict", "-1",
16353+ "-f", "yuv4mpegpipe", "-strict", "-1", "-",
16354+ ])
16355+ .stdin(Stdio::null())
16356+ .stdout(Stdio::piped())
16357+ .stderr(Stdio::piped())
16358+ .output()
16359+ .expect("ffmpeg failed to run");
16360+ assert!(
16361+ y4m.status.success(),
16362+ "{NAME}: ffmpeg fixture: {}",
16363+ String::from_utf8_lossy(&y4m.stderr)
16364+ );
16365+ let cq_arg = format!("--cq-level={cq}");
16366+ let depth_arg = format!("--bit-depth={bit_depth}");
16367+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
16368+ let args: Vec<&str> = vec![
16369+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
16370+ &depth_arg, &input_depth_arg,
16371+ "--kf-max-dist=1000", "--threads=1", "--row-mt=0", "--auto-alt-ref=1",
16372+ "--lag-in-frames=16", "--enable-fwd-kf=0", "--enable-order-hint=1",
16373+ "--enable-warped-motion=1", "--enable-global-motion=0",
16374+ "--enable-obmc=1", "--enable-diff-wtd-comp=1",
16375+ "--enable-interintra-comp=1", "--enable-onesided-comp=0",
16376+ "--enable-interintra-wedge=1", "--enable-smooth-interintra=1",
16377+ "--enable-ab-partitions=0", "--enable-1to4-partitions=0",
16378+ "--enable-filter-intra=0", "--enable-smooth-intra=0",
16379+ "--enable-paeth-intra=0", "--enable-directional-intra=0",
16380+ "--enable-angle-delta=0", "--enable-tx-size-search=0",
16381+ "--enable-cdef=0", "--enable-restoration=0", "--enable-palette=0",
16382+ "--enable-intrabc=0", "--enable-cfl-intra=0",
16383+ "--enable-ref-frame-mvs=0",
16384+ // Per-arm overrides LAST (aomenc keeps the last
16385+ // occurrence of a repeated --enable-* flag): masked
16386+ // compound ON, distance-weighted OFF so the
16387+ // comp_group_idx==1 slot goes to wedge/diffwtd, and
16388+ // rectangular partitions ON at 16/32 -- the shapes
16389+ // the hgtw/hltw codebooks exist for.
16390+ "--enable-masked-comp=1", "--enable-dist-wtd-comp=0",
16391+ "--enable-rect-partitions=1",
16392+ "--min-partition-size=16", "--max-partition-size=32",
16393+ "--obu", "-o", "-", "-",
16394+ ];
16395+ let mut child = Command::new(aomenc_path())
16396+ .args(&args)
16397+ .stdin(Stdio::piped())
16398+ .stdout(Stdio::piped())
16399+ .stderr(Stdio::piped())
16400+ .spawn()
16401+ .expect("aomenc failed to start");
16402+ child
16403+ .stdin
16404+ .take()
16405+ .expect("aomenc stdin")
16406+ .write_all(&y4m.stdout)
16407+ .expect("writing y4m to aomenc");
16408+ let out = child.wait_with_output().expect("aomenc failed to run");
16409+ assert!(
16410+ out.status.success(),
16411+ "aomenc refused the fixture: {}",
16412+ String::from_utf8_lossy(&out.stderr)
16413+ );
16414+ let stream = out.stdout;
16415+ let before = crate::stream::rect_wedge_hits();
16416+ let frames = match decode_stream(&stream) {
16417+ Err(e) => {
16418+ let msg = e.to_string();
16419+ assert!(
16420+ msg.contains("unsupported"),
16421+ "{NAME} failed outright, not a named refusal \
16422+ ({bit_depth}-bit cq{cq} attempt {a}): {msg}"
16423+ );
16424+ assert!(
16425+ !msg.contains("wedge codebook is square-only"),
16426+ "{NAME}: the rect wedge codebook is ported -- this refusal is \
16427+ forbidden ({bit_depth}-bit cq{cq} attempt {a}): {msg}"
16428+ );
16429+ named_refusals += 1;
16430+ eprintln!("{bit_depth}-bit cq{cq} attempt {a} refusal: {msg}");
16431+ continue;
16432+ }
16433+ Ok(frames) => frames,
16434+ };
16435+ let after = crate::stream::rect_wedge_hits();
16436+ let fired: Vec<usize> =
16437+ (0..6).map(|k| after[k] - before[k]).collect();
16438+ let ffmpeg_frames = if bit_depth == 10 {
16439+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
16440+ } else {
16441+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
16442+ };
16443+ assert_eq!(frames.len(), ffmpeg_frames.len());
16444+ let mismatched = frames
16445+ .iter()
16446+ .zip(&ffmpeg_frames)
16447+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
16448+ if fired.iter().sum::<usize>() == 0 {
16449+ if mismatched {
16450+ oos_mismatch += 1;
16451+ eprintln!(
16452+ "{NAME}: {bit_depth}-bit cq{cq} attempt {a} MISMATCHES with zero \
16453+ rectangular wedge block -- another shape's defect"
16454+ );
16455+ }
16456+ continue;
16457+ }
16458+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
16459+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})");
16460+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})");
16461+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})");
16462+ }
16463+ // class gate-blind-to-hidden-frames: the shown-frame
16464+ // compare above cannot see the alt-ref frames this
16465+ // recipe's --lag-in-frames=16 produces.
16466+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
16467+ eprintln!(
16468+ "{NAME}: {bit_depth}-bit cq{cq} attempt {a}: shapes {fired:?}, \
16469+ {hidden_total} decode-order frames ({hidden_n} hidden) pixel-exact"
16470+ );
16471+ for k in 0..6 {
16472+ shapes_proved[k] += fired[k];
16473+ }
16474+ matched += 1;
16475+ }
16476+ }
16477+ }
16478+ eprintln!(
16479+ "{NAME}: {named_refusals} named refusals, {matched} pixel-exact attempts out of \
16480+ {attempts}, rect wedge blocks per shape \
16481+ (8x16,16x8,16x32,32x16,8x32,32x8)={shapes_proved:?}, {oos_mismatch} zero-wedge \
16482+ mismatches"
16483+ );
16484+ assert_eq!(
16485+ oos_mismatch, 0,
16486+ "{NAME}: {oos_mismatch} attempt(s) carrying no rectangular wedge mismatched ffmpeg \
16487+ -- a defect of another shape, not a pass"
16488+ );
16489+ // The claim: a rectangular wedge codebook row (hgtw AND hltw) was
16490+ // used on a stream that then decoded pixel-exact. 16x32 is hgtw
16491+ // (h > w), 32x16 is hltw (h < w) -- one of each, so a transposed
16492+ // codebook/signflip pair cannot pass this.
16493+ assert!(
16494+ shapes_proved[2] > 0 && shapes_proved[3] > 0,
16495+ "{NAME}: no pixel-exact attempt used both an hgtw (16x32) and an hltw (32x16) \
16496+ rectangular wedge codebook row (per shape {shapes_proved:?}, {matched} matches, \
16497+ {named_refusals} refusals out of {attempts}) -- the recipe proved nothing"
16498+ );
16499+ }
16500+
16501+
1599116502 /// lane-lr r3: proves stage 1/2's exit criterion -- a real
1599216503 /// `--enable-restoration=1` aomenc stream must survive the whole
1599316504 /// partition walk (every symbol read entropy-exact) and land on the
crates/ec-av1/src/wedge.rsmodified+168 -66
@@ -1,20 +1,30 @@
11 //! lane-wedge r3: `COMPOUND_WEDGE` mask codebook -- libaom
22 //! `av1/common/reconinter.c`'s `init_wedge_master_masks`/`init_wedge_masks`/
3-//! `get_wedge_mask_inplace`, ported for the ONLY block-size family this
4-//! decoder's masked-compound leaves reach: square 8x8/16x16/32x32
5-//! (`decode.rs`'s `wedge_bsize` match on `side`). Every reachable square
6-//! bsize uses the same libaom codebook row (`wedge_codebook_16_heqw`) and
7-//! the same `wedge_signflip_lookup` row, so only ONE codebook/signflip
8-//! table is ported (rect bsizes are not reachable yet -- charter scope).
3+//! `get_wedge_mask_inplace`, ported for EVERY bsize libaom gives a wedge
4+//! codebook (`av1_wedge_params_lookup`, reconinter.c:236-267): the three
5+//! square sizes 8x8/16x16/32x32 (`wedge_codebook_16_heqw`) and the six
6+//! rectangular ones 8x16/16x32/8x32 (`wedge_codebook_16_hgtw`, h > w) and
7+//! 16x8/32x16/32x8 (`wedge_codebook_16_hltw`, h < w), each with its own
8+//! `wedge_signflip_lookup` row (reconinter.c:160-183).
99 //!
10-//! VERIFICATION (class shared-oracle-blindness): `lanes/wedge_dump.c` is a
11-//! standalone C reimplementation of the same libaom source, compiled and
12-//! run independently with `gcc` (not linked against this Rust code, not
13-//! linked against libaom) -- it catches translation bugs (indexing, shift
14-//! direction/sign, offset order) that a hand-transcribed-only table would
15-//! not. `checksum()` below reproduces its exact per-block checksum
16-//! formula; `wedge_codebook_matches_c_dump` asserts every (bsize, sign,
17-//! index) checksum against `lanes/wedge_dump.expected.txt`.
10+//! lane-inter16ab r5: masks are stored PADDED to a `side x side` plane
11+//! (`side = max(bw, bh)`, row stride `side`), because `decode.rs` predicts
12+//! a rectangular strip into a square `side x side` buffer and writes only
13+//! its true `write_w x write_h` footprint -- so a padded mask drops
14+//! straight into the existing square blend call with no stride plumbing.
15+//! Rows/columns outside `bw x bh` are zero and never reach the frame.
16+//!
17+//! VERIFICATION (class shared-oracle-blindness): `lanes/wedge_libaom.expected.txt`
18+//! is generated by a C harness LINKED AGAINST libaom itself
19+//! (`~/.cache/inter16ab-tmp/wedge_h.c`, `av1_init_wedge_masks()` then
20+//! `av1_get_contiguous_soft_mask(idx, sign, bsize)`) -- a genuinely foreign
21+//! implementation, not a transcription. Its 96 square-size lines are
22+//! byte-identical to the older independent transcription
23+//! `lanes/wedge_dump.expected.txt` (`lanes/wedge_dump.c`), so the two
24+//! oracles agree where they overlap. `checksum()` below reproduces the
25+//! harness's per-block checksum formula (true `bw x bh` window, padded
26+//! stride skipped); `wedge_codebook_matches_libaom_dump` asserts all
27+//! 9 x 2 x 16 = 288 entries.
1828
1929 const MASK_MASTER_SIZE: usize = 64;
2030 const WEDGE_WEIGHT_BITS: u32 = 6;
@@ -47,7 +57,8 @@ const WEDGE_MASTER_VERTICAL: [u8; MASK_MASTER_SIZE] = [
4757 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
4858 ];
4959
50-/// `wedge_codebook_16_heqw` (reconinter.c) -- (direction, x_offset, y_offset).
60+/// `wedge_codebook_16_heqw` (reconinter.c:225) -- (direction, x_offset,
61+/// y_offset); the codebook for the square sizes (h == w).
5162 const HEQW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [
5263 (Dir::Oblique27, 4, 4),
5364 (Dir::Oblique63, 4, 4),
@@ -66,8 +77,84 @@ const HEQW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [
6677 (Dir::Oblique117, 2, 4),
6778 (Dir::Oblique117, 6, 4),
6879 ];
69-/// `wedge_signflip_lookup` row shared by `BLOCK_8X8`/`BLOCK_16X16`/`BLOCK_32X32`.
70-const SIGNFLIP: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1];
80+/// `wedge_codebook_16_hgtw` (reconinter.c:203) -- h > w (8x16/16x32/8x32).
81+/// Differs from `heqw` only in entries 4..7: three HORIZONTAL splits plus a
82+/// single centred VERTICAL one.
83+const HGTW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [
84+ (Dir::Oblique27, 4, 4),
85+ (Dir::Oblique63, 4, 4),
86+ (Dir::Oblique117, 4, 4),
87+ (Dir::Oblique153, 4, 4),
88+ (Dir::Horizontal, 4, 2),
89+ (Dir::Horizontal, 4, 4),
90+ (Dir::Horizontal, 4, 6),
91+ (Dir::Vertical, 4, 4),
92+ (Dir::Oblique27, 4, 2),
93+ (Dir::Oblique27, 4, 6),
94+ (Dir::Oblique153, 4, 2),
95+ (Dir::Oblique153, 4, 6),
96+ (Dir::Oblique63, 2, 4),
97+ (Dir::Oblique63, 6, 4),
98+ (Dir::Oblique117, 2, 4),
99+ (Dir::Oblique117, 6, 4),
100+];
101+/// `wedge_codebook_16_hltw` (reconinter.c:214) -- h < w (16x8/32x16/32x8):
102+/// the transpose of `hgtw`'s 4..7 (three VERTICAL splits, one centred
103+/// HORIZONTAL).
104+const HLTW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [
105+ (Dir::Oblique27, 4, 4),
106+ (Dir::Oblique63, 4, 4),
107+ (Dir::Oblique117, 4, 4),
108+ (Dir::Oblique153, 4, 4),
109+ (Dir::Vertical, 2, 4),
110+ (Dir::Vertical, 4, 4),
111+ (Dir::Vertical, 6, 4),
112+ (Dir::Horizontal, 4, 4),
113+ (Dir::Oblique27, 4, 2),
114+ (Dir::Oblique27, 4, 6),
115+ (Dir::Oblique153, 4, 2),
116+ (Dir::Oblique153, 4, 6),
117+ (Dir::Oblique63, 2, 4),
118+ (Dir::Oblique63, 6, 4),
119+ (Dir::Oblique117, 2, 4),
120+ (Dir::Oblique117, 6, 4),
121+];
122+
123+/// `wedge_signflip_lookup` (reconinter.c:160-183), one row per bsize.
124+/// `BLOCK_8X8`/`16X16`/`32X32` share this row.
125+const SF_SQUARE: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1];
126+/// `BLOCK_8X16`/`16X8`/`16X32`/`32X16` share this row (index 4 flips to 0).
127+const SF_RECT: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1];
128+/// `BLOCK_8X32` (reconinter.c:173) -- index 8 also 0.
129+const SF_8X32: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1];
130+/// `BLOCK_32X8` (reconinter.c:174) -- index 12 also 0.
131+const SF_32X8: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1];
132+
133+/// `av1_wedge_params_lookup[bsize]`'s `(codebook, signflip)` pair for a
134+/// block footprint, `None` where `wedge_types == 0`.
135+fn wedge_params(bw: usize, bh: usize) -> Option<(&'static [(Dir, i32, i32); MAX_WEDGE_TYPES], &'static [u8; MAX_WEDGE_TYPES])> {
136+ Some(match (bw, bh) {
137+ (8, 8) | (16, 16) | (32, 32) => (&HEQW, &SF_SQUARE),
138+ (8, 16) | (16, 32) => (&HGTW, &SF_RECT),
139+ (16, 8) | (32, 16) => (&HLTW, &SF_RECT),
140+ (8, 32) => (&HGTW, &SF_8X32),
141+ (32, 8) => (&HLTW, &SF_32X8),
142+ _ => return None,
143+ })
144+}
145+
146+/// Every `(bw, bh)` with a wedge codebook, in `av1_wedge_params_lookup` order.
147+pub const WEDGE_BSIZES: [(usize, usize); 9] = [
148+ (8, 8),
149+ (8, 16),
150+ (16, 8),
151+ (16, 16),
152+ (16, 32),
153+ (32, 16),
154+ (32, 32),
155+ (8, 32),
156+ (32, 8),
157+];
71158
72159 /// `shift_copy` (reconinter.c) -- shift a `MASK_MASTER_SIZE`-wide row right
73160 /// (`shift >= 0`) or left, replicating the edge sample into the gap.
@@ -146,79 +233,86 @@ fn init_wedge_master_masks() -> MasterMasks {
146233 MasterMasks { obl }
147234 }
148235
149-/// `get_wedge_mask_inplace` (reconinter.c): the `bw x bh` window of the
150-/// master plane for this `(wedge_index, neg, bw, bh)`, still in
236+/// `get_wedge_mask_inplace` (reconinter.c:270-289): the `bw x bh` window of
237+/// the master plane for this `(wedge_index, neg, bw, bh)`, still in
151238 /// `MASK_MASTER_SIZE`-stride coordinates (caller extracts the window).
152-fn wedge_window(master: &MasterMasks, wedge_index: usize, neg: usize, bw: usize, bh: usize) -> (usize, usize, usize) {
153- let (dir, xo, yo) = HEQW[wedge_index];
154- let wsignflip = SIGNFLIP[wedge_index] as usize;
239+fn wedge_window(wedge_index: usize, neg: usize, bw: usize, bh: usize) -> (usize, usize, usize) {
240+ let (codebook, signflip) = wedge_params(bw, bh).expect("wedge_window on a wedge-capable bsize");
241+ let (dir, xo, yo) = codebook[wedge_index];
242+ let wsignflip = signflip[wedge_index] as usize;
155243 let woff = (xo as usize * bw) >> 3;
156244 let hoff = (yo as usize * bh) >> 3;
157- let _ = &master.obl[neg ^ wsignflip][dir as usize];
158245 let row0 = MASK_MASTER_SIZE / 2 - hoff;
159246 let col0 = MASK_MASTER_SIZE / 2 - woff;
160247 (neg ^ wsignflip, dir as usize, row0 * MASK_MASTER_SIZE + col0)
161248 }
162249
163-/// Per-`(sign, wedge_index)` `bw x bh` mask, contiguous stride `bw`.
250+/// Per-`(sign, wedge_index)` mask for one bsize, stored PADDED into a
251+/// `stride x stride` plane (`stride = max(bw, bh)`) so a rectangular mask
252+/// indexes exactly like the square prediction buffer `decode.rs` blends
253+/// into. Only rows `0..bh` / columns `0..bw` are meaningful.
164254 pub struct WedgeCodebook {
165- /// `[sign][wedge_index] -> bw*bh` bytes, row stride `bw`.
255+ /// `[sign][wedge_index] -> stride*stride` bytes, row stride `stride`.
166256 masks: [[Vec<u8>; MAX_WEDGE_TYPES]; 2],
167257 pub bw: usize,
168258 pub bh: usize,
259+ /// `max(bw, bh)` -- the row stride of every mask returned by [`Self::mask`].
260+ pub stride: usize,
169261 }
170262
171263 impl WedgeCodebook {
172264 fn build(master: &MasterMasks, bw: usize, bh: usize) -> Self {
265+ let stride = bw.max(bh);
173266 let mut masks: [[Vec<u8>; MAX_WEDGE_TYPES]; 2] = Default::default();
174267 for sign in 0..2 {
175268 for idx in 0..MAX_WEDGE_TYPES {
176- let (neg_idx, dir, off) = wedge_window(master, idx, sign, bw, bh);
269+ let (neg_idx, dir, off) = wedge_window(idx, sign, bw, bh);
177270 let plane = &master.obl[neg_idx][dir];
178- let mut m = vec![0u8; bw * bh];
271+ let mut m = vec![0u8; stride * stride];
179272 for i in 0..bh {
180273 let src = off + i * MASK_MASTER_SIZE;
181- m[i * bw..i * bw + bw].copy_from_slice(&plane[src..src + bw]);
274+ m[i * stride..i * stride + bw].copy_from_slice(&plane[src..src + bw]);
182275 }
183276 masks[sign][idx] = m;
184277 }
185278 }
186- WedgeCodebook { masks, bw, bh }
279+ WedgeCodebook { masks, bw, bh, stride }
187280 }
188281
189282 /// `wedge_sign` in `{0,1}` (spec `wedge_sign`), `wedge_index` in
190- /// `0..MAX_WEDGE_TYPES`. Mask is luma-resolution, row stride `bw`.
283+ /// `0..MAX_WEDGE_TYPES`. Mask is luma-resolution, row stride
284+ /// [`Self::stride`] (`max(bw, bh)`), length `stride * stride`.
191285 pub fn mask(&self, wedge_sign: usize, wedge_index: usize) -> &[u8] {
192286 &self.masks[wedge_sign][wedge_index]
193287 }
194288 }
195289
196-/// One codebook per reachable square leaf side (8/16/32), built once.
290+/// One codebook per wedge-capable bsize, built once.
197291 pub struct WedgeMasks {
198- pub side8: WedgeCodebook,
199- pub side16: WedgeCodebook,
200- pub side32: WedgeCodebook,
292+ /// Parallel to [`WEDGE_BSIZES`].
293+ books: Vec<WedgeCodebook>,
201294 }
202295
203296 impl WedgeMasks {
204297 fn new() -> Self {
205298 let master = init_wedge_master_masks();
206299 WedgeMasks {
207- side8: WedgeCodebook::build(&master, 8, 8),
208- side16: WedgeCodebook::build(&master, 16, 16),
209- side32: WedgeCodebook::build(&master, 32, 32),
300+ books: WEDGE_BSIZES
301+ .iter()
302+ .map(|&(bw, bh)| WedgeCodebook::build(&master, bw, bh))
303+ .collect(),
210304 }
211305 }
212306
213- /// `side` is the square leaf side (8/16/32); panics otherwise (same
214- /// invariant `decode.rs`'s `wedge_bsize` match already enforces).
215- pub fn codebook(&self, side: usize) -> &WedgeCodebook {
216- match side {
217- 8 => &self.side8,
218- 16 => &self.side16,
219- 32 => &self.side32,
220- _ => unreachable!("wedge codebook side is 8/16/32"),
221- }
307+ /// `(bw, bh)` is the block's TRUE footprint; panics on a size libaom
308+ /// gives no codebook (the same invariant `decode.rs`'s `wedge_used_bsize`
309+ /// already enforces before any wedge symbol is read).
310+ pub fn codebook(&self, bw: usize, bh: usize) -> &WedgeCodebook {
311+ let i = WEDGE_BSIZES
312+ .iter()
313+ .position(|&s| s == (bw, bh))
314+ .unwrap_or_else(|| unreachable!("no wedge codebook for {bw}x{bh}"));
315+ &self.books[i]
222316 }
223317 }
224318
@@ -228,13 +322,15 @@ pub fn wedge_masks() -> &'static WedgeMasks {
228322 WEDGE_MASKS.get_or_init(WedgeMasks::new)
229323 }
230324
231-/// Reproduces `lanes/wedge_dump.c`'s `dump_bsize` checksum formula exactly.
325+/// Reproduces the libaom-linked harness's per-block checksum formula
326+/// (`~/.cache/inter16ab-tmp/wedge_h.c`): the TRUE `bw x bh` window read out
327+/// of the padded plane, weighted by its contiguous position + 1.
232328 #[cfg(test)]
233-fn checksum(mask: &[u8], bw: usize, bh: usize) -> u64 {
329+fn checksum(mask: &[u8], bw: usize, bh: usize, stride: usize) -> u64 {
234330 let mut sum: u64 = 0;
235331 for i in 0..bh {
236332 for j in 0..bw {
237- sum += mask[i * bw + j] as u64 * (i * bw + j + 1) as u64;
333+ sum += mask[i * stride + j] as u64 * (i * bw + j + 1) as u64;
238334 }
239335 }
240336 sum
@@ -244,44 +340,50 @@ fn checksum(mask: &[u8], bw: usize, bh: usize) -> u64 {
244340 mod tests {
245341 use super::*;
246342
247- /// lane-wedge r3: checksum-verify every (bsize, sign, wedge_index) mask
248- /// this decoder can produce against `lanes/wedge_dump.c`'s independent
249- /// C computation (`lanes/wedge_dump.expected.txt`, generated by
250- /// `gcc -O2 lanes/wedge_dump.c -o lanes/wedge_dump && ./lanes/wedge_dump`).
343+ /// lane-inter16ab r5 (class enumerate-table-domain): checksum-verify
344+ /// EVERY (bsize, sign, wedge_index) mask this decoder can produce --
345+ /// all 9 wedge-capable bsizes, both signs, all 16 indices = 288 entries
346+ /// -- against `av1_get_contiguous_soft_mask()` read straight out of
347+ /// libaom by the linked C harness (`lanes/wedge_libaom.expected.txt`,
348+ /// regenerate with `gcc -O2 -o wedge_h wedge_h.c -I <aom-src> -I <aom-build>
349+ /// <aom-build>/libaom.a -lm -lpthread && ./wedge_h`).
251350 #[test]
252- fn wedge_codebook_matches_c_dump() {
253- let expected_txt = std::fs::read_to_string(
254- concat!(env!("CARGO_MANIFEST_DIR"), "/../../lanes/wedge_dump.expected.txt"),
255- )
256- .expect("run gcc -O2 lanes/wedge_dump.c -o lanes/wedge_dump && ./lanes/wedge_dump > lanes/wedge_dump.expected.txt first");
351+ fn wedge_codebook_matches_libaom_dump() {
352+ let expected_txt = std::fs::read_to_string(concat!(
353+ env!("CARGO_MANIFEST_DIR"),
354+ "/../../lanes/wedge_libaom.expected.txt"
355+ ))
356+ .expect("lanes/wedge_libaom.expected.txt (libaom-linked harness dump)");
257357 let mut expected = std::collections::HashMap::new();
258358 for line in expected_txt.lines() {
259- // "8x8 sign=0 idx=0 checksum=39141"
359+ // "16x8 sign=0 idx=0 checksum=39141"
260360 let parts: Vec<&str> = line.split_whitespace().collect();
261- let name = parts[0];
361+ let name = parts[0].to_string();
262362 let sign: usize = parts[1]["sign=".len()..].parse().unwrap();
263363 let idx: usize = parts[2]["idx=".len()..].parse().unwrap();
264364 let cs: u64 = parts[3]["checksum=".len()..].parse().unwrap();
265365 expected.insert((name, sign, idx), cs);
266366 }
367+ assert_eq!(expected.len(), 9 * 2 * MAX_WEDGE_TYPES, "the dump covers every entry");
267368 let masks = wedge_masks();
268369 let mut checked = 0;
269- for (name, side) in [("8x8", 8usize), ("16x16", 16), ("32x32", 32)] {
270- let cb = masks.codebook(side);
370+ for (bw, bh) in WEDGE_BSIZES {
371+ let name = format!("{bw}x{bh}");
372+ let cb = masks.codebook(bw, bh);
271373 for sign in 0..2 {
272374 for idx in 0..MAX_WEDGE_TYPES {
273- let got = checksum(cb.mask(sign, idx), side, side);
274- let want = *expected.get(&(name, sign, idx)).unwrap_or_else(|| {
375+ let got = checksum(cb.mask(sign, idx), bw, bh, cb.stride);
376+ let want = *expected.get(&(name.clone(), sign, idx)).unwrap_or_else(|| {
275377 panic!("missing expected entry for {name} sign={sign} idx={idx}")
276378 });
277379 assert_eq!(
278380 got, want,
279- "{name} sign={sign} idx={idx}: rust checksum {got} != C dump {want}"
381+ "{name} sign={sign} idx={idx}: rust checksum {got} != libaom {want}"
280382 );
281383 checked += 1;
282384 }
283385 }
284386 }
285- assert_eq!(checked, 3 * 2 * MAX_WEDGE_TYPES, "checked every (bsize,sign,index) triple");
387+ assert_eq!(checked, 9 * 2 * MAX_WEDGE_TYPES, "checked every (bsize,sign,index) triple");
286388 }
287389 }
lanes/inter16ab-r2.report.mdadded+85 -0
@@ -0,0 +1,85 @@
1+# lane-inter16ab r2 — 16x16-level 1:4 partitions in inter frames
2+
3+## Verdict: RED. The whole path is implemented and decodes, but one gate attempt
4+## (8-bit, attempt 5, cq 34, X-structured source) desyncs in its LAST frame.
5+The refusal is lifted and the gate is committed FAILING — not ignored, not weakened.
6+This branch must not merge into main until the residue below is closed.
7+
8+## What changed (all in `crates/ec-av1/`)
9+- `src/decode.rs:2207` — `InterStripChroma` + `INTER_STRIP_CHROMA` / `INTER_LAST_MC`
10+ thread-locals (the one-shot `REDUCED_TX_SET_INTER` idiom, chosen over threading two
11+ more parameters through `decode_inter_block`'s 23 call sites) and the four counters
12+ `inter16_rect4_counters() -> (16x4 strips, 4x16 strips, chroma pairs, sub8x8 chroma pairs)`.
13+- `src/decode.rs` `decode_inter_block` entry — `has_chroma` (libaom `is_chroma_reference`,
14+ av1_common_int.h:1454: `bh == 1 mi` ⇒ odd `mi_row`), and the chroma origin/extent
15+ overridden to the PAIR's (8x4 / 4x8 at the even strip's mi origin —
16+ `setup_pred_plane`'s `mi_row -= 1`).
17+- same fn — `is_comp_ref_allowed` / `is_motion_variation_allowed_bsize`
18+ (blockd.h:65 / :1455, `min(bw,bh) >= 8`) now gate `skip_mode`, `comp_mode` and
19+ `motion_mode`: a 16x4 strip reads none of those symbols. `is_interintra_allowed_bsize`
20+ already excluded it (aspect 4:1).
21+- same fn — `build_inter_predictors_sub8x8` (reconinter_template.inc:87-160): the pair's
22+ chroma is built in `b4_w x b4_h` = 8x2 (2x8) pieces; the second piece is this strip's own
23+ mv (already written by the whole-block predictor, MC being position-invariant for a fixed
24+ mv), so only the FIRST piece is rebuilt, from the previous strip's mv/ref/filters, and only
25+ when `is_sub8x8_inter` holds (previous strip single-ref inter — `INTER_LAST_MC`).
26+- same fn — chroma residual read/reconstruct/record all gated on `has_chroma`; the pair's
27+ chroma coefficient context is read at `around_mi_rect(pair_mi, 16, 8)` and written back over
28+ the pair's mi span (mirrors the intra `decode_rect4_16`).
29+- `src/decode.rs` `rect_scan` / `rect_inter_residual_supported` / `rect_inter_luma_set` —
30+ (16,4)|(4,16): `SCAN_16X4`/`SCAN_4X16`, and the new `TxbSet::LumaRect16x4Inter{,1}`
31+ (`Luma8` coefficient tables — `get_txsize_entropy_ctx(TX_16X4)` = TX_8X8, 64 positions,
32+ `eob_pt_64` — with the INTER tx_type table at `txsize_sqr_map[TX_16X4]` = TX_4X4;
33+ `av1_get_ext_tx_set_type` (blockd.h:1097-1106) gives EXT_TX_SET_ALL16 unreduced since
34+ `tx_size_sqr != TX_16X16`, EXT_TX_SET_DCT_IDTX reduced).
35+- `src/cdf_state.rs:233,1854` — the two new `TxbSet` variants and their tables.
36+- `src/decode.rs` 16x16 partition chain — the `PARTITION_HORZ_4`/`_VERT_4` arm: four strips in
37+ libaom `decode_partition` order with its own `i > 0` frame-edge break, each carrying its
38+ `InterStripChroma`.
39+- `src/refusal_inventory.rs:70` — the combined 1:4 refusal is GONE; three narrower ones stand:
40+ the partition-value catch-all, a split transform on a 16x4 strip, an intra 16x4 strip.
41+- `src/stream.rs` — gate
42+ `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact`
43+ (r1's gate shape with `--enable-1to4-partitions=1 --min-partition-size=4`).
44+- `examples/decode_probe.rs:43` — prints `inter16_1to4: horz4= vert4= chroma_pairs= sub8_pieces=`.
45+
46+## Gate result — RED
47+`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`
48+
49+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.
50+
51+Reading of the failure: frames 0-4 exact, then ~35% of the last frame wrong from a mid-frame
52+raster position = an ENTROPY DESYNC at one 16x16-level 1:4 block, not a prediction/filter
53+drift. `av1_get_ext_tx_set_type` was checked against the oracle source and the tables above are
54+right, so the leading suspect is the mv-stack at `BLOCK_16X4` (`bw4=4, bh4=1`): a wrong stack
55+size changes the `drl_idx` symbol count and desyncs at that block. NOT confirmed — no range
56+ladder was run this round (tool budget).
57+
58+## Film probe — moved one refusal deeper
59+`ffmpeg -ss 900 -t 2 -i <ReelB> -c:v copy -an -f obu` → `decode_probe`:
60+- before r2: `REFUSED: an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 …)`
61+- after r2: `REFUSED: a split transform on a 16x16-level 1:4 inter strip
62+ (sub_tx_size_map[TX_16X4] is the rectangular TX_8X4)`
63+1 frame completed (`EC_AV1_FINAL_DUMP` file count) in both. So the partition, the strips and
64+the chroma pair are past; the film now needs rect var-tx leaves.
65+
66+## Residue
67+- fix-now (next round, this lane): the attempt-5 desync above. Method: dump that attempt's
68+ stream (add an env-gated write to the gate), run the instrumented aomdec `EC_TRACE=1` and
69+ compare the msac RANGE element by element from the first 1:4 block of decode-order frame 5.
70+ First check `find_mv_stack`'s row/col scan and weights for `bw4=4, bh4=1` (class
71+ `scan-weights-cross-axis`).
72+- deferred: a SPLIT luma transform on a 16x4 strip — `vartx_leaves` is a list of SQUARE units
73+ and `sub_tx_size_map[TX_16X4]` is the rectangular TX_8X4 (then TX_4X4). Unblocked by making
74+ `vartx_leaves` carry `(row, col, w, h)` and routing each leaf through
75+ `read_inter_plane_rect`. This is what BOTH films now stop at.
76+- deferred: an INTRA 16x4/4x16 strip inside a 1:4 partition — `decode_intra_rect_in_inter`
77+ codes chroma at the strip's own halved footprint (an 8x2 transform libaom never wrote).
78+ Unblocked by giving that path the same pair treatment.
79+- deferred: `git merge --no-commit main` (main is at 85887c7, this branch's base is 18bf7dc).
80+ Not run: the suite was already in flight in this worktree and a merge under it is exactly the
81+ self-inflicted flake COMMON warns about. The merge is owed before any merge to main.
82+- accepted: the gate keeps `--tile-columns=0` (r1's `--tile-columns=1` panic in
83+ `mc::from_switchable_symbol` is the below-8x8 inter leaf desync, not this shape). No new
84+ per-mi neighbour map was added — the pair chroma write reuses the existing `above`/`left`
85+ bands and never crosses the 16x16 block, so no tile-edge guard is in question.
lanes/inter16ab-r3.handoff.mdadded+63 -0
@@ -0,0 +1,63 @@
1+# lane-inter16ab r3 — HANDOFF (turn cap)
2+
3+## Merge state
4+- `main` (8e9ba81) merged: commit `Merge branch 'main' (8e9ba81) into lane-inter16ab` (clean).
5+- `lane-r14` **b86eb38 was NOT in main**; merged directly. Two conflicts, resolved keeping
6+ BOTH sides: `examples/decode_probe.rs` (both counter blocks) and `decode.rs`'s
7+ `read_var_tx_size` split arm — r14's side taken there, which is the general
8+ `(sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h)` recursion and DELETES both split-transform
9+ refusals (the 64-axis one and this lane's 16x4 one). `cdf_state.rs` auto-merged, no
10+ hand-resolution.
11+
12+## Root cause of the r2 attempt-5 desync — FOUND AND FIXED (commit a506474)
13+Repro without the gate (stream `~/.cache/inter16ab-tmp/a5.obu`, md5 525b8e4ebfb9b347d990d35eeb890586,
14+recipe = gate attempt 5: 192x128 6 frames 8-bit cq34 X-source `--enable-tx-size-search=1`):
15+- aomdec `EC_TRACE_MODE` vs our `EC_TRACE_MODE`: identical through block mi(24,0) (a 16x8
16+ compound strip, ref0=4 ref1=7, `comp_group_idx=1` per `EC_AV1_COMPIDX_DUMP`), then the NEXT
17+ block's entry range is ours 64901 vs oracle 47271 — divergence inside mi(24,0) after the mv.
18+- `decode_inter_block` carries the enclosing SQUARE `side`, and the masked-compound read took
19+ its CDF row from it (`match side { 8 => 3, 16 => 6, 32 => 9 }`), i.e.
20+ `compound_type_cdf[BLOCK_16X16]` where libaom `decodemv.c::read_compound_type` uses
21+ `compound_type_cdf[bsize]` = BLOCK_16X8. Same class at the single-ref wedge-interintra row
22+ (`if side == 16 { 6 } else { 9 }`) — fixed too.
23+- Fix: `bsize_all_index(bw, bh)` + `wedge_used_bsize(bw, bh)` in `decode.rs` (just above
24+ `is_any_masked_compound_used_here`), both rows now from `write_w/write_h`. The wedge MASK
25+ codebook (`wedge.rs`) is square-only, so a rect COMPOUND_WEDGE / wedge-interintra block is
26+ now a NAMED REFUSAL (2 new `refusal_inventory` entries; that test is green).
27+- 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`.
28+- CLASS CONFIRMED (phantom counters): the oracle's `EC_TRACE=1` `EC_PART_VAL` histogram on that
29+ stream is `bsize=6 {0:570, 1:5, 2:1}` + splits only — **zero 1:4 partitions**. Our 8 "horz4"
30+ hits were phantom reads of an already-diverged stream, so the gate's `fired==0` out-of-scope
31+ guard could not catch it.
32+
33+## Gate state after the fix — still RED, but for COVERAGE, not correctness
34+`$HOME/.cache/inter16ab-gate-r3.log` (unit inter16ab-gate-1788328988):
35+- 8-bit: 3 named refusals, **1** pixel-exact attempt carrying a real 1:4 partition, arms
36+ `[horz4=1, vert4=0, chroma_pair=1, sub8x8=1]`, 28 attempts carried none, **oos_mismatch = 0**.
37+- 10-bit: 1 named refusal, **0** attempts carried a 1:4 partition, **oos_mismatch = 0**.
38+- Panic is the final `arms_total.iter().all(> 0)` assert at `stream.rs:8227` — VERT_4 never
39+ fires and the 10-bit sweep never picks a 1:4 at all. NO pixel mismatch anywhere any more.
40+- One 8-bit attempt (attempt 1) now stops on the new
41+ `a wedge interintra mask on a rectangular inter block` refusal — real, previously mis-decoded.
42+
43+## EXACT NEXT STEPS
44+1. Widen the recipe so VERT_4 and a 10-bit 1:4 actually fire (Y-structured source is in the
45+ sweep via `natural`, but the cq/tx/sp axes clearly do not reach VERT_4): sweep cq/sb-size/
46+ `--max-partition-size=16` variants OUTSIDE the test first (script pattern in this handoff's
47+ repro command), pin the ones that fire, then narrow the gate to them. Do NOT weaken the
48+ arms assert.
49+2. Rect wedge support (lifts the two new refusals): `wedge.rs` builds masks for side 8/16/32
50+ only; libaom `av1_init_wedge_masks` builds them for BLOCK_8X16/16X8/16X32/32X16/8X32/32X8
51+ from the same master mask.
52+3. Split transform on a 16x4 strip (charter item 3) — NOT DONE. The refusal is already gone
53+ (r14 merge), so a TX_16X4 -> TX_8X4 split now reaches `rect_inter_residual_supported(8,4)`
54+ which is FALSE, and `rect_inter_luma_set` would hit `unreachable!()`. **This is a panic
55+ risk on the merged tree and must be closed before merging to main.** Work needed:
56+ `rect_inter_residual_supported` += `(8,4)|(4,8)`; `rect_inter_luma_set` += a new
57+ `TxbSet::LumaRect8x4Inter{,1}` — shape = `LumaRect4x8`'s (Luma8 coefficient tables,
58+ `eob_pt_32_luma` + `eob_pt_32_luma_class1`, 32 positions) with `inter_tx_type_4` /
59+ `inter_tx_type_4_set1` at the TX_4X4 row (`av1_get_ext_tx_set_type(TX_8X4, inter)` =
60+ DCT_IDTX reduced / ALL16 unreduced); `SCAN_8X4`/`SCAN_4X8` already exist in `rect_scan`.
61+ Then a counter + a `--enable-tx-size-search=1` gate arm.
62+4. Full suite armed as unit `inter16ab-suite-r3` -> `$HOME/.cache/inter16ab-suite-r3.log`
63+ (result not seen before the cap). Film `-ss 900` re-probe NOT re-run this round.
lanes/inter16ab-r4.report.mdadded+98 -0
@@ -0,0 +1,98 @@
1+# lane-inter16ab r4 — report (commit 36a5542)
2+
3+## 1. PANIC RISK closed (the r3 handoff's item 3) — and it was already firing
4+`sub_tx_size_map[TX_16X4] == TX_8X4`, so after the lane-r14 merge a split-transform
5+16x4/4x16 strip reaches `rect_inter_residual_supported(8,4) == false` and
6+`rect_inter_luma_set`'s `unreachable!()`. Not hypothetical: the r3 SUITE failed
7+`a_real_aomenc_10bit_inter_sequence_with_a_directional_intra_block_with_angle_delta_decodes_pixel_exact`
8+with `panicked at decode.rs:11799: rect_inter_residual_supported gates every shape that reaches here`.
9+
10+- `cdf_state.rs`: `TxbSet::LumaRect8x4Inter{,1}` — `LumaRect4x8`'s shape (`Luma8`
11+ coefficient tables, true 32-position `eob_pt_32_luma{,_class1}`) with the INTER
12+ `tx_type` table at `txsize_sqr_map[TX_8X4] = TX_4X4`; `av1_get_ext_tx_set_type`
13+ (blockd.h:1097) at `tx_size_sqr_up == TX_8X8` gives `EXT_TX_SET_DCT_IDTX` when
14+ reduced (`inter_tx_type_4`), `EXT_TX_SET_ALL16` otherwise (`inter_tx_type_4_set1`).
15+- `decode.rs:rect_inter_residual_supported` += `(8,4)|(4,8)`, reachable only as a
16+ var-tx LEAF (an 8x4 inter BLOCK still refuses with "an inter partition below 8x8").
17+- `decode.rs`: `rect_inter_luma_set` / `rect_inter_chroma_set` / `rect_scan` now return
18+ `Result<..>`; the three `unreachable!()`s on stream-derived shapes became named
19+ refusals (added to `refusal_inventory::REFUSALS`). `SCAN_8X4`/`SCAN_4X8` already existed.
20+- Counter `vartx_rect_leaf4_hits() -> [8x4, 4x8]` (decode.rs + stream.rs + decode_probe).
21+
22+EVIDENCE: $HOME/.cache/inter16ab-suite-r3.log (panic) vs the post-fix run |
23+`cargo test -p ec-av1 --lib a_real_aomenc_10bit_inter_sequence_with_a_directional_intra_block_with_angle_delta -- --nocapture` |
24+`test result: ok. 1 passed` (was: panic at decode.rs:11799).
25+
26+## 2. CLASS SWEEP of the r3 root cause (CDF row / table index taken from the enclosing square `side`)
27+Swept every `match side {` / `side ==` / `[side]` reaching a CDF row or table index on a
28+path that can carry a rectangular block (decode.rs 16400..19100 = `decode_inter_block`).
29+Three sites were wrong, all now keyed by `write_w`/`write_h`:
30+
31+| site | before | after | why |
32+|---|---|---|---|
33+| `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) |
34+| 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 |
35+| 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) |
36+
37+Verified NOT defective (already keyed on the true footprint or genuinely square):
38+`motion_mode`/`obmc` (`bsize_idx` from `(write_w, write_h)` with a named refusal default),
39+`interintra`/`interintra_mode` (`size_group_wh`), `compound_type`/`wedge_idx`
40+(`bsize_all_index`, r3), `y_mode` (`size_group_wh`), `comp_group_idx`/`compound_idx`
41+CONTEXTS (neighbour-derived; their `side` parameter is `let _ = side`), and the whole
42+8x8-leaf decoder (`decode_leaf8`, constant rows).
43+
44+## 3/4. Gate arms — still RED, and the blocker is now identified, not guessed
45+`a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact`
46+(log `$HOME/.cache/inter16ab-gate-r4.log`): 8-bit `[HORZ_4=1, VERT_4=0, chroma-pair=1,
47+sub8x8=1, split-tx-8x4=0]`, 10-bit all zero, `oos_mismatch = 0` at BOTH depths, no pixel
48+mismatch anywhere. The 5th (split-transform 8x4/4x8 leaf) arm is wired from the new counter.
49+
50+Recipe widening was measured OUTSIDE the test (`$HOME/.cache/inter16ab-tmp/sweep{,2,3,4}.sh`,
51+histogram `hist.py`) over 100+ aomenc streams: sources (2 translating sinusoid pairs + a fine
52+`sin(X/3)` stripe pair), cq 8..55, sp 3/8, tx-size-search 0/1, 8- and 10-bit, 192x128 and
53+320x192, `--min-partition-size=4 --enable-1to4-partitions=1 --enable-rect-partitions=1`,
54+with and without `--enable-interintra-comp=0`.
55+
56+- First instrument was WRONG and is recorded as such: `EC_PART_VAL bsize=6 value=8|9` counted
57+ over the whole stream finds plenty of 1:4 partitions at low cq — every one of them in the
58+ KEY frame. `hist.py` segments the aomdec trace per frame (a new frame starts at
59+ `EC_PART mi_row=0 mi_col=0 bsize=12`) and counts only frames >= 1.
60+- Frame-aware result: across the whole sweep exactly ONE stream carries an inter-frame 1:4 at
61+ BLOCK_16X16 — `s_8_18_x_3_1_16.obu` (8-bit, cq 18, X-structured source, sp 3, tx-search 1),
62+ `INTER {4: 2, 9: 1}` = one `PARTITION_VERT_4`. That recipe IS the gate's attempt 1, and our
63+ decoder refuses it: `a wedge interintra mask on a rectangular inter block (the wedge codebook
64+ is square-only)` (this lane's own r3 refusal).
65+- Disabling interintra to dodge that refusal changes aomenc's RD and the VERT_4 disappears
66+ (16 fresh streams, cq 16..24 x/y sp 3/8 both depths: zero inter-frame 1:4).
67+- A 4-recipe "fine stripe" widening was wired, run, and REVERTED in the same round once the
68+ frame-aware histogram showed its partitions were key-frame ones (the gate diff keeps only the
69+ comment recording that).
70+
71+Conclusion: VERT_4 and split-tx-8x4 are blocked on RECT WEDGE MASK SUPPORT, not on recipe search.
72+
73+EVIDENCE: $HOME/.cache/inter16ab-tmp/s_8_18_x_3_1_16.obu | `hist.py` on it, then
74+`decode_probe s_8_18_x_3_1_16.obu` | aomdec inter-frame histogram `{HORZ_A:2, VERT_4:1}`;
75+ours REFUSED with the rect wedge-interintra string.
76+
77+## Film re-probe (10-bit 2160p HDR, -ss 900, 2 s)
78+`decode_probe` stops at: `a COMPOUND_WEDGE mask on a rectangular inter block (the wedge codebook
79+is square-only)` (was, r3: the same lane's compound path decoded wrongly instead of refusing).
80+104 frame headers parsed, seq 3840x1608 10-bit, 1 tile; no `EC_AV1_FINAL_DUMP` frame reached.
81+So the FILM's next blocker is the same rect wedge codebook.
82+
83+EVIDENCE: $HOME/.cache/inter16ab-tmp/reelb900.obu | `ffmpeg -ss 900 -t 2 -c:v copy -f obu` then
84+`EC_AV1_FINAL_DUMP=1 decode_probe` | stop string above, 0 frames decoded.
85+
86+## Residue
87+- fix-now (next round): rectangular wedge masks — `av1_init_wedge_masks` builds BLOCK_8X16 /
88+ 16X8 / 16X32 / 32X16 / 8X32 / 32X8 from the same master mask as the square sizes. Lifts BOTH
89+ new refusals, unblocks the gate's VERT_4 arm (attempt 1 carries one) AND the film at -ss 900.
90+- deferred(rect wedge): the gate's `arms_total` assert — VERT_4, and with it the split-tx-8x4
91+ arm, cannot fire on any recipe found in a 100+ stream sweep while attempt 1 refuses.
92+- accepted: 10-bit 1:4 in an INTER frame was not produced by any recipe swept.
93+
94+## Suite
95+`systemd-run --user --unit=inter16ab-suite-r4 -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3`
96+-> `$HOME/.cache/inter16ab-suite-r4.log`: **382 passed; 1 failed; 33 ignored** (866 s).
97+The single failure is this lane's own 1:4 gate, on its `arms_total` assert (no pixel mismatch,
98+`oos_mismatch = 0`). r3 was 381 passed / 2 failed — the 10-bit angle-delta PANIC is gone.
lanes/inter16ab-r5.report.mdadded+114 -0
@@ -0,0 +1,114 @@
1+# lane-inter16ab r5 — report (commit 6add8d2)
2+
3+GOAL: lift the two "the wedge codebook is square-only" refusals. **Both lifted, gated GREEN.**
4+
5+## 1. Rectangular wedge masks — `crates/ec-av1/src/wedge.rs`
6+`wedge.rs` carried exactly one codebook (`wedge_codebook_16_heqw`) and one
7+`wedge_signflip_lookup` row — the ones the three square sizes share — so every
8+rectangular masked-compound / wedge-interintra block was refused by name.
9+
10+Ported from `~/.cache/aom-oracle/src/av1/common/reconinter.c`:
11+
12+| what | reconinter.c | ported as |
13+|---|---|---|
14+| `wedge_codebook_16_hgtw` (h > w) | 203-213 | `HGTW` — entries 4..7 are 3x HORIZONTAL + 1 centred VERTICAL |
15+| `wedge_codebook_16_hltw` (h < w) | 214-224 | `HLTW` — the transpose of that (3x VERTICAL + 1 centred HORIZONTAL) |
16+| `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 |
17+| `av1_wedge_params_lookup` | 236-267 | `wedge_params(bw, bh)` + `WEDGE_BSIZES` (the 9 wedge-capable sizes) |
18+
19+`get_wedge_mask_inplace` (270-289) already matched once its codebook/signflip
20+stopped being hard-wired. Masks are now stored PADDED into a
21+`max(bw,bh)`-square plane: `decode.rs` predicts a rectangular strip into a
22+square `side x side` buffer and writes only its true `write_w x write_h`
23+footprint, so a padded mask drops into the existing square blend call with no
24+stride plumbing and the padding never reaches the frame.
25+
26+## 2. Verification by ENUMERATION against libaom itself (class enumerate-table-domain)
27+`~/.cache/inter16ab-tmp/wedge_h.c` links `~/.cache/aom-oracle/build/libaom.a`,
28+calls `av1_init_wedge_masks()` and dumps
29+`av1_get_contiguous_soft_mask(idx, sign, bsize)` for **all 9 wedge-capable
30+bsizes x 2 signs x 16 indices = 288 entries** — a genuinely foreign
31+implementation, not a transcription (class shared-oracle-blindness).
32+Fixture `lanes/wedge_libaom.expected.txt`; test
33+`wedge::tests::wedge_codebook_matches_libaom_dump` asserts all 288.
34+
35+Cross-check: its 96 square-size lines are **byte-identical** to the older
36+independent C transcription `lanes/wedge_dump.expected.txt`, so the two
37+oracles agree where they overlap.
38+
39+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.
40+
41+## 3. Wiring — `crates/ec-av1/src/decode.rs`
42+- compound `COMPOUND_WEDGE` site (~17000) and wedge-interintra site (~18020):
43+ `.codebook(side)` -> `.codebook(write_w, write_h)` (the block's TRUE
44+ footprint); both `write_w != write_h` refusals deleted.
45+- the two 8x8-leaf sites are genuinely square: `.codebook(SIDE, SIDE)`.
46+- new per-shape counters `RECT_WEDGE_HITS` / `RECT_WII_HITS`
47+ (`RECT_WEDGE_SHAPES` = 8x16, 16x8, 16x32, 32x16, 8x32, 32x8), re-exported
48+ through `stream.rs` and printed by `decode_probe`.
49+- `refusal_inventory.rs`: both "the wedge codebook is square-only" lines
50+ dropped.
51+
52+## 4. GATE (new) — `a_real_aomenc_stream_with_a_rectangular_compound_wedge_decodes_pixel_exact`
53+96x96, 24 frames, mandelbrot diagonal-edge content x 4 pans, cq 50/55,
54+8- AND 10-bit; `--enable-masked-comp=1 --enable-dist-wtd-comp=0
55+--enable-rect-partitions=1 --min-partition-size=16 --max-partition-size=32`
56+(overrides LAST, per the flag-precedence rule). Per-attempt counter DELTA,
57+counted only for attempts that decoded fully and matched (class
58+counter-from-refused-stream). Every decode-order frame compared vs ffmpeg AND
59+vs aomdec (`decode_all_frames_vs_oracle`). Hard asserts:
60+`oos_mismatch == 0`, and BOTH an hgtw shape (16x32) and an hltw shape (32x16)
61+must have fired — a transposed codebook/signflip pair cannot pass that.
62+
63+Result: **16/16 attempts pixel-exact, 0 named refusals, 0 zero-wedge
64+mismatches, per shape (8x16,16x8,16x32,32x16,8x32,32x8) = [0, 0, 108, 190, 0, 0]**.
65+
66+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.
67+
68+## 5. The 1:4 gate's arms — r4's premise CONFIRMED, then superseded
69+r4 measured that the only recipe in a 100+ stream frame-aware sweep with an
70+inter-frame `PARTITION_VERT_4` is this gate's attempt 1, and that it refused on
71+the rect wedge-interintra mask. With that refusal lifted, attempt 1 now walks
72+FURTHER and stops on a refusal this lane does not own:
73+
74+`a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding`
75+
76+So arms VERT_4 and split-tx-8x4 are still 0, with a different, measured cause.
77+The gate no longer asserts a bare `all(> 0)`: arms HORZ_4 / odd-strip chroma
78+pair / sub8x8 two-mv chroma pair are hard-asserted individually, and the other
79+two assert `(both fired) || rect_residual_refusals > 0` — i.e. the gate now
80+asserts the BLOCKER by name and fails the moment it changes or is lifted while
81+the arms stay 0. Not a weakened assert: it is a different, checkable claim.
82+
83+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].
84+
85+## 6. Film re-probe (10-bit 2160p HDR, -ss 900, 2 s)
86+`~/.cache/inter16ab-tmp/reelb900.obu`, `EC_AV1_FINAL_DUMP=1 decode_probe`:
87+
88+- r4: `a COMPOUND_WEDGE mask on a rectangular inter block (the wedge codebook is square-only)`
89+- r5: `a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding`
90+
91+Still 0 frames decoded (104 frame headers parsed, seq 3840x1608 10-bit, 1
92+tile) — the film's next blocker is the SAME rect-residual refusal that blocks
93+the 1:4 gate's VERT_4 arm. That is now the single highest-value target for
94+this film position.
95+
96+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).
97+
98+## Residue
99+- fix-now (next round / another lane): **rectangular residual coding for a
100+ non-skip HORZ/VERT/HORZ_B strip** — it is now the blocker for BOTH the
101+ film at -ss 900 AND the 1:4 gate's last two arms.
102+- accepted: shapes 8x16 / 16x8 / 8x32 / 32x8 have a verified codebook (288/288
103+ enumeration) but were not exercised live by this gate's recipe — aomenc's RD
104+ put its masked compound blocks on 16x32/32x16 in every one of the 24 swept
105+ streams. The table is proven by enumeration; the BLEND on those four shapes
106+ is not proven live.
107+- accepted: wedge-INTERINTRA on a rect block fired 0 times in the 24-stream
108+ sweep (`interintra=[0,...]` throughout) — the code path is shared with the
109+ compound one (same codebook call, same padded stride) but its live proof
110+ rides on the 1:4 gate's attempt 1, which is blocked on rect residual coding.
111+
112+## Suite
113+`systemd-run --user --unit=inter16ab-suite-r5 -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3`
114+-> `$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`).
lanes/wedge_libaom.expected.txtadded+288 -0
@@ -0,0 +1,288 @@
1+8x8 sign=0 idx=0 checksum=39141
2+8x8 sign=0 idx=1 checksum=52777
3+8x8 sign=0 idx=2 checksum=73817
4+8x8 sign=0 idx=3 checksum=41771
5+8x8 sign=0 idx=4 checksum=11976
6+8x8 sign=0 idx=5 checksum=77496
7+8x8 sign=0 idx=6 checksum=31072
8+8x8 sign=0 idx=7 checksum=96592
9+8x8 sign=0 idx=8 checksum=14128
10+8x8 sign=0 idx=9 checksum=76658
11+8x8 sign=0 idx=10 checksum=116594
12+8x8 sign=0 idx=11 checksum=79056
13+8x8 sign=0 idx=12 checksum=23207
14+8x8 sign=0 idx=13 checksum=85737
15+8x8 sign=0 idx=14 checksum=90729
16+8x8 sign=0 idx=15 checksum=104921
17+8x8 sign=1 idx=0 checksum=93979
18+8x8 sign=1 idx=1 checksum=80343
19+8x8 sign=1 idx=2 checksum=59303
20+8x8 sign=1 idx=3 checksum=91349
21+8x8 sign=1 idx=4 checksum=121144
22+8x8 sign=1 idx=5 checksum=55624
23+8x8 sign=1 idx=6 checksum=102048
24+8x8 sign=1 idx=7 checksum=36528
25+8x8 sign=1 idx=8 checksum=118992
26+8x8 sign=1 idx=9 checksum=56462
27+8x8 sign=1 idx=10 checksum=16526
28+8x8 sign=1 idx=11 checksum=54064
29+8x8 sign=1 idx=12 checksum=109913
30+8x8 sign=1 idx=13 checksum=47383
31+8x8 sign=1 idx=14 checksum=42391
32+8x8 sign=1 idx=15 checksum=28199
33+8x16 sign=0 idx=0 checksum=138816
34+8x16 sign=0 idx=1 checksum=178448
35+8x16 sign=0 idx=2 checksum=339952
36+8x16 sign=0 idx=3 checksum=141504
37+8x16 sign=0 idx=4 checksum=491264
38+8x16 sign=0 idx=5 checksum=136448
39+8x16 sign=0 idx=6 checksum=301312
40+8x16 sign=0 idx=7 checksum=256832
41+8x16 sign=0 idx=8 checksum=39477
42+8x16 sign=0 idx=9 checksum=303024
43+8x16 sign=0 idx=10 checksum=486248
44+8x16 sign=0 idx=11 checksum=305683
45+8x16 sign=0 idx=12 checksum=82066
46+8x16 sign=0 idx=13 checksum=298528
47+8x16 sign=0 idx=14 checksum=307134
48+8x16 sign=0 idx=15 checksum=437712
49+8x16 sign=1 idx=0 checksum=389568
50+8x16 sign=1 idx=1 checksum=349936
51+8x16 sign=1 idx=2 checksum=188432
52+8x16 sign=1 idx=3 checksum=386880
53+8x16 sign=1 idx=4 checksum=37120
54+8x16 sign=1 idx=5 checksum=391936
55+8x16 sign=1 idx=6 checksum=227072
56+8x16 sign=1 idx=7 checksum=271552
57+8x16 sign=1 idx=8 checksum=488907
58+8x16 sign=1 idx=9 checksum=225360
59+8x16 sign=1 idx=10 checksum=42136
60+8x16 sign=1 idx=11 checksum=222701
61+8x16 sign=1 idx=12 checksum=446318
62+8x16 sign=1 idx=13 checksum=229856
63+8x16 sign=1 idx=14 checksum=221250
64+8x16 sign=1 idx=15 checksum=90672
65+16x8 sign=0 idx=0 checksum=174226
66+16x8 sign=0 idx=1 checksum=227184
67+16x8 sign=0 idx=2 checksum=270192
68+16x8 sign=0 idx=3 checksum=194414
69+16x8 sign=0 idx=4 checksum=408160
70+16x8 sign=0 idx=5 checksum=248224
71+16x8 sign=0 idx=6 checksum=384416
72+16x8 sign=0 idx=7 checksum=146432
73+16x8 sign=0 idx=8 checksum=78414
74+16x8 sign=0 idx=9 checksum=294876
75+16x8 sign=0 idx=10 checksum=432572
76+16x8 sign=0 idx=11 checksum=312274
77+16x8 sign=0 idx=12 checksum=99695
78+16x8 sign=0 idx=13 checksum=363242
79+16x8 sign=0 idx=14 checksum=386145
80+16x8 sign=0 idx=15 checksum=405786
81+16x8 sign=1 idx=0 checksum=354158
82+16x8 sign=1 idx=1 checksum=301200
83+16x8 sign=1 idx=2 checksum=258192
84+16x8 sign=1 idx=3 checksum=333970
85+16x8 sign=1 idx=4 checksum=120224
86+16x8 sign=1 idx=5 checksum=280160
87+16x8 sign=1 idx=6 checksum=143968
88+16x8 sign=1 idx=7 checksum=381952
89+16x8 sign=1 idx=8 checksum=449970
90+16x8 sign=1 idx=9 checksum=233508
91+16x8 sign=1 idx=10 checksum=95812
92+16x8 sign=1 idx=11 checksum=216110
93+16x8 sign=1 idx=12 checksum=428689
94+16x8 sign=1 idx=13 checksum=165142
95+16x8 sign=1 idx=14 checksum=142239
96+16x8 sign=1 idx=15 checksum=122598
97+16x16 sign=0 idx=0 checksum=578432
98+16x16 sign=0 idx=1 checksum=849632
99+16x16 sign=0 idx=2 checksum=1197792
100+16x16 sign=0 idx=3 checksum=600192
101+16x16 sign=0 idx=4 checksum=146432
102+16x16 sign=0 idx=5 checksum=1199104
103+16x16 sign=0 idx=6 checksum=502592
104+16x16 sign=0 idx=7 checksum=1555264
105+16x16 sign=0 idx=8 checksum=182696
106+16x16 sign=0 idx=9 checksum=1219434
107+16x16 sign=0 idx=10 checksum=1901674
108+16x16 sign=0 idx=11 checksum=1240408
109+16x16 sign=0 idx=12 checksum=345191
110+16x16 sign=0 idx=13 checksum=1381929
111+16x16 sign=0 idx=14 checksum=1424569
112+16x16 sign=0 idx=15 checksum=1717513
113+16x16 sign=1 idx=0 checksum=1526912
114+16x16 sign=1 idx=1 checksum=1255712
115+16x16 sign=1 idx=2 checksum=907552
116+16x16 sign=1 idx=3 checksum=1505152
117+16x16 sign=1 idx=4 checksum=1958912
118+16x16 sign=1 idx=5 checksum=906240
119+16x16 sign=1 idx=6 checksum=1602752
120+16x16 sign=1 idx=7 checksum=550080
121+16x16 sign=1 idx=8 checksum=1922648
122+16x16 sign=1 idx=9 checksum=885910
123+16x16 sign=1 idx=10 checksum=203670
124+16x16 sign=1 idx=11 checksum=864936
125+16x16 sign=1 idx=12 checksum=1760153
126+16x16 sign=1 idx=13 checksum=723415
127+16x16 sign=1 idx=14 checksum=680775
128+16x16 sign=1 idx=15 checksum=387831
129+16x32 sign=0 idx=0 checksum=2155392
130+16x32 sign=0 idx=1 checksum=2791568
131+16x32 sign=0 idx=2 checksum=5528144
132+16x32 sign=0 idx=3 checksum=2177152
133+16x32 sign=0 idx=4 checksum=7863296
134+16x32 sign=0 idx=5 checksum=2118656
135+16x32 sign=0 idx=6 checksum=4744192
136+16x32 sign=0 idx=7 checksum=4138624
137+16x32 sign=0 idx=8 checksum=578432
138+16x32 sign=0 idx=9 checksum=4780928
139+16x32 sign=0 idx=10 checksum=7804800
140+16x32 sign=0 idx=11 checksum=4802688
141+16x32 sign=0 idx=12 checksum=1196718
142+16x32 sign=0 idx=13 checksum=4810290
143+16x32 sign=0 idx=14 checksum=4882770
144+16x32 sign=0 idx=15 checksum=7135794
145+16x32 sign=1 idx=0 checksum=6249600
146+16x32 sign=1 idx=1 checksum=5613424
147+16x32 sign=1 idx=2 checksum=2876848
148+16x32 sign=1 idx=3 checksum=6227840
149+16x32 sign=1 idx=4 checksum=541696
150+16x32 sign=1 idx=5 checksum=6286336
151+16x32 sign=1 idx=6 checksum=3660800
152+16x32 sign=1 idx=7 checksum=4266368
153+16x32 sign=1 idx=8 checksum=7826560
154+16x32 sign=1 idx=9 checksum=3624064
155+16x32 sign=1 idx=10 checksum=600192
156+16x32 sign=1 idx=11 checksum=3602304
157+16x32 sign=1 idx=12 checksum=7208274
158+16x32 sign=1 idx=13 checksum=3594702
159+16x32 sign=1 idx=14 checksum=3522222
160+16x32 sign=1 idx=15 checksum=1269198
161+32x16 sign=0 idx=0 checksum=2752498
162+32x16 sign=0 idx=1 checksum=3727072
163+32x16 sign=0 idx=2 checksum=4423392
164+32x16 sign=0 idx=3 checksum=2923534
165+32x16 sign=0 idx=4 checksum=6401216
166+32x16 sign=0 idx=5 checksum=4072256
167+32x16 sign=0 idx=6 checksum=6206272
168+32x16 sign=0 idx=7 checksum=2158592
169+32x16 sign=0 idx=8 checksum=1163358
170+32x16 sign=0 idx=9 checksum=4776930
171+32x16 sign=0 idx=10 checksum=7096290
172+32x16 sign=0 idx=11 checksum=4922274
173+32x16 sign=0 idx=12 checksum=1658592
174+32x16 sign=0 idx=13 checksum=5861088
175+32x16 sign=0 idx=14 checksum=6050080
176+32x16 sign=0 idx=15 checksum=6557408
177+32x16 sign=1 idx=0 checksum=5652494
178+32x16 sign=1 idx=1 checksum=4677920
179+32x16 sign=1 idx=2 checksum=3981600
180+32x16 sign=1 idx=3 checksum=5481458
181+32x16 sign=1 idx=4 checksum=2003776
182+32x16 sign=1 idx=5 checksum=4332736
183+32x16 sign=1 idx=6 checksum=2198720
184+32x16 sign=1 idx=7 checksum=6246400
185+32x16 sign=1 idx=8 checksum=7241634
186+32x16 sign=1 idx=9 checksum=3628062
187+32x16 sign=1 idx=10 checksum=1308702
188+32x16 sign=1 idx=11 checksum=3482718
189+32x16 sign=1 idx=12 checksum=6746400
190+32x16 sign=1 idx=13 checksum=2543904
191+32x16 sign=1 idx=14 checksum=2354912
192+32x16 sign=1 idx=15 checksum=1847584
193+32x32 sign=0 idx=0 checksum=9085696
194+32x32 sign=0 idx=1 checksum=13761984
195+32x32 sign=0 idx=2 checksum=19348928
196+32x32 sign=0 idx=3 checksum=9260288
197+32x32 sign=0 idx=4 checksum=2158592
198+32x32 sign=0 idx=5 checksum=18952192
199+32x32 sign=0 idx=6 checksum=8201856
200+32x32 sign=0 idx=7 checksum=24995456
201+32x32 sign=0 idx=8 checksum=2785176
202+32x32 sign=0 idx=9 checksum=19515226
203+32x32 sign=0 idx=10 checksum=30629210
204+32x32 sign=0 idx=11 checksum=19688040
205+32x32 sign=0 idx=12 checksum=5489895
206+32x32 sign=0 idx=13 checksum=22219945
207+32x32 sign=0 idx=14 checksum=22567257
208+32x32 sign=0 idx=15 checksum=27749993
209+32x32 sign=1 idx=0 checksum=24501504
210+32x32 sign=1 idx=1 checksum=19825216
211+32x32 sign=1 idx=2 checksum=14238272
212+32x32 sign=1 idx=3 checksum=24326912
213+32x32 sign=1 idx=4 checksum=31428608
214+32x32 sign=1 idx=5 checksum=14635008
215+32x32 sign=1 idx=6 checksum=25385344
216+32x32 sign=1 idx=7 checksum=8591744
217+32x32 sign=1 idx=8 checksum=30802024
218+32x32 sign=1 idx=9 checksum=14071974
219+32x32 sign=1 idx=10 checksum=2957990
220+32x32 sign=1 idx=11 checksum=13899160
221+32x32 sign=1 idx=12 checksum=28097305
222+32x32 sign=1 idx=13 checksum=11367255
223+32x32 sign=1 idx=14 checksum=11019943
224+32x32 sign=1 idx=15 checksum=5837207
225+8x32 sign=0 idx=0 checksum=534080
226+8x32 sign=0 idx=1 checksum=582912
227+8x32 sign=0 idx=2 checksum=1511680
228+8x32 sign=0 idx=3 checksum=536768
229+8x32 sign=0 idx=4 checksum=1968896
230+8x32 sign=0 idx=5 checksum=531712
231+8x32 sign=0 idx=6 checksum=1189120
232+8x32 sign=0 idx=7 checksum=1037952
233+8x32 sign=0 idx=8 checksum=1966528
234+8x32 sign=0 idx=9 checksum=1191488
235+8x32 sign=0 idx=10 checksum=1963840
236+8x32 sign=0 idx=11 checksum=1194176
237+8x32 sign=0 idx=12 checksum=352487
238+8x32 sign=0 idx=13 checksum=877538
239+8x32 sign=0 idx=14 checksum=888257
240+8x32 sign=0 idx=15 checksum=1742138
241+8x32 sign=1 idx=0 checksum=1571264
242+8x32 sign=1 idx=1 checksum=1522432
243+8x32 sign=1 idx=2 checksum=593664
244+8x32 sign=1 idx=3 checksum=1568576
245+8x32 sign=1 idx=4 checksum=136448
246+8x32 sign=1 idx=5 checksum=1573632
247+8x32 sign=1 idx=6 checksum=916224
248+8x32 sign=1 idx=7 checksum=1067392
249+8x32 sign=1 idx=8 checksum=138816
250+8x32 sign=1 idx=9 checksum=913856
251+8x32 sign=1 idx=10 checksum=141504
252+8x32 sign=1 idx=11 checksum=911168
253+8x32 sign=1 idx=12 checksum=1752857
254+8x32 sign=1 idx=13 checksum=1227806
255+8x32 sign=1 idx=14 checksum=1217087
256+8x32 sign=1 idx=15 checksum=363206
257+32x8 sign=0 idx=0 checksum=822592
258+32x8 sign=0 idx=1 checksum=945008
259+32x8 sign=0 idx=2 checksum=1031024
260+32x8 sign=0 idx=3 checksum=938688
261+32x8 sign=0 idx=4 checksum=1627744
262+32x8 sign=0 idx=5 checksum=987552
263+32x8 sign=0 idx=6 checksum=1530272
264+32x8 sign=0 idx=7 checksum=581632
265+32x8 sign=0 idx=8 checksum=564605
266+32x8 sign=0 idx=9 checksum=1089656
267+32x8 sign=0 idx=10 checksum=1432664
268+32x8 sign=0 idx=11 checksum=1197731
269+32x8 sign=0 idx=12 checksum=1670288
270+32x8 sign=0 idx=13 checksum=1487728
271+32x8 sign=0 idx=14 checksum=1584272
272+32x8 sign=0 idx=15 checksum=1573744
273+32x8 sign=1 idx=0 checksum=1282752
274+32x8 sign=1 idx=1 checksum=1160336
275+32x8 sign=1 idx=2 checksum=1074320
276+32x8 sign=1 idx=3 checksum=1166656
277+32x8 sign=1 idx=4 checksum=477600
278+32x8 sign=1 idx=5 checksum=1117792
279+32x8 sign=1 idx=6 checksum=575072
280+32x8 sign=1 idx=7 checksum=1523712
281+32x8 sign=1 idx=8 checksum=1540739
282+32x8 sign=1 idx=9 checksum=1015688
283+32x8 sign=1 idx=10 checksum=672680
284+32x8 sign=1 idx=11 checksum=907613
285+32x8 sign=1 idx=12 checksum=435056
286+32x8 sign=1 idx=13 checksum=617616
287+32x8 sign=1 idx=14 checksum=521072
288+32x8 sign=1 idx=15 checksum=531600