Rect-flake-1 byte-exact -- MiInfo size_h, rect warp samples/projection dims, OBMC per-pass overlap, deblock tx-height grid
Browse files at this commit8e2b541ef4ac91a7f15a84a7345813af2d64e003Parent: ab0445e- fix
- rect-flake-1 byte-exact -- MiInfo size_h, rect warp samples/projection dims, OBMC per-pass overlap, deblock tx-height grid
4 changed files +119 -32
- crates/ec-av1/src/decode.rs +87 -28
- crates/ec-av1/src/encode.rs +6 -0
- crates/ec-av1/src/mvstack.rs +18 -4
- crates/ec-av1/src/tile.rs +8 -0
crates/ec-av1/src/decode.rsmodified+87 -28
| @@ -957,6 +957,10 @@ struct Neighbours { | ||
| 957 | 957 | /// transform size, spec 7.14's `get_transform_size`/`get_filter_level` |
| 958 | 958 | /// edge-length lookup (`apply_deblock`). |
| 959 | 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 | 964 | /// Per-4x4-mi reference frame (`0` = intra, magnitude `1..=7` = |
| 961 | 965 | /// `MV_REFERENCE_FRAME`, negative = that reference coded as `GLOBALMV` -- |
| 962 | 966 | /// `lf_level`'s `mode_lf_lut` row 0, lane-av1golden2) |
| @@ -1001,6 +1005,7 @@ impl Neighbours { | ||
| 1001 | 1005 | skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], |
| 1002 | 1006 | skip_grid_cols_mi: cols * (SUB / MI), |
| 1003 | 1007 | tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 1008 | + tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], | |
| 1004 | 1009 | ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 1005 | 1010 | } |
| 1006 | 1011 | } |
| @@ -1010,7 +1015,7 @@ impl Neighbours { | ||
| 1010 | 1015 | /// per-edge lookup (`apply_deblock`), filled at the same call sites and |
| 1011 | 1016 | /// units as [`Self::fill_skip_grid`]. |
| 1012 | 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 | 1021 | /// [`Self::fill_lf_grid`] with independent row/col extents -- lane-partitions |
| @@ -1025,6 +1030,7 @@ impl Neighbours { | ||
| 1025 | 1030 | w_mi: usize, |
| 1026 | 1031 | h_mi: usize, |
| 1027 | 1032 | tx_px: u8, |
| 1033 | + tx_h_px: u8, | |
| 1028 | 1034 | ref_frame: i8, |
| 1029 | 1035 | ) { |
| 1030 | 1036 | let (mi_r, mi_c) = at_mi; |
| @@ -1034,6 +1040,9 @@ impl Neighbours { | ||
| 1034 | 1040 | if let Some(cell) = self.tx_grid.get_mut(idx) { |
| 1035 | 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 | 1046 | if let Some(cell) = self.ref_grid.get_mut(idx) { |
| 1038 | 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 | 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 | 2775 | /// `get_tx_size_context` (spec 9.3's `TxDepthCtx`, libaom |
| 2755 | 2776 | /// `TXFM_CONTEXT`/`entropymode.c`): the sum of two boolean terms, each |
| 2756 | 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 | 2780 | /// as `own_side`. |
| 2760 | 2781 | fn tx_size_context(n: &Neighbours, (mi_r, mi_c): (usize, usize), own_side: usize) -> usize { |
| 2761 | 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 | 2784 | usize::from(above) + usize::from(left) |
| 2764 | 2785 | } |
| 2765 | 2786 | |
| @@ -2895,7 +2916,11 @@ fn edge_params( | ||
| 2895 | 2916 | y0: usize, |
| 2896 | 2917 | ) -> Option<(u8, i32)> { |
| 2897 | 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 | 2924 | if cur_tx == 0 || (if dir == 0 { x0 } else { y0 }) % cur_tx as usize != 0 { |
| 2900 | 2925 | return None; |
| 2901 | 2926 | } |
| @@ -2905,7 +2930,11 @@ fn edge_params( | ||
| 2905 | 2930 | } else { |
| 2906 | 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 | 2938 | let pv_ref = n.ref_grid[pv_mi_r * n.skip_grid_cols_mi + pv_mi_c]; |
| 2910 | 2939 | |
| 2911 | 2940 | let cur_level = lf_level(lf, plane_idx, dir, cur_ref); |
| @@ -4346,6 +4375,7 @@ fn find_samples( | ||
| 4346 | 4375 | mi_row: usize, |
| 4347 | 4376 | mi_col: usize, |
| 4348 | 4377 | bw4: usize, |
| 4378 | + bh4: usize, | |
| 4349 | 4379 | mi_cols: usize, |
| 4350 | 4380 | mi_rows: usize, |
| 4351 | 4381 | ref_frame: i8, |
| @@ -4359,7 +4389,11 @@ fn find_samples( | ||
| 4359 | 4389 | let mut do_tr = true; |
| 4360 | 4390 | let rec = |info: &MiInfo, row_offset: i32, sign_r: i32, col_offset: i32, sign_c: i32| { |
| 4361 | 4391 | 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) | |
| 4392 | + // lane-rect r2: the neighbour's own true height -- a rect strip | |
| 4393 | + // neighbour donates its sample at ITS center (aom pts y=-72 for a | |
| 4394 | + // 32x16 above strip; the square assumption put it at -136). | |
| 4395 | + let nb_bh = (info.size_h * 4) as i32; | |
| 4396 | + crate::warp::record_sample(nb_bw, nb_bh, info.mv, row_offset, sign_r, col_offset, sign_c) | |
| 4363 | 4397 | }; |
| 4364 | 4398 | |
| 4365 | 4399 | 'outer: { |
| @@ -4403,8 +4437,8 @@ fn find_samples( | ||
| 4403 | 4437 | |
| 4404 | 4438 | if left_available { |
| 4405 | 4439 | 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 { | |
| 4440 | + let superblock_height = left.map_or(1, |c| c.size_h).max(1); | |
| 4441 | + if bh4 <= superblock_height { | |
| 4408 | 4442 | let row_offset = -((mi_row % superblock_height) as isize); |
| 4409 | 4443 | if row_offset < 0 { |
| 4410 | 4444 | do_tl = false; |
| @@ -4419,10 +4453,10 @@ fn find_samples( | ||
| 4419 | 4453 | } |
| 4420 | 4454 | } else { |
| 4421 | 4455 | let mut i = 0usize; |
| 4422 | - let limit = bw4.min(mi_rows.saturating_sub(mi_row)); | |
| 4456 | + let limit = bh4.min(mi_rows.saturating_sub(mi_row)); | |
| 4423 | 4457 | while i < limit { |
| 4424 | 4458 | let cell = grid.get(mi_row + i, mi_col - 1); |
| 4425 | - let sh = cell.map_or(1, |c| c.size).max(1); | |
| 4459 | + let sh = cell.map_or(1, |c| c.size_h).max(1); | |
| 4426 | 4460 | if let Some(info) = cell { |
| 4427 | 4461 | if single_ref_match(info) { |
| 4428 | 4462 | samples.push(rec(info, i as i32, 1, 0, -1)); |
| @@ -4470,11 +4504,12 @@ fn num_proj_ref( | ||
| 4470 | 4504 | mi_row: usize, |
| 4471 | 4505 | mi_col: usize, |
| 4472 | 4506 | bw4: usize, |
| 4507 | + bh4: usize, | |
| 4473 | 4508 | mi_cols: usize, |
| 4474 | 4509 | mi_rows: usize, |
| 4475 | 4510 | ref_frame: i8, |
| 4476 | 4511 | ) -> u8 { |
| 4477 | - find_samples(grid, mi_row, mi_col, bw4, mi_cols, mi_rows, ref_frame).len() as u8 | |
| 4512 | + find_samples(grid, mi_row, mi_col, bw4, bh4, mi_cols, mi_rows, ref_frame).len() as u8 | |
| 4478 | 4513 | } |
| 4479 | 4514 | |
| 4480 | 4515 | /// `av1_get_obmc_mask` (`reconinter.c`): the per-position blend weight |
| @@ -4669,9 +4704,12 @@ fn obmc_blend( | ||
| 4669 | 4704 | mi_row: usize, |
| 4670 | 4705 | mi_col: usize, |
| 4671 | 4706 | bw4: usize, |
| 4707 | + bh4: usize, | |
| 4672 | 4708 | mi_rows: usize, |
| 4673 | 4709 | mi_cols: usize, |
| 4674 | 4710 | side: usize, |
| 4711 | + write_w: usize, | |
| 4712 | + write_h: usize, | |
| 4675 | 4713 | chroma_side: usize, |
| 4676 | 4714 | px: usize, |
| 4677 | 4715 | py: usize, |
| @@ -4686,15 +4724,19 @@ fn obmc_blend( | ||
| 4686 | 4724 | pred_u: &mut [u8], |
| 4687 | 4725 | pred_v: &mut [u8], |
| 4688 | 4726 | ) -> Result<()> { |
| 4689 | - let max_neighbors = match bw4 { | |
| 4727 | + // lane-rect r2 (libaom av1_build_obmc_inter_prediction): each pass has | |
| 4728 | + // its OWN neighbour cap (width-log2 for above, height-log2 for left) and | |
| 4729 | + // overlap (bh/2 rows above, bw/2 cols left) -- one square `side` was | |
| 4730 | + // right only for square blocks. | |
| 4731 | + let max_nb = |n4: usize| match n4 { | |
| 4690 | 4732 | 1..=4 => 2, |
| 4691 | 4733 | 5..=8 => 3, |
| 4692 | 4734 | _ => 4, |
| 4693 | 4735 | }; |
| 4694 | - let overlap = side / 2; | |
| 4695 | - let coverlap = overlap / 2; | |
| 4736 | + let overlap_above = write_h / 2; | |
| 4737 | + let overlap_left = write_w / 2; | |
| 4696 | 4738 | |
| 4697 | - for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_neighbors) | |
| 4739 | + for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4)) | |
| 4698 | 4740 | { |
| 4699 | 4741 | // `Neighbours::above_filter` is indexed in `SUB`(16px)-wide columns |
| 4700 | 4742 | // (this decoder's own outer block-loop granularity), one step |
| @@ -4705,26 +4747,26 @@ fn obmc_blend( | ||
| 4705 | 4747 | neighbours.above_filter[(mi_col + off4) / SUB_MI as usize], |
| 4706 | 4748 | ); |
| 4707 | 4749 | 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); | |
| 4750 | + let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4); | |
| 4709 | 4751 | let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind); |
| 4710 | 4752 | obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y); |
| 4711 | - let (cbw, cbh, cox) = (bw / 2, coverlap, ox / 2); | |
| 4753 | + let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2); | |
| 4712 | 4754 | let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); |
| 4713 | 4755 | obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u); |
| 4714 | 4756 | let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); |
| 4715 | 4757 | obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v); |
| 4716 | 4758 | } |
| 4717 | 4759 | |
| 4718 | - for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bw4, mi_rows, max_neighbors) { | |
| 4760 | + for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) { | |
| 4719 | 4761 | let (h_kind, v_kind) = neighbour_filter( |
| 4720 | 4762 | interp_fixed, |
| 4721 | 4763 | neighbours.left_filter[(mi_row + off4) / SUB_MI as usize], |
| 4722 | 4764 | ); |
| 4723 | 4765 | 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); | |
| 4766 | + let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4); | |
| 4725 | 4767 | let tmp_y = obmc_neighbour_pred(ny, px, py + oy, nb.mv, bw, bh, true, h_kind, v_kind); |
| 4726 | 4768 | obmc_blend_h(pred_y, side, 0, oy, bw, bh, &tmp_y); |
| 4727 | - let (cbw, cbh, coy) = (coverlap, bh / 2, oy / 2); | |
| 4769 | + let (cbw, cbh, coy) = (overlap_left / 2, bh / 2, oy / 2); | |
| 4728 | 4770 | let tmp_u = obmc_neighbour_pred(nu, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind); |
| 4729 | 4771 | obmc_blend_h(pred_u, chroma_side, 0, coy, cbw, cbh, &tmp_u); |
| 4730 | 4772 | let tmp_v = obmc_neighbour_pred(nv, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind); |
| @@ -5313,6 +5355,7 @@ fn decode_inter_block( | ||
| 5313 | 5355 | mv: mv0, |
| 5314 | 5356 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), |
| 5315 | 5357 | size: bw4, |
| 5358 | + size_h: bh4, | |
| 5316 | 5359 | }, |
| 5317 | 5360 | ); |
| 5318 | 5361 | } |
| @@ -6096,7 +6139,7 @@ fn decode_inter_block( | ||
| 6096 | 6139 | // instead of the 2-symbol `obmc_cdf` exactly when |
| 6097 | 6140 | // `num_proj_ref >= 1` under `allow_warped_motion`. |
| 6098 | 6141 | let warp_eligible = allow_warped_motion |
| 6099 | - && num_proj_ref(grid, mi_row, mi_col, bw4, mi_cols as usize, mi_rows as usize, ref_frame) >= 1; | |
| 6142 | + && num_proj_ref(grid, mi_row, mi_col, bw4, bh4, mi_cols as usize, mi_rows as usize, ref_frame) >= 1; | |
| 6100 | 6143 | if warp_eligible { |
| 6101 | 6144 | let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]); |
| 6102 | 6145 | match mode { |
| @@ -6113,6 +6156,7 @@ fn decode_inter_block( | ||
| 6113 | 6156 | mi_row, |
| 6114 | 6157 | mi_col, |
| 6115 | 6158 | bw4, |
| 6159 | + bh4, | |
| 6116 | 6160 | mi_cols as usize, |
| 6117 | 6161 | mi_rows as usize, |
| 6118 | 6162 | ref_frame, |
| @@ -6131,8 +6175,11 @@ fn decode_inter_block( | ||
| 6131 | 6175 | } |
| 6132 | 6176 | warp_params = crate::warp::find_projection( |
| 6133 | 6177 | &samples, |
| 6134 | - side as i32, | |
| 6135 | - side as i32, | |
| 6178 | + // lane-rect r2: the block's TRUE dims -- a | |
| 6179 | + // 32x16 strip's model center is not a | |
| 6180 | + // 32x32's (aom av1_find_projection bw/bh). | |
| 6181 | + write_w as i32, | |
| 6182 | + write_h as i32, | |
| 6136 | 6183 | mv.1, |
| 6137 | 6184 | mv.0, |
| 6138 | 6185 | mi_row as i32, |
| @@ -6233,6 +6280,7 @@ fn decode_inter_block( | ||
| 6233 | 6280 | mv, |
| 6234 | 6281 | is_new_mv, |
| 6235 | 6282 | size: bw4, |
| 6283 | + size_h: bh4, | |
| 6236 | 6284 | }, |
| 6237 | 6285 | ); |
| 6238 | 6286 | } |
| @@ -6307,9 +6355,12 @@ fn decode_inter_block( | ||
| 6307 | 6355 | mi_row, |
| 6308 | 6356 | mi_col, |
| 6309 | 6357 | bw4, |
| 6358 | + bh4, | |
| 6310 | 6359 | mi_rows as usize, |
| 6311 | 6360 | mi_cols as usize, |
| 6312 | 6361 | side, |
| 6362 | + write_w, | |
| 6363 | + write_h, | |
| 6313 | 6364 | chroma_side, |
| 6314 | 6365 | px, |
| 6315 | 6366 | py, |
| @@ -6475,6 +6526,7 @@ fn decode_inter_block( | ||
| 6475 | 6526 | mv: (0, 0), |
| 6476 | 6527 | is_new_mv: false, |
| 6477 | 6528 | size: side / 4, |
| 6529 | + size_h: side / 4, | |
| 6478 | 6530 | }, |
| 6479 | 6531 | ); |
| 6480 | 6532 | } |
| @@ -6623,11 +6675,11 @@ fn decode_inter_block( | ||
| 6623 | 6675 | (r * (SUB / MI), c * (SUB / MI)), |
| 6624 | 6676 | write_w / MI, |
| 6625 | 6677 | write_h / MI, |
| 6626 | - // lane-warp r5 / lane-partitions r1: `tx_grid` names one scalar | |
| 6627 | - // (its own doc comment) -- a true rectangular strip's real | |
| 6628 | - // TX_32X16/TX_16X32 keeps using `side`, the same square-context | |
| 6629 | - // corner-cut `HORZ_B`'s top strip already shipped. | |
| 6630 | - side as u8, | |
| 6678 | + // lane-rect r2: the strip's true TX_32X16/TX_16X32 dims -- the | |
| 6679 | + // single-scalar corner-cut deblocked the strip seam with the wrong | |
| 6680 | + // edge length (1-px chroma drift on rect-flake-1 f17+). | |
| 6681 | + write_w as u8, | |
| 6682 | + write_h as u8, | |
| 6631 | 6683 | // ref_grid's packed convention (lf_level): sign carries GLOBALMV, |
| 6632 | 6684 | // whose mode_lf_lut row is 0, not the 1 every other inter mode gets. |
| 6633 | 6685 | if globalmv_for_lf { |
| @@ -6932,6 +6984,7 @@ fn decode_inter_block8( | ||
| 6932 | 6984 | mv: mv0, |
| 6933 | 6985 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), |
| 6934 | 6986 | size: 2, |
| 6987 | + size_h: 2, | |
| 6935 | 6988 | }, |
| 6936 | 6989 | ); |
| 6937 | 6990 | } |
| @@ -7269,7 +7322,7 @@ fn decode_inter_block8( | ||
| 7269 | 7322 | // (see its own doc) -- this leaf is always `LAST_FRAME`-only |
| 7270 | 7323 | // (grid.set below hardcodes it). |
| 7271 | 7324 | let warp_eligible = allow_warped_motion |
| 7272 | - && num_proj_ref(grid, mi_row, mi_col, 2, mi_cols as usize, mi_rows as usize, LAST_FRAME) >= 1; | |
| 7325 | + && num_proj_ref(grid, mi_row, mi_col, 2, 2, mi_cols as usize, mi_rows as usize, LAST_FRAME) >= 1; | |
| 7273 | 7326 | if warp_eligible { |
| 7274 | 7327 | let mode = dec.symbol(&mut cdfs.motion_mode[0]); |
| 7275 | 7328 | match mode { |
| @@ -7312,6 +7365,7 @@ fn decode_inter_block8( | ||
| 7312 | 7365 | mv, |
| 7313 | 7366 | is_new_mv, |
| 7314 | 7367 | size: 2, |
| 7368 | + size_h: 2, | |
| 7315 | 7369 | }, |
| 7316 | 7370 | ); |
| 7317 | 7371 | } |
| @@ -7362,9 +7416,12 @@ fn decode_inter_block8( | ||
| 7362 | 7416 | mi_row, |
| 7363 | 7417 | mi_col, |
| 7364 | 7418 | 2, |
| 7419 | + 2, | |
| 7365 | 7420 | mi_rows as usize, |
| 7366 | 7421 | mi_cols as usize, |
| 7367 | 7422 | SIDE, |
| 7423 | + SIDE, | |
| 7424 | + SIDE, | |
| 7368 | 7425 | CHROMA_SIDE, |
| 7369 | 7426 | px, |
| 7370 | 7427 | py, |
| @@ -7502,6 +7559,7 @@ fn decode_inter_block8( | ||
| 7502 | 7559 | mv: (0, 0), |
| 7503 | 7560 | is_new_mv: false, |
| 7504 | 7561 | size: 2, |
| 7562 | + size_h: 2, | |
| 7505 | 7563 | }, |
| 7506 | 7564 | ); |
| 7507 | 7565 | } |
| @@ -9160,6 +9218,7 @@ mod tests { | ||
| 9160 | 9218 | mv, |
| 9161 | 9219 | is_new_mv: false, |
| 9162 | 9220 | size: 1, |
| 9221 | + size_h: 1, | |
| 9163 | 9222 | }; |
| 9164 | 9223 | for col in mi_col..mi_col + bw4 { |
| 9165 | 9224 | 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 | 2617 | mv: info.mv, |
| 2618 | 2618 | is_new_mv: matches!(info.mode, InterMode::NewMv), |
| 2619 | 2619 | size: 8, |
| 2620 | + size_h: 8, | |
| 2620 | 2621 | }, |
| 2621 | 2622 | // Intra: no vote, but still a coded cell |
| 2622 | 2623 | // -- mvstack's extended-scan coverage |
| @@ -2630,6 +2631,7 @@ pub(crate) fn encode_inter_frame( | ||
| 2630 | 2631 | mv: (0, 0), |
| 2631 | 2632 | is_new_mv: false, |
| 2632 | 2633 | size: 8, |
| 2634 | + size_h: 8, | |
| 2633 | 2635 | }, |
| 2634 | 2636 | }, |
| 2635 | 2637 | ); |
| @@ -2709,6 +2711,7 @@ pub(crate) fn encode_inter_frame( | ||
| 2709 | 2711 | mv: info.mv, |
| 2710 | 2712 | is_new_mv: matches!(info.mode, InterMode::NewMv), |
| 2711 | 2713 | size: 4, |
| 2714 | + size_h: 4, | |
| 2712 | 2715 | }, |
| 2713 | 2716 | None => MiInfo { |
| 2714 | 2717 | is_inter: false, |
| @@ -2718,6 +2721,7 @@ pub(crate) fn encode_inter_frame( | ||
| 2718 | 2721 | mv: (0, 0), |
| 2719 | 2722 | is_new_mv: false, |
| 2720 | 2723 | size: 4, |
| 2724 | + size_h: 4, | |
| 2721 | 2725 | }, |
| 2722 | 2726 | }, |
| 2723 | 2727 | ); |
| @@ -2766,6 +2770,7 @@ pub(crate) fn encode_inter_frame( | ||
| 2766 | 2770 | InterMode::NewMv |
| 2767 | 2771 | ), |
| 2768 | 2772 | size: 2, |
| 2773 | + size_h: 2, | |
| 2769 | 2774 | }, |
| 2770 | 2775 | None => MiInfo { |
| 2771 | 2776 | is_inter: false, |
| @@ -2775,6 +2780,7 @@ pub(crate) fn encode_inter_frame( | ||
| 2775 | 2780 | mv: (0, 0), |
| 2776 | 2781 | is_new_mv: false, |
| 2777 | 2782 | size: 2, |
| 2783 | + size_h: 2, | |
| 2778 | 2784 | }, |
| 2779 | 2785 | }, |
| 2780 | 2786 | ); |
crates/ec-av1/src/mvstack.rsmodified+18 -4
| @@ -153,6 +153,10 @@ pub struct MiInfo { | ||
| 153 | 153 | /// candidate's `bsize` regardless of whether it also casts a vote (that |
| 154 | 154 | /// requires a ref-frame match, checked separately in `add_ref_mv_candidate`). |
| 155 | 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 | 162 | /// The whole frame's `mi` grid, one [`MiInfo`] per 4x4 unit, in raster order. |
| @@ -472,7 +476,7 @@ fn scan_col( | ||
| 472 | 476 | i += 1; |
| 473 | 477 | continue; |
| 474 | 478 | }; |
| 475 | - let n4 = info.size; | |
| 479 | + let n4 = info.size_h; | |
| 476 | 480 | let mut len = bh4.min(n4); |
| 477 | 481 | if use_step_16 { |
| 478 | 482 | len = len.max(4); |
| @@ -923,7 +927,7 @@ pub fn find_mv_stack_with_sign_bias( | ||
| 923 | 927 | let mut idx = 0usize; |
| 924 | 928 | while idx < mi_size && candidates.len() < MAX_MV_REF_CANDIDATES { |
| 925 | 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 | 931 | if let Some(c) = cand { |
| 928 | 932 | process_single_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut candidates); |
| 929 | 933 | } |
| @@ -1170,7 +1174,7 @@ fn scan_col_compound( | ||
| 1170 | 1174 | i += 1; |
| 1171 | 1175 | continue; |
| 1172 | 1176 | }; |
| 1173 | - let n4 = info.size; | |
| 1177 | + let n4 = info.size_h; | |
| 1174 | 1178 | let mut len = bh4.min(n4); |
| 1175 | 1179 | if use_step_16 { |
| 1176 | 1180 | len = len.max(4); |
| @@ -1581,7 +1585,7 @@ pub fn find_mv_stack_compound( | ||
| 1581 | 1585 | let mut idx = 0usize; |
| 1582 | 1586 | while idx < mi_size { |
| 1583 | 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 | 1589 | if let Some(c) = cand { |
| 1586 | 1590 | process_compound_ref_mv_candidate(c, ref_frame, sign_bias_table, &mut lists); |
| 1587 | 1591 | } |
| @@ -1978,6 +1982,7 @@ mod tests { | ||
| 1978 | 1982 | // so it never trips the extended-scan coverage boost -- these |
| 1979 | 1983 | // tests only exercise the immediate/corner/top-right scans. |
| 1980 | 1984 | size: 1, |
| 1985 | + size_h: 1, | |
| 1981 | 1986 | } |
| 1982 | 1987 | } |
| 1983 | 1988 | |
| @@ -2131,6 +2136,7 @@ mod tests { | ||
| 2131 | 2136 | mv: (4, 4), |
| 2132 | 2137 | is_new_mv: true, |
| 2133 | 2138 | size: 1, |
| 2139 | + size_h: 1, | |
| 2134 | 2140 | }, |
| 2135 | 2141 | ); |
| 2136 | 2142 | // Only the row matches (nearest_match == 1): newmv_count > 0 picks |
| @@ -2211,6 +2217,7 @@ mod tests { | ||
| 2211 | 2217 | mv, |
| 2212 | 2218 | is_new_mv: false, |
| 2213 | 2219 | size: 8, |
| 2220 | + size_h: 8, | |
| 2214 | 2221 | }, |
| 2215 | 2222 | ); |
| 2216 | 2223 | |
| @@ -2240,6 +2247,7 @@ mod tests { | ||
| 2240 | 2247 | mv: (0, 0), |
| 2241 | 2248 | is_new_mv: false, |
| 2242 | 2249 | size: 8, |
| 2250 | + size_h: 8, | |
| 2243 | 2251 | } |
| 2244 | 2252 | } |
| 2245 | 2253 | |
| @@ -2256,6 +2264,7 @@ mod tests { | ||
| 2256 | 2264 | mv, |
| 2257 | 2265 | is_new_mv: false, |
| 2258 | 2266 | size: 8, |
| 2267 | + size_h: 8, | |
| 2259 | 2268 | } |
| 2260 | 2269 | } |
| 2261 | 2270 | |
| @@ -2493,6 +2502,7 @@ mod tests { | ||
| 2493 | 2502 | mv1: Some(mv1), |
| 2494 | 2503 | is_new_mv: false, |
| 2495 | 2504 | size: 1, |
| 2505 | + size_h: 1, | |
| 2496 | 2506 | } |
| 2497 | 2507 | } |
| 2498 | 2508 | |
| @@ -2513,6 +2523,7 @@ mod tests { | ||
| 2513 | 2523 | mv1: Some((9, 9)), |
| 2514 | 2524 | is_new_mv: false, |
| 2515 | 2525 | size: 1, |
| 2526 | + size_h: 1, | |
| 2516 | 2527 | }, |
| 2517 | 2528 | ); |
| 2518 | 2529 | // Exact pair match. |
| @@ -2613,6 +2624,7 @@ mod tests { | ||
| 2613 | 2624 | mv1: None, |
| 2614 | 2625 | is_new_mv: false, |
| 2615 | 2626 | size: 1, |
| 2627 | + size_h: 1, | |
| 2616 | 2628 | }; |
| 2617 | 2629 | process_compound_ref_mv_candidate(&candidate, COMP_PAIR, &NO_SIGN_BIAS, &mut lists); |
| 2618 | 2630 | assert_eq!(lists.ref_id[0], vec![(5, 5)]); |
| @@ -2639,6 +2651,7 @@ mod tests { | ||
| 2639 | 2651 | mv1: None, |
| 2640 | 2652 | is_new_mv: false, |
| 2641 | 2653 | size: 8, |
| 2654 | + size_h: 8, | |
| 2642 | 2655 | }, |
| 2643 | 2656 | ); |
| 2644 | 2657 | grid.set( |
| @@ -2652,6 +2665,7 @@ mod tests { | ||
| 2652 | 2665 | mv1: None, |
| 2653 | 2666 | is_new_mv: false, |
| 2654 | 2667 | size: 8, |
| 2668 | + size_h: 8, | |
| 2655 | 2669 | }, |
| 2656 | 2670 | ); |
| 2657 | 2671 |
crates/ec-av1/src/tile.rsmodified+8 -0
| @@ -2439,6 +2439,7 @@ pub fn sb_coeff_inter_frame_tile( | ||
| 2439 | 2439 | mv, |
| 2440 | 2440 | is_new_mv, |
| 2441 | 2441 | size: 8, |
| 2442 | + size_h: 8, | |
| 2442 | 2443 | }, |
| 2443 | 2444 | ); |
| 2444 | 2445 | for dr in 0..8 { |
| @@ -2457,6 +2458,7 @@ pub fn sb_coeff_inter_frame_tile( | ||
| 2457 | 2458 | mv, |
| 2458 | 2459 | is_new_mv, |
| 2459 | 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 | 2488 | mv: (0, 0), |
| 2487 | 2489 | is_new_mv: false, |
| 2488 | 2490 | size: 8, |
| 2491 | + size_h: 8, | |
| 2489 | 2492 | }, |
| 2490 | 2493 | ); |
| 2491 | 2494 | } |
| @@ -2626,6 +2629,7 @@ fn write_inter_frame_leaf( | ||
| 2626 | 2629 | mv, |
| 2627 | 2630 | is_new_mv, |
| 2628 | 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 | 2659 | mv: (0, 0), |
| 2656 | 2660 | is_new_mv: false, |
| 2657 | 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 | 2823 | mv, |
| 2819 | 2824 | is_new_mv, |
| 2820 | 2825 | size: 2, |
| 2826 | + size_h: 2, | |
| 2821 | 2827 | }, |
| 2822 | 2828 | ); |
| 2823 | 2829 | } |
| @@ -2847,6 +2853,7 @@ fn write_inter_frame_leaf8( | ||
| 2847 | 2853 | mv: (0, 0), |
| 2848 | 2854 | is_new_mv: false, |
| 2849 | 2855 | size: 2, |
| 2856 | + size_h: 2, | |
| 2850 | 2857 | }, |
| 2851 | 2858 | ); |
| 2852 | 2859 | } |
| @@ -5101,6 +5108,7 @@ mod tests { | ||
| 5101 | 5108 | mv, |
| 5102 | 5109 | is_new_mv, |
| 5103 | 5110 | size: 8, |
| 5111 | + size_h: 8, | |
| 5104 | 5112 | }, |
| 5105 | 5113 | ); |
| 5106 | 5114 | } |