forge
Explore
Log in

Don't you dare go Hollow

S7: vp8 mc uses the one mb_edges in modes.rs (same values; was a duplicate with vis-size arguments)

Browse files at this commit

91fc6e60e84fc8b46cc352e747a4e89a1fab7c0dAhmet Kaan GümüşParent: 4452a0c
crates/ec-vp8/src/mc.rsmodified+3 -25
@@ -23,6 +23,7 @@
2323 //! [RFC 6386]: https://www.rfc-editor.org/rfc/rfc6386
2424 use archmage::SimdToken;
2525 use multiversion::target::match_target;
26+use crate::modes;
2627
2728 /// `VP8_FILTER_WEIGHT` (filter.c): tap weights sum to this, DC passes.
2829 const VP8_FILTER_WEIGHT: i32 = 128;
@@ -755,29 +756,6 @@ fn clamp_read_origin(
755756 (sx.clamp(2, max_x) as usize, sy.clamp(2, max_y) as usize)
756757 }
757758
758-/// The macroblock-level UMV border edges in eighth-pel units, exactly the
759-/// decoder's `xd->mb_to_{left,right,top,bottom}_edge` (decodeframe.c:503-532):
760-///
761-/// ```c
762-/// xd->mb_to_top_edge = -((mb_row * 16) << 3);
763-/// xd->mb_to_bottom_edge = ((mb_rows - 1 - mb_row) * 16) << 3;
764-/// xd->mb_to_left_edge = -((mb_col * 16) << 3);
765-/// xd->mb_to_right_edge = ((mb_cols - 1 - mb_col) * 16) << 3;
766-/// ```
767-///
768-/// with `mb_rows`/`mb_cols` the full (partial MB inclusive) MB counts of the
769-/// visible frame. Returns `(left, right, top, bottom)`.
770-fn mb_edges(mb_col: usize, mb_row: usize, vis_w: usize, vis_h: usize) -> (i32, i32, i32, i32) {
771- let mb_cols = (vis_w + 15) >> 4;
772- let mb_rows = (vis_h + 15) >> 4;
773- debug_assert!(mb_col < mb_cols && mb_row < mb_rows);
774- let left = -(((mb_col * 16) as i32) << 3);
775- let right = (((mb_cols - 1 - mb_col) * 16) as i32) << 3;
776- let top = -(((mb_row * 16) as i32) << 3);
777- let bottom = (((mb_rows - 1 - mb_row) * 16) as i32) << 3;
778- (left, right, top, bottom)
779-}
780-
781759 /// Port of `clamp_mv_to_umv_border` (reconinter.c:257-278), luma MV in
782760 /// eighth-pel units:
783761 ///
@@ -797,7 +775,7 @@ fn mb_edges(mb_col: usize, mb_row: usize, vis_w: usize, vis_h: usize) -> (i32, i
797775 /// when `need_to_clamp_mvs` is set, for each SPLITMV subblock MV too
798776 /// (reconinter.c:370-375, 397-400).
799777 fn clamp_mv_to_umv_border(mv: &mut (i32, i32), mb_col: usize, mb_row: usize, vis_w: usize, vis_h: usize) {
800- let (left, right, top, bottom) = mb_edges(mb_col, mb_row, vis_w, vis_h);
778+ let (left, right, top, bottom) = modes::mb_edges(mb_col, mb_row, (vis_w + 15) >> 4, (vis_h + 15) >> 4);
801779 if mv.1 < left - (19 << 3) {
802780 mv.1 = left - (16 << 3);
803781 } else if mv.1 > right + (18 << 3) {
@@ -836,7 +814,7 @@ fn clamp_mv_to_umv_border(mv: &mut (i32, i32), mb_col: usize, mb_row: usize, vis
836814 /// (reconinter.c:336-339 — the 16x16 path clamps the chroma MV
837815 /// unconditionally for exactly this reason).
838816 fn clamp_uvmv_to_umv_border(mv: &mut (i32, i32), mb_col: usize, mb_row: usize, vis_w: usize, vis_h: usize) {
839- let (left, right, top, bottom) = mb_edges(mb_col, mb_row, vis_w, vis_h);
817+ let (left, right, top, bottom) = modes::mb_edges(mb_col, mb_row, (vis_w + 15) >> 4, (vis_h + 15) >> 4);
840818
841819 if 2 * mv.1 < left - (19 << 3) {
842820 mv.1 = (left - (16 << 3)) >> 1;