forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-inter16ab' (2e711e1): 16-level inter 1:4 arms and rectangular wedge codebooks

Browse files at this commit

305b01ae69795f193e63b37c9abceb1e87017b09Ahmet Kaan GümüşParent: fa9efb8d2534b6
Rect compound_type/wedge_idx CDF rows keyed by the block's true (w,h), the
8x4/4x8 inter coefficient sets, and the hgtw/hltw rectangular wedge codebooks
(288-entry libaom enumeration pinned at lanes/wedge_libaom.expected.txt).

Conflict resolution: the lane and main had each landed the same
BLOCK_SIZES_ALL row fix under different names -- kept the lane's
bsize_all_index / wedge_used_bsize / is_any_masked_compound_used_here and
deleted main's duplicates (main's wedge_used_wh wrongly listed 16x64/64x16,
which have no wedge codebook in libaom). The TxbSet 8x4-inter variants were
also duplicated: kept main's names, dropped the lane's identical twins. Main's
non-square COMPOUND_WEDGE refusal, auto-merged into the lane's lifted code,
removed.

Gates: wedge (1), interintra_wedge (2), rectangular_compound_wedge (1),
16x16_level_1to4 (1), 16x16_level_ab (1), 1to4 family (7),
refusal_inventory (3), gate_coverage (9), base_ctx_rect_offsets (1) -- pass.

11 changed files +1883 -178

crates/ec-av1/examples/decode_probe.rsmodified+10 -0
@@ -56,6 +56,16 @@ fn main() {
56 println!(56 println!(
57 "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}",57 "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}",
58 es[0], es[1], es[2], es[3], es[4], es[5]58 es[0], es[1], es[2], es[3], es[4], es[5]
59+
60+ );
61+ let (h4, v4, pairs, sub8) = ec_av1::decode::inter16_rect4_counters();
62+ println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}");
63+ let leaf4 = ec_av1::stream::vartx_rect_leaf4_hits();
64+ println!("vartx_rect_leaf4: 8x4={} 4x8={}", leaf4[0], leaf4[1]);
65+ let rw = ec_av1::stream::rect_wedge_hits();
66+ let rwi = ec_av1::stream::rect_wii_hits();
67+ println!(
68+ "rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}"
59 );69 );
60 let ir = ec_av1::stream::inter_rect_counters();70 let ir = ec_av1::stream::inter_rect_counters();
61 println!(71 println!(
crates/ec-av1/src/cdf_state.rsmodified+37 -0
@@ -246,6 +246,19 @@ pub(crate) enum TxbSet {
246 /// symbols at the `TX_4X4` inter row, the table246 /// symbols at the `TX_4X4` inter row, the table
247 /// [`Luma4InterSet1`](TxbSet::Luma4InterSet1) also reads.247 /// [`Luma4InterSet1`](TxbSet::Luma4InterSet1) also reads.
248 LumaRect8x4InterSet1,248 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,
249 }262 }
250 263
251 /// The tables one transform block is coded with, borrowed from the state for264 /// The tables one transform block is coded with, borrowed from the state for
@@ -1904,6 +1917,30 @@ impl Cdfs {
1904 tx_type: Some(self.intra_tx_type_4_set1[mode].as_mut_slice()),1917 tx_type: Some(self.intra_tx_type_4_set1[mode].as_mut_slice()),
1905 eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),1918 eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
1906 },1919 },
1920+ TxbSet::LumaRect16x4Inter => TxbTables {
1921+ side: 8,
1922+ txb_skip: &mut self.txb_skip_luma_8,
1923+ eob_pt: &mut self.eob_pt_64_luma,
1924+ eob_extra: &mut self.eob_extra_luma_8,
1925+ base: &mut self.base_luma_8,
1926+ base_eob: &mut self.base_eob_luma_8,
1927+ br: &mut self.br_luma_8,
1928+ dc_sign: &mut self.dc_sign_luma,
1929+ tx_type: Some(self.inter_tx_type_4.as_mut_slice()),
1930+ eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
1931+ },
1932+ TxbSet::LumaRect16x4Inter1 => TxbTables {
1933+ side: 8,
1934+ txb_skip: &mut self.txb_skip_luma_8,
1935+ eob_pt: &mut self.eob_pt_64_luma,
1936+ eob_extra: &mut self.eob_extra_luma_8,
1937+ base: &mut self.base_luma_8,
1938+ base_eob: &mut self.base_eob_luma_8,
1939+ br: &mut self.br_luma_8,
1940+ dc_sign: &mut self.dc_sign_luma,
1941+ tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()),
1942+ eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
1943+ },
1907 TxbSet::LumaRect16x8Inter => TxbTables {1944 TxbSet::LumaRect16x8Inter => TxbTables {
1908 side: 16,1945 side: 16,
1909 txb_skip: &mut self.txb_skip_luma_16,1946 txb_skip: &mut self.txb_skip_luma_16,
crates/ec-av1/src/decode.rsmodified+493 -103
@@ -999,6 +999,9 @@ thread_local! {
999 static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };999 static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1000 // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32].1000 // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32].
1001 static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };1001 static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
1002+ // lane-inter16ab r4: rectangular var-tx leaves with a 4-px axis, [8x4, 4x8]
1003+ // -- the `sub_tx_size_map[TX_16X4]` split leaves of a 16x16-level 1:4 strip.
1004+ static VARTX_RECT_LEAF4_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
1002 // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter1005 // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter
1003 // frame -- 16x8 and 8x16 inter leaves.1006 // frame -- 16x8 and 8x16 inter leaves.
1004 static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };1007 static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
@@ -1057,9 +1060,16 @@ pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] {
1057 VARTX_RECT_LEAF_HITS.with(|c| c.get())1060 VARTX_RECT_LEAF_HITS.with(|c| c.get())
1058 }1061 }
1059 1062
1063+/// Current value of [`VARTX_RECT_LEAF4_HITS`] (lane-inter16ab r4): 8x4/4x8
1064+/// split leaves of a 16x4/4x16 strip, `[8x4, 4x8]`.
1065+pub(crate) fn vartx_rect_leaf4_hits() -> [usize; 2] {
1066+ VARTX_RECT_LEAF4_HITS.with(|c| c.get())
1067+}
1068+
1060 /// Records one rectangular var-tx leaf.1069 /// Records one rectangular var-tx leaf.
1061 fn vartx_rect_leaf_hit(tw: usize, th: usize) {1070 fn vartx_rect_leaf_hit(tw: usize, th: usize) {
1062- VARTX_RECT_LEAF_HITS.with(|c| {1071+ let cell = if tw.min(th) == 4 { &VARTX_RECT_LEAF4_HITS } else { &VARTX_RECT_LEAF_HITS };
1072+ cell.with(|c| {
1063 let mut h = c.get();1073 let mut h = c.get();
1064 h[usize::from(th > tw)] += 1;1074 h[usize::from(th > tw)] += 1;
1065 c.set(h);1075 c.set(h);
@@ -2029,6 +2039,34 @@ pub(crate) fn nocfl_uv_mode_hits() -> usize {
2029 NOCFL_UV_MODE_HITS.with(|c| c.get())2039 NOCFL_UV_MODE_HITS.with(|c| c.get())
2030 }2040 }
2031 2041
2042+/// lane-inter16ab r5: the six RECTANGULAR wedge shapes, in this order --
2043+/// the counter slots of [`RECT_WEDGE_HITS`]/[`RECT_WII_HITS`].
2044+pub(crate) const RECT_WEDGE_SHAPES: [(usize, usize); 6] =
2045+ [(8, 16), (16, 8), (16, 32), (32, 16), (8, 32), (32, 8)];
2046+
2047+fn rect_wedge_slot(bw: usize, bh: usize) -> Option<usize> {
2048+ RECT_WEDGE_SHAPES.iter().position(|&s| s == (bw, bh))
2049+}
2050+
2051+// lane-inter16ab r5: how many COMPOUND_WEDGE / wedge-INTERINTRA blocks used a
2052+// RECTANGULAR codebook row (hgtw/hltw), per shape -- the gate's proof that
2053+// the rect wedge masks lifted this round actually fired, not just the square
2054+// ones already counted by `WEDGE_HITS`/`WII_HITS`.
2055+thread_local! {
2056+ static RECT_WEDGE_HITS: std::cell::Cell<[usize; 6]> = const { std::cell::Cell::new([0; 6]) };
2057+ static RECT_WII_HITS: std::cell::Cell<[usize; 6]> = const { std::cell::Cell::new([0; 6]) };
2058+}
2059+
2060+/// Current value of [`RECT_WEDGE_HITS`], indexed by [`RECT_WEDGE_SHAPES`].
2061+pub(crate) fn rect_wedge_hits() -> [usize; 6] {
2062+ RECT_WEDGE_HITS.with(|c| c.get())
2063+}
2064+
2065+/// Current value of [`RECT_WII_HITS`], indexed by [`RECT_WEDGE_SHAPES`].
2066+pub(crate) fn rect_wii_hits() -> [usize; 6] {
2067+ RECT_WII_HITS.with(|c| c.get())
2068+}
2069+
2032 // lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC2070 // lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC
2033 // blend -- the gate's proof that `--enable-obmc=1` reached this shape (the2071 // blend -- the gate's proof that `--enable-obmc=1` reached this shape (the
2034 // r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented2072 // r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented
@@ -2423,6 +2461,64 @@ pub fn ab16_inter_hits_by_arm() -> [usize; 4] {
2423 AB16_INTER_HITS.with(std::cell::Cell::get)2461 AB16_INTER_HITS.with(std::cell::Cell::get)
2424 }2462 }
2425 2463
2464+// lane-inter16ab r2: the 16x16-level 1:4 pair as INTER blocks -- four 16x4
2465+// (`PARTITION_HORZ_4`) or 4x16 (`PARTITION_VERT_4`) strips. `CHROMA_PAIRS`
2466+// counts the odd strips that close a 4:2:0 chroma pair
2467+// (`is_chroma_reference`, av1_common_int.h:1454: bh == 1 mi => odd mi_row),
2468+// `SUB8_PIECES` the pair chroma blocks whose TOP (LEFT) half was built from
2469+// the PREVIOUS strip's own mv/ref/filters -- libaom
2470+// `build_inter_predictors_sub8x8` (reconinter_template.inc:87-160), reached
2471+// through `is_sub8x8_inter` (same file, :54).
2472+thread_local! {
2473+ static INTER16_HORZ4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2474+ static INTER16_VERT4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2475+ static INTER16_CHROMA_PAIR_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2476+ static INTER16_SUB8_PIECE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2477+}
2478+
2479+/// Current values of the inter 16x16-level 1:4 counters: `(16x4 strips, 4x16
2480+/// strips, chroma pairs closed, chroma pairs built from two different
2481+/// strips' motion vectors)`.
2482+pub fn inter16_rect4_counters() -> (usize, usize, usize, usize) {
2483+ (
2484+ INTER16_HORZ4_HITS.with(std::cell::Cell::get),
2485+ INTER16_VERT4_HITS.with(std::cell::Cell::get),
2486+ INTER16_CHROMA_PAIR_HITS.with(std::cell::Cell::get),
2487+ INTER16_SUB8_PIECE_HITS.with(std::cell::Cell::get),
2488+ )
2489+}
2490+
2491+/// One 16x4 / 4x16 inter strip's chroma situation, handed to
2492+/// [`decode_inter_block`] out of band (the same one-shot thread-local idiom
2493+/// `REDUCED_TX_SET_INTER` uses) rather than through twenty-three call sites
2494+/// that all mean "an ordinary block, chroma of its own".
2495+#[derive(Clone, Copy)]
2496+struct InterStripChroma {
2497+ /// `is_chroma_reference` for this strip: false on strips 0 and 2, which
2498+ /// read and reconstruct NO chroma at all.
2499+ has_chroma: bool,
2500+ /// `PARTITION_HORZ_4` (16x4 strips) rather than `PARTITION_VERT_4`.
2501+ horz: bool,
2502+ /// The mi position of the EVEN strip of this pair -- `setup_pred_plane`'s
2503+ /// `if (ss_y && (mi_row & 1) && mi_size_high[bsize] == 1) mi_row -= 1`,
2504+ /// i.e. the origin of the 8x4 (4x8) chroma transform.
2505+ pair_mi: (usize, usize),
2506+ /// The previous (even) strip's single-reference MC parameters, `None`
2507+ /// when it was intra or compound -- `is_sub8x8_inter` then returns false
2508+ /// and the whole chroma block is predicted from THIS strip's mv.
2509+ prev: Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>,
2510+}
2511+
2512+thread_local! {
2513+ static INTER_STRIP_CHROMA: std::cell::Cell<Option<InterStripChroma>> =
2514+ const { std::cell::Cell::new(None) };
2515+ /// The single-reference MC parameters of the inter block that decoded
2516+ /// last -- read by the next 1:4 strip to build its pair's chroma.
2517+ static INTER_LAST_MC: std::cell::Cell<
2518+ Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>,
2519+ > = const { std::cell::Cell::new(None) };
2520+}
2521+
2426 fn bump_ab16_inter(arm: usize) {2522 fn bump_ab16_inter(arm: usize) {
2427 AB16_INTER_HITS.with(|c| {2523 AB16_INTER_HITS.with(|c| {
2428 let mut v = c.get();2524 let mut v = c.get();
@@ -12375,6 +12471,10 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool {
12375 (w, h),12471 (w, h),
12376 // 2:1 strips whose transform is coded in full (lane-inter4).12472 // 2:1 strips whose transform is coded in full (lane-inter4).
12377 (32, 16) | (16, 32) | (16, 8) | (8, 16)12473 (32, 16) | (16, 32) | (16, 8) | (8, 16)
12474+ // lane-inter16ab r2: the 16x16-level 1:4 strips. TX_16X4/TX_4X16
12475+ // codes all 64 of its positions, and its chroma pair is an 8x4 /
12476+ // 4x8 unit (`ss_size_lookup[BLOCK_16X4]` = BLOCK_8X4).
12477+ | (16, 4) | (4, 16)
12378 // lane-r14 r2: strips with a 64-px axis. `av1_get_max_eob` codes12478 // lane-r14 r2: strips with a 64-px axis. `av1_get_max_eob` codes
12379 // only the low 32 coefficients of a 64-length axis, so these read12479 // only the low 32 coefficients of a 64-length axis, so these read
12380 // exactly the truncated corner the INTRA superblock-strip path12480 // exactly the truncated corner the INTRA superblock-strip path
@@ -12383,6 +12483,11 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool {
12383 // `TX_64X64`, so `av1_get_ext_tx_set_type` is `DCT_ONLY` and no12483 // `TX_64X64`, so `av1_get_ext_tx_set_type` is `DCT_ONLY` and no
12384 // `tx_type` symbol is coded at all.12484 // `tx_type` symbol is coded at all.
12385 | (64, 32) | (32, 64) | (64, 16) | (16, 64)12485 | (64, 32) | (32, 64) | (64, 16) | (16, 64)
12486+ // lane-inter16ab r4: `sub_tx_size_map[TX_16X4] == TX_8X4`, so a
12487+ // split-transform 16x4/4x16 strip has RECTANGULAR 8x4/4x8 leaves.
12488+ // Only reachable as a var-tx LEAF -- an 8x4/4x8 inter BLOCK is
12489+ // refused earlier ("an inter partition below 8x8").
12490+ | (8, 4) | (4, 8)
12386 )12491 )
12387 }12492 }
12388 12493
@@ -12394,9 +12499,27 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool {
12394 /// `tx_size_sqr == TX_8X8`, so it reads `EXT_TX_SET_DCT_IDTX` when reduced12499 /// `tx_size_sqr == TX_8X8`, so it reads `EXT_TX_SET_DCT_IDTX` when reduced
12395 /// and the 16-symbol `EXT_TX_SET_ALL16` otherwise -- both at the *8x8* CDF12500 /// and the 16-symbol `EXT_TX_SET_ALL16` otherwise -- both at the *8x8* CDF
12396 /// row (`txsize_sqr_map`), never the 16x16 one.12501 /// row (`txsize_sqr_map`), never the 16x16 one.
12397-fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet {12502+fn rect_inter_luma_set(w: usize, h: usize) -> Result<TxbSet> {
12398- match (w, h) {12503+ Ok(match (w, h) {
12399 (32, 16) | (16, 32) => TxbSet::LumaRect32x16Inter,12504 (32, 16) | (16, 32) => TxbSet::LumaRect32x16Inter,
12505+ // lane-inter16ab r4: the 8x4/4x8 split leaf of a 16x4/4x16 strip.
12506+ // `av1_get_ext_tx_set_type` (blockd.h:1097) at `tx_size_sqr_up ==
12507+ // TX_8X8`, `tx_size_sqr == TX_4X4`, inter: DCT_IDTX when reduced,
12508+ // ALL16 otherwise -- both at the TX_4X4 row.
12509+ (8, 4) | (4, 8) => {
12510+ if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) {
12511+ TxbSet::LumaRect8x4Inter
12512+ } else {
12513+ TxbSet::LumaRect8x4InterSet1
12514+ }
12515+ }
12516+ (16, 4) | (4, 16) => {
12517+ if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) {
12518+ TxbSet::LumaRect16x4Inter
12519+ } else {
12520+ TxbSet::LumaRect16x4Inter1
12521+ }
12522+ }
12400 (16, 8) | (8, 16) => {12523 (16, 8) | (8, 16) => {
12401 if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) {12524 if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) {
12402 TxbSet::LumaRect16x8Inter12525 TxbSet::LumaRect16x8Inter
@@ -12411,16 +12534,20 @@ fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet {
12411 // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot.12534 // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot.
12412 (64, 32) | (32, 64) => TxbSet::Luma64,12535 (64, 32) | (32, 64) => TxbSet::Luma64,
12413 (64, 16) | (16, 64) => TxbSet::LumaRect32x16,12536 (64, 16) | (16, 64) => TxbSet::LumaRect32x16,
12414- _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),12537+ _ => {
12415- }12538+ return Err(unsupported(
12539+ "a rectangular inter luma transform unit whose shape has no coefficient table set here",
12540+ ));
12541+ }
12542+ })
12416 }12543 }
12417 12544
12418 /// The chroma table set of the same block's single rectangular chroma unit12545 /// The chroma table set of the same block's single rectangular chroma unit
12419 /// (`av1_get_max_uv_txsize`): 16x8/8x16 under a 32x16/16x32 strip, 8x4/4x812546 /// (`av1_get_max_uv_txsize`): 16x8/8x16 under a 32x16/16x32 strip, 8x4/4x8
12420 /// under a 16x8/8x16 one. Neither codes a `tx_type` symbol -- both inherit12547 /// under a 16x8/8x16 one. Neither codes a `tx_type` symbol -- both inherit
12421 /// the luma unit's.12548 /// the luma unit's.
12422-fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet {12549+fn rect_inter_chroma_set(w: usize, h: usize) -> Result<TxbSet> {
12423- match (w, h) {12550+ Ok(match (w, h) {
12424 (16, 8) | (8, 16) => TxbSet::ChromaRect16x8,12551 (16, 8) | (8, 16) => TxbSet::ChromaRect16x8,
12425 (8, 4) | (4, 8) => TxbSet::ChromaRect8x4,12552 (8, 4) | (4, 8) => TxbSet::ChromaRect8x4,
12426 // lane-r14 r2: chroma of a 64-axis strip -- 32x16/16x32 under a12553 // lane-r14 r2: chroma of a 64-axis strip -- 32x16/16x32 under a
@@ -12430,8 +12557,12 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet {
12430 // `txsize_log2_minus4` = 4), same as the intra strip path uses.12557 // `txsize_log2_minus4` = 4), same as the intra strip path uses.
12431 (32, 16) | (16, 32) => TxbSet::ChromaRect32x16,12558 (32, 16) | (16, 32) => TxbSet::ChromaRect32x16,
12432 (32, 8) | (8, 32) => TxbSet::Chroma16,12559 (32, 8) | (8, 32) => TxbSet::Chroma16,
12433- _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),12560+ _ => {
12434- }12561+ return Err(unsupported(
12562+ "a rectangular inter chroma transform unit whose shape has no coefficient table set here",
12563+ ));
12564+ }
12565+ })
12435 }12566 }
12436 12567
12437 /// libaom `size_group_lookup[bsize]` for the block shapes this decoder's12568 /// libaom `size_group_lookup[bsize]` for the block shapes this decoder's
@@ -12467,18 +12598,24 @@ fn size_group_wh_matches_libaom_size_group_lookup() {
12467 }12598 }
12468 12599
12469 /// The default (2D) coefficient scan of a rectangular transform.12600 /// The default (2D) coefficient scan of a rectangular transform.
12470-fn rect_scan(w: usize, h: usize) -> &'static [u16] {12601+fn rect_scan(w: usize, h: usize) -> Result<&'static [u16]> {
12471- match (w, h) {12602+ Ok(match (w, h) {
12472 (32, 16) => &SCAN_32X16,12603 (32, 16) => &SCAN_32X16,
12473 (16, 32) => &SCAN_16X32,12604 (16, 32) => &SCAN_16X32,
12474 (16, 8) => &SCAN_16X8,12605 (16, 8) => &SCAN_16X8,
12475 (8, 16) => &SCAN_8X16,12606 (8, 16) => &SCAN_8X16,
12607+ (16, 4) => &SCAN_16X4,
12608+ (4, 16) => &SCAN_4X16,
12476 (8, 4) => &SCAN_8X4,12609 (8, 4) => &SCAN_8X4,
12477 (4, 8) => &SCAN_4X8,12610 (4, 8) => &SCAN_4X8,
12478 (32, 8) => &SCAN_32X8,12611 (32, 8) => &SCAN_32X8,
12479 (8, 32) => &SCAN_8X32,12612 (8, 32) => &SCAN_8X32,
12480- _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"),12613+ _ => {
12481- }12614+ return Err(unsupported(
12615+ "a rectangular transform unit whose shape has no coefficient scan table here",
12616+ ));
12617+ }
12618+ })
12482 }12619 }
12483 12620
12484 /// [`read_block_tx_size`] for a rectangular inter block (lane-inter4 r2):12621 /// [`read_block_tx_size`] for a rectangular inter block (lane-inter4 r2):
@@ -12640,7 +12777,7 @@ fn read_inter_plane_rect(
12640 read_coeffs_rect(12777 read_coeffs_rect(
12641 dec,12778 dec,
12642 &mut coding,12779 &mut coding,
12643- rect_scan(cw, ch),12780+ rect_scan(cw, ch)?,
12644 cw,12781 cw,
12645 ch,12782 ch,
12646 skip_ctx,12783 skip_ctx,
@@ -16902,18 +17039,26 @@ fn obmc_blend(
16902 /// always `is_interinter_compound_used`, so the function is always `true`17039 /// always `is_interinter_compound_used`, so the function is always `true`
16903 /// for `side` -- kept as a named call (rather than inlined `true`) so a17040 /// for `side` -- kept as a named call (rather than inlined `true`) so a
16904 /// future sub-8 block size does not silently misdecode a real stream.17041 /// future sub-8 block size does not silently misdecode a real stream.
16905-fn is_any_masked_compound_used_here(side: usize) -> bool {17042+fn is_any_masked_compound_used_here(bw: usize, bh: usize) -> bool {
16906- side.min(side) >= 817043+ // lane-inter16ab r4 (class sweep of the r3 CDF-row defect):
16907-}17044+ // `is_comp_ref_allowed(bsize)` is `AOMMIN(block_size_wide, block_size_high)
16908-17045+ // >= 8` on the block's TRUE footprint -- a 16x4/4x16 strip is NOT allowed,
16909-/// libaom's `BLOCK_SIZES_ALL` index of a `w`x`h` block (`common_data.h`'s own17046+ // so libaom writes no `comp_group_idx` symbol there at all. Keyed off the
16910-/// enum order) -- the row every bsize-indexed CDF (`compound_type_cdf`,17047+ // square `side` we read one the reference never wrote.
16911-/// `wedge_idx_cdf`) is read at. lane-intersub8 r4: these two used to be17048+ bw.min(bh) >= 8
16912-/// indexed by the caller's SQUARE envelope, so a 16x8 compound block read17049+}
16913-/// `BLOCK_16X16`'s row (class table-indexed-by-raw-size) and desynced the17050+
16914-/// tile at its first masked-compound rect block.17051+/// The `BLOCK_SIZES_ALL` index of a `bw x bh` block (libaom `enum BLOCK_SIZE`,
16915-fn bsize_index(w: usize, h: usize) -> Option<usize> {17052+/// `blockd.h`) -- the row every size-indexed inter CDF table
16916- Some(match (w, h) {17053+/// (`compound_type_cdf`, `wedge_idx_cdf`) is keyed by. Our `decode_inter_block`
17054+/// carries the enclosing SQUARE `side` for context purposes (the accepted
17055+/// strip corner-cut), so a 16x8 / 8x16 PARTITION_HORZ/VERT strip that reads
17056+/// one of those symbols off `side` alone takes BLOCK_16X16's row and desyncs
17057+/// (lane-inter16ab r3: a real 16x8 compound strip with `comp_group_idx == 1`,
17058+/// decode-order frame 5, our range 64901 vs the oracle's 47271 at the very
17059+/// next block's mode read).
17060+fn bsize_all_index(bw: usize, bh: usize) -> Option<usize> {
17061+ Some(match (bw, bh) {
16917 (4, 4) => 0,17062 (4, 4) => 0,
16918 (4, 8) => 1,17063 (4, 8) => 1,
16919 (8, 4) => 2,17064 (8, 4) => 2,
@@ -16940,33 +17085,20 @@ fn bsize_index(w: usize, h: usize) -> Option<usize> {
16940 })17085 })
16941 }17086 }
16942 17087
16943-/// `is_any_masked_compound_used` (libaom `reconinter.h`) on the block's TRUE
16944-/// footprint: `is_comp_ref_allowed` is `AOMMIN(bw, bh) >= 8`, and every
16945-/// shape that clears it has either a wedge or a DIFFWTD compound available.
16946-fn masked_compound_used_wh(w: usize, h: usize) -> bool {
16947- w.min(h) >= 8
16948-}
16949-
16950 /// `av1_wedge_params_lookup[bsize].wedge_types > 0` (libaom `reconinter.c`):17088 /// `av1_wedge_params_lookup[bsize].wedge_types > 0` (libaom `reconinter.c`):
16951-/// the shapes whose `compound_type` symbol is really coded. Everything else17089+/// the block sizes that carry a wedge codebook at all. A `compound_type`
16952-/// with a compound mask infers `COMPOUND_DIFFWTD` without a symbol.17090+/// symbol is written only for these; every other size infers
16953-fn wedge_used_wh(w: usize, h: usize) -> bool {17091+/// `COMPOUND_DIFFWTD`.
17092+fn wedge_used_bsize(bw: usize, bh: usize) -> bool {
16954 matches!(17093 matches!(
16955- (w, h),17094+ (bw, bh),
16956- (8, 8)17095+ (8, 8) | (8, 16) | (16, 8) | (16, 16) | (16, 32) | (32, 16) | (32, 32) | (8, 32) | (32, 8)
16957- | (8, 16)
16958- | (16, 8)
16959- | (16, 16)
16960- | (16, 32)
16961- | (32, 16)
16962- | (32, 32)
16963- | (8, 32)
16964- | (32, 8)
16965- | (16, 64)
16966- | (64, 16)
16967 )17096 )
16968 }17097 }
16969 17098
17099+
17100+
17101+
16970 /// Whether a compound reference pair is unidirectional (both references on17102 /// Whether a compound reference pair is unidirectional (both references on
16971 /// the same temporal side of the current frame) -- `has_uni_comp_refs`17103 /// the same temporal side of the current frame) -- `has_uni_comp_refs`
16972 /// (libaom `av1_reference_frame_utils.h`/`pred_common.c`'s own definition:17104 /// (libaom `av1_reference_frame_utils.h`/`pred_common.c`'s own definition:
@@ -17416,9 +17548,27 @@ fn decode_inter_block(
17416 // exactly what it read before.17548 // exactly what it read before.
17417 let (rmi, cmi) = at;17549 let (rmi, cmi) = at;
17418 let (px, py) = (at.1 * MI, at.0 * MI);17550 let (px, py) = (at.1 * MI, at.0 * MI);
17419- let (cpx, cpy) = (px / 2, py / 2);17551+ // lane-inter16ab r2: a 16x4 / 4x16 inter strip's chroma is the PAIR's
17552+ // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd
17553+ // strip (`is_chroma_reference`); every other block keeps its own.
17554+ let strip_chroma = INTER_STRIP_CHROMA.with(std::cell::Cell::take);
17555+ INTER_LAST_MC.with(|c| c.set(None));
17556+ let has_chroma = strip_chroma.is_none_or(|s| s.has_chroma);
17557+ let (cpx, cpy) = match strip_chroma {
17558+ Some(s) if s.has_chroma => (s.pair_mi.1 * MI / 2, s.pair_mi.0 * MI / 2),
17559+ _ => (px / 2, py / 2),
17560+ };
17420 let chroma_side = side / 2;17561 let chroma_side = side / 2;
17421- let (write_chroma_w, write_chroma_h) = (write_w / 2, write_h / 2);17562+ let (write_chroma_w, write_chroma_h) = match strip_chroma {
17563+ Some(s) if s.has_chroma => {
17564+ if s.horz {
17565+ (8, 4)
17566+ } else {
17567+ (4, 8)
17568+ }
17569+ }
17570+ _ => (write_w / 2, write_h / 2),
17571+ };
17422 17572
17423 if std::env::var_os("EC_AV1_TELL").is_some() {17573 if std::env::var_os("EC_AV1_TELL").is_some() {
17424 eprintln!(17574 eprintln!(
@@ -17442,7 +17592,12 @@ fn decode_inter_block(
17442 let (seg_mi_r, seg_mi_c) = (rmi, cmi);17592 let (seg_mi_r, seg_mi_c) = (rmi, cmi);
17443 let (seg_w_mi, seg_h_mi) = (write_w / 4, write_h / 4);17593 let (seg_w_mi, seg_h_mi) = (write_w / 4, write_h / 4);
17444 inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, false, true);17594 inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, false, true);
17445- let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;17595+ // libaom `read_skip_mode` (decodemv.c): `if (!is_comp_ref_allowed(bsize))
17596+ // return 0` -- a 16x4 / 4x16 strip (min(bw, bh) == 4, blockd.h:65) reads
17597+ // no `skip_mode` symbol at all.
17598+ let comp_allowed = write_w.min(write_h) >= 8;
17599+ let skip_mode =
17600+ skip_mode_present && comp_allowed && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
17446 if std::env::var_os("EC_AV1_SKIPMODE_DUMP").is_some() {17601 if std::env::var_os("EC_AV1_SKIPMODE_DUMP").is_some() {
17447 eprintln!(17602 eprintln!(
17448 "EC_SKIPMODE r={r} c={c} result={skip_mode} tell_after={}",17603 "EC_SKIPMODE r={r} c={c} result={skip_mode} tell_after={}",
@@ -17554,7 +17709,12 @@ fn decode_inter_block(
17554 );17709 );
17555 }17710 }
17556 let is_compound =17711 let is_compound =
17557- skip_mode || (reference_select && read_comp_mode(dec, cdfs, above_nbr, left_nbr));17712+ skip_mode
17713+ || (reference_select
17714+ // `is_comp_ref_allowed` (blockd.h:65) gates the
17715+ // `comp_mode` read exactly as it gates `skip_mode`.
17716+ && comp_allowed
17717+ && read_comp_mode(dec, cdfs, above_nbr, left_nbr));
17558 if is_compound {17718 if is_compound {
17559 let (ref0, ref1) = if skip_mode {17719 let (ref0, ref1) = if skip_mode {
17560 (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8)17720 (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8)
@@ -17756,7 +17916,7 @@ fn decode_inter_block(
17756 let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side);17916 let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side);
17757 let comp_group_idx = if !skip_mode17917 let comp_group_idx = if !skip_mode
17758 && enable_masked_compound17918 && enable_masked_compound
17759- && masked_compound_used_wh(write_w, write_h)17919+ && is_any_masked_compound_used_here(write_w, write_h)
17760 {17920 {
17761 dec.symbol(&mut cdfs.comp_group_idx[group_ctx])17921 dec.symbol(&mut cdfs.comp_group_idx[group_ctx])
17762 } else {17922 } else {
@@ -17789,11 +17949,11 @@ fn decode_inter_block(
17789 // writes NO `compound_type` symbol there and INFERS17949 // writes NO `compound_type` symbol there and INFERS
17790 // `COMPOUND_DIFFWTD` -- only the 1-bit `mask_type` literal17950 // `COMPOUND_DIFFWTD` -- only the 1-bit `mask_type` literal
17791 // follows. `None` here is exactly that inferred arm.17951 // follows. `None` here is exactly that inferred arm.
17792- // lane-intersub8 r4: the block's TRUE footprint, not the17952+ // lane-inter16ab r3: the row is this block's TRUE
17793- // square envelope -- `compound_type_cdf`/`wedge_idx_cdf` are17953+ // `BLOCK_SIZES_ALL` index, not the enclosing square `side`'s
17794- // `BLOCK_SIZES_ALL`-indexed.17954+ // -- a 16x8 strip reads `compound_type_cdf[BLOCK_16X8]`.
17795 let wedge_bsize =17955 let wedge_bsize =
17796- bsize_index(write_w, write_h).filter(|_| wedge_used_wh(write_w, write_h));17956+ bsize_all_index(write_w, write_h).filter(|_| wedge_used_bsize(write_w, write_h));
17797 let compound_type = match wedge_bsize {17957 let compound_type = match wedge_bsize {
17798 Some(b) => dec.symbol(&mut cdfs.compound_type[b]),17958 Some(b) => dec.symbol(&mut cdfs.compound_type[b]),
17799 None => 1,17959 None => 1,
@@ -17801,20 +17961,26 @@ fn decode_inter_block(
17801 if let Some(wedge_bsize) = wedge_bsize.filter(|_| compound_type == 0) {17961 if let Some(wedge_bsize) = wedge_bsize.filter(|_| compound_type == 0) {
17802 // COMPOUND_WEDGE: lane-wedge r3, codebook checksum-17962 // COMPOUND_WEDGE: lane-wedge r3, codebook checksum-
17803 // verified vs independent C dump (wedge.rs).17963 // verified vs independent C dump (wedge.rs).
17804- if write_w != write_h {
17805- // lane-intersub8 r4: the wedge codebook here is built
17806- // per SQUARE side only; a rect block's own codebook
17807- // (BLOCK_16X8 etc.) is a different mask set.
17808- return Err(unsupported(
17809- "a COMPOUND_WEDGE mask on a non-square inter block (rect wedge codebook unimplemented)",
17810- ));
17811- }
17812 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]);17964 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]);
17813 let wedge_sign = dec.literal(1);17965 let wedge_sign = dec.literal(1);
17814 WEDGE_HITS.with(|c| c.set(c.get() + 1));17966 WEDGE_HITS.with(|c| c.set(c.get() + 1));
17967+ if let Some(k) = rect_wedge_slot(write_w, write_h) {
17968+ RECT_WEDGE_HITS.with(|c| {
17969+ let mut a = c.get();
17970+ a[k] += 1;
17971+ c.set(a);
17972+ });
17973+ }
17974+ // lane-inter16ab r5: the codebook row is this block's TRUE
17975+ // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for
17976+ // h>w, hltw for h<w, plus that bsize's own signflip row).
17977+ // Masks are padded to stride `max(bw,bh) == side`, so the
17978+ // square blend below indexes them unchanged and the
17979+ // padding never reaches the frame (only `write_w x
17980+ // write_h` is written out).
17815 wedge_mask = Some(17981 wedge_mask = Some(
17816 crate::wedge::wedge_masks()17982 crate::wedge::wedge_masks()
17817- .codebook(side)17983+ .codebook(write_w, write_h)
17818 .mask(wedge_sign as usize, wedge_index as usize),17984 .mask(wedge_sign as usize, wedge_index as usize),
17819 );17985 );
17820 } else {17986 } else {
@@ -18455,7 +18621,7 @@ fn decode_inter_block(
18455 read_inter_plane_rect(18621 read_inter_plane_rect(
18456 dec,18622 dec,
18457 cdfs,18623 cdfs,
18458- rect_inter_luma_set(tw, th),18624+ rect_inter_luma_set(tw, th)?,
18459 (tw, th),18625 (tw, th),
18460 side,18626 side,
18461 0,18627 0,
@@ -18485,7 +18651,7 @@ fn decode_inter_block(
18485 let (grid, tx_type) = read_inter_plane_rect(18651 let (grid, tx_type) = read_inter_plane_rect(
18486 dec,18652 dec,
18487 cdfs,18653 cdfs,
18488- rect_inter_luma_set(write_w, write_h),18654+ rect_inter_luma_set(write_w, write_h)?,
18489 (write_w, write_h),18655 (write_w, write_h),
18490 side,18656 side,
18491 0,18657 0,
@@ -18529,7 +18695,7 @@ fn decode_inter_block(
18529 &read_inter_plane_rect(18695 &read_inter_plane_rect(
18530 dec,18696 dec,
18531 cdfs,18697 cdfs,
18532- rect_inter_chroma_set(write_chroma_w, write_chroma_h),18698+ rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,
18533 (uw, uh),18699 (uw, uh),
18534 chroma_side,18700 chroma_side,
18535 1,18701 1,
@@ -18551,7 +18717,7 @@ fn decode_inter_block(
18551 &read_inter_plane_rect(18717 &read_inter_plane_rect(
18552 dec,18718 dec,
18553 cdfs,18719 cdfs,
18554- rect_inter_chroma_set(write_chroma_w, write_chroma_h),18720+ rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,
18555 (uw, uh),18721 (uw, uh),
18556 chroma_side,18722 chroma_side,
18557 2,18723 2,
@@ -18826,7 +18992,13 @@ fn decode_inter_block(
18826 // `enable_interintra_wedge` seq bit -- the wedge flag18992 // `enable_interintra_wedge` seq bit -- the wedge flag
18827 // (`av1_is_wedge_used(bsize)` holds for 16x16/32x32).18993 // (`av1_is_wedge_used(bsize)` holds for 16x16/32x32).
18828 let ii = dec.symbol(&mut cdfs.interintra_mode[bsize_group]) as u8;18994 let ii = dec.symbol(&mut cdfs.interintra_mode[bsize_group]) as u8;
18829- let wedge_bsize = if side == 16 { 6 } else { 9 };18995+ // lane-inter16ab r3 (same class as the compound
18996+ // `compound_type` row below): the row is the block's TRUE
18997+ // `BLOCK_SIZES_ALL` index -- a 16x8 / 32x16 interintra
18998+ // strip is BLOCK_16X8 / BLOCK_32X16, not its square
18999+ // `side`'s BLOCK_16X16 / BLOCK_32X32.
19000+ let wedge_bsize = bsize_all_index(write_w, write_h)
19001+ .expect("interintra shape is a BLOCK_SIZES_ALL size");
18830 let wedge = dec.symbol(&mut cdfs.wedge_interintra[wedge_bsize]) == 1;19002 let wedge = dec.symbol(&mut cdfs.wedge_interintra[wedge_bsize]) == 1;
18831 if wedge {19003 if wedge {
18832 // lane-wii r2 (spec 5.11.25): `wedge_index` is an19004 // lane-wii r2 (spec 5.11.25): `wedge_index` is an
@@ -18835,9 +19007,19 @@ fn decode_inter_block(
18835 // INTERINTRA_WEDGE_SIGN 0 (blockd.h).19007 // INTERINTRA_WEDGE_SIGN 0 (blockd.h).
18836 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]);19008 let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]);
18837 WII_HITS.with(|c| c.set(c.get() + 1));19009 WII_HITS.with(|c| c.set(c.get() + 1));
19010+ if let Some(k) = rect_wedge_slot(write_w, write_h) {
19011+ RECT_WII_HITS.with(|c| {
19012+ let mut a = c.get();
19013+ a[k] += 1;
19014+ c.set(a);
19015+ });
19016+ }
19017+ // lane-inter16ab r5: true-footprint codebook row,
19018+ // mask padded to stride `max(bw,bh) == side` -- see
19019+ // the compound site's own comment.
18838 wedge_mask = Some((19020 wedge_mask = Some((
18839 crate::wedge::wedge_masks()19021 crate::wedge::wedge_masks()
18840- .codebook(side)19022+ .codebook(write_w, write_h)
18841 .mask(0, wedge_index as usize),19023 .mask(0, wedge_index as usize),
18842 side,19024 side,
18843 ));19025 ));
@@ -18879,6 +19061,9 @@ fn decode_inter_block(
18879 // motion_mode symbol is NOT read (SIMPLE_TRANSLATION implied).19061 // motion_mode symbol is NOT read (SIMPLE_TRANSLATION implied).
18880 let motion_mode_eligible = switchable_motion_mode19062 let motion_mode_eligible = switchable_motion_mode
18881 && !skip_mode19063 && !skip_mode
19064+ // `is_motion_variation_allowed_bsize` (blockd.h:1455):
19065+ // min(bw, bh) >= 8, false for a 16x4 / 4x16 strip.
19066+ && write_w.min(write_h) >= 8
18882 && interintra_mode.is_none()19067 && interintra_mode.is_none()
18883 && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty()19068 && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty()
18884 || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1)19069 || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1)
@@ -19187,6 +19372,11 @@ fn decode_inter_block(
19187 }19372 }
19188 }19373 }
19189 19374
19375+ // lane-inter16ab r2: `is_sub8x8_inter`'s neighbour walk reads the
19376+ // PREVIOUS strip's `mv`/`ref_frame`/`interp_filters`
19377+ // (reconinter_template.inc:75-82); record them for the next 1:4
19378+ // strip, which is the only reader.
19379+ INTER_LAST_MC.with(|c| c.set(Some((ref_frame, mv, h_filter, v_filter))));
19190 let mut pred_y = vec![0u16; side * side];19380 let mut pred_y = vec![0u16; side * side];
19191 let mut pred_u = vec![0u16; chroma_side * chroma_side];19381 let mut pred_u = vec![0u16; chroma_side * chroma_side];
19192 let mut pred_v = vec![0u16; chroma_side * chroma_side];19382 let mut pred_v = vec![0u16; chroma_side * chroma_side];
@@ -19360,6 +19550,46 @@ fn decode_inter_block(
19360 interintra_blend(v, cpx, cpy, chroma_side, ii, wedge_mask, &mut pred_v);19550 interintra_blend(v, cpx, cpy, chroma_side, ii, wedge_mask, &mut pred_v);
19361 }19551 }
19362 19552
19553+ // lane-inter16ab r2: libaom `build_inter_predictors_sub8x8`
19554+ // (reconinter_template.inc:87-160). A 4:2:0 chroma block under a
19555+ // 16x4 (4x16) luma pair covers TWO luma blocks, so it is built in
19556+ // `b4_w x b4_h` = 8x2 (2x8) pieces, each from its own strip's
19557+ // mv/ref/filters. The bottom (right) piece is this strip's own mv
19558+ // over its own rows, which the whole-block prediction above
19559+ // already wrote there (MC is position-invariant for a fixed mv),
19560+ // so only the FIRST piece has to be rebuilt -- and only when
19561+ // `is_sub8x8_inter` holds, i.e. the previous strip was itself a
19562+ // single-reference inter block (`prev`), else libaom falls
19563+ // through to the ordinary whole-block predictor.
19564+ if let Some(s) = strip_chroma.filter(|s| s.has_chroma)
19565+ && let Some((prev_ref, prev_mv, prev_h, prev_v)) = s.prev
19566+ && luma_scale == mc::REF_NO_SCALE
19567+ {
19568+ let (piece_w, piece_h) = if s.horz { (8usize, 2usize) } else { (2usize, 8usize) };
19569+ let (_, prev_u, prev_v_plane) = ref_planes(prev_ref, ref_y, ref_u, ref_v, other_refs)?;
19570+ for (src, dst) in [(prev_u, &mut pred_u), (prev_v_plane, &mut pred_v)] {
19571+ let mut piece = vec![0u16; piece_w * piece_h];
19572+ mc::predict_with_filters(
19573+ &src.data,
19574+ src.width,
19575+ src.true_width,
19576+ src.true_height,
19577+ mv_to_q4(cpx, prev_mv.1, false),
19578+ mv_to_q4(cpy, prev_mv.0, false),
19579+ piece_w,
19580+ piece_h,
19581+ prev_h,
19582+ prev_v,
19583+ &mut piece,
19584+ );
19585+ for row in 0..piece_h {
19586+ dst[row * chroma_side..row * chroma_side + piece_w]
19587+ .copy_from_slice(&piece[row * piece_w..(row + 1) * piece_w]);
19588+ }
19589+ }
19590+ INTER16_SUB8_PIECE_HITS.with(|c| c.set(c.get() + 1));
19591+ }
19592+
19363 // lane-inter4 r2: a rectangular strip's transform tree starts from19593 // lane-inter4 r2: a rectangular strip's transform tree starts from
19364 // its own rect `max_txsize_rect_lookup` entry, not a square one.19594 // its own rect `max_txsize_rect_lookup` entry, not a square one.
19365 let rect_tu = (write_w, write_h) != (side, side);19595 let rect_tu = (write_w, write_h) != (side, side);
@@ -19396,24 +19626,26 @@ fn decode_inter_block(
19396 &pred_y,19626 &pred_y,
19397 &vec![0i32; side * side],19627 &vec![0i32; side * side],
19398 );19628 );
19399- u.reconstruct_mc_rect(19629+ if has_chroma {
19400- cpx,19630+ u.reconstruct_mc_rect(
19401- cpy,19631+ cpx,
19402- chroma_side,19632+ cpy,
19403- write_chroma_w,19633+ chroma_side,
19404- write_chroma_h,19634+ write_chroma_w,
19405- &pred_u,19635+ write_chroma_h,
19406- &vec![0i32; chroma_side * chroma_side],19636+ &pred_u,
19407- );19637+ &vec![0i32; chroma_side * chroma_side],
19408- v.reconstruct_mc_rect(19638+ );
19409- cpx,19639+ v.reconstruct_mc_rect(
19410- cpy,19640+ cpx,
19411- chroma_side,19641+ cpy,
19412- write_chroma_w,19642+ chroma_side,
19413- write_chroma_h,19643+ write_chroma_w,
19414- &pred_v,19644+ write_chroma_h,
19415- &vec![0i32; chroma_side * chroma_side],19645+ &pred_v,
19416- );19646+ &vec![0i32; chroma_side * chroma_side],
19647+ );
19648+ }
19417 luma_grid = vec![0i32; side * side];19649 luma_grid = vec![0i32; side * side];
19418 u_grid = vec![0i32; chroma_side * chroma_side];19650 u_grid = vec![0i32; chroma_side * chroma_side];
19419 v_grid = vec![0i32; chroma_side * chroma_side];19651 v_grid = vec![0i32; chroma_side * chroma_side];
@@ -19426,6 +19658,18 @@ fn decode_inter_block(
19426 } else {19658 } else {
19427 neighbours.around_mi(at, side)19659 neighbours.around_mi(at, side)
19428 };19660 };
19661+ // lane-inter16ab r2: the pair's chroma transform sits at the
19662+ // EVEN strip's mi origin and spans both strips, so its
19663+ // above/left coefficient context is the pair's, not this
19664+ // strip's row.
19665+ let around_c = match strip_chroma {
19666+ Some(s) if s.has_chroma => neighbours.around_mi_rect(
19667+ s.pair_mi,
19668+ if s.horz { 16 } else { 8 },
19669+ if s.horz { 8 } else { 16 },
19670+ ),
19671+ _ => around,
19672+ };
19429 let luma_tx_type;19673 let luma_tx_type;
19430 if let Some(leaves) = vartx_leaves.clone() {19674 if let Some(leaves) = vartx_leaves.clone() {
19431 // spec 5.11.17's transform tree, leaf by leaf in the order19675 // spec 5.11.17's transform tree, leaf by leaf in the order
@@ -19479,7 +19723,7 @@ fn decode_inter_block(
19479 read_inter_plane_rect(19723 read_inter_plane_rect(
19480 dec,19724 dec,
19481 cdfs,19725 cdfs,
19482- rect_inter_luma_set(tw, th),19726+ rect_inter_luma_set(tw, th)?,
19483 (tw, th),19727 (tw, th),
19484 side,19728 side,
19485 0,19729 0,
@@ -19509,7 +19753,7 @@ fn decode_inter_block(
19509 let (grid, tx_type) = read_inter_plane_rect(19753 let (grid, tx_type) = read_inter_plane_rect(
19510 dec,19754 dec,
19511 cdfs,19755 cdfs,
19512- rect_inter_luma_set(write_w, write_h),19756+ rect_inter_luma_set(write_w, write_h)?,
19513 (write_w, write_h),19757 (write_w, write_h),
19514 side,19758 side,
19515 0,19759 0,
@@ -19543,7 +19787,16 @@ fn decode_inter_block(
19543 None,19787 None,
19544 )?;19788 )?;
19545 }19789 }
19546- if rect_tu {19790+ if !has_chroma {
19791+ // `is_chroma_reference` is false for this strip: libaom's
19792+ // plane loop (decodeframe.c
19793+ // `predict_and_reconstruct_intra_block`/
19794+ // `reconstruct_inter_block`'s `for (plane...)` guarded by
19795+ // `xd->is_chroma_ref`) codes NO chroma transform here, so
19796+ // neither symbol nor context exists.
19797+ u_grid = vec![0i32; chroma_side * chroma_side];
19798+ v_grid = vec![0i32; chroma_side * chroma_side];
19799+ } else if rect_tu {
19547 // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a19800 // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a
19548 // 2:1 strip is the strip's own rect chroma size (16x8 /19801 // 2:1 strip is the strip's own rect chroma size (16x8 /
19549 // 8x16), one unit for the whole block, and it codes no19802 // 8x16), one unit for the whole block, and it codes no
@@ -19553,11 +19806,11 @@ fn decode_inter_block(
19553 &read_inter_plane_rect(19806 &read_inter_plane_rect(
19554 dec,19807 dec,
19555 cdfs,19808 cdfs,
19556- rect_inter_chroma_set(write_chroma_w, write_chroma_h),19809+ rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,
19557 (uw, uh),19810 (uw, uh),
19558 chroma_side,19811 chroma_side,
19559 1,19812 1,
19560- around[1],19813+ around_c[1],
19561 mode_for_tx,19814 mode_for_tx,
19562 u,19815 u,
19563 cpx,19816 cpx,
@@ -19575,11 +19828,11 @@ fn decode_inter_block(
19575 &read_inter_plane_rect(19828 &read_inter_plane_rect(
19576 dec,19829 dec,
19577 cdfs,19830 cdfs,
19578- rect_inter_chroma_set(write_chroma_w, write_chroma_h),19831+ rect_inter_chroma_set(write_chroma_w, write_chroma_h)?,
19579 (uw, uh),19832 (uw, uh),
19580 chroma_side,19833 chroma_side,
19581 2,19834 2,
19582- around[2],19835+ around_c[2],
19583 mode_for_tx,19836 mode_for_tx,
19584 v,19837 v,
19585 cpx,19838 cpx,
@@ -19640,6 +19893,16 @@ fn decode_inter_block(
19640 // skip path above (which only needed a clipped write of an19893 // skip path above (which only needed a clipped write of an
19641 // already-square-predicted buffer). Named refusal instead of a19894 // already-square-predicted buffer). Named refusal instead of a
19642 // silently wrong square-shaped intra prediction.19895 // silently wrong square-shaped intra prediction.
19896+ // lane-inter16ab r2: `decode_intra_rect_in_inter` has no chroma-pair
19897+ // path (it predicts and codes chroma at the strip's own halved
19898+ // footprint), so an INTRA 16x4 / 4x16 strip inside a 1:4 partition is
19899+ // refused by name rather than decoded with a 8x2 chroma transform
19900+ // libaom never coded.
19901+ if write_w.min(write_h) < 8 {
19902+ return Err(unsupported(
19903+ "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)",
19904+ ));
19905+ }
19643 if write_w != side || write_h != side {19906 if write_w != side || write_h != side {
19644 // lane-intrarect r1: the strip decodes through its own rect19907 // lane-intrarect r1: the strip decodes through its own rect
19645 // machinery ([`decode_intra_rect_in_inter`] -> the key-frame19908 // machinery ([`decode_intra_rect_in_inter`] -> the key-frame
@@ -19790,8 +20053,12 @@ fn decode_inter_block(
19790 // -- `palette_mode_ctx`/`palette_uv_mode_ctx` hardcoded 0, provably20053 // -- `palette_mode_ctx`/`palette_uv_mode_ctx` hardcoded 0, provably
19791 // safe since a nonzero neighbour `palette_size` would already have20054 // safe since a nonzero neighbour `palette_size` would already have
19792 // refused the decode that produced it.20055 // refused the decode that produced it.
20056+ // lane-inter16ab r4 (class sweep): `av1_get_palette_bsize_ctx` is keyed
20057+ // by the block's TRUE footprint -- a rect strip's row is not its
20058+ // enclosing square's, and a 16x4 strip (64 pixels) reads no palette
20059+ // symbol at all.
19793 if allow_screen_content_tools20060 if allow_screen_content_tools
19794- && let Some(bsize_ctx) = palette_bsize_ctx(side)20061+ && let Some(bsize_ctx) = palette_bsize_ctx_wh(write_w, write_h)
19795 {20062 {
19796 if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][0]) != 0 {20063 if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][0]) != 0 {
19797 return Err(unsupported(20064 return Err(unsupported(
@@ -19815,7 +20082,9 @@ fn decode_inter_block(
19815 let mut filter_intra = None;20082 let mut filter_intra = None;
19816 if mode == DC_PRED20083 if mode == DC_PRED
19817 && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get)20084 && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get)
19818- && let Some(class) = filter_intra_size_class(side)20085+ // lane-inter16ab r4 (class sweep): `cdf::FILTER_INTRA`'s row is the
20086+ // true `BLOCK_SIZES_ALL` class of this strip, not its square side's.
20087+ && let Some(class) = filter_intra_size_class_rect(write_w, write_h)
19819 && dec.symbol(&mut cdfs.filter_intra[class]) != 020088 && dec.symbol(&mut cdfs.filter_intra[class]) != 0
19820 {20089 {
19821 FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));20090 FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));
@@ -20056,6 +20325,14 @@ fn decode_inter_block(
20056 rmi, cmi, dec.debug_bitpos(), dec.debug_state().020325 rmi, cmi, dec.debug_bitpos(), dec.debug_state().0
20057 );20326 );
20058 }20327 }
20328+ // lane-inter16ab r2: the pair's chroma coefficient context spans BOTH
20329+ // strips (mirroring the intra `decode_rect4_16` path), and the even
20330+ // strip's own record wrote empty chroma state over those cells -- this
20331+ // rewrite is what libaom's single `av1_set_contexts` call for the 8x4
20332+ // (4x8) chroma unit leaves behind.
20333+ let pair_chroma = strip_chroma
20334+ .filter(|s| s.has_chroma)
20335+ .map(|s| (s, neighbour_state(&u_grid), neighbour_state(&v_grid)));
20059 if vartx_leaves.is_some() {20336 if vartx_leaves.is_some() {
20060 // Plane 0 is already correct per transform unit20337 // Plane 0 is already correct per transform unit
20061 // ([`Neighbours::record_mi_luma`] above); this writes everything else20338 // ([`Neighbours::record_mi_luma`] above); this writes everything else
@@ -20072,6 +20349,32 @@ fn decode_inter_block(
20072 &[luma_grid, u_grid, v_grid],20349 &[luma_grid, u_grid, v_grid],
20073 );20350 );
20074 }20351 }
20352+ if let Some((s, u_state, v_state)) = pair_chroma {
20353+ let (pw, ph) = if s.horz { (16usize, 8usize) } else { (8, 16) };
20354+ let round_up_even = |n: usize| n.div_ceil(2) * 2;
20355+ let (bound_h, bound_w) = (
20356+ round_up_even(neighbours.mi_rows),
20357+ round_up_even(neighbours.mi_cols),
20358+ );
20359+ for cell in 0..(ph / MI) {
20360+ if s.pair_mi.0 + cell < bound_h
20361+ && let Some(slot) = neighbours.left.get_mut(s.pair_mi.0 + cell)
20362+ {
20363+ slot[1] = u_state;
20364+ slot[2] = v_state;
20365+ }
20366+ }
20367+ for cell in 0..(pw / MI) {
20368+ if s.pair_mi.1 + cell < bound_w
20369+ && let Some(slot) = neighbours.above.get_mut(s.pair_mi.1 + cell)
20370+ {
20371+ slot[1] = u_state;
20372+ slot[2] = v_state;
20373+ }
20374+ }
20375+ neighbours.record_uv_mode_mi(s.pair_mi.0, s.pair_mi.1, pw / MI, ph / MI, uv_predict_mode);
20376+ INTER16_CHROMA_PAIR_HITS.with(|c| c.set(c.get() + 1));
20377+ }
20075 neighbours.record_inter_rect_mi(20378 neighbours.record_inter_rect_mi(
20076 at,20379 at,
20077 write_w / MI,20380 write_w / MI,
@@ -21416,7 +21719,7 @@ fn decode_inter_block8(
21416 let group_ctx = get_comp_group_idx_context(neighbours, leaf_mi, SIDE);21719 let group_ctx = get_comp_group_idx_context(neighbours, leaf_mi, SIDE);
21417 let comp_group_idx = if !skip_mode21720 let comp_group_idx = if !skip_mode
21418 && enable_masked_compound21721 && enable_masked_compound
21419- && is_any_masked_compound_used_here(SIDE)21722+ && is_any_masked_compound_used_here(SIDE, SIDE)
21420 {21723 {
21421 dec.symbol(&mut cdfs.comp_group_idx[group_ctx])21724 dec.symbol(&mut cdfs.comp_group_idx[group_ctx])
21422 } else {21725 } else {
@@ -21439,7 +21742,7 @@ fn decode_inter_block8(
21439 WEDGE_HITS.with(|c| c.set(c.get() + 1));21742 WEDGE_HITS.with(|c| c.set(c.get() + 1));
21440 wedge_mask = Some(21743 wedge_mask = Some(
21441 crate::wedge::wedge_masks()21744 crate::wedge::wedge_masks()
21442- .codebook(SIDE)21745+ .codebook(SIDE, SIDE)
21443 .mask(wedge_sign as usize, wedge_index as usize),21746 .mask(wedge_sign as usize, wedge_index as usize),
21444 );21747 );
21445 } else {21748 } else {
@@ -22033,7 +22336,7 @@ fn decode_inter_block8(
22033 WII_HITS.with(|c| c.set(c.get() + 1));22336 WII_HITS.with(|c| c.set(c.get() + 1));
22034 wedge_mask = Some((22337 wedge_mask = Some((
22035 crate::wedge::wedge_masks()22338 crate::wedge::wedge_masks()
22036- .codebook(SIDE)22339+ .codebook(SIDE, SIDE)
22037 .mask(0, wedge_index as usize),22340 .mask(0, wedge_index as usize),
22038 SIDE,22341 SIDE,
22039 ));22342 ));
@@ -23942,9 +24245,96 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
23942 inter_leaf8!(at16, br);24245 inter_leaf8!(at16, br);
23943 }24246 }
23944 }24247 }
24248+ } else if part16 == PARTITION_HORZ_4
24249+ || part16 == PARTITION_VERT_4
24250+ {
24251+ // lane-inter16ab r2: four 16x4 (4x16) INTER
24252+ // strips. libaom `decode_partition`
24253+ // (decodeframe.c, PARTITION_HORZ_4/VERT_4)
24254+ // walks them top to bottom (left to right)
24255+ // with its own `i > 0` frame-edge break.
24256+ //
24257+ // Each strip is >= 8 in one dimension only,
24258+ // so `is_comp_ref_allowed`,
24259+ // `is_motion_variation_allowed_bsize`
24260+ // (blockd.h:65/1455, min(bw, bh) >= 8) and
24261+ // `is_interintra_allowed_bsize` (BLOCK_8X8..
24262+ // BLOCK_32X32 in enum order, which excludes
24263+ // BLOCK_16X4 = 17) are all false: no
24264+ // skip_mode, no comp_mode, no OBMC/warp and
24265+ // no interintra symbol is read -- gated in
24266+ // `decode_inter_block` off `write_w`/
24267+ // `write_h`.
24268+ //
24269+ // CHROMA is the pair's:
24270+ // `is_chroma_reference`
24271+ // (av1_common_int.h:1454) is false on the
24272+ // even strips, and the odd one codes one 8x4
24273+ // (4x8) chroma transform at the pair's
24274+ // origin, built from BOTH strips' motion
24275+ // (`is_sub8x8_inter`).
24276+ let horz = part16 == PARTITION_HORZ_4;
24277+ let (mi_row0, mi_col0) = sub16_to_mi(at16);
24278+ let (bw, bh) = if horz { (16usize, 4usize) } else { (4usize, 16usize) };
24279+ for i in 0..4usize {
24280+ let at_mi = if horz {
24281+ (mi_row0 + i, mi_col0)
24282+ } else {
24283+ (mi_row0, mi_col0 + i)
24284+ };
24285+ if i > 0
24286+ && (at_mi.0 >= mi_rows as usize
24287+ || at_mi.1 >= mi_cols as usize)
24288+ {
24289+ break;
24290+ }
24291+ let strip_has_chroma = i % 2 == 1;
24292+ let pair_mi = if !strip_has_chroma {
24293+ at_mi
24294+ } else if horz {
24295+ (at_mi.0 - 1, at_mi.1)
24296+ } else {
24297+ (at_mi.0, at_mi.1 - 1)
24298+ };
24299+ INTER_STRIP_CHROMA.with(|c| {
24300+ c.set(Some(InterStripChroma {
24301+ has_chroma: strip_has_chroma,
24302+ horz,
24303+ pair_mi,
24304+ prev: if strip_has_chroma {
24305+ INTER_LAST_MC.with(std::cell::Cell::get)
24306+ } else {
24307+ None
24308+ },
24309+ }))
24310+ });
24311+ inter_piece!(
24312+ at_mi,
24313+ SUB,
24314+ TxbSet::Luma16,
24315+ if reduced_tx_set {
24316+ TxbSet::Luma16Inter
24317+ } else {
24318+ TxbSet::Luma16InterSet1
24319+ },
24320+ TxbSet::Chroma8,
24321+ TX16,
24322+ TX8,
24323+ &scan16,
24324+ &scan8,
24325+ 1,
24326+ bw,
24327+ bh
24328+ );
24329+ if horz {
24330+ INTER16_HORZ4_HITS.with(|c| c.set(c.get() + 1));
24331+ } else {
24332+ INTER16_VERT4_HITS.with(|c| c.set(c.get() + 1));
24333+ }
24334+ }
23945 } else if part16 != PARTITION_SPLIT {24335 } else if part16 != PARTITION_SPLIT {
23946 return Err(unsupported(24336 return Err(unsupported(
23947- "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)",24337+ "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4",
23948 ));24338 ));
23949 } else {24339 } else {
23950 if has_cols16 && has_rows16 {24340 if has_cols16 && has_rows16 {
crates/ec-av1/src/refusal_inventory.rsmodified+16 -9
@@ -37,7 +37,9 @@ const REFUSALS: &[&str] = &[
37 "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes only inter 4x4 sub-blocks there)",37 "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes only inter 4x4 sub-blocks there)",
38 "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition (this decoder codes only inter sub-blocks there)",38 "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition (this decoder codes only inter sub-blocks there)",
39 "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",39 "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",
40- "a COMPOUND_WEDGE mask on a non-square inter block (rect wedge codebook unimplemented)",40+ "a rectangular inter luma transform unit whose shape has no coefficient table set here",
41+ "a rectangular inter chroma transform unit whose shape has no coefficient table set here",
42+ "a rectangular transform unit whose shape has no coefficient scan table here",
41 "a 32x32 partition type this decoder does not code (value={part32})",43 "a 32x32 partition type this decoder does not code (value={part32})",
42 "a Golomb tail longer than this decoder reads",44 "a Golomb tail longer than this decoder reads",
43 "a tx_type symbol outside its CDF's own set: {t}",45 "a tx_type symbol outside its CDF's own set: {t}",
@@ -69,14 +71,19 @@ const REFUSALS: &[&str] = &[
69 "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units",71 "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units",
70 "an inter frame with no key frame before it",72 "an inter frame with no key frame before it",
71 "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 "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)",
72- // lane-inter16ab r1 lifted the AB half (HORZ_A/HORZ_B/VERT_A/VERT_B at74+ // lane-inter16ab r1 lifted the AB half and r2 the 1:4 half (four 16x4 /
73- // the 16x16 level of an inter frame: two 8x8 inter leaves plus one true75+ // 4x16 inter strips, their 8x4/4x8 chroma pair built from BOTH strips'
74- // 16x8/8x16 inter strip, gate76+ // motion vectors -- gate
75- // `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact`).77+ // `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact`).
76- // What is left is the 1:4 pair, whose 16x4/4x16 strips need the sub-878+ // Two narrower refusals are what is left of that shape:
77- // inter chroma-pair path (odd-strip `is_chroma_reference`, chroma built79+ "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4",
78- // from BOTH strips' MVs) that no inter block writer has yet.80+ // r2 residue: `vartx_leaves` is a list of SQUARE units, and
79- "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)",81+ // `sub_tx_size_map[TX_16X4]` is the rectangular TX_8X4 -- the split tree
82+ // and its per-unit residual reader both need rect leaves.
83+ // r2 residue: `decode_intra_rect_in_inter` codes chroma at the strip's own
84+ // halved footprint, which for a 16x4 strip is an 8x2 transform libaom
85+ // never wrote (its chroma is the PAIR's 8x4, coded by the odd strip).
86+ "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)",
80 "an intra mode this decoder does not code (round 2)",87 "an intra mode this decoder does not code (round 2)",
81 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the88 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the
82 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);89 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);
crates/ec-av1/src/stream.rsmodified+511 -0
@@ -86,6 +86,25 @@ pub fn rect_intrabc_reads() -> usize {
86 crate::decode::rect_intrabc_reads()86 crate::decode::rect_intrabc_reads()
87 }87 }
88 88
89+/// lane-inter16ab r4: RECTANGULAR var-tx leaves with a 4-px axis, `[8x4, 4x8]`
90+/// -- what `sub_tx_size_map[TX_16X4] == TX_8X4` produces when a 16x16-level
91+/// 1:4 inter strip splits its transform.
92+pub fn vartx_rect_leaf4_hits() -> [usize; 2] {
93+ crate::decode::vartx_rect_leaf4_hits()
94+}
95+
96+/// lane-inter16ab r5: COMPOUND_WEDGE / wedge-INTERINTRA blocks that used a
97+/// RECTANGULAR wedge codebook row, per shape (`RECT_WEDGE_SHAPES` order:
98+/// 8x16, 16x8, 16x32, 32x16, 8x32, 32x8).
99+pub fn rect_wedge_hits() -> [usize; 6] {
100+ crate::decode::rect_wedge_hits()
101+}
102+
103+/// lane-inter16ab r5: the wedge-interintra half of [`rect_wedge_hits`].
104+pub fn rect_wii_hits() -> [usize; 6] {
105+ crate::decode::rect_wii_hits()
106+}
107+
89 pub fn rect4_32_counters() -> (usize, usize, usize) {108 pub fn rect4_32_counters() -> (usize, usize, usize) {
90 (109 (
91 crate::decode::rect4_32_horz_hits(),110 crate::decode::rect4_32_horz_hits(),
@@ -9420,6 +9439,296 @@ mod tests {
9420 }9439 }
9421 9440
9422 9441
9442+
9443+ #[test]
9444+ // lane-inter16ab r2: the 16x16-level 1:4 partitions on an INTER frame --
9445+ // PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 16x16, i.e. two 8x8 inter
9446+ // leaves plus one true 16x8/8x16 inter strip. Every decode-order frame is
9447+ // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped,
9448+ // out-of-scope mismatches fail the gate, and EACH of the four arms must
9449+ // have fired on a pixel-exact attempt (RD picking only HORZ_A is not
9450+ // proof of four). `--min-partition-size=4` is what lets aomenc's RD reach
9451+ // `PARTITION_HORZ_4`/`_VERT_4` at BLOCK_16X16 (16x4 / 4x16 inter strips);
9452+ // the last two counters are the chroma half of the claim -- the odd
9453+ // strip's `is_chroma_reference` pair and the pairs whose chroma was built
9454+ // from two different strips' motion vectors
9455+ // (`build_inter_predictors_sub8x8`).
9456+ fn a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact() {
9457+ const NAME: &str =
9458+ "a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact";
9459+ let _gate_lock = lock_gate_counters();
9460+ if !have_ffmpeg() {
9461+ eprintln!("SKIP {NAME}: no ffmpeg");
9462+ return;
9463+ }
9464+ if !have_aomenc() {
9465+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
9466+ return;
9467+ }
9468+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
9469+ // Per arm, over both bit depths: how many pixel-exact attempts fired
9470+ // it at least once.
9471+ let mut arms_total = [0u32; 5];
9472+ // lane-inter16ab r5: attempts refused on "a non-skip rectangular
9473+ // (HORZ/VERT/HORZ_B) strip needs rectangular residual coding".
9474+ let mut rect_residual_refusals = 0u32;
9475+ for bit_depth in [8u32, 10u32] {
9476+ let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =
9477+ (0u32, 0u32, 0u32, 0u32);
9478+ let mut arms_proved = [0u32; 5];
9479+ // lane-inter16ab r4: a 4-recipe widening (fine `sin(X/3)` stripes
9480+ // at cq 8..14, both depths) was measured and REMOVED again -- every
9481+ // extra 1:4 partition it produced is in the KEY frame, and this
9482+ // gate's arms count INTER-frame strips. Frame-aware histogram
9483+ // script + table in lanes/inter16ab-r4.report.md; the only recipe
9484+ // in the whole sweep with an inter-frame `PARTITION_VERT_4` is
9485+ // attempt 1's, which refuses on the rect wedge-interintra mask.
9486+ for attempt in 0..32u32 {
9487+ // Two sources (structure along X vs along Y -- an AB
9488+ // partition needs an L/T-shaped feature, so both orientations
9489+ // are swept), four quantisers, two motion steps, two tiling
9490+ // arms. r1 measured (sweep script in the report): a 16-attempt
9491+ // sweep at cq 34/22 alone never made aomenc's RD pick HORZ_A
9492+ // at 8 bits, so the quantiser axis is four wide here; cq 46 on
9493+ // the X-structured source is deliberately NOT in the list --
9494+ // that stream's decode-order frame 4 desyncs on a defect this
9495+ // lane does not own (aomdec's own EC_PART trace reads ZERO
9496+ // AB partitions at BLOCK_16X16 anywhere in it, so the AB
9497+ // counters it raises are read out of an already-diverged
9498+ // stream; see lanes/inter16ab-r1.report.md).
9499+ let tx_search = if attempt % 2 == 0 { "0" } else { "1" };
9500+ // The 10-bit arm swaps cq 40 for 28 on the same sources: at
9501+ // cq 40 the X-structured 10-bit stream mismatches ffmpeg with
9502+ // ZERO 16-level AB partitions in it (another shape's defect,
9503+ // measured r1 -- the gate's own `oos_mismatch` counter is
9504+ // what found it, and it is reported, not silenced).
9505+ let cq = if bit_depth == 10 {
9506+ [18, 22, 34, 28][(attempt / 2 % 4) as usize]
9507+ } else {
9508+ [18, 22, 34, 40][(attempt / 2 % 4) as usize]
9509+ };
9510+ let natural = attempt / 8 % 2 == 1;
9511+ let group = attempt / 16;
9512+ // r1: a `--tile-columns=1` arm of this same sweep PANICS in
9513+ // `mc::from_switchable_symbol` (a 4th symbol out of a
9514+ // 3-symbol alphabet = someone else's desync, the signature
9515+ // the ledger already pins for the below-8x8 inter leaf), not
9516+ // in anything this lane added -- so the tiled arm is left out
9517+ // rather than turned into a SKIP or a weakened assert.
9518+ // Reported as residue in lanes/inter16ab-r1.report.md.
9519+ let tile_cols = "0";
9520+ let sp = 3 + (group % 2) * 5;
9521+ let duration = frame_count as f64 / 25.0;
9522+ // Continuous-tone translating texture with a second, coarser
9523+ // component on the cross axis: aomenc's RD picks an AB
9524+ // partition where one 16x16 quadrant differs from its three
9525+ // siblings, which the two sinusoids at different periods
9526+ // produce all over the frame.
9527+ let lum = if natural {
9528+ format!("128+58*sin((Y+N*{sp})/6)+40*sin(X/11)+20*sin((X+Y)/5)")
9529+ } else {
9530+ format!("128+58*sin((X+N*{sp})/6)+40*sin(Y/11)+20*sin((X-Y)/5)")
9531+ };
9532+ let source = format!(
9533+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
9534+ geq=lum='{lum}',format=yuv420p"
9535+ );
9536+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
9537+ let y4m = Command::new("ffmpeg")
9538+ .args([
9539+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
9540+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
9541+ ])
9542+ .stdin(Stdio::null())
9543+ .stdout(Stdio::piped())
9544+ .stderr(Stdio::piped())
9545+ .output()
9546+ .expect("ffmpeg failed to run");
9547+ assert!(
9548+ y4m.status.success(),
9549+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
9550+ String::from_utf8_lossy(&y4m.stderr)
9551+ );
9552+ let cq_arg = format!("--cq-level={cq}");
9553+ let depth_arg = format!("--bit-depth={bit_depth}");
9554+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
9555+ let tx_arg = format!("--enable-tx-size-search={tx_search}");
9556+ let tile_arg = format!("--tile-columns={tile_cols}");
9557+ let args: Vec<&str> = vec![
9558+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
9559+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
9560+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
9561+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
9562+ "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg,
9563+ // Per-arm overrides go LAST: aomenc keeps the last
9564+ // occurrence of a repeated --enable-* flag.
9565+ &tx_arg,
9566+ "--enable-rect-partitions=1", "--enable-ab-partitions=1",
9567+ "--enable-1to4-partitions=1", "--min-partition-size=4",
9568+ "--max-partition-size=16",
9569+ "--obu", "-o", "-", "-",
9570+ ];
9571+ let mut child = Command::new(aomenc_path())
9572+ .args(&args)
9573+ .stdin(Stdio::piped())
9574+ .stdout(Stdio::piped())
9575+ .stderr(Stdio::piped())
9576+ .spawn()
9577+ .expect("aomenc failed to start");
9578+ child
9579+ .stdin
9580+ .take()
9581+ .expect("aomenc stdin")
9582+ .write_all(&y4m.stdout)
9583+ .expect("writing y4m to aomenc");
9584+ let out = child.wait_with_output().expect("aomenc failed to run");
9585+ assert!(
9586+ out.status.success(),
9587+ "aomenc refused the fixture: {}",
9588+ String::from_utf8_lossy(&out.stderr)
9589+ );
9590+ let stream = out.stdout;
9591+ let before = decode::inter16_rect4_counters();
9592+ let leaf4_before = crate::stream::vartx_rect_leaf4_hits();
9593+ let frames = match decode_stream(&stream) {
9594+ Err(e) => {
9595+ let msg = e.to_string();
9596+ assert!(
9597+ msg.contains("unsupported"),
9598+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
9599+ attempt {attempt}): {msg}"
9600+ );
9601+ // lane-inter16ab r5: attempt 1 is the ONLY recipe in
9602+ // r4's 100+ stream frame-aware sweep with an
9603+ // inter-frame PARTITION_VERT_4. In r4 it refused on
9604+ // the rect wedge codebook (lifted this round); it now
9605+ // walks further and stops on rect RESIDUAL coding, a
9606+ // refusal this lane does not own -- tracked so the
9607+ // VERT_4 / split-tx arms can name their blocker
9608+ // instead of silently reading 0.
9609+ if msg.contains("needs rectangular residual coding") {
9610+ rect_residual_refusals += 1;
9611+ }
9612+ named_refusals += 1;
9613+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
9614+ continue;
9615+ }
9616+ Ok(frames) => frames,
9617+ };
9618+ let after = decode::inter16_rect4_counters();
9619+ let leaf4_after = crate::stream::vartx_rect_leaf4_hits();
9620+ // [16x4 strips, 4x16 strips, chroma pairs closed, chroma
9621+ // pairs built from two strips' motion vectors].
9622+ let fired = [
9623+ after.0 - before.0,
9624+ after.1 - before.1,
9625+ after.2 - before.2,
9626+ after.3 - before.3,
9627+ // lane-inter16ab r4: the SPLIT-transform arm --
9628+ // `sub_tx_size_map[TX_16X4] == TX_8X4`, so a 1:4 strip
9629+ // that splits its transform codes 8x4/4x8 RECTANGULAR
9630+ // var-tx leaves (`--enable-tx-size-search=1`).
9631+ (leaf4_after[0] - leaf4_before[0]) + (leaf4_after[1] - leaf4_before[1]),
9632+ ];
9633+ let ffmpeg_frames = if bit_depth == 10 {
9634+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
9635+ } else {
9636+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
9637+ };
9638+ assert_eq!(frames.len(), frame_count);
9639+ let mismatched = frames
9640+ .iter()
9641+ .zip(&ffmpeg_frames)
9642+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
9643+ if fired[0] + fired[1] == 0 {
9644+ out_of_scope += 1;
9645+ if mismatched {
9646+ oos_mismatch += 1;
9647+ eprintln!(
9648+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
9649+ 16-level inter AB partition -- another shape's defect"
9650+ );
9651+ }
9652+ continue;
9653+ }
9654+ if mismatched {
9655+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
9656+ let bad: Vec<usize> =
9657+ (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect();
9658+ if !bad.is_empty() {
9659+ eprintln!(
9660+ "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \
9661+ pixels differ, first at ({}, {}), max |delta| {}",
9662+ bad.len(),
9663+ bad[0] % width,
9664+ bad[0] / width,
9665+ bad.iter()
9666+ .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs())
9667+ .max()
9668+ .unwrap_or(0)
9669+ );
9670+ }
9671+ }
9672+ }
9673+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
9674+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
9675+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
9676+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
9677+ }
9678+ for a in 0..5 {
9679+ if fired[a] > 0 {
9680+ arms_proved[a] += 1;
9681+ arms_total[a] += 1;
9682+ }
9683+ }
9684+ matched += 1;
9685+ }
9686+ eprintln!(
9687+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
9688+ attempts carrying a 16-level inter 1:4 partition, per-arm attempts \
9689+ HORZ_4/VERT_4/chroma-pair/sub8x8-chroma/split-tx-8x4={arms_proved:?}, {out_of_scope} attempts carried \
9690+ none ({oos_mismatch} of them mismatched)"
9691+ );
9692+ assert_eq!(
9693+ oos_mismatch, 0,
9694+ "{NAME}: {oos_mismatch} attempt(s) with no 16-level inter 1:4 partition decoded \
9695+ but mismatched ffmpeg -- a defect of another shape, not a pass"
9696+ );
9697+ }
9698+ // Arms 1/3/4 (HORZ_4, the odd-strip `is_chroma_reference` pair, the
9699+ // `build_inter_predictors_sub8x8` two-mv chroma build) are proven
9700+ // outright.
9701+ for (a, what) in [
9702+ (0usize, "HORZ_4 16x4 strips"),
9703+ (2, "odd-strip chroma pairs"),
9704+ (3, "sub8x8 two-mv chroma pairs"),
9705+ ] {
9706+ assert!(
9707+ arms_total[a] > 0,
9708+ "{NAME}: arm {a} ({what}) never fired on a pixel-exact attempt \
9709+ (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?})"
9710+ );
9711+ }
9712+ // lane-inter16ab r5, MEASURED reason for the other two arms: the only
9713+ // recipe in r4's 100+ stream frame-aware sweep carrying an
9714+ // inter-frame `PARTITION_VERT_4` is attempt 1, and in r4 it refused on
9715+ // the rect wedge-interintra codebook. That refusal is LIFTED this
9716+ // round -- the stream now walks past it and stops on "a non-skip
9717+ // rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual
9718+ // coding", a refusal this lane does not own. VERT_4 (and with it the
9719+ // split-transform 8x4 leaf it feeds) is blocked on THAT, and the gate
9720+ // asserts exactly that -- if rect residual coding lands and the arms
9721+ // still read 0, or the blocker changes, this fails.
9722+ assert!(
9723+ (arms_total[1] > 0 && arms_total[4] > 0) || rect_residual_refusals > 0,
9724+ "{NAME}: the VERT_4 / split-tx-8x4 arms read 0 \
9725+ (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?}) and NO \
9726+ attempt refused on rectangular residual coding -- their documented blocker is gone, \
9727+ so a zero arm is now unexplained"
9728+ );
9729+ }
9730+
9731+
9423 #[test]9732 #[test]
9424 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {9733 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {
9425 if !have_ffmpeg() {9734 if !have_ffmpeg() {
@@ -15446,6 +15755,208 @@ mod tests {
15446 }15755 }
15447 15756
15448 15757
15758+ /// lane-inter16ab r5: `COMPOUND_WEDGE` on a RECTANGULAR inter block --
15759+ /// the shapes `av1_wedge_params_lookup` gives the `hgtw`/`hltw`
15760+ /// codebooks (8x16/16x32/8x32 and 16x8/32x16/32x8), which this decoder
15761+ /// refused by name until this round ("the wedge codebook is
15762+ /// square-only"). `--enable-rect-partitions=1` with
15763+ /// `--min-partition-size=16 --max-partition-size=32` is what makes
15764+ /// aomenc's RD put a masked compound block on a 16x32/32x16 strip
15765+ /// (measured: ~/.cache/inter16ab-tmp/rw2.sh, 24/24 streams at cq 50/55
15766+ /// carry one and decode to the end at BOTH bit depths).
15767+ ///
15768+ /// Class `counter-from-refused-stream`: the per-shape counters are read
15769+ /// as a DELTA around one attempt and only counted for attempts that
15770+ /// decoded fully AND compared pixel-exact -- a refused attempt's hits
15771+ /// are discarded. Every decode-order frame (including hidden alt-ref
15772+ /// frames) is compared via [`decode_all_frames_vs_oracle`], and an
15773+ /// attempt that mismatches while carrying NO rect wedge fails the gate
15774+ /// through `oos_mismatch` rather than being blamed on this lane.
15775+ #[test]
15776+ fn a_real_aomenc_stream_with_a_rectangular_compound_wedge_decodes_pixel_exact() {
15777+ const NAME: &str =
15778+ "a_real_aomenc_stream_with_a_rectangular_compound_wedge_decodes_pixel_exact";
15779+ let _gate_lock = lock_gate_counters();
15780+ if !have_ffmpeg() {
15781+ eprintln!("SKIP {NAME}: no ffmpeg");
15782+ return;
15783+ }
15784+ if !have_aomenc() {
15785+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
15786+ return;
15787+ }
15788+ let (width, height, frame_count) = (96usize, 96usize, 24usize);
15789+ // Per rect shape (8x16, 16x8, 16x32, 32x16, 8x32, 32x8), summed over
15790+ // the attempts that decoded AND matched.
15791+ let mut shapes_proved = [0usize; 6];
15792+ let (mut named_refusals, mut matched, mut oos_mismatch) = (0u32, 0u32, 0u32);
15793+ let mut attempts = 0u32;
15794+ for bit_depth in [8u32, 10u32] {
15795+ for &cq in &[50u32, 55] {
15796+ for a in 0..4u32 {
15797+ attempts += 1;
15798+ let duration = frame_count as f64 / 25.0;
15799+ // Same hard-diagonal-edge content the square wedge gate
15800+ // uses (wedge's masters are OBLIQUE), panned per attempt.
15801+ let source = format!(
15802+ "mandelbrot=size={width}x{height}:rate=25:start_x={sx}:start_y={sy}",
15803+ sx = -0.6 + 0.01 * (a as f64),
15804+ sy = -0.4 + 0.01 * (a as f64)
15805+ );
15806+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
15807+ let y4m = Command::new("ffmpeg")
15808+ .args([
15809+ "-v", "error", "-f", "lavfi", "-i", &source, "-t",
15810+ &duration.to_string(), "-pix_fmt", pix_fmt, "-strict", "-1",
15811+ "-f", "yuv4mpegpipe", "-strict", "-1", "-",
15812+ ])
15813+ .stdin(Stdio::null())
15814+ .stdout(Stdio::piped())
15815+ .stderr(Stdio::piped())
15816+ .output()
15817+ .expect("ffmpeg failed to run");
15818+ assert!(
15819+ y4m.status.success(),
15820+ "{NAME}: ffmpeg fixture: {}",
15821+ String::from_utf8_lossy(&y4m.stderr)
15822+ );
15823+ let cq_arg = format!("--cq-level={cq}");
15824+ let depth_arg = format!("--bit-depth={bit_depth}");
15825+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
15826+ let args: Vec<&str> = vec![
15827+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
15828+ &depth_arg, &input_depth_arg,
15829+ "--kf-max-dist=1000", "--threads=1", "--row-mt=0", "--auto-alt-ref=1",
15830+ "--lag-in-frames=16", "--enable-fwd-kf=0", "--enable-order-hint=1",
15831+ "--enable-warped-motion=1", "--enable-global-motion=0",
15832+ "--enable-obmc=1", "--enable-diff-wtd-comp=1",
15833+ "--enable-interintra-comp=1", "--enable-onesided-comp=0",
15834+ "--enable-interintra-wedge=1", "--enable-smooth-interintra=1",
15835+ "--enable-ab-partitions=0", "--enable-1to4-partitions=0",
15836+ "--enable-filter-intra=0", "--enable-smooth-intra=0",
15837+ "--enable-paeth-intra=0", "--enable-directional-intra=0",
15838+ "--enable-angle-delta=0", "--enable-tx-size-search=0",
15839+ "--enable-cdef=0", "--enable-restoration=0", "--enable-palette=0",
15840+ "--enable-intrabc=0", "--enable-cfl-intra=0",
15841+ "--enable-ref-frame-mvs=0",
15842+ // Per-arm overrides LAST (aomenc keeps the last
15843+ // occurrence of a repeated --enable-* flag): masked
15844+ // compound ON, distance-weighted OFF so the
15845+ // comp_group_idx==1 slot goes to wedge/diffwtd, and
15846+ // rectangular partitions ON at 16/32 -- the shapes
15847+ // the hgtw/hltw codebooks exist for.
15848+ "--enable-masked-comp=1", "--enable-dist-wtd-comp=0",
15849+ "--enable-rect-partitions=1",
15850+ "--min-partition-size=16", "--max-partition-size=32",
15851+ "--obu", "-o", "-", "-",
15852+ ];
15853+ let mut child = Command::new(aomenc_path())
15854+ .args(&args)
15855+ .stdin(Stdio::piped())
15856+ .stdout(Stdio::piped())
15857+ .stderr(Stdio::piped())
15858+ .spawn()
15859+ .expect("aomenc failed to start");
15860+ child
15861+ .stdin
15862+ .take()
15863+ .expect("aomenc stdin")
15864+ .write_all(&y4m.stdout)
15865+ .expect("writing y4m to aomenc");
15866+ let out = child.wait_with_output().expect("aomenc failed to run");
15867+ assert!(
15868+ out.status.success(),
15869+ "aomenc refused the fixture: {}",
15870+ String::from_utf8_lossy(&out.stderr)
15871+ );
15872+ let stream = out.stdout;
15873+ let before = crate::stream::rect_wedge_hits();
15874+ let frames = match decode_stream(&stream) {
15875+ Err(e) => {
15876+ let msg = e.to_string();
15877+ assert!(
15878+ msg.contains("unsupported"),
15879+ "{NAME} failed outright, not a named refusal \
15880+ ({bit_depth}-bit cq{cq} attempt {a}): {msg}"
15881+ );
15882+ assert!(
15883+ !msg.contains("wedge codebook is square-only"),
15884+ "{NAME}: the rect wedge codebook is ported -- this refusal is \
15885+ forbidden ({bit_depth}-bit cq{cq} attempt {a}): {msg}"
15886+ );
15887+ named_refusals += 1;
15888+ eprintln!("{bit_depth}-bit cq{cq} attempt {a} refusal: {msg}");
15889+ continue;
15890+ }
15891+ Ok(frames) => frames,
15892+ };
15893+ let after = crate::stream::rect_wedge_hits();
15894+ let fired: Vec<usize> =
15895+ (0..6).map(|k| after[k] - before[k]).collect();
15896+ let ffmpeg_frames = if bit_depth == 10 {
15897+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
15898+ } else {
15899+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
15900+ };
15901+ assert_eq!(frames.len(), ffmpeg_frames.len());
15902+ let mismatched = frames
15903+ .iter()
15904+ .zip(&ffmpeg_frames)
15905+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
15906+ if fired.iter().sum::<usize>() == 0 {
15907+ if mismatched {
15908+ oos_mismatch += 1;
15909+ eprintln!(
15910+ "{NAME}: {bit_depth}-bit cq{cq} attempt {a} MISMATCHES with zero \
15911+ rectangular wedge block -- another shape's defect"
15912+ );
15913+ }
15914+ continue;
15915+ }
15916+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
15917+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})");
15918+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})");
15919+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})");
15920+ }
15921+ // class gate-blind-to-hidden-frames: the shown-frame
15922+ // compare above cannot see the alt-ref frames this
15923+ // recipe's --lag-in-frames=16 produces.
15924+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
15925+ eprintln!(
15926+ "{NAME}: {bit_depth}-bit cq{cq} attempt {a}: shapes {fired:?}, \
15927+ {hidden_total} decode-order frames ({hidden_n} hidden) pixel-exact"
15928+ );
15929+ for k in 0..6 {
15930+ shapes_proved[k] += fired[k];
15931+ }
15932+ matched += 1;
15933+ }
15934+ }
15935+ }
15936+ eprintln!(
15937+ "{NAME}: {named_refusals} named refusals, {matched} pixel-exact attempts out of \
15938+ {attempts}, rect wedge blocks per shape \
15939+ (8x16,16x8,16x32,32x16,8x32,32x8)={shapes_proved:?}, {oos_mismatch} zero-wedge \
15940+ mismatches"
15941+ );
15942+ assert_eq!(
15943+ oos_mismatch, 0,
15944+ "{NAME}: {oos_mismatch} attempt(s) carrying no rectangular wedge mismatched ffmpeg \
15945+ -- a defect of another shape, not a pass"
15946+ );
15947+ // The claim: a rectangular wedge codebook row (hgtw AND hltw) was
15948+ // used on a stream that then decoded pixel-exact. 16x32 is hgtw
15949+ // (h > w), 32x16 is hltw (h < w) -- one of each, so a transposed
15950+ // codebook/signflip pair cannot pass this.
15951+ assert!(
15952+ shapes_proved[2] > 0 && shapes_proved[3] > 0,
15953+ "{NAME}: no pixel-exact attempt used both an hgtw (16x32) and an hltw (32x16) \
15954+ rectangular wedge codebook row (per shape {shapes_proved:?}, {matched} matches, \
15955+ {named_refusals} refusals out of {attempts}) -- the recipe proved nothing"
15956+ );
15957+ }
15958+
15959+
15449 /// lane-lr r3: proves stage 1/2's exit criterion -- a real15960 /// lane-lr r3: proves stage 1/2's exit criterion -- a real
15450 /// `--enable-restoration=1` aomenc stream must survive the whole15961 /// `--enable-restoration=1` aomenc stream must survive the whole
15451 /// partition walk (every symbol read entropy-exact) and land on the15962 /// partition walk (every symbol read entropy-exact) and land on the
crates/ec-av1/src/wedge.rsmodified+168 -66
@@ -1,20 +1,30 @@
1 //! lane-wedge r3: `COMPOUND_WEDGE` mask codebook -- libaom1 //! lane-wedge r3: `COMPOUND_WEDGE` mask codebook -- libaom
2 //! `av1/common/reconinter.c`'s `init_wedge_master_masks`/`init_wedge_masks`/2 //! `av1/common/reconinter.c`'s `init_wedge_master_masks`/`init_wedge_masks`/
3-//! `get_wedge_mask_inplace`, ported for the ONLY block-size family this3+//! `get_wedge_mask_inplace`, ported for EVERY bsize libaom gives a wedge
4-//! decoder's masked-compound leaves reach: square 8x8/16x16/32x324+//! codebook (`av1_wedge_params_lookup`, reconinter.c:236-267): the three
5-//! (`decode.rs`'s `wedge_bsize` match on `side`). Every reachable square5+//! square sizes 8x8/16x16/32x32 (`wedge_codebook_16_heqw`) and the six
6-//! bsize uses the same libaom codebook row (`wedge_codebook_16_heqw`) and6+//! rectangular ones 8x16/16x32/8x32 (`wedge_codebook_16_hgtw`, h > w) and
7-//! the same `wedge_signflip_lookup` row, so only ONE codebook/signflip7+//! 16x8/32x16/32x8 (`wedge_codebook_16_hltw`, h < w), each with its own
8-//! table is ported (rect bsizes are not reachable yet -- charter scope).8+//! `wedge_signflip_lookup` row (reconinter.c:160-183).
9 //!9 //!
10-//! VERIFICATION (class shared-oracle-blindness): `lanes/wedge_dump.c` is a10+//! lane-inter16ab r5: masks are stored PADDED to a `side x side` plane
11-//! standalone C reimplementation of the same libaom source, compiled and11+//! (`side = max(bw, bh)`, row stride `side`), because `decode.rs` predicts
12-//! run independently with `gcc` (not linked against this Rust code, not12+//! a rectangular strip into a square `side x side` buffer and writes only
13-//! linked against libaom) -- it catches translation bugs (indexing, shift13+//! its true `write_w x write_h` footprint -- so a padded mask drops
14-//! direction/sign, offset order) that a hand-transcribed-only table would14+//! straight into the existing square blend call with no stride plumbing.
15-//! not. `checksum()` below reproduces its exact per-block checksum15+//! Rows/columns outside `bw x bh` are zero and never reach the frame.
16-//! formula; `wedge_codebook_matches_c_dump` asserts every (bsize, sign,16+//!
17-//! index) checksum against `lanes/wedge_dump.expected.txt`.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.
18 28
19 const MASK_MASTER_SIZE: usize = 64;29 const MASK_MASTER_SIZE: usize = 64;
20 const WEDGE_WEIGHT_BITS: u32 = 6;30 const WEDGE_WEIGHT_BITS: u32 = 6;
@@ -47,7 +57,8 @@ const WEDGE_MASTER_VERTICAL: [u8; MASK_MASTER_SIZE] = [
47 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,57 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
48 ];58 ];
49 59
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).
51 const HEQW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [62 const HEQW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [
52 (Dir::Oblique27, 4, 4),63 (Dir::Oblique27, 4, 4),
53 (Dir::Oblique63, 4, 4),64 (Dir::Oblique63, 4, 4),
@@ -66,8 +77,84 @@ const HEQW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [
66 (Dir::Oblique117, 2, 4),77 (Dir::Oblique117, 2, 4),
67 (Dir::Oblique117, 6, 4),78 (Dir::Oblique117, 6, 4),
68 ];79 ];
69-/// `wedge_signflip_lookup` row shared by `BLOCK_8X8`/`BLOCK_16X16`/`BLOCK_32X32`.80+/// `wedge_codebook_16_hgtw` (reconinter.c:203) -- h > w (8x16/16x32/8x32).
70-const SIGNFLIP: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1];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+];
71 158
72 /// `shift_copy` (reconinter.c) -- shift a `MASK_MASTER_SIZE`-wide row right159 /// `shift_copy` (reconinter.c) -- shift a `MASK_MASTER_SIZE`-wide row right
73 /// (`shift >= 0`) or left, replicating the edge sample into the gap.160 /// (`shift >= 0`) or left, replicating the edge sample into the gap.
@@ -146,79 +233,86 @@ fn init_wedge_master_masks() -> MasterMasks {
146 MasterMasks { obl }233 MasterMasks { obl }
147 }234 }
148 235
149-/// `get_wedge_mask_inplace` (reconinter.c): the `bw x bh` window of the236+/// `get_wedge_mask_inplace` (reconinter.c:270-289): the `bw x bh` window of
150-/// master plane for this `(wedge_index, neg, bw, bh)`, still in237+/// the master plane for this `(wedge_index, neg, bw, bh)`, still in
151 /// `MASK_MASTER_SIZE`-stride coordinates (caller extracts the window).238 /// `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) {239+fn wedge_window(wedge_index: usize, neg: usize, bw: usize, bh: usize) -> (usize, usize, usize) {
153- let (dir, xo, yo) = HEQW[wedge_index];240+ let (codebook, signflip) = wedge_params(bw, bh).expect("wedge_window on a wedge-capable bsize");
154- let wsignflip = SIGNFLIP[wedge_index] as usize;241+ let (dir, xo, yo) = codebook[wedge_index];
242+ let wsignflip = signflip[wedge_index] as usize;
155 let woff = (xo as usize * bw) >> 3;243 let woff = (xo as usize * bw) >> 3;
156 let hoff = (yo as usize * bh) >> 3;244 let hoff = (yo as usize * bh) >> 3;
157- let _ = &master.obl[neg ^ wsignflip][dir as usize];
158 let row0 = MASK_MASTER_SIZE / 2 - hoff;245 let row0 = MASK_MASTER_SIZE / 2 - hoff;
159 let col0 = MASK_MASTER_SIZE / 2 - woff;246 let col0 = MASK_MASTER_SIZE / 2 - woff;
160 (neg ^ wsignflip, dir as usize, row0 * MASK_MASTER_SIZE + col0)247 (neg ^ wsignflip, dir as usize, row0 * MASK_MASTER_SIZE + col0)
161 }248 }
162 249
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.
164 pub struct WedgeCodebook {254 pub struct WedgeCodebook {
165- /// `[sign][wedge_index] -> bw*bh` bytes, row stride `bw`.255+ /// `[sign][wedge_index] -> stride*stride` bytes, row stride `stride`.
166 masks: [[Vec<u8>; MAX_WEDGE_TYPES]; 2],256 masks: [[Vec<u8>; MAX_WEDGE_TYPES]; 2],
167 pub bw: usize,257 pub bw: usize,
168 pub bh: usize,258 pub bh: usize,
259+ /// `max(bw, bh)` -- the row stride of every mask returned by [`Self::mask`].
260+ pub stride: usize,
169 }261 }
170 262
171 impl WedgeCodebook {263 impl WedgeCodebook {
172 fn build(master: &MasterMasks, bw: usize, bh: usize) -> Self {264 fn build(master: &MasterMasks, bw: usize, bh: usize) -> Self {
265+ let stride = bw.max(bh);
173 let mut masks: [[Vec<u8>; MAX_WEDGE_TYPES]; 2] = Default::default();266 let mut masks: [[Vec<u8>; MAX_WEDGE_TYPES]; 2] = Default::default();
174 for sign in 0..2 {267 for sign in 0..2 {
175 for idx in 0..MAX_WEDGE_TYPES {268 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);
177 let plane = &master.obl[neg_idx][dir];270 let plane = &master.obl[neg_idx][dir];
178- let mut m = vec![0u8; bw * bh];271+ let mut m = vec![0u8; stride * stride];
179 for i in 0..bh {272 for i in 0..bh {
180 let src = off + i * MASK_MASTER_SIZE;273 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]);
182 }275 }
183 masks[sign][idx] = m;276 masks[sign][idx] = m;
184 }277 }
185 }278 }
186- WedgeCodebook { masks, bw, bh }279+ WedgeCodebook { masks, bw, bh, stride }
187 }280 }
188 281
189 /// `wedge_sign` in `{0,1}` (spec `wedge_sign`), `wedge_index` in282 /// `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`.
191 pub fn mask(&self, wedge_sign: usize, wedge_index: usize) -> &[u8] {285 pub fn mask(&self, wedge_sign: usize, wedge_index: usize) -> &[u8] {
192 &self.masks[wedge_sign][wedge_index]286 &self.masks[wedge_sign][wedge_index]
193 }287 }
194 }288 }
195 289
196-/// One codebook per reachable square leaf side (8/16/32), built once.290+/// One codebook per wedge-capable bsize, built once.
197 pub struct WedgeMasks {291 pub struct WedgeMasks {
198- pub side8: WedgeCodebook,292+ /// Parallel to [`WEDGE_BSIZES`].
199- pub side16: WedgeCodebook,293+ books: Vec<WedgeCodebook>,
200- pub side32: WedgeCodebook,
201 }294 }
202 295
203 impl WedgeMasks {296 impl WedgeMasks {
204 fn new() -> Self {297 fn new() -> Self {
205 let master = init_wedge_master_masks();298 let master = init_wedge_master_masks();
206 WedgeMasks {299 WedgeMasks {
207- side8: WedgeCodebook::build(&master, 8, 8),300+ books: WEDGE_BSIZES
208- side16: WedgeCodebook::build(&master, 16, 16),301+ .iter()
209- side32: WedgeCodebook::build(&master, 32, 32),302+ .map(|&(bw, bh)| WedgeCodebook::build(&master, bw, bh))
303+ .collect(),
210 }304 }
211 }305 }
212 306
213- /// `side` is the square leaf side (8/16/32); panics otherwise (same307+ /// `(bw, bh)` is the block's TRUE footprint; panics on a size libaom
214- /// invariant `decode.rs`'s `wedge_bsize` match already enforces).308+ /// gives no codebook (the same invariant `decode.rs`'s `wedge_used_bsize`
215- pub fn codebook(&self, side: usize) -> &WedgeCodebook {309+ /// already enforces before any wedge symbol is read).
216- match side {310+ pub fn codebook(&self, bw: usize, bh: usize) -> &WedgeCodebook {
217- 8 => &self.side8,311+ let i = WEDGE_BSIZES
218- 16 => &self.side16,312+ .iter()
219- 32 => &self.side32,313+ .position(|&s| s == (bw, bh))
220- _ => unreachable!("wedge codebook side is 8/16/32"),314+ .unwrap_or_else(|| unreachable!("no wedge codebook for {bw}x{bh}"));
221- }315+ &self.books[i]
222 }316 }
223 }317 }
224 318
@@ -228,13 +322,15 @@ pub fn wedge_masks() -> &'static WedgeMasks {
228 WEDGE_MASKS.get_or_init(WedgeMasks::new)322 WEDGE_MASKS.get_or_init(WedgeMasks::new)
229 }323 }
230 324
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.
232 #[cfg(test)]328 #[cfg(test)]
233-fn checksum(mask: &[u8], bw: usize, bh: usize) -> u64 {329+fn checksum(mask: &[u8], bw: usize, bh: usize, stride: usize) -> u64 {
234 let mut sum: u64 = 0;330 let mut sum: u64 = 0;
235 for i in 0..bh {331 for i in 0..bh {
236 for j in 0..bw {332 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;
238 }334 }
239 }335 }
240 sum336 sum
@@ -244,44 +340,50 @@ fn checksum(mask: &[u8], bw: usize, bh: usize) -> u64 {
244 mod tests {340 mod tests {
245 use super::*;341 use super::*;
246 342
247- /// lane-wedge r3: checksum-verify every (bsize, sign, wedge_index) mask343+ /// lane-inter16ab r5 (class enumerate-table-domain): checksum-verify
248- /// this decoder can produce against `lanes/wedge_dump.c`'s independent344+ /// EVERY (bsize, sign, wedge_index) mask this decoder can produce --
249- /// C computation (`lanes/wedge_dump.expected.txt`, generated by345+ /// all 9 wedge-capable bsizes, both signs, all 16 indices = 288 entries
250- /// `gcc -O2 lanes/wedge_dump.c -o lanes/wedge_dump && ./lanes/wedge_dump`).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`).
251 #[test]350 #[test]
252- fn wedge_codebook_matches_c_dump() {351+ fn wedge_codebook_matches_libaom_dump() {
253- let expected_txt = std::fs::read_to_string(352+ let expected_txt = std::fs::read_to_string(concat!(
254- concat!(env!("CARGO_MANIFEST_DIR"), "/../../lanes/wedge_dump.expected.txt"),353+ env!("CARGO_MANIFEST_DIR"),
255- )354+ "/../../lanes/wedge_libaom.expected.txt"
256- .expect("run gcc -O2 lanes/wedge_dump.c -o lanes/wedge_dump && ./lanes/wedge_dump > lanes/wedge_dump.expected.txt first");355+ ))
356+ .expect("lanes/wedge_libaom.expected.txt (libaom-linked harness dump)");
257 let mut expected = std::collections::HashMap::new();357 let mut expected = std::collections::HashMap::new();
258 for line in expected_txt.lines() {358 for line in expected_txt.lines() {
259- // "8x8 sign=0 idx=0 checksum=39141"359+ // "16x8 sign=0 idx=0 checksum=39141"
260 let parts: Vec<&str> = line.split_whitespace().collect();360 let parts: Vec<&str> = line.split_whitespace().collect();
261- let name = parts[0];361+ let name = parts[0].to_string();
262 let sign: usize = parts[1]["sign=".len()..].parse().unwrap();362 let sign: usize = parts[1]["sign=".len()..].parse().unwrap();
263 let idx: usize = parts[2]["idx=".len()..].parse().unwrap();363 let idx: usize = parts[2]["idx=".len()..].parse().unwrap();
264 let cs: u64 = parts[3]["checksum=".len()..].parse().unwrap();364 let cs: u64 = parts[3]["checksum=".len()..].parse().unwrap();
265 expected.insert((name, sign, idx), cs);365 expected.insert((name, sign, idx), cs);
266 }366 }
367+ assert_eq!(expected.len(), 9 * 2 * MAX_WEDGE_TYPES, "the dump covers every entry");
267 let masks = wedge_masks();368 let masks = wedge_masks();
268 let mut checked = 0;369 let mut checked = 0;
269- for (name, side) in [("8x8", 8usize), ("16x16", 16), ("32x32", 32)] {370+ for (bw, bh) in WEDGE_BSIZES {
270- let cb = masks.codebook(side);371+ let name = format!("{bw}x{bh}");
372+ let cb = masks.codebook(bw, bh);
271 for sign in 0..2 {373 for sign in 0..2 {
272 for idx in 0..MAX_WEDGE_TYPES {374 for idx in 0..MAX_WEDGE_TYPES {
273- let got = checksum(cb.mask(sign, idx), side, side);375+ let got = checksum(cb.mask(sign, idx), bw, bh, cb.stride);
274- let want = *expected.get(&(name, sign, idx)).unwrap_or_else(|| {376+ let want = *expected.get(&(name.clone(), sign, idx)).unwrap_or_else(|| {
275 panic!("missing expected entry for {name} sign={sign} idx={idx}")377 panic!("missing expected entry for {name} sign={sign} idx={idx}")
276 });378 });
277 assert_eq!(379 assert_eq!(
278 got, want,380 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}"
280 );382 );
281 checked += 1;383 checked += 1;
282 }384 }
283 }385 }
284 }386 }
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");
286 }388 }
287 }389 }
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