forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-rect2': HORZ/VERT partitions decode for real (rect mvstack/warp/OBMC/deblock threading; scan weight cross-axis; overlappable_left height step)

Browse files at this commit

653e4413a6b71de3d9073685003e7280c1aefb9dAhmet Kaan GümüşParent: 9cec3a26959345
crates/ec-av1/src/cdf.rsmodified+10 -2
@@ -1211,11 +1211,16 @@ pub const SKIP_MODE: [[u16; 3]; 3] = [[32621, 32768, 0], [20708, 32768, 0], [812
12111211 /// `motion_mode_allowed` (spec 5.11.24's `read_motion_mode`) offers
12121212 /// `OBMC_CAUSAL` rather than `WARPED_CAUSAL` -- lane-motionmode round 1
12131213 /// never reaches the three-way `motion_mode_cdf`, see `decode.rs`.
1214-pub const OBMC: [[u16; 3]; 4] = [
1214+pub const OBMC: [[u16; 3]; 6] = [
12151215 [10437, 32768, 0],
12161216 [17432, 32768, 0],
12171217 [25817, 32768, 0],
12181218 [30128, 32768, 0],
1219+ // lane-rect r2: BLOCK_16X32 (index 7) and BLOCK_32X16 (index 8) rows --
1220+ // rect strips read their own bsize row, not the square class
1221+ // (rect-flake-1: the strip's motion_mode read diverged on this).
1222+ [14423, 32768, 0],
1223+ [15142, 32768, 0],
12191224 ];
12201225
12211226 /// `default_motion_mode_cdf` (spec 9.4, `entropymode.c`), the square-bsize
@@ -1225,11 +1230,14 @@ pub const OBMC: [[u16; 3]; 4] = [
12251230 /// `read_motion_mode` reads instead of [`OBMC`] whenever `motion_mode_allowed`
12261231 /// (spec 5.11.24) resolves to `WARPED_CAUSAL`-eligible (`num_proj_ref >= 1`
12271232 /// under `allow_warped_motion`) -- lane-warp round 1.
1228-pub const MOTION_MODE: [[u16; 4]; 4] = [
1233+pub const MOTION_MODE: [[u16; 4]; 6] = [
12291234 [7651, 24760, 32768, 0],
12301235 [19419, 26810, 32768, 0],
12311236 [26260, 29116, 32768, 0],
12321237 [29516, 30701, 32768, 0],
1238+ // lane-rect r2: BLOCK_16X32 / BLOCK_32X16 rows (indices 7/8).
1239+ [5123, 23606, 32768, 0],
1240+ [11606, 24308, 32768, 0],
12331241 ];
12341242
12351243 /// `default_interintra_cdf` (spec 9.4): `interintra`, indexed by
crates/ec-av1/src/cdf_state.rsmodified+2 -2
@@ -326,13 +326,13 @@ pub(crate) struct Cdfs {
326326 /// `BLOCK_8X8`, 1 = `BLOCK_16X16`, 2 = `BLOCK_32X32`, 3 = `BLOCK_64X64`
327327 /// (`default_obmc_cdf`'s own `BLOCK_SIZES_ALL` indices 3/6/9/12 --
328328 /// this decoder only ever codes those four square sizes).
329- pub obmc: [[u16; 3]; 4],
329+ pub obmc: [[u16; 3]; 6],
330330 /// `motion_mode` (spec 5.11.24's `read_motion_mode`), the 3-symbol
331331 /// `SIMPLE_TRANSLATION`/`OBMC_CAUSAL`/`WARPED_CAUSAL` alphabet read
332332 /// instead of [`Self::obmc`] whenever `motion_mode_allowed` resolves to
333333 /// `WARPED_CAUSAL`-eligible -- same square-bsize indexing as `obmc`.
334334 /// lane-warp round 1.
335- pub motion_mode: [[u16; 4]; 4],
335+ pub motion_mode: [[u16; 4]; 6],
336336 /// `interintra`, indexed by `size_group_lookup[bsize]` -- see
337337 /// `cdf::INTERINTRA`'s own doc.
338338 pub interintra: [[u16; 3]; 4],
crates/ec-av1/src/decode.rsmodified+323 -67
@@ -957,6 +957,10 @@ struct Neighbours {
957957 /// transform size, spec 7.14's `get_transform_size`/`get_filter_level`
958958 /// edge-length lookup (`apply_deblock`).
959959 tx_grid: Vec<u8>,
960+ /// The transform HEIGHT companion to [`Self::tx_grid`]'s width --
961+ /// lane-rect r2: TX_32X16/TX_16X32 strips deblock their horizontal
962+ /// edges by tx height (spec 7.14.2 `set_lpf_parameters` dir==VERT).
963+ tx_h_grid: Vec<u8>,
960964 /// Per-4x4-mi reference frame (`0` = intra, magnitude `1..=7` =
961965 /// `MV_REFERENCE_FRAME`, negative = that reference coded as `GLOBALMV` --
962966 /// `lf_level`'s `mode_lf_lut` row 0, lane-av1golden2)
@@ -1001,6 +1005,7 @@ impl Neighbours {
10011005 skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)],
10021006 skip_grid_cols_mi: cols * (SUB / MI),
10031007 tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)],
1008+ tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)],
10041009 ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)],
10051010 }
10061011 }
@@ -1010,7 +1015,7 @@ impl Neighbours {
10101015 /// per-edge lookup (`apply_deblock`), filled at the same call sites and
10111016 /// units as [`Self::fill_skip_grid`].
10121017 fn fill_lf_grid(&mut self, at_mi: (usize, usize), side_mi: usize, tx_px: u8, ref_frame: i8) {
1013- self.fill_lf_grid_rect(at_mi, side_mi, side_mi, tx_px, ref_frame);
1018+ self.fill_lf_grid_rect(at_mi, side_mi, side_mi, tx_px, tx_px, ref_frame);
10141019 }
10151020
10161021 /// [`Self::fill_lf_grid`] with independent row/col extents -- lane-partitions
@@ -1025,6 +1030,7 @@ impl Neighbours {
10251030 w_mi: usize,
10261031 h_mi: usize,
10271032 tx_px: u8,
1033+ tx_h_px: u8,
10281034 ref_frame: i8,
10291035 ) {
10301036 let (mi_r, mi_c) = at_mi;
@@ -1034,6 +1040,9 @@ impl Neighbours {
10341040 if let Some(cell) = self.tx_grid.get_mut(idx) {
10351041 *cell = tx_px;
10361042 }
1043+ if let Some(cell) = self.tx_h_grid.get_mut(idx) {
1044+ *cell = tx_h_px;
1045+ }
10371046 if let Some(cell) = self.ref_grid.get_mut(idx) {
10381047 *cell = ref_frame;
10391048 }
@@ -2751,6 +2760,18 @@ fn tx_px_at(n: &Neighbours, chroma: bool, mi_r: usize, mi_c: usize) -> u32 {
27512760 if chroma { luma_tx / 2 } else { luma_tx }
27522761 }
27532762
2763+/// [`tx_px_at`]'s HEIGHT twin (lane-rect r2): the deblocker's horizontal
2764+/// edges step and gate by transform height, which differs from width only
2765+/// on rect partition strips.
2766+fn tx_h_px_at(n: &Neighbours, chroma: bool, mi_r: usize, mi_c: usize) -> u32 {
2767+ let luma_tx = n
2768+ .tx_h_grid
2769+ .get(mi_r * n.skip_grid_cols_mi + mi_c)
2770+ .copied()
2771+ .unwrap_or(0) as u32;
2772+ if chroma { luma_tx / 2 } else { luma_tx }
2773+}
2774+
27542775 /// `get_tx_size_context` (spec 9.3's `TxDepthCtx`, libaom
27552776 /// `TXFM_CONTEXT`/`entropymode.c`): the sum of two boolean terms, each
27562777 /// present only when its neighbour exists inside the true frame -- whether
@@ -2759,7 +2780,7 @@ fn tx_px_at(n: &Neighbours, chroma: bool, mi_r: usize, mi_c: usize) -> u32 {
27592780 /// as `own_side`.
27602781 fn tx_size_context(n: &Neighbours, (mi_r, mi_c): (usize, usize), own_side: usize) -> usize {
27612782 let above = mi_r > 0 && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_side;
2762- let left = mi_c > 0 && tx_px_at(n, false, mi_r, mi_c - 1) as usize >= own_side;
2783+ let left = mi_c > 0 && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_side;
27632784 usize::from(above) + usize::from(left)
27642785 }
27652786
@@ -2895,7 +2916,11 @@ fn edge_params(
28952916 y0: usize,
28962917 ) -> Option<(u8, i32)> {
28972918 let (mi_r, mi_c) = (plane_to_mi(chroma, y0), plane_to_mi(chroma, x0));
2898- let cur_tx = tx_px_at(n, chroma, mi_r, mi_c);
2919+ let cur_tx = if dir == 0 {
2920+ tx_px_at(n, chroma, mi_r, mi_c)
2921+ } else {
2922+ tx_h_px_at(n, chroma, mi_r, mi_c)
2923+ };
28992924 if cur_tx == 0 || (if dir == 0 { x0 } else { y0 }) % cur_tx as usize != 0 {
29002925 return None;
29012926 }
@@ -2905,7 +2930,11 @@ fn edge_params(
29052930 } else {
29062931 (mi_r - 1, mi_c)
29072932 };
2908- let pv_tx = tx_px_at(n, chroma, pv_mi_r, pv_mi_c);
2933+ let pv_tx = if dir == 0 {
2934+ tx_px_at(n, chroma, pv_mi_r, pv_mi_c)
2935+ } else {
2936+ tx_h_px_at(n, chroma, pv_mi_r, pv_mi_c)
2937+ };
29092938 let pv_ref = n.ref_grid[pv_mi_r * n.skip_grid_cols_mi + pv_mi_c];
29102939
29112940 let cur_level = lf_level(lf, plane_idx, dir, cur_ref);
@@ -4290,7 +4319,9 @@ fn overlappable_left(
42904319 let mut row = mi_row;
42914320 while row < end_row && out.len() < max_neighbors {
42924321 let cell = grid.get(row, mi_col - 1);
4293- let step = cell.map_or(1, |c| c.size).max(1);
4322+ // Vertical walk steps by the neighbour's HEIGHT -- a 32x16 strip's
4323+ // width (8) would swallow the strip below it.
4324+ let step = cell.map_or(1, |c| c.size_h).max(1);
42944325 if let Some(info) = cell {
42954326 if info.is_inter {
42964327 out.push((row - mi_row, step.min(end_row - row), *info));
@@ -4346,6 +4377,7 @@ fn find_samples(
43464377 mi_row: usize,
43474378 mi_col: usize,
43484379 bw4: usize,
4380+ bh4: usize,
43494381 mi_cols: usize,
43504382 mi_rows: usize,
43514383 ref_frame: i8,
@@ -4359,7 +4391,11 @@ fn find_samples(
43594391 let mut do_tr = true;
43604392 let rec = |info: &MiInfo, row_offset: i32, sign_r: i32, col_offset: i32, sign_c: i32| {
43614393 let nb_bw = (info.size * 4) as i32;
4362- crate::warp::record_sample(nb_bw, nb_bw, info.mv, row_offset, sign_r, col_offset, sign_c)
4394+ // lane-rect r2: the neighbour's own true height -- a rect strip
4395+ // neighbour donates its sample at ITS center (aom pts y=-72 for a
4396+ // 32x16 above strip; the square assumption put it at -136).
4397+ let nb_bh = (info.size_h * 4) as i32;
4398+ crate::warp::record_sample(nb_bw, nb_bh, info.mv, row_offset, sign_r, col_offset, sign_c)
43634399 };
43644400
43654401 'outer: {
@@ -4403,8 +4439,8 @@ fn find_samples(
44034439
44044440 if left_available {
44054441 let left = grid.get(mi_row, mi_col - 1);
4406- let superblock_height = left.map_or(1, |c| c.size).max(1);
4407- if bw4 <= superblock_height {
4442+ let superblock_height = left.map_or(1, |c| c.size_h).max(1);
4443+ if bh4 <= superblock_height {
44084444 let row_offset = -((mi_row % superblock_height) as isize);
44094445 if row_offset < 0 {
44104446 do_tl = false;
@@ -4419,10 +4455,10 @@ fn find_samples(
44194455 }
44204456 } else {
44214457 let mut i = 0usize;
4422- let limit = bw4.min(mi_rows.saturating_sub(mi_row));
4458+ let limit = bh4.min(mi_rows.saturating_sub(mi_row));
44234459 while i < limit {
44244460 let cell = grid.get(mi_row + i, mi_col - 1);
4425- let sh = cell.map_or(1, |c| c.size).max(1);
4461+ let sh = cell.map_or(1, |c| c.size_h).max(1);
44264462 if let Some(info) = cell {
44274463 if single_ref_match(info) {
44284464 samples.push(rec(info, i as i32, 1, 0, -1));
@@ -4470,11 +4506,12 @@ fn num_proj_ref(
44704506 mi_row: usize,
44714507 mi_col: usize,
44724508 bw4: usize,
4509+ bh4: usize,
44734510 mi_cols: usize,
44744511 mi_rows: usize,
44754512 ref_frame: i8,
44764513 ) -> u8 {
4477- find_samples(grid, mi_row, mi_col, bw4, mi_cols, mi_rows, ref_frame).len() as u8
4514+ find_samples(grid, mi_row, mi_col, bw4, bh4, mi_cols, mi_rows, ref_frame).len() as u8
44784515 }
44794516
44804517 /// `av1_get_obmc_mask` (`reconinter.c`): the per-position blend weight
@@ -4669,9 +4706,12 @@ fn obmc_blend(
46694706 mi_row: usize,
46704707 mi_col: usize,
46714708 bw4: usize,
4709+ bh4: usize,
46724710 mi_rows: usize,
46734711 mi_cols: usize,
46744712 side: usize,
4713+ write_w: usize,
4714+ write_h: usize,
46754715 chroma_side: usize,
46764716 px: usize,
46774717 py: usize,
@@ -4686,15 +4726,19 @@ fn obmc_blend(
46864726 pred_u: &mut [u8],
46874727 pred_v: &mut [u8],
46884728 ) -> Result<()> {
4689- let max_neighbors = match bw4 {
4729+ // lane-rect r2 (libaom av1_build_obmc_inter_prediction): each pass has
4730+ // its OWN neighbour cap (width-log2 for above, height-log2 for left) and
4731+ // overlap (bh/2 rows above, bw/2 cols left) -- one square `side` was
4732+ // right only for square blocks.
4733+ let max_nb = |n4: usize| match n4 {
46904734 1..=4 => 2,
46914735 5..=8 => 3,
46924736 _ => 4,
46934737 };
4694- let overlap = side / 2;
4695- let coverlap = overlap / 2;
4738+ let overlap_above = write_h / 2;
4739+ let overlap_left = write_w / 2;
46964740
4697- for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_neighbors)
4741+ for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4))
46984742 {
46994743 // `Neighbours::above_filter` is indexed in `SUB`(16px)-wide columns
47004744 // (this decoder's own outer block-loop granularity), one step
@@ -4705,26 +4749,26 @@ fn obmc_blend(
47054749 neighbours.above_filter[(mi_col + off4) / SUB_MI as usize],
47064750 );
47074751 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
4708- let (bw, bh, ox) = (span4 * 4, overlap, off4 * 4);
4752+ let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);
47094753 let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind);
47104754 obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y);
4711- let (cbw, cbh, cox) = (bw / 2, coverlap, ox / 2);
4755+ let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);
47124756 let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
47134757 obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u);
47144758 let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);
47154759 obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v);
47164760 }
47174761
4718- for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bw4, mi_rows, max_neighbors) {
4762+ for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) {
47194763 let (h_kind, v_kind) = neighbour_filter(
47204764 interp_fixed,
47214765 neighbours.left_filter[(mi_row + off4) / SUB_MI as usize],
47224766 );
47234767 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
4724- let (bw, bh, oy) = (overlap, span4 * 4, off4 * 4);
4768+ let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);
47254769 let tmp_y = obmc_neighbour_pred(ny, px, py + oy, nb.mv, bw, bh, true, h_kind, v_kind);
47264770 obmc_blend_h(pred_y, side, 0, oy, bw, bh, &tmp_y);
4727- let (cbw, cbh, coy) = (coverlap, bh / 2, oy / 2);
4771+ let (cbw, cbh, coy) = (overlap_left / 2, bh / 2, oy / 2);
47284772 let tmp_u = obmc_neighbour_pred(nu, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind);
47294773 obmc_blend_h(pred_u, chroma_side, 0, coy, cbw, cbh, &tmp_u);
47304774 let tmp_v = obmc_neighbour_pred(nv, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind);
@@ -5222,7 +5266,9 @@ fn decode_inter_block(
52225266 )
52235267 };
52245268 let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize);
5225- let bw4 = side / 4;
5269+ // lane-rect r2: true footprint, mirroring the single-ref path below.
5270+ let bw4 = write_w / 4;
5271+ let bh4 = write_h / 4;
52265272 // spec 7.10.2.8, doubled per side (`CompoundTplArgs`): same
52275273 // `use_ref_frame_mvs` gating as the single-ref `tpl` build
52285274 // below, just one `get_relative_dist` per reference.
@@ -5245,7 +5291,7 @@ fn decode_inter_block(
52455291 mi_row,
52465292 mi_col,
52475293 bw4,
5248- bw4,
5294+ bh4,
52495295 (ref0, ref1),
52505296 mi_cols as usize,
52515297 mi_rows as usize,
@@ -5293,7 +5339,12 @@ fn decode_inter_block(
52935339 globalmv_for_lf = is_globalmv;
52945340 ref_frame_for_lf = ref0;
52955341 mode_for_tx = 0;
5296- for dr in 0..bw4 {
5342+ // lane-rect r2: `grid` (mvstack.rs's own MiGrid, distinct from
5343+ // `neighbours`) must be stamped with the block's true footprint
5344+ // too -- a square `bw4`x`bw4` stamp here claims a rect strip's
5345+ // NEXT strip's own rows/cols before it decodes, corrupting
5346+ // every later mvstack scan that reads this cell back.
5347+ for dr in 0..bh4 {
52975348 for dc in 0..bw4 {
52985349 grid.set(
52995350 mi_row + dr,
@@ -5306,6 +5357,7 @@ fn decode_inter_block(
53065357 mv: mv0,
53075358 is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7),
53085359 size: bw4,
5360+ size_h: bh4,
53095361 },
53105362 );
53115363 }
@@ -5884,13 +5936,14 @@ fn decode_inter_block(
58845936 };
58855937
58865938 let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize);
5887- let bw4 = side / 4;
5888- // lane-warp r5d: `reject_residual` marks the HORZ_B arm's top
5889- // strip, decoded as a square 32x32 block but truly 32x16 -- the
5890- // mv stack must be queried with the block's REAL extent (libaom
5891- // `av1_get_mv_refs` gets bw4=8, bh4=4), else scan_col, the
5892- // corner probes and `clamp_mv_ref` all size a 32-tall block.
5893- let bh4 = if reject_residual { bw4 / 2 } else { bw4 };
5939+ // lane-rect r2: the mv stack must be queried with the block's
5940+ // REAL extent (libaom `av1_get_mv_refs` gets bw4/bh4 from
5941+ // xd->width/xd->height, not a square guess) -- `write_w`/
5942+ // `write_h` already name the true HORZ/VERT/HORZ_B strip
5943+ // footprint (r1's plumbing), so derive bw4/bh4 from those
5944+ // instead of the old `side`-square (HORZ_B-only) heuristic.
5945+ let bw4 = write_w / 4;
5946+ let bh4 = write_h / 4;
58945947 // spec 7.10.2.8: only reached when the frame header set
58955948 // `use_ref_frame_mvs` (`tpl_frame` is `Some` then, `None`
58965949 // otherwise) -- `cur_offset_0` is this query block's own resolved
@@ -6050,7 +6103,7 @@ fn decode_inter_block(
60506103 && !skip_mode
60516104 && interintra_mode.is_none()
60526105 && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty()
6053- || !overlappable_left(grid, mi_row, mi_col, bw4, mi_rows as usize, 1)
6106+ || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1)
60546107 .is_empty());
60556108 let mut obmc_selected = false;
60566109 // lane-warp round 2: `Some` when motion_mode == WARPED_CAUSAL
@@ -6072,13 +6125,23 @@ fn decode_inter_block(
60726125 // wmtype check here.
60736126 let mut warped_selected = false;
60746127 if motion_mode_eligible {
6075- // `default_obmc_cdf`'s own index: square bsize 8/16/32/64 -> 0/1/2/3.
6076- let bsize_idx = (side.trailing_zeros() - 3) as usize;
6128+ // `default_obmc_cdf`'s own index: square bsize 8/16/32/64 ->
6129+ // 0/1/2/3; lane-rect r2: a rect strip reads its OWN bsize row
6130+ // (libaom `motion_mode_cdf[mbmi->bsize]`: BLOCK_16X32 -> 4,
6131+ // BLOCK_32X16 -> 5 in our packed table) -- rect-flake-1's
6132+ // strip motion_mode read diverged on the square row.
6133+ let bsize_idx = if write_w == write_h {
6134+ (write_w.trailing_zeros() - 3) as usize
6135+ } else if write_w == 16 {
6136+ 4
6137+ } else {
6138+ 5
6139+ };
60776140 // `motion_mode_allowed` reads the 3-symbol `motion_mode_cdf`
60786141 // instead of the 2-symbol `obmc_cdf` exactly when
60796142 // `num_proj_ref >= 1` under `allow_warped_motion`.
60806143 let warp_eligible = allow_warped_motion
6081- && num_proj_ref(grid, mi_row, mi_col, bw4, mi_cols as usize, mi_rows as usize, ref_frame) >= 1;
6144+ && num_proj_ref(grid, mi_row, mi_col, bw4, bh4, mi_cols as usize, mi_rows as usize, ref_frame) >= 1;
60826145 if warp_eligible {
60836146 let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]);
60846147 match mode {
@@ -6095,6 +6158,7 @@ fn decode_inter_block(
60956158 mi_row,
60966159 mi_col,
60976160 bw4,
6161+ bh4,
60986162 mi_cols as usize,
60996163 mi_rows as usize,
61006164 ref_frame,
@@ -6113,8 +6177,11 @@ fn decode_inter_block(
61136177 }
61146178 warp_params = crate::warp::find_projection(
61156179 &samples,
6116- side as i32,
6117- side as i32,
6180+ // lane-rect r2: the block's TRUE dims -- a
6181+ // 32x16 strip's model center is not a
6182+ // 32x32's (aom av1_find_projection bw/bh).
6183+ write_w as i32,
6184+ write_h as i32,
61186185 mv.1,
61196186 mv.0,
61206187 mi_row as i32,
@@ -6193,7 +6260,10 @@ fn decode_inter_block(
61936260 skip as u8, mv.0, mv.1, block_filter, motion_mode_eligible as u8, obmc_selected as u8, warp_params.is_some() as u8, dec.debug_bitpos()
61946261 );
61956262 }
6196- for dr in 0..bw4 {
6263+ // lane-rect r2: see the compound path's matching comment above --
6264+ // `grid` must be stamped with the block's true bh4/bw4 span, not
6265+ // a square `bw4`x`bw4` guess.
6266+ for dr in 0..bh4 {
61976267 for dc in 0..bw4 {
61986268 grid.set(
61996269 mi_row + dr,
@@ -6212,6 +6282,7 @@ fn decode_inter_block(
62126282 mv,
62136283 is_new_mv,
62146284 size: bw4,
6285+ size_h: bh4,
62156286 },
62166287 );
62176288 }
@@ -6286,9 +6357,12 @@ fn decode_inter_block(
62866357 mi_row,
62876358 mi_col,
62886359 bw4,
6360+ bh4,
62896361 mi_rows as usize,
62906362 mi_cols as usize,
62916363 side,
6364+ write_w,
6365+ write_h,
62926366 chroma_side,
62936367 px,
62946368 py,
@@ -6454,6 +6528,7 @@ fn decode_inter_block(
64546528 mv: (0, 0),
64556529 is_new_mv: false,
64566530 size: side / 4,
6531+ size_h: side / 4,
64576532 },
64586533 );
64596534 }
@@ -6602,11 +6677,11 @@ fn decode_inter_block(
66026677 (r * (SUB / MI), c * (SUB / MI)),
66036678 write_w / MI,
66046679 write_h / MI,
6605- // lane-warp r5 / lane-partitions r1: `tx_grid` names one scalar
6606- // (its own doc comment) -- a true rectangular strip's real
6607- // TX_32X16/TX_16X32 keeps using `side`, the same square-context
6608- // corner-cut `HORZ_B`'s top strip already shipped.
6609- side as u8,
6680+ // lane-rect r2: the strip's true TX_32X16/TX_16X32 dims -- the
6681+ // single-scalar corner-cut deblocked the strip seam with the wrong
6682+ // edge length (1-px chroma drift on rect-flake-1 f17+).
6683+ write_w as u8,
6684+ write_h as u8,
66106685 // ref_grid's packed convention (lf_level): sign carries GLOBALMV,
66116686 // whose mode_lf_lut row is 0, not the 1 every other inter mode gets.
66126687 if globalmv_for_lf {
@@ -6911,6 +6986,7 @@ fn decode_inter_block8(
69116986 mv: mv0,
69126987 is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7),
69136988 size: 2,
6989+ size_h: 2,
69146990 },
69156991 );
69166992 }
@@ -7248,7 +7324,7 @@ fn decode_inter_block8(
72487324 // (see its own doc) -- this leaf is always `LAST_FRAME`-only
72497325 // (grid.set below hardcodes it).
72507326 let warp_eligible = allow_warped_motion
7251- && num_proj_ref(grid, mi_row, mi_col, 2, mi_cols as usize, mi_rows as usize, LAST_FRAME) >= 1;
7327+ && num_proj_ref(grid, mi_row, mi_col, 2, 2, mi_cols as usize, mi_rows as usize, LAST_FRAME) >= 1;
72527328 if warp_eligible {
72537329 let mode = dec.symbol(&mut cdfs.motion_mode[0]);
72547330 match mode {
@@ -7291,6 +7367,7 @@ fn decode_inter_block8(
72917367 mv,
72927368 is_new_mv,
72937369 size: 2,
7370+ size_h: 2,
72947371 },
72957372 );
72967373 }
@@ -7341,9 +7418,12 @@ fn decode_inter_block8(
73417418 mi_row,
73427419 mi_col,
73437420 2,
7421+ 2,
73447422 mi_rows as usize,
73457423 mi_cols as usize,
73467424 SIDE,
7425+ SIDE,
7426+ SIDE,
73477427 CHROMA_SIDE,
73487428 px,
73497429 py,
@@ -7481,6 +7561,7 @@ fn decode_inter_block8(
74817561 mv: (0, 0),
74827562 is_new_mv: false,
74837563 size: 2,
7564+ size_h: 2,
74847565 },
74857566 );
74867567 }
@@ -8208,8 +8289,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
82088289 switchable_motion_mode,
82098290 allow_warped_motion,
82108291 true,
8292+ // lane-rect r2: the top strip's TRUE 32x16
8293+ // footprint (was BLOCK,BLOCK -- the same square
8294+ // corner-cut rect-flake-1 exposed on HORZ).
82118295 BLOCK,
8212- BLOCK,
8296+ SUB,
82138297 )?;
82148298 if (r32 * 2 + 1) as u32 * SUB_MI < mi_rows {
82158299 decode_inter_block(
@@ -8317,31 +8401,202 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
83178401 }
83188402 }
83198403 PARTITION_HORZ => {
8320- // lane-partitions r1 FINDING (pin rect-flake-1.obu,
8321- // decode frame 16 strip 2): decoding each 32x16 strip
8322- // with `side=32` square contexts desyncs -- a real
8323- // 32x16 block's mvstack weights/DRL selection use
8324- // n4_h=4, and the second strip picked a different
8325- // NEARMV than aomdec (class
8326- // decision-at-wrong-granularity). The write-footprint
8327- // plumbing (`write_w`/`write_h`, `_rect` methods)
8328- // stays; r2 threads true bw4/bh4 through
8329- // find_mv_stack + every neighbour ctx, gated by the
8330- // pinned stream. NOTE: HORZ_B's top strip carries the
8331- // same square-context corner-cut and owes the same
8332- // fix; its pins are byte-exact only because their
8333- // stacks happen to coincide.
8334- return Err(unsupported(
8335- "a HORZ rect partition (32x16 strips need rectangular \
8336- mvstack/context derivation, r2)",
8337- ));
8404+ // lane-rect r2: two true 32x16 strips. Both read at
8405+ // `side=BLOCK` (CDF/size-class selection stays square,
8406+ // matching HORZ_B's accepted corner-cut) but bw4/bh4
8407+ // (mvstack.rs, `motion_mode_eligible`) now derive from
8408+ // `write_w`/`write_h`'s true 32x16 footprint -- the
8409+ // pin's fix (r1's finding).
8410+ RECT_PARTITION_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
8411+ decode_inter_block(
8412+ &mut dec,
8413+ &mut cdfs,
8414+ &mut neighbours,
8415+ &mut grid,
8416+ at,
8417+ BLOCK,
8418+ mi_cols,
8419+ mi_rows,
8420+ &mut y,
8421+ &mut u,
8422+ &mut v,
8423+ &ref_y,
8424+ &ref_u,
8425+ &ref_v,
8426+ &ref_slots,
8427+ &sign_bias_table,
8428+ base_q_idx,
8429+ TxbSet::Luma32,
8430+ TxbSet::Luma32Inter,
8431+ TxbSet::Chroma16,
8432+ TX32,
8433+ TX16,
8434+ &scan32,
8435+ &scan16,
8436+ 3,
8437+ allow_high_precision_mv,
8438+ force_integer_mv,
8439+ interp_fixed,
8440+ enable_dual_filter,
8441+ tpl_frame.as_ref(),
8442+ reference_select,
8443+ enable_masked_compound,
8444+ enable_interintra_compound,
8445+ enable_jnt_comp,
8446+ order_hint_bits,
8447+ order_hint,
8448+ ref_order_hints,
8449+ skip_mode_present,
8450+ skip_mode_frame,
8451+ switchable_motion_mode,
8452+ allow_warped_motion,
8453+ true,
8454+ BLOCK,
8455+ SUB,
8456+ )?;
8457+ decode_inter_block(
8458+ &mut dec,
8459+ &mut cdfs,
8460+ &mut neighbours,
8461+ &mut grid,
8462+ (r32 as usize * 2 + 1, c32 as usize * 2),
8463+ BLOCK,
8464+ mi_cols,
8465+ mi_rows,
8466+ &mut y,
8467+ &mut u,
8468+ &mut v,
8469+ &ref_y,
8470+ &ref_u,
8471+ &ref_v,
8472+ &ref_slots,
8473+ &sign_bias_table,
8474+ base_q_idx,
8475+ TxbSet::Luma32,
8476+ TxbSet::Luma32Inter,
8477+ TxbSet::Chroma16,
8478+ TX32,
8479+ TX16,
8480+ &scan32,
8481+ &scan16,
8482+ 3,
8483+ allow_high_precision_mv,
8484+ force_integer_mv,
8485+ interp_fixed,
8486+ enable_dual_filter,
8487+ tpl_frame.as_ref(),
8488+ reference_select,
8489+ enable_masked_compound,
8490+ enable_interintra_compound,
8491+ enable_jnt_comp,
8492+ order_hint_bits,
8493+ order_hint,
8494+ ref_order_hints,
8495+ skip_mode_present,
8496+ skip_mode_frame,
8497+ switchable_motion_mode,
8498+ allow_warped_motion,
8499+ true,
8500+ BLOCK,
8501+ SUB,
8502+ )?;
83388503 }
83398504 PARTITION_VERT => {
8340- // See PARTITION_HORZ above -- same r2 refusal.
8341- return Err(unsupported(
8342- "a VERT rect partition (16x32 strips need rectangular \
8343- mvstack/context derivation, r2)",
8344- ));
8505+ // lane-rect r2: mirror of PARTITION_HORZ above with
8506+ // width/height swapped.
8507+ RECT_PARTITION_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
8508+ decode_inter_block(
8509+ &mut dec,
8510+ &mut cdfs,
8511+ &mut neighbours,
8512+ &mut grid,
8513+ at,
8514+ BLOCK,
8515+ mi_cols,
8516+ mi_rows,
8517+ &mut y,
8518+ &mut u,
8519+ &mut v,
8520+ &ref_y,
8521+ &ref_u,
8522+ &ref_v,
8523+ &ref_slots,
8524+ &sign_bias_table,
8525+ base_q_idx,
8526+ TxbSet::Luma32,
8527+ TxbSet::Luma32Inter,
8528+ TxbSet::Chroma16,
8529+ TX32,
8530+ TX16,
8531+ &scan32,
8532+ &scan16,
8533+ 3,
8534+ allow_high_precision_mv,
8535+ force_integer_mv,
8536+ interp_fixed,
8537+ enable_dual_filter,
8538+ tpl_frame.as_ref(),
8539+ reference_select,
8540+ enable_masked_compound,
8541+ enable_interintra_compound,
8542+ enable_jnt_comp,
8543+ order_hint_bits,
8544+ order_hint,
8545+ ref_order_hints,
8546+ skip_mode_present,
8547+ skip_mode_frame,
8548+ switchable_motion_mode,
8549+ allow_warped_motion,
8550+ true,
8551+ SUB,
8552+ BLOCK,
8553+ )?;
8554+ decode_inter_block(
8555+ &mut dec,
8556+ &mut cdfs,
8557+ &mut neighbours,
8558+ &mut grid,
8559+ (r32 as usize * 2, c32 as usize * 2 + 1),
8560+ BLOCK,
8561+ mi_cols,
8562+ mi_rows,
8563+ &mut y,
8564+ &mut u,
8565+ &mut v,
8566+ &ref_y,
8567+ &ref_u,
8568+ &ref_v,
8569+ &ref_slots,
8570+ &sign_bias_table,
8571+ base_q_idx,
8572+ TxbSet::Luma32,
8573+ TxbSet::Luma32Inter,
8574+ TxbSet::Chroma16,
8575+ TX32,
8576+ TX16,
8577+ &scan32,
8578+ &scan16,
8579+ 3,
8580+ allow_high_precision_mv,
8581+ force_integer_mv,
8582+ interp_fixed,
8583+ enable_dual_filter,
8584+ tpl_frame.as_ref(),
8585+ reference_select,
8586+ enable_masked_compound,
8587+ enable_interintra_compound,
8588+ enable_jnt_comp,
8589+ order_hint_bits,
8590+ order_hint,
8591+ ref_order_hints,
8592+ skip_mode_present,
8593+ skip_mode_frame,
8594+ switchable_motion_mode,
8595+ allow_warped_motion,
8596+ true,
8597+ SUB,
8598+ BLOCK,
8599+ )?;
83458600 }
83468601 _ => {
83478602 return Err(unsupported(format!(
@@ -8968,6 +9223,7 @@ mod tests {
89689223 mv,
89699224 is_new_mv: false,
89709225 size: 1,
9226+ size_h: 1,
89719227 };
89729228 for col in mi_col..mi_col + bw4 {
89739229 grid.set(mi_row - 1, col, neighbour(above_mv));
crates/ec-av1/src/encode.rsmodified+6 -0
@@ -2617,6 +2617,7 @@ pub(crate) fn encode_inter_frame(
26172617 mv: info.mv,
26182618 is_new_mv: matches!(info.mode, InterMode::NewMv),
26192619 size: 8,
2620+ size_h: 8,
26202621 },
26212622 // Intra: no vote, but still a coded cell
26222623 // -- mvstack's extended-scan coverage
@@ -2630,6 +2631,7 @@ pub(crate) fn encode_inter_frame(
26302631 mv: (0, 0),
26312632 is_new_mv: false,
26322633 size: 8,
2634+ size_h: 8,
26332635 },
26342636 },
26352637 );
@@ -2709,6 +2711,7 @@ pub(crate) fn encode_inter_frame(
27092711 mv: info.mv,
27102712 is_new_mv: matches!(info.mode, InterMode::NewMv),
27112713 size: 4,
2714+ size_h: 4,
27122715 },
27132716 None => MiInfo {
27142717 is_inter: false,
@@ -2718,6 +2721,7 @@ pub(crate) fn encode_inter_frame(
27182721 mv: (0, 0),
27192722 is_new_mv: false,
27202723 size: 4,
2724+ size_h: 4,
27212725 },
27222726 },
27232727 );
@@ -2766,6 +2770,7 @@ pub(crate) fn encode_inter_frame(
27662770 InterMode::NewMv
27672771 ),
27682772 size: 2,
2773+ size_h: 2,
27692774 },
27702775 None => MiInfo {
27712776 is_inter: false,
@@ -2775,6 +2780,7 @@ pub(crate) fn encode_inter_frame(
27752780 mv: (0, 0),
27762781 is_new_mv: false,
27772782 size: 2,
2783+ size_h: 2,
27782784 },
27792785 },
27802786 );
crates/ec-av1/src/mvstack.rsmodified+22 -8
@@ -153,6 +153,10 @@ pub struct MiInfo {
153153 /// candidate's `bsize` regardless of whether it also casts a vote (that
154154 /// requires a ref-frame match, checked separately in `add_ref_mv_candidate`).
155155 pub size: usize,
156+ /// The unit's height in 4x4 mi cells (== `size` for every square block;
157+ /// differs only for rect partition strips, lane-rect r2). Row scans step
158+ /// and weight by `size` (width), column scans by `size_h`.
159+ pub size_h: usize,
156160 }
157161
158162 /// The whole frame's `mi` grid, one [`MiInfo`] per 4x4 unit, in raster order.
@@ -408,7 +412,7 @@ fn scan_row(
408412 }
409413 let mut weight = ROW_COL_WEIGHT_FLOOR;
410414 if bw4 <= n4 {
411- let inc = ((-max_row_offset + row_offset + 1) as usize).min(n4);
415+ let inc = ((-max_row_offset + row_offset + 1) as usize).min(info.size_h);
412416 weight = weight.max(inc as u32);
413417 *processed_rows = (inc as isize - row_offset - 1).max(0) as usize;
414418 }
@@ -472,7 +476,7 @@ fn scan_col(
472476 i += 1;
473477 continue;
474478 };
475- let n4 = info.size;
479+ let n4 = info.size_h;
476480 let mut len = bh4.min(n4);
477481 if use_step_16 {
478482 len = len.max(4);
@@ -481,7 +485,7 @@ fn scan_col(
481485 }
482486 let mut weight = ROW_COL_WEIGHT_FLOOR;
483487 if bh4 <= n4 {
484- let inc = ((-max_col_offset + col_offset + 1) as usize).min(n4);
488+ let inc = ((-max_col_offset + col_offset + 1) as usize).min(info.size);
485489 weight = weight.max(inc as u32);
486490 *processed_cols = (inc as isize - col_offset - 1).max(0) as usize;
487491 }
@@ -923,7 +927,7 @@ pub fn find_mv_stack_with_sign_bias(
923927 let mut idx = 0usize;
924928 while idx < mi_size && candidates.len() < MAX_MV_REF_CANDIDATES {
925929 let cand = grid.get(mi_row + idx, mi_col - 1);
926- let step = cand.map_or(1, |c| c.size).max(1);
930+ let step = cand.map_or(1, |c| c.size_h).max(1);
927931 if let Some(c) = cand {
928932 process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut candidates);
929933 }
@@ -1123,7 +1127,7 @@ fn scan_row_compound(
11231127 }
11241128 let mut weight = ROW_COL_WEIGHT_FLOOR;
11251129 if bw4 <= n4 {
1126- let inc = ((-max_row_offset + row_offset + 1) as usize).min(n4);
1130+ let inc = ((-max_row_offset + row_offset + 1) as usize).min(info.size_h);
11271131 weight = weight.max(inc as u32);
11281132 *processed_rows = (inc as isize - row_offset - 1).max(0) as usize;
11291133 }
@@ -1170,7 +1174,7 @@ fn scan_col_compound(
11701174 i += 1;
11711175 continue;
11721176 };
1173- let n4 = info.size;
1177+ let n4 = info.size_h;
11741178 let mut len = bh4.min(n4);
11751179 if use_step_16 {
11761180 len = len.max(4);
@@ -1179,7 +1183,7 @@ fn scan_col_compound(
11791183 }
11801184 let mut weight = ROW_COL_WEIGHT_FLOOR;
11811185 if bh4 <= n4 {
1182- let inc = ((-max_col_offset + col_offset + 1) as usize).min(n4);
1186+ let inc = ((-max_col_offset + col_offset + 1) as usize).min(info.size);
11831187 weight = weight.max(inc as u32);
11841188 *processed_cols = (inc as isize - col_offset - 1).max(0) as usize;
11851189 }
@@ -1581,7 +1585,7 @@ pub fn find_mv_stack_compound(
15811585 let mut idx = 0usize;
15821586 while idx < mi_size {
15831587 let cand = grid.get(mi_row + idx, mi_col - 1);
1584- let step = cand.map_or(1, |c| c.size).max(1);
1588+ let step = cand.map_or(1, |c| c.size_h).max(1);
15851589 if let Some(c) = cand {
15861590 process_compound_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut lists);
15871591 }
@@ -1978,6 +1982,7 @@ mod tests {
19781982 // so it never trips the extended-scan coverage boost -- these
19791983 // tests only exercise the immediate/corner/top-right scans.
19801984 size: 1,
1985+ size_h: 1,
19811986 }
19821987 }
19831988
@@ -2131,6 +2136,7 @@ mod tests {
21312136 mv: (4, 4),
21322137 is_new_mv: true,
21332138 size: 1,
2139+ size_h: 1,
21342140 },
21352141 );
21362142 // Only the row matches (nearest_match == 1): newmv_count > 0 picks
@@ -2211,6 +2217,7 @@ mod tests {
22112217 mv,
22122218 is_new_mv: false,
22132219 size: 8,
2220+ size_h: 8,
22142221 },
22152222 );
22162223
@@ -2240,6 +2247,7 @@ mod tests {
22402247 mv: (0, 0),
22412248 is_new_mv: false,
22422249 size: 8,
2250+ size_h: 8,
22432251 }
22442252 }
22452253
@@ -2256,6 +2264,7 @@ mod tests {
22562264 mv,
22572265 is_new_mv: false,
22582266 size: 8,
2267+ size_h: 8,
22592268 }
22602269 }
22612270
@@ -2493,6 +2502,7 @@ mod tests {
24932502 mv1: Some(mv1),
24942503 is_new_mv: false,
24952504 size: 1,
2505+ size_h: 1,
24962506 }
24972507 }
24982508
@@ -2513,6 +2523,7 @@ mod tests {
25132523 mv1: Some((9, 9)),
25142524 is_new_mv: false,
25152525 size: 1,
2526+ size_h: 1,
25162527 },
25172528 );
25182529 // Exact pair match.
@@ -2613,6 +2624,7 @@ mod tests {
26132624 mv1: None,
26142625 is_new_mv: false,
26152626 size: 1,
2627+ size_h: 1,
26162628 };
26172629 process_compound_ref_mv_candidate(&candidate, COMP_PAIR, &NO_SIGN_BIAS, &mut lists);
26182630 assert_eq!(lists.ref_id[0], vec![(5, 5)]);
@@ -2639,6 +2651,7 @@ mod tests {
26392651 mv1: None,
26402652 is_new_mv: false,
26412653 size: 8,
2654+ size_h: 8,
26422655 },
26432656 );
26442657 grid.set(
@@ -2652,6 +2665,7 @@ mod tests {
26522665 mv1: None,
26532666 is_new_mv: false,
26542667 size: 8,
2668+ size_h: 8,
26552669 },
26562670 );
26572671
crates/ec-av1/src/stream.rsmodified+18 -6
@@ -3741,11 +3741,11 @@ mod tests {
37413741 "--enable-onesided-comp=0",
37423742 "--enable-interintra-wedge=0",
37433743 "--enable-smooth-interintra=0",
3744- // lane-partitions r1: the free (rect=1, min=16) recipe found
3745- // and PINNED rect-flake-1.obu -- the 32x16 strip mvstack
3746- // desync now refused by name for r2; recipe re-clamped so the
3747- // gate stays green until rectangular contexts land.
3748- "--enable-rect-partitions=0",
3744+ // lane-rect r2: HORZ/VERT decode for real (rect-flake-1
3745+ // byte-exact: size_h + warp dims + OBMC overlap + tx height)
3746+ // -- free recipe restored; remaining partition kinds refuse
3747+ // by name and skip their seeds.
3748+ "--enable-rect-partitions=1",
37493749 "--enable-ab-partitions=1",
37503750 "--enable-1to4-partitions=0",
37513751 "--enable-filter-intra=0",
@@ -3757,7 +3757,7 @@ mod tests {
37573757 "--enable-cdef=0",
37583758 "--enable-restoration=0",
37593759 "--max-partition-size=32",
3760- "--min-partition-size=32",
3760+ "--min-partition-size=16",
37613761 "--enable-palette=0",
37623762 "--enable-intrabc=0",
37633763 "--enable-cfl-intra=0",
@@ -4081,6 +4081,18 @@ mod tests {
40814081 // saturation slowed the adaptation rate) -- unrelated to
40824082 // interintra, caught by the same gate.
40834083 "ii-flake-9",
4084+ // lane-rect r2: HORZ strip rect defects (mvstack size_h,
4085+ // warp sample/projection dims, OBMC overlap, deblock tx-h).
4086+ "rect-flake-1",
4087+ // scan_row/scan_col weight `inc` min'd by the wrong candidate
4088+ // axis (width vs height) -- ties reordered DRL entry 1 for a
4089+ // block under a 32x16 strip, and suppressed the -5 extended
4090+ // row scan.
4091+ "rect-flake-2",
4092+ // overlappable_left stepped the vertical walk by the
4093+ // neighbour's WIDTH: a 32x16 left strip swallowed the strip
4094+ // below it, blending the wrong OBMC prediction there.
4095+ "rect-flake-3",
40844096 ]
40854097 .iter()
40864098 .map(|n| format!("{fixtures}/{n}.obu"))
crates/ec-av1/src/tile.rsmodified+8 -0
@@ -2439,6 +2439,7 @@ pub fn sb_coeff_inter_frame_tile(
24392439 mv,
24402440 is_new_mv,
24412441 size: 8,
2442+ size_h: 8,
24422443 },
24432444 );
24442445 for dr in 0..8 {
@@ -2457,6 +2458,7 @@ pub fn sb_coeff_inter_frame_tile(
24572458 mv,
24582459 is_new_mv,
24592460 size: 8,
2461+ size_h: 8,
24602462 },
24612463 );
24622464 }
@@ -2486,6 +2488,7 @@ pub fn sb_coeff_inter_frame_tile(
24862488 mv: (0, 0),
24872489 is_new_mv: false,
24882490 size: 8,
2491+ size_h: 8,
24892492 },
24902493 );
24912494 }
@@ -2626,6 +2629,7 @@ fn write_inter_frame_leaf(
26262629 mv,
26272630 is_new_mv,
26282631 size: SUB_MI as usize,
2632+ size_h: SUB_MI as usize,
26292633 },
26302634 );
26312635 }
@@ -2655,6 +2659,7 @@ fn write_inter_frame_leaf(
26552659 mv: (0, 0),
26562660 is_new_mv: false,
26572661 size: SUB_MI as usize,
2662+ size_h: SUB_MI as usize,
26582663 },
26592664 );
26602665 }
@@ -2818,6 +2823,7 @@ fn write_inter_frame_leaf8(
28182823 mv,
28192824 is_new_mv,
28202825 size: 2,
2826+ size_h: 2,
28212827 },
28222828 );
28232829 }
@@ -2847,6 +2853,7 @@ fn write_inter_frame_leaf8(
28472853 mv: (0, 0),
28482854 is_new_mv: false,
28492855 size: 2,
2856+ size_h: 2,
28502857 },
28512858 );
28522859 }
@@ -5101,6 +5108,7 @@ mod tests {
51015108 mv,
51025109 is_new_mv,
51035110 size: 8,
5111+ size_h: 8,
51045112 },
51055113 );
51065114 }
lanes/rect-r2.charter.mdadded+66 -0
@@ -0,0 +1,66 @@
1+# lane-rect r2 charter — rectangular mvstack/context threading; HORZ/VERT decode for real
2+
3+## Where you are
4+Worktree /home/user/Documents/Code/Rust/edith_codecs-rect2, branch lane-rect2 @ f9f9767.
5+Build/test ONLY: `env CARGO_TARGET_DIR=$HOME/.cache/cargo-target-rect2 cargo test -p ec-av1 --release --lib <name> -- --nocapture`
6+FOREGROUND, `nice -n 19`, `CARGO_BUILD_JOBS=4`. Never push; never touch other worktrees; fixtures/ is a symlink.
7+BUDGET DISCIPLINE (you have ~75 tool calls, two predecessors died at the cap): read ONLY the files/lines named here; commit compiling WIP + write the report by call 60, whatever state you are in.
8+
9+## Read first (in this order, nothing else)
10+1. lanes/partitions-r1.report.md — the defect you are fixing, fully localized.
11+2. git show 4782e57 -- crates/ec-av1/src/decode.rs — the strip-decode implementation
12+ to resurrect (HORZ/VERT arms with write_w/write_h; the arms currently refuse at
13+ decode.rs ~8212/~8232 with the finding in a comment).
14+3. crates/ec-av1/src/mvstack.rs — find_mv_stack's signature and its row/col scan +
15+ weight math (it takes a square bw4 today).
16+4. libaom /tmp/libaom-src/av1/common/mvref_common.c setup_ref_mv_list + scan_row_mbmi
17+ /scan_col_mbmi/scan_blk_mbmi: everywhere xd->width vs xd->height (n4_w/n4_h)
18+ appear asymmetrically — row scans use n4_w, col scans n4_h, weights use
19+ AOMMIN(2, ...) of each, max_row/col_offset derivation, has_top_right.
20+
21+## The defect (pinned, deterministic)
22+fixtures/rect-flake-1.obu, decode frame 16, block (0,8) = PARTITION_HORZ:
23+strip 2 (32x16 at mi 4,8) must build its mvstack as a 32x16 block (n4_w=8, n4_h=4);
24+our square-context decode picked the wrong NEARMV DRL entry (got strip 1's (0,-16),
25+aom gets (0,0)). Range ladder diverges inside strip 2.
26+
27+## Scope
28+1. Give find_mv_stack (and its ctx outputs new_mv_ctx/ref_mv_ctx + drl weighting)
29+ separate bw4/bh4 params; audit inside it every use of the current square bw4 and
30+ split per libaom (row scan lengths/weights vs col scan lengths/weights,
31+ max offsets, the extra-search + has_top_right rules). Square callers pass
32+ (bw4, bw4) — zero behavior change there (the lib suite proves it).
33+2. Thread bw4/bh4 through decode_inter_block's other side-derived SYNTAX surfaces
34+ for a rect block: is_inter/skip/ref ctx gathers over the true mi span (the _rect
35+ record methods from r1 already write the true span — the READ side must match),
36+ warp num_proj_ref/find_samples (bw4 vs bh4 in its row/col walks), obmc overlap
37+ eligibility (above row uses width, left col uses height). grep `bw4` inside
38+ decode_inter_block and adjudicate each use: width, height, or both.
39+3. Resurrect the HORZ/VERT arms from 4782e57 on top of this (side still drives CDF
40+ size-class selection — bsize 32x16 shares the 32-class tables? NO: check libaom
41+ size lookups: partition ctx bsize, tx size TX_32X16, size_group_lookup,
42+ skip/mode CDFs are indexed by bsize where 32x16 != 32x32 — verify EACH indexed
43+ table against libaom's bsize enum for BLOCK_32X16/16X32 and use the right rows;
44+ class cdf-row-held-constant).
45+4. GATE LADDER (in order): (a) rect-flake-1 pin must decode byte-exact:
46+ `EC_AV1_GATE_DUMP_PIN=/home/user/Documents/Code/Rust/edith_codecs/fixtures/rect-flake-1.obu cargo test -p ec-av1 --release --lib pinned_warp_stream_decodes_pixel_exact -- --ignored --nocapture`
47+ (b) existing 11-pin default list stays green (c) un-clamp the free-partition gate
48+ recipe (stream.rs a_real_aomenc_stream_with_free_partitions_decodes_pixel_exact:
49+ set --enable-rect-partitions=1 and --min-partition-size=16; the comment there
50+ documents this) and hammer 6x with EC_AV1_GATE_DUMP self-pin
51+ (/tmp/claude-1000/rect-flake-N.obu) — new mismatches: pin + localize via the
52+ report's ladder (recon dump → range ladder ours[k]=aom[k+1] → EC_AV1_TELL).
53+ (d) full lib suite.
54+5. Sweep HORZ_B's top strip (same class, latent): its arm should build the strip's
55+ stack as 32x16 too once find_mv_stack is rect-capable — flip it and confirm the
56+ 3 warp pins + ii pins stay byte-exact (they contain HORZ_B).
57+6. Add rect-flake-1 to the pinned test's default fixture list ONLY once it passes.
58+
59+## Done criteria
60+1. rect-flake-1 byte-exact; free gate un-clamped green 6/6 (or new pins + localization
61+ for anything beyond HORZ/VERT scope, refusing by name is fine for HORZ_A etc.);
62+ 12-fixture pin list green; lib suite green.
63+2. Committed to lane-rect2 (wip commits as you go — commit after EVERY green
64+ milestone); REPORT lanes/rect-r2.report.md, verdict FIRST line.
65+If the full ctx audit cannot finish: land find_mv_stack rect-capability + the pin
66+green + arms still refusing the residue you did not audit, report what is left.
lanes/rect-r2.report.mdadded+38 -0
@@ -0,0 +1,38 @@
1+# lane-rect r2 report
2+
3+VERDICT: PASS — HORZ/VERT decode for real; rect-flake-1/2/3 byte-exact; free gate un-clamped 6/6; 14-pin list green; lib 220/0.
4+
5+## What landed (lane-rect2, on f9f9767)
6+- c5b21ad/faadb91 (builder): find_mv_stack bw4/bh4 split; grid.set stamps the true
7+ rect footprint; HORZ/VERT arms resurrected from 4782e57.
8+- 20f93eb: motion_mode/obmc CDFs gain BLOCK_16X32/32X16 rows (class
9+ cdf-row-held-constant).
10+- 64a20c7 (rect-flake-1, 4 root causes): MiInfo.size_h everywhere (col scans step
11+ and weight by it); find_samples/find_projection true dims (warp samples at the
12+ neighbour's real center); obmc_blend per-pass caps + overlap (above=write_h/2,
13+ left=write_w/2); tx_h_grid so deblock horizontal edges gate on tx HEIGHT
14+ (1-px chroma seam). HORZ_B top strip flipped to a true (BLOCK, SUB) 32x16.
15+- 6d5c75d (rect-flake-2): scan_row/scan_col weight `inc` must min by the
16+ candidate's CROSS axis (libaom mi_size_high in the row scan, mi_size_wide in
17+ the col scan) — all 4 sites (single + compound). Square candidates hide it; a
18+ 32x16 strip above tied weights, reordering DRL entry 1 and suppressing the -5
19+ extended row scan. EVIDENCE: aom EC_DRL w0=688 w1=672 + EC_ROWSCAN
20+ row_offset=-5 weight=2 vs our tie 688/688; pin byte-exact after.
21+- 441003d (rect-flake-3): overlappable_left stepped the vertical walk by the
22+ neighbour's WIDTH; a 32x16 left strip swallowed the strip below it and rows
23+ 48-63 blended strip1's OBMC prediction. EVIDENCE: recon diff exactly the
24+ second strip's band, ranges exact everywhere. Class sweep: all other grid
25+ walks step by the matching axis (mvstack 919/1577 + decode 4293/4404/4426 are
26+ horizontal, correctly width-stepped).
27+
28+## Gates
29+- 14 pins green (warp-mismatch, warp-flake-5/7, ii-flake-1..3,5..9,
30+ rect-flake-1/2/3) — EVIDENCE: default pin test inside lib run.
31+- Free-partition gate un-clamped (--enable-rect-partitions=1
32+ --min-partition-size=16): 6/6 with EC_AV1_GATE_DUMP self-pin armed.
33+- Full lib: 220 passed / 0 failed.
34+
35+## Residue
36+- HORZ_A/VERT_A/VERT_B/HORZ_4/VERT_4 still refuse by name (machinery is now
37+ rect-capable; next lane).
38+- rect-flake-2/3 fixture .bak copies + /tmp dumps are scratch, not repo.