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 commit9 changed files +493 -85
- crates/ec-av1/src/cdf.rs +10 -2
- crates/ec-av1/src/cdf_state.rs +2 -2
- crates/ec-av1/src/decode.rs +323 -67
- crates/ec-av1/src/encode.rs +6 -0
- crates/ec-av1/src/mvstack.rs +22 -8
- crates/ec-av1/src/stream.rs +18 -6
- crates/ec-av1/src/tile.rs +8 -0
- lanes/rect-r2.charter.md +66 -0
- lanes/rect-r2.report.md +38 -0
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 | |||
| 1211 | /// `motion_mode_allowed` (spec 5.11.24's `read_motion_mode`) offers | 1211 | /// `motion_mode_allowed` (spec 5.11.24's `read_motion_mode`) offers |
| 1212 | /// `OBMC_CAUSAL` rather than `WARPED_CAUSAL` -- lane-motionmode round 1 | 1212 | /// `OBMC_CAUSAL` rather than `WARPED_CAUSAL` -- lane-motionmode round 1 |
| 1213 | /// never reaches the three-way `motion_mode_cdf`, see `decode.rs`. | 1213 | /// 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] = [ |
| 1215 | [10437, 32768, 0], | 1215 | [10437, 32768, 0], |
| 1216 | [17432, 32768, 0], | 1216 | [17432, 32768, 0], |
| 1217 | [25817, 32768, 0], | 1217 | [25817, 32768, 0], |
| 1218 | [30128, 32768, 0], | 1218 | [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], | ||
| 1219 | ]; | 1224 | ]; |
| 1220 | 1225 | ||
| 1221 | /// `default_motion_mode_cdf` (spec 9.4, `entropymode.c`), the square-bsize | 1226 | /// `default_motion_mode_cdf` (spec 9.4, `entropymode.c`), the square-bsize |
| @@ -1225,11 +1230,14 @@ pub const OBMC: [[u16; 3]; 4] = [ | |||
| 1225 | /// `read_motion_mode` reads instead of [`OBMC`] whenever `motion_mode_allowed` | 1230 | /// `read_motion_mode` reads instead of [`OBMC`] whenever `motion_mode_allowed` |
| 1226 | /// (spec 5.11.24) resolves to `WARPED_CAUSAL`-eligible (`num_proj_ref >= 1` | 1231 | /// (spec 5.11.24) resolves to `WARPED_CAUSAL`-eligible (`num_proj_ref >= 1` |
| 1227 | /// under `allow_warped_motion`) -- lane-warp round 1. | 1232 | /// under `allow_warped_motion`) -- lane-warp round 1. |
| 1228 | -pub const MOTION_MODE: [[u16; 4]; 4] = [ | 1233 | +pub const MOTION_MODE: [[u16; 4]; 6] = [ |
| 1229 | [7651, 24760, 32768, 0], | 1234 | [7651, 24760, 32768, 0], |
| 1230 | [19419, 26810, 32768, 0], | 1235 | [19419, 26810, 32768, 0], |
| 1231 | [26260, 29116, 32768, 0], | 1236 | [26260, 29116, 32768, 0], |
| 1232 | [29516, 30701, 32768, 0], | 1237 | [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], | ||
| 1233 | ]; | 1241 | ]; |
| 1234 | 1242 | ||
| 1235 | /// `default_interintra_cdf` (spec 9.4): `interintra`, indexed by | 1243 | /// `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 { | |||
| 326 | /// `BLOCK_8X8`, 1 = `BLOCK_16X16`, 2 = `BLOCK_32X32`, 3 = `BLOCK_64X64` | 326 | /// `BLOCK_8X8`, 1 = `BLOCK_16X16`, 2 = `BLOCK_32X32`, 3 = `BLOCK_64X64` |
| 327 | /// (`default_obmc_cdf`'s own `BLOCK_SIZES_ALL` indices 3/6/9/12 -- | 327 | /// (`default_obmc_cdf`'s own `BLOCK_SIZES_ALL` indices 3/6/9/12 -- |
| 328 | /// this decoder only ever codes those four square sizes). | 328 | /// this decoder only ever codes those four square sizes). |
| 329 | - pub obmc: [[u16; 3]; 4], | 329 | + pub obmc: [[u16; 3]; 6], |
| 330 | /// `motion_mode` (spec 5.11.24's `read_motion_mode`), the 3-symbol | 330 | /// `motion_mode` (spec 5.11.24's `read_motion_mode`), the 3-symbol |
| 331 | /// `SIMPLE_TRANSLATION`/`OBMC_CAUSAL`/`WARPED_CAUSAL` alphabet read | 331 | /// `SIMPLE_TRANSLATION`/`OBMC_CAUSAL`/`WARPED_CAUSAL` alphabet read |
| 332 | /// instead of [`Self::obmc`] whenever `motion_mode_allowed` resolves to | 332 | /// instead of [`Self::obmc`] whenever `motion_mode_allowed` resolves to |
| 333 | /// `WARPED_CAUSAL`-eligible -- same square-bsize indexing as `obmc`. | 333 | /// `WARPED_CAUSAL`-eligible -- same square-bsize indexing as `obmc`. |
| 334 | /// lane-warp round 1. | 334 | /// lane-warp round 1. |
| 335 | - pub motion_mode: [[u16; 4]; 4], | 335 | + pub motion_mode: [[u16; 4]; 6], |
| 336 | /// `interintra`, indexed by `size_group_lookup[bsize]` -- see | 336 | /// `interintra`, indexed by `size_group_lookup[bsize]` -- see |
| 337 | /// `cdf::INTERINTRA`'s own doc. | 337 | /// `cdf::INTERINTRA`'s own doc. |
| 338 | pub interintra: [[u16; 3]; 4], | 338 | pub interintra: [[u16; 3]; 4], |
crates/ec-av1/src/decode.rsmodified+323 -67
| @@ -957,6 +957,10 @@ struct Neighbours { | |||
| 957 | /// transform size, spec 7.14's `get_transform_size`/`get_filter_level` | 957 | /// transform size, spec 7.14's `get_transform_size`/`get_filter_level` |
| 958 | /// edge-length lookup (`apply_deblock`). | 958 | /// edge-length lookup (`apply_deblock`). |
| 959 | tx_grid: Vec<u8>, | 959 | 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>, | ||
| 960 | /// Per-4x4-mi reference frame (`0` = intra, magnitude `1..=7` = | 964 | /// Per-4x4-mi reference frame (`0` = intra, magnitude `1..=7` = |
| 961 | /// `MV_REFERENCE_FRAME`, negative = that reference coded as `GLOBALMV` -- | 965 | /// `MV_REFERENCE_FRAME`, negative = that reference coded as `GLOBALMV` -- |
| 962 | /// `lf_level`'s `mode_lf_lut` row 0, lane-av1golden2) | 966 | /// `lf_level`'s `mode_lf_lut` row 0, lane-av1golden2) |
| @@ -1001,6 +1005,7 @@ impl Neighbours { | |||
| 1001 | skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], | 1005 | skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], |
| 1002 | skip_grid_cols_mi: cols * (SUB / MI), | 1006 | skip_grid_cols_mi: cols * (SUB / MI), |
| 1003 | tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], | 1007 | tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 1008 | + tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], | ||
| 1004 | ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)], | 1009 | ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 1005 | } | 1010 | } |
| 1006 | } | 1011 | } |
| @@ -1010,7 +1015,7 @@ impl Neighbours { | |||
| 1010 | /// per-edge lookup (`apply_deblock`), filled at the same call sites and | 1015 | /// per-edge lookup (`apply_deblock`), filled at the same call sites and |
| 1011 | /// units as [`Self::fill_skip_grid`]. | 1016 | /// units as [`Self::fill_skip_grid`]. |
| 1012 | fn fill_lf_grid(&mut self, at_mi: (usize, usize), side_mi: usize, tx_px: u8, ref_frame: i8) { | 1017 | 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); |
| 1014 | } | 1019 | } |
| 1015 | 1020 | ||
| 1016 | /// [`Self::fill_lf_grid`] with independent row/col extents -- lane-partitions | 1021 | /// [`Self::fill_lf_grid`] with independent row/col extents -- lane-partitions |
| @@ -1025,6 +1030,7 @@ impl Neighbours { | |||
| 1025 | w_mi: usize, | 1030 | w_mi: usize, |
| 1026 | h_mi: usize, | 1031 | h_mi: usize, |
| 1027 | tx_px: u8, | 1032 | tx_px: u8, |
| 1033 | + tx_h_px: u8, | ||
| 1028 | ref_frame: i8, | 1034 | ref_frame: i8, |
| 1029 | ) { | 1035 | ) { |
| 1030 | let (mi_r, mi_c) = at_mi; | 1036 | let (mi_r, mi_c) = at_mi; |
| @@ -1034,6 +1040,9 @@ impl Neighbours { | |||
| 1034 | if let Some(cell) = self.tx_grid.get_mut(idx) { | 1040 | if let Some(cell) = self.tx_grid.get_mut(idx) { |
| 1035 | *cell = tx_px; | 1041 | *cell = tx_px; |
| 1036 | } | 1042 | } |
| 1043 | + if let Some(cell) = self.tx_h_grid.get_mut(idx) { | ||
| 1044 | + *cell = tx_h_px; | ||
| 1045 | + } | ||
| 1037 | if let Some(cell) = self.ref_grid.get_mut(idx) { | 1046 | if let Some(cell) = self.ref_grid.get_mut(idx) { |
| 1038 | *cell = ref_frame; | 1047 | *cell = ref_frame; |
| 1039 | } | 1048 | } |
| @@ -2751,6 +2760,18 @@ fn tx_px_at(n: &Neighbours, chroma: bool, mi_r: usize, mi_c: usize) -> u32 { | |||
| 2751 | if chroma { luma_tx / 2 } else { luma_tx } | 2760 | if chroma { luma_tx / 2 } else { luma_tx } |
| 2752 | } | 2761 | } |
| 2753 | 2762 | ||
| 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 | + | ||
| 2754 | /// `get_tx_size_context` (spec 9.3's `TxDepthCtx`, libaom | 2775 | /// `get_tx_size_context` (spec 9.3's `TxDepthCtx`, libaom |
| 2755 | /// `TXFM_CONTEXT`/`entropymode.c`): the sum of two boolean terms, each | 2776 | /// `TXFM_CONTEXT`/`entropymode.c`): the sum of two boolean terms, each |
| 2756 | /// present only when its neighbour exists inside the true frame -- whether | 2777 | /// 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 { | |||
| 2759 | /// as `own_side`. | 2780 | /// as `own_side`. |
| 2760 | fn tx_size_context(n: &Neighbours, (mi_r, mi_c): (usize, usize), own_side: usize) -> usize { | 2781 | fn tx_size_context(n: &Neighbours, (mi_r, mi_c): (usize, usize), own_side: usize) -> usize { |
| 2761 | let above = mi_r > 0 && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_side; | 2782 | 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; |
| 2763 | usize::from(above) + usize::from(left) | 2784 | usize::from(above) + usize::from(left) |
| 2764 | } | 2785 | } |
| 2765 | 2786 | ||
| @@ -2895,7 +2916,11 @@ fn edge_params( | |||
| 2895 | y0: usize, | 2916 | y0: usize, |
| 2896 | ) -> Option<(u8, i32)> { | 2917 | ) -> Option<(u8, i32)> { |
| 2897 | let (mi_r, mi_c) = (plane_to_mi(chroma, y0), plane_to_mi(chroma, x0)); | 2918 | 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 | + }; | ||
| 2899 | if cur_tx == 0 || (if dir == 0 { x0 } else { y0 }) % cur_tx as usize != 0 { | 2924 | if cur_tx == 0 || (if dir == 0 { x0 } else { y0 }) % cur_tx as usize != 0 { |
| 2900 | return None; | 2925 | return None; |
| 2901 | } | 2926 | } |
| @@ -2905,7 +2930,11 @@ fn edge_params( | |||
| 2905 | } else { | 2930 | } else { |
| 2906 | (mi_r - 1, mi_c) | 2931 | (mi_r - 1, mi_c) |
| 2907 | }; | 2932 | }; |
| 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 | + }; | ||
| 2909 | let pv_ref = n.ref_grid[pv_mi_r * n.skip_grid_cols_mi + pv_mi_c]; | 2938 | let pv_ref = n.ref_grid[pv_mi_r * n.skip_grid_cols_mi + pv_mi_c]; |
| 2910 | 2939 | ||
| 2911 | let cur_level = lf_level(lf, plane_idx, dir, cur_ref); | 2940 | let cur_level = lf_level(lf, plane_idx, dir, cur_ref); |
| @@ -4290,7 +4319,9 @@ fn overlappable_left( | |||
| 4290 | let mut row = mi_row; | 4319 | let mut row = mi_row; |
| 4291 | while row < end_row && out.len() < max_neighbors { | 4320 | while row < end_row && out.len() < max_neighbors { |
| 4292 | let cell = grid.get(row, mi_col - 1); | 4321 | 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); | ||
| 4294 | if let Some(info) = cell { | 4325 | if let Some(info) = cell { |
| 4295 | if info.is_inter { | 4326 | if info.is_inter { |
| 4296 | out.push((row - mi_row, step.min(end_row - row), *info)); | 4327 | out.push((row - mi_row, step.min(end_row - row), *info)); |
| @@ -4346,6 +4377,7 @@ fn find_samples( | |||
| 4346 | mi_row: usize, | 4377 | mi_row: usize, |
| 4347 | mi_col: usize, | 4378 | mi_col: usize, |
| 4348 | bw4: usize, | 4379 | bw4: usize, |
| 4380 | + bh4: usize, | ||
| 4349 | mi_cols: usize, | 4381 | mi_cols: usize, |
| 4350 | mi_rows: usize, | 4382 | mi_rows: usize, |
| 4351 | ref_frame: i8, | 4383 | ref_frame: i8, |
| @@ -4359,7 +4391,11 @@ fn find_samples( | |||
| 4359 | let mut do_tr = true; | 4391 | let mut do_tr = true; |
| 4360 | let rec = |info: &MiInfo, row_offset: i32, sign_r: i32, col_offset: i32, sign_c: i32| { | 4392 | let rec = |info: &MiInfo, row_offset: i32, sign_r: i32, col_offset: i32, sign_c: i32| { |
| 4361 | let nb_bw = (info.size * 4) as i32; | 4393 | 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) | ||
| 4363 | }; | 4399 | }; |
| 4364 | 4400 | ||
| 4365 | 'outer: { | 4401 | 'outer: { |
| @@ -4403,8 +4439,8 @@ fn find_samples( | |||
| 4403 | 4439 | ||
| 4404 | if left_available { | 4440 | if left_available { |
| 4405 | let left = grid.get(mi_row, mi_col - 1); | 4441 | let left = grid.get(mi_row, mi_col - 1); |
| 4406 | - let superblock_height = left.map_or(1, |c| c.size).max(1); | 4442 | + let superblock_height = left.map_or(1, |c| c.size_h).max(1); |
| 4407 | - if bw4 <= superblock_height { | 4443 | + if bh4 <= superblock_height { |
| 4408 | let row_offset = -((mi_row % superblock_height) as isize); | 4444 | let row_offset = -((mi_row % superblock_height) as isize); |
| 4409 | if row_offset < 0 { | 4445 | if row_offset < 0 { |
| 4410 | do_tl = false; | 4446 | do_tl = false; |
| @@ -4419,10 +4455,10 @@ fn find_samples( | |||
| 4419 | } | 4455 | } |
| 4420 | } else { | 4456 | } else { |
| 4421 | let mut i = 0usize; | 4457 | 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)); |
| 4423 | while i < limit { | 4459 | while i < limit { |
| 4424 | let cell = grid.get(mi_row + i, mi_col - 1); | 4460 | 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); |
| 4426 | if let Some(info) = cell { | 4462 | if let Some(info) = cell { |
| 4427 | if single_ref_match(info) { | 4463 | if single_ref_match(info) { |
| 4428 | samples.push(rec(info, i as i32, 1, 0, -1)); | 4464 | samples.push(rec(info, i as i32, 1, 0, -1)); |
| @@ -4470,11 +4506,12 @@ fn num_proj_ref( | |||
| 4470 | mi_row: usize, | 4506 | mi_row: usize, |
| 4471 | mi_col: usize, | 4507 | mi_col: usize, |
| 4472 | bw4: usize, | 4508 | bw4: usize, |
| 4509 | + bh4: usize, | ||
| 4473 | mi_cols: usize, | 4510 | mi_cols: usize, |
| 4474 | mi_rows: usize, | 4511 | mi_rows: usize, |
| 4475 | ref_frame: i8, | 4512 | ref_frame: i8, |
| 4476 | ) -> u8 { | 4513 | ) -> 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 |
| 4478 | } | 4515 | } |
| 4479 | 4516 | ||
| 4480 | /// `av1_get_obmc_mask` (`reconinter.c`): the per-position blend weight | 4517 | /// `av1_get_obmc_mask` (`reconinter.c`): the per-position blend weight |
| @@ -4669,9 +4706,12 @@ fn obmc_blend( | |||
| 4669 | mi_row: usize, | 4706 | mi_row: usize, |
| 4670 | mi_col: usize, | 4707 | mi_col: usize, |
| 4671 | bw4: usize, | 4708 | bw4: usize, |
| 4709 | + bh4: usize, | ||
| 4672 | mi_rows: usize, | 4710 | mi_rows: usize, |
| 4673 | mi_cols: usize, | 4711 | mi_cols: usize, |
| 4674 | side: usize, | 4712 | side: usize, |
| 4713 | + write_w: usize, | ||
| 4714 | + write_h: usize, | ||
| 4675 | chroma_side: usize, | 4715 | chroma_side: usize, |
| 4676 | px: usize, | 4716 | px: usize, |
| 4677 | py: usize, | 4717 | py: usize, |
| @@ -4686,15 +4726,19 @@ fn obmc_blend( | |||
| 4686 | pred_u: &mut [u8], | 4726 | pred_u: &mut [u8], |
| 4687 | pred_v: &mut [u8], | 4727 | pred_v: &mut [u8], |
| 4688 | ) -> Result<()> { | 4728 | ) -> 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 { | ||
| 4690 | 1..=4 => 2, | 4734 | 1..=4 => 2, |
| 4691 | 5..=8 => 3, | 4735 | 5..=8 => 3, |
| 4692 | _ => 4, | 4736 | _ => 4, |
| 4693 | }; | 4737 | }; |
| 4694 | - let overlap = side / 2; | 4738 | + let overlap_above = write_h / 2; |
| 4695 | - let coverlap = overlap / 2; | 4739 | + let overlap_left = write_w / 2; |
| 4696 | 4740 | ||
| 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)) |
| 4698 | { | 4742 | { |
| 4699 | // `Neighbours::above_filter` is indexed in `SUB`(16px)-wide columns | 4743 | // `Neighbours::above_filter` is indexed in `SUB`(16px)-wide columns |
| 4700 | // (this decoder's own outer block-loop granularity), one step | 4744 | // (this decoder's own outer block-loop granularity), one step |
| @@ -4705,26 +4749,26 @@ fn obmc_blend( | |||
| 4705 | neighbours.above_filter[(mi_col + off4) / SUB_MI as usize], | 4749 | neighbours.above_filter[(mi_col + off4) / SUB_MI as usize], |
| 4706 | ); | 4750 | ); |
| 4707 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; | 4751 | 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); |
| 4709 | let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind); | 4753 | let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind); |
| 4710 | obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y); | 4754 | 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); |
| 4712 | let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); | 4756 | let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); |
| 4713 | obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u); | 4757 | obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u); |
| 4714 | let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); | 4758 | let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); |
| 4715 | obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v); | 4759 | obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v); |
| 4716 | } | 4760 | } |
| 4717 | 4761 | ||
| 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)) { |
| 4719 | let (h_kind, v_kind) = neighbour_filter( | 4763 | let (h_kind, v_kind) = neighbour_filter( |
| 4720 | interp_fixed, | 4764 | interp_fixed, |
| 4721 | neighbours.left_filter[(mi_row + off4) / SUB_MI as usize], | 4765 | neighbours.left_filter[(mi_row + off4) / SUB_MI as usize], |
| 4722 | ); | 4766 | ); |
| 4723 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; | 4767 | 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); |
| 4725 | let tmp_y = obmc_neighbour_pred(ny, px, py + oy, nb.mv, bw, bh, true, h_kind, v_kind); | 4769 | let tmp_y = obmc_neighbour_pred(ny, px, py + oy, nb.mv, bw, bh, true, h_kind, v_kind); |
| 4726 | obmc_blend_h(pred_y, side, 0, oy, bw, bh, &tmp_y); | 4770 | 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); |
| 4728 | let tmp_u = obmc_neighbour_pred(nu, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind); | 4772 | let tmp_u = obmc_neighbour_pred(nu, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind); |
| 4729 | obmc_blend_h(pred_u, chroma_side, 0, coy, cbw, cbh, &tmp_u); | 4773 | obmc_blend_h(pred_u, chroma_side, 0, coy, cbw, cbh, &tmp_u); |
| 4730 | let tmp_v = obmc_neighbour_pred(nv, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind); | 4774 | 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( | |||
| 5222 | ) | 5266 | ) |
| 5223 | }; | 5267 | }; |
| 5224 | let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); | 5268 | 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; | ||
| 5226 | // spec 7.10.2.8, doubled per side (`CompoundTplArgs`): same | 5272 | // spec 7.10.2.8, doubled per side (`CompoundTplArgs`): same |
| 5227 | // `use_ref_frame_mvs` gating as the single-ref `tpl` build | 5273 | // `use_ref_frame_mvs` gating as the single-ref `tpl` build |
| 5228 | // below, just one `get_relative_dist` per reference. | 5274 | // below, just one `get_relative_dist` per reference. |
| @@ -5245,7 +5291,7 @@ fn decode_inter_block( | |||
| 5245 | mi_row, | 5291 | mi_row, |
| 5246 | mi_col, | 5292 | mi_col, |
| 5247 | bw4, | 5293 | bw4, |
| 5248 | - bw4, | 5294 | + bh4, |
| 5249 | (ref0, ref1), | 5295 | (ref0, ref1), |
| 5250 | mi_cols as usize, | 5296 | mi_cols as usize, |
| 5251 | mi_rows as usize, | 5297 | mi_rows as usize, |
| @@ -5293,7 +5339,12 @@ fn decode_inter_block( | |||
| 5293 | globalmv_for_lf = is_globalmv; | 5339 | globalmv_for_lf = is_globalmv; |
| 5294 | ref_frame_for_lf = ref0; | 5340 | ref_frame_for_lf = ref0; |
| 5295 | mode_for_tx = 0; | 5341 | 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 { | ||
| 5297 | for dc in 0..bw4 { | 5348 | for dc in 0..bw4 { |
| 5298 | grid.set( | 5349 | grid.set( |
| 5299 | mi_row + dr, | 5350 | mi_row + dr, |
| @@ -5306,6 +5357,7 @@ fn decode_inter_block( | |||
| 5306 | mv: mv0, | 5357 | mv: mv0, |
| 5307 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), | 5358 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), |
| 5308 | size: bw4, | 5359 | size: bw4, |
| 5360 | + size_h: bh4, | ||
| 5309 | }, | 5361 | }, |
| 5310 | ); | 5362 | ); |
| 5311 | } | 5363 | } |
| @@ -5884,13 +5936,14 @@ fn decode_inter_block( | |||
| 5884 | }; | 5936 | }; |
| 5885 | 5937 | ||
| 5886 | let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); | 5938 | let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); |
| 5887 | - let bw4 = side / 4; | 5939 | + // lane-rect r2: the mv stack must be queried with the block's |
| 5888 | - // lane-warp r5d: `reject_residual` marks the HORZ_B arm's top | 5940 | + // REAL extent (libaom `av1_get_mv_refs` gets bw4/bh4 from |
| 5889 | - // strip, decoded as a square 32x32 block but truly 32x16 -- the | 5941 | + // xd->width/xd->height, not a square guess) -- `write_w`/ |
| 5890 | - // mv stack must be queried with the block's REAL extent (libaom | 5942 | + // `write_h` already name the true HORZ/VERT/HORZ_B strip |
| 5891 | - // `av1_get_mv_refs` gets bw4=8, bh4=4), else scan_col, the | 5943 | + // footprint (r1's plumbing), so derive bw4/bh4 from those |
| 5892 | - // corner probes and `clamp_mv_ref` all size a 32-tall block. | 5944 | + // instead of the old `side`-square (HORZ_B-only) heuristic. |
| 5893 | - let bh4 = if reject_residual { bw4 / 2 } else { bw4 }; | 5945 | + let bw4 = write_w / 4; |
| 5946 | + let bh4 = write_h / 4; | ||
| 5894 | // spec 7.10.2.8: only reached when the frame header set | 5947 | // spec 7.10.2.8: only reached when the frame header set |
| 5895 | // `use_ref_frame_mvs` (`tpl_frame` is `Some` then, `None` | 5948 | // `use_ref_frame_mvs` (`tpl_frame` is `Some` then, `None` |
| 5896 | // otherwise) -- `cur_offset_0` is this query block's own resolved | 5949 | // otherwise) -- `cur_offset_0` is this query block's own resolved |
| @@ -6050,7 +6103,7 @@ fn decode_inter_block( | |||
| 6050 | && !skip_mode | 6103 | && !skip_mode |
| 6051 | && interintra_mode.is_none() | 6104 | && interintra_mode.is_none() |
| 6052 | && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty() | 6105 | && (!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) |
| 6054 | .is_empty()); | 6107 | .is_empty()); |
| 6055 | let mut obmc_selected = false; | 6108 | let mut obmc_selected = false; |
| 6056 | // lane-warp round 2: `Some` when motion_mode == WARPED_CAUSAL | 6109 | // lane-warp round 2: `Some` when motion_mode == WARPED_CAUSAL |
| @@ -6072,13 +6125,23 @@ fn decode_inter_block( | |||
| 6072 | // wmtype check here. | 6125 | // wmtype check here. |
| 6073 | let mut warped_selected = false; | 6126 | let mut warped_selected = false; |
| 6074 | if motion_mode_eligible { | 6127 | if motion_mode_eligible { |
| 6075 | - // `default_obmc_cdf`'s own index: square bsize 8/16/32/64 -> 0/1/2/3. | 6128 | + // `default_obmc_cdf`'s own index: square bsize 8/16/32/64 -> |
| 6076 | - let bsize_idx = (side.trailing_zeros() - 3) as usize; | 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 | + }; | ||
| 6077 | // `motion_mode_allowed` reads the 3-symbol `motion_mode_cdf` | 6140 | // `motion_mode_allowed` reads the 3-symbol `motion_mode_cdf` |
| 6078 | // instead of the 2-symbol `obmc_cdf` exactly when | 6141 | // instead of the 2-symbol `obmc_cdf` exactly when |
| 6079 | // `num_proj_ref >= 1` under `allow_warped_motion`. | 6142 | // `num_proj_ref >= 1` under `allow_warped_motion`. |
| 6080 | let warp_eligible = allow_warped_motion | 6143 | 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; |
| 6082 | if warp_eligible { | 6145 | if warp_eligible { |
| 6083 | let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); | 6146 | let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); |
| 6084 | match mode { | 6147 | match mode { |
| @@ -6095,6 +6158,7 @@ fn decode_inter_block( | |||
| 6095 | mi_row, | 6158 | mi_row, |
| 6096 | mi_col, | 6159 | mi_col, |
| 6097 | bw4, | 6160 | bw4, |
| 6161 | + bh4, | ||
| 6098 | mi_cols as usize, | 6162 | mi_cols as usize, |
| 6099 | mi_rows as usize, | 6163 | mi_rows as usize, |
| 6100 | ref_frame, | 6164 | ref_frame, |
| @@ -6113,8 +6177,11 @@ fn decode_inter_block( | |||
| 6113 | } | 6177 | } |
| 6114 | warp_params = crate::warp::find_projection( | 6178 | warp_params = crate::warp::find_projection( |
| 6115 | &samples, | 6179 | &samples, |
| 6116 | - side as i32, | 6180 | + // lane-rect r2: the block's TRUE dims -- a |
| 6117 | - side as i32, | 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, | ||
| 6118 | mv.1, | 6185 | mv.1, |
| 6119 | mv.0, | 6186 | mv.0, |
| 6120 | mi_row as i32, | 6187 | mi_row as i32, |
| @@ -6193,7 +6260,10 @@ fn decode_inter_block( | |||
| 6193 | 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() | 6260 | 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() |
| 6194 | ); | 6261 | ); |
| 6195 | } | 6262 | } |
| 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 { | ||
| 6197 | for dc in 0..bw4 { | 6267 | for dc in 0..bw4 { |
| 6198 | grid.set( | 6268 | grid.set( |
| 6199 | mi_row + dr, | 6269 | mi_row + dr, |
| @@ -6212,6 +6282,7 @@ fn decode_inter_block( | |||
| 6212 | mv, | 6282 | mv, |
| 6213 | is_new_mv, | 6283 | is_new_mv, |
| 6214 | size: bw4, | 6284 | size: bw4, |
| 6285 | + size_h: bh4, | ||
| 6215 | }, | 6286 | }, |
| 6216 | ); | 6287 | ); |
| 6217 | } | 6288 | } |
| @@ -6286,9 +6357,12 @@ fn decode_inter_block( | |||
| 6286 | mi_row, | 6357 | mi_row, |
| 6287 | mi_col, | 6358 | mi_col, |
| 6288 | bw4, | 6359 | bw4, |
| 6360 | + bh4, | ||
| 6289 | mi_rows as usize, | 6361 | mi_rows as usize, |
| 6290 | mi_cols as usize, | 6362 | mi_cols as usize, |
| 6291 | side, | 6363 | side, |
| 6364 | + write_w, | ||
| 6365 | + write_h, | ||
| 6292 | chroma_side, | 6366 | chroma_side, |
| 6293 | px, | 6367 | px, |
| 6294 | py, | 6368 | py, |
| @@ -6454,6 +6528,7 @@ fn decode_inter_block( | |||
| 6454 | mv: (0, 0), | 6528 | mv: (0, 0), |
| 6455 | is_new_mv: false, | 6529 | is_new_mv: false, |
| 6456 | size: side / 4, | 6530 | size: side / 4, |
| 6531 | + size_h: side / 4, | ||
| 6457 | }, | 6532 | }, |
| 6458 | ); | 6533 | ); |
| 6459 | } | 6534 | } |
| @@ -6602,11 +6677,11 @@ fn decode_inter_block( | |||
| 6602 | (r * (SUB / MI), c * (SUB / MI)), | 6677 | (r * (SUB / MI), c * (SUB / MI)), |
| 6603 | write_w / MI, | 6678 | write_w / MI, |
| 6604 | write_h / MI, | 6679 | write_h / MI, |
| 6605 | - // lane-warp r5 / lane-partitions r1: `tx_grid` names one scalar | 6680 | + // lane-rect r2: the strip's true TX_32X16/TX_16X32 dims -- the |
| 6606 | - // (its own doc comment) -- a true rectangular strip's real | 6681 | + // single-scalar corner-cut deblocked the strip seam with the wrong |
| 6607 | - // TX_32X16/TX_16X32 keeps using `side`, the same square-context | 6682 | + // edge length (1-px chroma drift on rect-flake-1 f17+). |
| 6608 | - // corner-cut `HORZ_B`'s top strip already shipped. | 6683 | + write_w as u8, |
| 6609 | - side as u8, | 6684 | + write_h as u8, |
| 6610 | // ref_grid's packed convention (lf_level): sign carries GLOBALMV, | 6685 | // ref_grid's packed convention (lf_level): sign carries GLOBALMV, |
| 6611 | // whose mode_lf_lut row is 0, not the 1 every other inter mode gets. | 6686 | // whose mode_lf_lut row is 0, not the 1 every other inter mode gets. |
| 6612 | if globalmv_for_lf { | 6687 | if globalmv_for_lf { |
| @@ -6911,6 +6986,7 @@ fn decode_inter_block8( | |||
| 6911 | mv: mv0, | 6986 | mv: mv0, |
| 6912 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), | 6987 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), |
| 6913 | size: 2, | 6988 | size: 2, |
| 6989 | + size_h: 2, | ||
| 6914 | }, | 6990 | }, |
| 6915 | ); | 6991 | ); |
| 6916 | } | 6992 | } |
| @@ -7248,7 +7324,7 @@ fn decode_inter_block8( | |||
| 7248 | // (see its own doc) -- this leaf is always `LAST_FRAME`-only | 7324 | // (see its own doc) -- this leaf is always `LAST_FRAME`-only |
| 7249 | // (grid.set below hardcodes it). | 7325 | // (grid.set below hardcodes it). |
| 7250 | let warp_eligible = allow_warped_motion | 7326 | 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; |
| 7252 | if warp_eligible { | 7328 | if warp_eligible { |
| 7253 | let mode = dec.symbol(&mut cdfs.motion_mode[0]); | 7329 | let mode = dec.symbol(&mut cdfs.motion_mode[0]); |
| 7254 | match mode { | 7330 | match mode { |
| @@ -7291,6 +7367,7 @@ fn decode_inter_block8( | |||
| 7291 | mv, | 7367 | mv, |
| 7292 | is_new_mv, | 7368 | is_new_mv, |
| 7293 | size: 2, | 7369 | size: 2, |
| 7370 | + size_h: 2, | ||
| 7294 | }, | 7371 | }, |
| 7295 | ); | 7372 | ); |
| 7296 | } | 7373 | } |
| @@ -7341,9 +7418,12 @@ fn decode_inter_block8( | |||
| 7341 | mi_row, | 7418 | mi_row, |
| 7342 | mi_col, | 7419 | mi_col, |
| 7343 | 2, | 7420 | 2, |
| 7421 | + 2, | ||
| 7344 | mi_rows as usize, | 7422 | mi_rows as usize, |
| 7345 | mi_cols as usize, | 7423 | mi_cols as usize, |
| 7346 | SIDE, | 7424 | SIDE, |
| 7425 | + SIDE, | ||
| 7426 | + SIDE, | ||
| 7347 | CHROMA_SIDE, | 7427 | CHROMA_SIDE, |
| 7348 | px, | 7428 | px, |
| 7349 | py, | 7429 | py, |
| @@ -7481,6 +7561,7 @@ fn decode_inter_block8( | |||
| 7481 | mv: (0, 0), | 7561 | mv: (0, 0), |
| 7482 | is_new_mv: false, | 7562 | is_new_mv: false, |
| 7483 | size: 2, | 7563 | size: 2, |
| 7564 | + size_h: 2, | ||
| 7484 | }, | 7565 | }, |
| 7485 | ); | 7566 | ); |
| 7486 | } | 7567 | } |
| @@ -8208,8 +8289,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8208 | switchable_motion_mode, | 8289 | switchable_motion_mode, |
| 8209 | allow_warped_motion, | 8290 | allow_warped_motion, |
| 8210 | true, | 8291 | 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). | ||
| 8211 | BLOCK, | 8295 | BLOCK, |
| 8212 | - BLOCK, | 8296 | + SUB, |
| 8213 | )?; | 8297 | )?; |
| 8214 | if (r32 * 2 + 1) as u32 * SUB_MI < mi_rows { | 8298 | if (r32 * 2 + 1) as u32 * SUB_MI < mi_rows { |
| 8215 | decode_inter_block( | 8299 | decode_inter_block( |
| @@ -8317,31 +8401,202 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8317 | } | 8401 | } |
| 8318 | } | 8402 | } |
| 8319 | PARTITION_HORZ => { | 8403 | PARTITION_HORZ => { |
| 8320 | - // lane-partitions r1 FINDING (pin rect-flake-1.obu, | 8404 | + // lane-rect r2: two true 32x16 strips. Both read at |
| 8321 | - // decode frame 16 strip 2): decoding each 32x16 strip | 8405 | + // `side=BLOCK` (CDF/size-class selection stays square, |
| 8322 | - // with `side=32` square contexts desyncs -- a real | 8406 | + // matching HORZ_B's accepted corner-cut) but bw4/bh4 |
| 8323 | - // 32x16 block's mvstack weights/DRL selection use | 8407 | + // (mvstack.rs, `motion_mode_eligible`) now derive from |
| 8324 | - // n4_h=4, and the second strip picked a different | 8408 | + // `write_w`/`write_h`'s true 32x16 footprint -- the |
| 8325 | - // NEARMV than aomdec (class | 8409 | + // pin's fix (r1's finding). |
| 8326 | - // decision-at-wrong-granularity). The write-footprint | 8410 | + RECT_PARTITION_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 8327 | - // plumbing (`write_w`/`write_h`, `_rect` methods) | 8411 | + decode_inter_block( |
| 8328 | - // stays; r2 threads true bw4/bh4 through | 8412 | + &mut dec, |
| 8329 | - // find_mv_stack + every neighbour ctx, gated by the | 8413 | + &mut cdfs, |
| 8330 | - // pinned stream. NOTE: HORZ_B's top strip carries the | 8414 | + &mut neighbours, |
| 8331 | - // same square-context corner-cut and owes the same | 8415 | + &mut grid, |
| 8332 | - // fix; its pins are byte-exact only because their | 8416 | + at, |
| 8333 | - // stacks happen to coincide. | 8417 | + BLOCK, |
| 8334 | - return Err(unsupported( | 8418 | + mi_cols, |
| 8335 | - "a HORZ rect partition (32x16 strips need rectangular \ | 8419 | + mi_rows, |
| 8336 | - mvstack/context derivation, r2)", | 8420 | + &mut y, |
| 8337 | - )); | 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 | + )?; | ||
| 8338 | } | 8503 | } |
| 8339 | PARTITION_VERT => { | 8504 | PARTITION_VERT => { |
| 8340 | - // See PARTITION_HORZ above -- same r2 refusal. | 8505 | + // lane-rect r2: mirror of PARTITION_HORZ above with |
| 8341 | - return Err(unsupported( | 8506 | + // width/height swapped. |
| 8342 | - "a VERT rect partition (16x32 strips need rectangular \ | 8507 | + RECT_PARTITION_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 8343 | - mvstack/context derivation, r2)", | 8508 | + decode_inter_block( |
| 8344 | - )); | 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 | + )?; | ||
| 8345 | } | 8600 | } |
| 8346 | _ => { | 8601 | _ => { |
| 8347 | return Err(unsupported(format!( | 8602 | return Err(unsupported(format!( |
| @@ -8968,6 +9223,7 @@ mod tests { | |||
| 8968 | mv, | 9223 | mv, |
| 8969 | is_new_mv: false, | 9224 | is_new_mv: false, |
| 8970 | size: 1, | 9225 | size: 1, |
| 9226 | + size_h: 1, | ||
| 8971 | }; | 9227 | }; |
| 8972 | for col in mi_col..mi_col + bw4 { | 9228 | for col in mi_col..mi_col + bw4 { |
| 8973 | grid.set(mi_row - 1, col, neighbour(above_mv)); | 9229 | 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( | |||
| 2617 | mv: info.mv, | 2617 | mv: info.mv, |
| 2618 | is_new_mv: matches!(info.mode, InterMode::NewMv), | 2618 | is_new_mv: matches!(info.mode, InterMode::NewMv), |
| 2619 | size: 8, | 2619 | size: 8, |
| 2620 | + size_h: 8, | ||
| 2620 | }, | 2621 | }, |
| 2621 | // Intra: no vote, but still a coded cell | 2622 | // Intra: no vote, but still a coded cell |
| 2622 | // -- mvstack's extended-scan coverage | 2623 | // -- mvstack's extended-scan coverage |
| @@ -2630,6 +2631,7 @@ pub(crate) fn encode_inter_frame( | |||
| 2630 | mv: (0, 0), | 2631 | mv: (0, 0), |
| 2631 | is_new_mv: false, | 2632 | is_new_mv: false, |
| 2632 | size: 8, | 2633 | size: 8, |
| 2634 | + size_h: 8, | ||
| 2633 | }, | 2635 | }, |
| 2634 | }, | 2636 | }, |
| 2635 | ); | 2637 | ); |
| @@ -2709,6 +2711,7 @@ pub(crate) fn encode_inter_frame( | |||
| 2709 | mv: info.mv, | 2711 | mv: info.mv, |
| 2710 | is_new_mv: matches!(info.mode, InterMode::NewMv), | 2712 | is_new_mv: matches!(info.mode, InterMode::NewMv), |
| 2711 | size: 4, | 2713 | size: 4, |
| 2714 | + size_h: 4, | ||
| 2712 | }, | 2715 | }, |
| 2713 | None => MiInfo { | 2716 | None => MiInfo { |
| 2714 | is_inter: false, | 2717 | is_inter: false, |
| @@ -2718,6 +2721,7 @@ pub(crate) fn encode_inter_frame( | |||
| 2718 | mv: (0, 0), | 2721 | mv: (0, 0), |
| 2719 | is_new_mv: false, | 2722 | is_new_mv: false, |
| 2720 | size: 4, | 2723 | size: 4, |
| 2724 | + size_h: 4, | ||
| 2721 | }, | 2725 | }, |
| 2722 | }, | 2726 | }, |
| 2723 | ); | 2727 | ); |
| @@ -2766,6 +2770,7 @@ pub(crate) fn encode_inter_frame( | |||
| 2766 | InterMode::NewMv | 2770 | InterMode::NewMv |
| 2767 | ), | 2771 | ), |
| 2768 | size: 2, | 2772 | size: 2, |
| 2773 | + size_h: 2, | ||
| 2769 | }, | 2774 | }, |
| 2770 | None => MiInfo { | 2775 | None => MiInfo { |
| 2771 | is_inter: false, | 2776 | is_inter: false, |
| @@ -2775,6 +2780,7 @@ pub(crate) fn encode_inter_frame( | |||
| 2775 | mv: (0, 0), | 2780 | mv: (0, 0), |
| 2776 | is_new_mv: false, | 2781 | is_new_mv: false, |
| 2777 | size: 2, | 2782 | size: 2, |
| 2783 | + size_h: 2, | ||
| 2778 | }, | 2784 | }, |
| 2779 | }, | 2785 | }, |
| 2780 | ); | 2786 | ); |
crates/ec-av1/src/mvstack.rsmodified+22 -8
| @@ -153,6 +153,10 @@ pub struct MiInfo { | |||
| 153 | /// candidate's `bsize` regardless of whether it also casts a vote (that | 153 | /// candidate's `bsize` regardless of whether it also casts a vote (that |
| 154 | /// requires a ref-frame match, checked separately in `add_ref_mv_candidate`). | 154 | /// requires a ref-frame match, checked separately in `add_ref_mv_candidate`). |
| 155 | pub size: usize, | 155 | 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, | ||
| 156 | } | 160 | } |
| 157 | 161 | ||
| 158 | /// The whole frame's `mi` grid, one [`MiInfo`] per 4x4 unit, in raster order. | 162 | /// The whole frame's `mi` grid, one [`MiInfo`] per 4x4 unit, in raster order. |
| @@ -408,7 +412,7 @@ fn scan_row( | |||
| 408 | } | 412 | } |
| 409 | let mut weight = ROW_COL_WEIGHT_FLOOR; | 413 | let mut weight = ROW_COL_WEIGHT_FLOOR; |
| 410 | if bw4 <= n4 { | 414 | 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); |
| 412 | weight = weight.max(inc as u32); | 416 | weight = weight.max(inc as u32); |
| 413 | *processed_rows = (inc as isize - row_offset - 1).max(0) as usize; | 417 | *processed_rows = (inc as isize - row_offset - 1).max(0) as usize; |
| 414 | } | 418 | } |
| @@ -472,7 +476,7 @@ fn scan_col( | |||
| 472 | i += 1; | 476 | i += 1; |
| 473 | continue; | 477 | continue; |
| 474 | }; | 478 | }; |
| 475 | - let n4 = info.size; | 479 | + let n4 = info.size_h; |
| 476 | let mut len = bh4.min(n4); | 480 | let mut len = bh4.min(n4); |
| 477 | if use_step_16 { | 481 | if use_step_16 { |
| 478 | len = len.max(4); | 482 | len = len.max(4); |
| @@ -481,7 +485,7 @@ fn scan_col( | |||
| 481 | } | 485 | } |
| 482 | let mut weight = ROW_COL_WEIGHT_FLOOR; | 486 | let mut weight = ROW_COL_WEIGHT_FLOOR; |
| 483 | if bh4 <= n4 { | 487 | 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); |
| 485 | weight = weight.max(inc as u32); | 489 | weight = weight.max(inc as u32); |
| 486 | *processed_cols = (inc as isize - col_offset - 1).max(0) as usize; | 490 | *processed_cols = (inc as isize - col_offset - 1).max(0) as usize; |
| 487 | } | 491 | } |
| @@ -923,7 +927,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 923 | let mut idx = 0usize; | 927 | let mut idx = 0usize; |
| 924 | while idx < mi_size && candidates.len() < MAX_MV_REF_CANDIDATES { | 928 | while idx < mi_size && candidates.len() < MAX_MV_REF_CANDIDATES { |
| 925 | let cand = grid.get(mi_row + idx, mi_col - 1); | 929 | 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); |
| 927 | if let Some(c) = cand { | 931 | if let Some(c) = cand { |
| 928 | process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut candidates); | 932 | process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut candidates); |
| 929 | } | 933 | } |
| @@ -1123,7 +1127,7 @@ fn scan_row_compound( | |||
| 1123 | } | 1127 | } |
| 1124 | let mut weight = ROW_COL_WEIGHT_FLOOR; | 1128 | let mut weight = ROW_COL_WEIGHT_FLOOR; |
| 1125 | if bw4 <= n4 { | 1129 | 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); |
| 1127 | weight = weight.max(inc as u32); | 1131 | weight = weight.max(inc as u32); |
| 1128 | *processed_rows = (inc as isize - row_offset - 1).max(0) as usize; | 1132 | *processed_rows = (inc as isize - row_offset - 1).max(0) as usize; |
| 1129 | } | 1133 | } |
| @@ -1170,7 +1174,7 @@ fn scan_col_compound( | |||
| 1170 | i += 1; | 1174 | i += 1; |
| 1171 | continue; | 1175 | continue; |
| 1172 | }; | 1176 | }; |
| 1173 | - let n4 = info.size; | 1177 | + let n4 = info.size_h; |
| 1174 | let mut len = bh4.min(n4); | 1178 | let mut len = bh4.min(n4); |
| 1175 | if use_step_16 { | 1179 | if use_step_16 { |
| 1176 | len = len.max(4); | 1180 | len = len.max(4); |
| @@ -1179,7 +1183,7 @@ fn scan_col_compound( | |||
| 1179 | } | 1183 | } |
| 1180 | let mut weight = ROW_COL_WEIGHT_FLOOR; | 1184 | let mut weight = ROW_COL_WEIGHT_FLOOR; |
| 1181 | if bh4 <= n4 { | 1185 | 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); |
| 1183 | weight = weight.max(inc as u32); | 1187 | weight = weight.max(inc as u32); |
| 1184 | *processed_cols = (inc as isize - col_offset - 1).max(0) as usize; | 1188 | *processed_cols = (inc as isize - col_offset - 1).max(0) as usize; |
| 1185 | } | 1189 | } |
| @@ -1581,7 +1585,7 @@ pub fn find_mv_stack_compound( | |||
| 1581 | let mut idx = 0usize; | 1585 | let mut idx = 0usize; |
| 1582 | while idx < mi_size { | 1586 | while idx < mi_size { |
| 1583 | let cand = grid.get(mi_row + idx, mi_col - 1); | 1587 | 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); |
| 1585 | if let Some(c) = cand { | 1589 | if let Some(c) = cand { |
| 1586 | process_compound_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut lists); | 1590 | process_compound_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut lists); |
| 1587 | } | 1591 | } |
| @@ -1978,6 +1982,7 @@ mod tests { | |||
| 1978 | // so it never trips the extended-scan coverage boost -- these | 1982 | // so it never trips the extended-scan coverage boost -- these |
| 1979 | // tests only exercise the immediate/corner/top-right scans. | 1983 | // tests only exercise the immediate/corner/top-right scans. |
| 1980 | size: 1, | 1984 | size: 1, |
| 1985 | + size_h: 1, | ||
| 1981 | } | 1986 | } |
| 1982 | } | 1987 | } |
| 1983 | 1988 | ||
| @@ -2131,6 +2136,7 @@ mod tests { | |||
| 2131 | mv: (4, 4), | 2136 | mv: (4, 4), |
| 2132 | is_new_mv: true, | 2137 | is_new_mv: true, |
| 2133 | size: 1, | 2138 | size: 1, |
| 2139 | + size_h: 1, | ||
| 2134 | }, | 2140 | }, |
| 2135 | ); | 2141 | ); |
| 2136 | // Only the row matches (nearest_match == 1): newmv_count > 0 picks | 2142 | // Only the row matches (nearest_match == 1): newmv_count > 0 picks |
| @@ -2211,6 +2217,7 @@ mod tests { | |||
| 2211 | mv, | 2217 | mv, |
| 2212 | is_new_mv: false, | 2218 | is_new_mv: false, |
| 2213 | size: 8, | 2219 | size: 8, |
| 2220 | + size_h: 8, | ||
| 2214 | }, | 2221 | }, |
| 2215 | ); | 2222 | ); |
| 2216 | 2223 | ||
| @@ -2240,6 +2247,7 @@ mod tests { | |||
| 2240 | mv: (0, 0), | 2247 | mv: (0, 0), |
| 2241 | is_new_mv: false, | 2248 | is_new_mv: false, |
| 2242 | size: 8, | 2249 | size: 8, |
| 2250 | + size_h: 8, | ||
| 2243 | } | 2251 | } |
| 2244 | } | 2252 | } |
| 2245 | 2253 | ||
| @@ -2256,6 +2264,7 @@ mod tests { | |||
| 2256 | mv, | 2264 | mv, |
| 2257 | is_new_mv: false, | 2265 | is_new_mv: false, |
| 2258 | size: 8, | 2266 | size: 8, |
| 2267 | + size_h: 8, | ||
| 2259 | } | 2268 | } |
| 2260 | } | 2269 | } |
| 2261 | 2270 | ||
| @@ -2493,6 +2502,7 @@ mod tests { | |||
| 2493 | mv1: Some(mv1), | 2502 | mv1: Some(mv1), |
| 2494 | is_new_mv: false, | 2503 | is_new_mv: false, |
| 2495 | size: 1, | 2504 | size: 1, |
| 2505 | + size_h: 1, | ||
| 2496 | } | 2506 | } |
| 2497 | } | 2507 | } |
| 2498 | 2508 | ||
| @@ -2513,6 +2523,7 @@ mod tests { | |||
| 2513 | mv1: Some((9, 9)), | 2523 | mv1: Some((9, 9)), |
| 2514 | is_new_mv: false, | 2524 | is_new_mv: false, |
| 2515 | size: 1, | 2525 | size: 1, |
| 2526 | + size_h: 1, | ||
| 2516 | }, | 2527 | }, |
| 2517 | ); | 2528 | ); |
| 2518 | // Exact pair match. | 2529 | // Exact pair match. |
| @@ -2613,6 +2624,7 @@ mod tests { | |||
| 2613 | mv1: None, | 2624 | mv1: None, |
| 2614 | is_new_mv: false, | 2625 | is_new_mv: false, |
| 2615 | size: 1, | 2626 | size: 1, |
| 2627 | + size_h: 1, | ||
| 2616 | }; | 2628 | }; |
| 2617 | process_compound_ref_mv_candidate(&candidate, COMP_PAIR, &NO_SIGN_BIAS, &mut lists); | 2629 | process_compound_ref_mv_candidate(&candidate, COMP_PAIR, &NO_SIGN_BIAS, &mut lists); |
| 2618 | assert_eq!(lists.ref_id[0], vec![(5, 5)]); | 2630 | assert_eq!(lists.ref_id[0], vec![(5, 5)]); |
| @@ -2639,6 +2651,7 @@ mod tests { | |||
| 2639 | mv1: None, | 2651 | mv1: None, |
| 2640 | is_new_mv: false, | 2652 | is_new_mv: false, |
| 2641 | size: 8, | 2653 | size: 8, |
| 2654 | + size_h: 8, | ||
| 2642 | }, | 2655 | }, |
| 2643 | ); | 2656 | ); |
| 2644 | grid.set( | 2657 | grid.set( |
| @@ -2652,6 +2665,7 @@ mod tests { | |||
| 2652 | mv1: None, | 2665 | mv1: None, |
| 2653 | is_new_mv: false, | 2666 | is_new_mv: false, |
| 2654 | size: 8, | 2667 | size: 8, |
| 2668 | + size_h: 8, | ||
| 2655 | }, | 2669 | }, |
| 2656 | ); | 2670 | ); |
| 2657 | 2671 | ||
crates/ec-av1/src/stream.rsmodified+18 -6
| @@ -3741,11 +3741,11 @@ mod tests { | |||
| 3741 | "--enable-onesided-comp=0", | 3741 | "--enable-onesided-comp=0", |
| 3742 | "--enable-interintra-wedge=0", | 3742 | "--enable-interintra-wedge=0", |
| 3743 | "--enable-smooth-interintra=0", | 3743 | "--enable-smooth-interintra=0", |
| 3744 | - // lane-partitions r1: the free (rect=1, min=16) recipe found | 3744 | + // lane-rect r2: HORZ/VERT decode for real (rect-flake-1 |
| 3745 | - // and PINNED rect-flake-1.obu -- the 32x16 strip mvstack | 3745 | + // byte-exact: size_h + warp dims + OBMC overlap + tx height) |
| 3746 | - // desync now refused by name for r2; recipe re-clamped so the | 3746 | + // -- free recipe restored; remaining partition kinds refuse |
| 3747 | - // gate stays green until rectangular contexts land. | 3747 | + // by name and skip their seeds. |
| 3748 | - "--enable-rect-partitions=0", | 3748 | + "--enable-rect-partitions=1", |
| 3749 | "--enable-ab-partitions=1", | 3749 | "--enable-ab-partitions=1", |
| 3750 | "--enable-1to4-partitions=0", | 3750 | "--enable-1to4-partitions=0", |
| 3751 | "--enable-filter-intra=0", | 3751 | "--enable-filter-intra=0", |
| @@ -3757,7 +3757,7 @@ mod tests { | |||
| 3757 | "--enable-cdef=0", | 3757 | "--enable-cdef=0", |
| 3758 | "--enable-restoration=0", | 3758 | "--enable-restoration=0", |
| 3759 | "--max-partition-size=32", | 3759 | "--max-partition-size=32", |
| 3760 | - "--min-partition-size=32", | 3760 | + "--min-partition-size=16", |
| 3761 | "--enable-palette=0", | 3761 | "--enable-palette=0", |
| 3762 | "--enable-intrabc=0", | 3762 | "--enable-intrabc=0", |
| 3763 | "--enable-cfl-intra=0", | 3763 | "--enable-cfl-intra=0", |
| @@ -4081,6 +4081,18 @@ mod tests { | |||
| 4081 | // saturation slowed the adaptation rate) -- unrelated to | 4081 | // saturation slowed the adaptation rate) -- unrelated to |
| 4082 | // interintra, caught by the same gate. | 4082 | // interintra, caught by the same gate. |
| 4083 | "ii-flake-9", | 4083 | "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", | ||
| 4084 | ] | 4096 | ] |
| 4085 | .iter() | 4097 | .iter() |
| 4086 | .map(|n| format!("{fixtures}/{n}.obu")) | 4098 | .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( | |||
| 2439 | mv, | 2439 | mv, |
| 2440 | is_new_mv, | 2440 | is_new_mv, |
| 2441 | size: 8, | 2441 | size: 8, |
| 2442 | + size_h: 8, | ||
| 2442 | }, | 2443 | }, |
| 2443 | ); | 2444 | ); |
| 2444 | for dr in 0..8 { | 2445 | for dr in 0..8 { |
| @@ -2457,6 +2458,7 @@ pub fn sb_coeff_inter_frame_tile( | |||
| 2457 | mv, | 2458 | mv, |
| 2458 | is_new_mv, | 2459 | is_new_mv, |
| 2459 | size: 8, | 2460 | size: 8, |
| 2461 | + size_h: 8, | ||
| 2460 | }, | 2462 | }, |
| 2461 | ); | 2463 | ); |
| 2462 | } | 2464 | } |
| @@ -2486,6 +2488,7 @@ pub fn sb_coeff_inter_frame_tile( | |||
| 2486 | mv: (0, 0), | 2488 | mv: (0, 0), |
| 2487 | is_new_mv: false, | 2489 | is_new_mv: false, |
| 2488 | size: 8, | 2490 | size: 8, |
| 2491 | + size_h: 8, | ||
| 2489 | }, | 2492 | }, |
| 2490 | ); | 2493 | ); |
| 2491 | } | 2494 | } |
| @@ -2626,6 +2629,7 @@ fn write_inter_frame_leaf( | |||
| 2626 | mv, | 2629 | mv, |
| 2627 | is_new_mv, | 2630 | is_new_mv, |
| 2628 | size: SUB_MI as usize, | 2631 | size: SUB_MI as usize, |
| 2632 | + size_h: SUB_MI as usize, | ||
| 2629 | }, | 2633 | }, |
| 2630 | ); | 2634 | ); |
| 2631 | } | 2635 | } |
| @@ -2655,6 +2659,7 @@ fn write_inter_frame_leaf( | |||
| 2655 | mv: (0, 0), | 2659 | mv: (0, 0), |
| 2656 | is_new_mv: false, | 2660 | is_new_mv: false, |
| 2657 | size: SUB_MI as usize, | 2661 | size: SUB_MI as usize, |
| 2662 | + size_h: SUB_MI as usize, | ||
| 2658 | }, | 2663 | }, |
| 2659 | ); | 2664 | ); |
| 2660 | } | 2665 | } |
| @@ -2818,6 +2823,7 @@ fn write_inter_frame_leaf8( | |||
| 2818 | mv, | 2823 | mv, |
| 2819 | is_new_mv, | 2824 | is_new_mv, |
| 2820 | size: 2, | 2825 | size: 2, |
| 2826 | + size_h: 2, | ||
| 2821 | }, | 2827 | }, |
| 2822 | ); | 2828 | ); |
| 2823 | } | 2829 | } |
| @@ -2847,6 +2853,7 @@ fn write_inter_frame_leaf8( | |||
| 2847 | mv: (0, 0), | 2853 | mv: (0, 0), |
| 2848 | is_new_mv: false, | 2854 | is_new_mv: false, |
| 2849 | size: 2, | 2855 | size: 2, |
| 2856 | + size_h: 2, | ||
| 2850 | }, | 2857 | }, |
| 2851 | ); | 2858 | ); |
| 2852 | } | 2859 | } |
| @@ -5101,6 +5108,7 @@ mod tests { | |||
| 5101 | mv, | 5108 | mv, |
| 5102 | is_new_mv, | 5109 | is_new_mv, |
| 5103 | size: 8, | 5110 | size: 8, |
| 5111 | + size_h: 8, | ||
| 5104 | }, | 5112 | }, |
| 5105 | ); | 5113 | ); |
| 5106 | } | 5114 | } |
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. | ||