From 91fc6e60e84fc8b46cc352e747a4e89a1fab7c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 15:12:19 +0300 Subject: [PATCH] S7: vp8 mc uses the one mb_edges in modes.rs (same values; was a duplicate with vis-size arguments) --- crates/ec-vp8/src/mc.rs | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/crates/ec-vp8/src/mc.rs b/crates/ec-vp8/src/mc.rs index d610cbd6..10a9707f 100644 --- a/crates/ec-vp8/src/mc.rs +++ b/crates/ec-vp8/src/mc.rs @@ -23,6 +23,7 @@ //! [RFC 6386]: https://www.rfc-editor.org/rfc/rfc6386 use archmage::SimdToken; use multiversion::target::match_target; +use crate::modes; /// `VP8_FILTER_WEIGHT` (filter.c): tap weights sum to this, DC passes. const VP8_FILTER_WEIGHT: i32 = 128; @@ -755,29 +756,6 @@ fn clamp_read_origin( (sx.clamp(2, max_x) as usize, sy.clamp(2, max_y) as usize) } -/// The macroblock-level UMV border edges in eighth-pel units, exactly the -/// decoder's `xd->mb_to_{left,right,top,bottom}_edge` (decodeframe.c:503-532): -/// -/// ```c -/// xd->mb_to_top_edge = -((mb_row * 16) << 3); -/// xd->mb_to_bottom_edge = ((mb_rows - 1 - mb_row) * 16) << 3; -/// xd->mb_to_left_edge = -((mb_col * 16) << 3); -/// xd->mb_to_right_edge = ((mb_cols - 1 - mb_col) * 16) << 3; -/// ``` -/// -/// with `mb_rows`/`mb_cols` the full (partial MB inclusive) MB counts of the -/// visible frame. Returns `(left, right, top, bottom)`. -fn mb_edges(mb_col: usize, mb_row: usize, vis_w: usize, vis_h: usize) -> (i32, i32, i32, i32) { - let mb_cols = (vis_w + 15) >> 4; - let mb_rows = (vis_h + 15) >> 4; - debug_assert!(mb_col < mb_cols && mb_row < mb_rows); - let left = -(((mb_col * 16) as i32) << 3); - let right = (((mb_cols - 1 - mb_col) * 16) as i32) << 3; - let top = -(((mb_row * 16) as i32) << 3); - let bottom = (((mb_rows - 1 - mb_row) * 16) as i32) << 3; - (left, right, top, bottom) -} - /// Port of `clamp_mv_to_umv_border` (reconinter.c:257-278), luma MV in /// eighth-pel units: /// @@ -797,7 +775,7 @@ fn mb_edges(mb_col: usize, mb_row: usize, vis_w: usize, vis_h: usize) -> (i32, i /// when `need_to_clamp_mvs` is set, for each SPLITMV subblock MV too /// (reconinter.c:370-375, 397-400). fn clamp_mv_to_umv_border(mv: &mut (i32, i32), mb_col: usize, mb_row: usize, vis_w: usize, vis_h: usize) { - let (left, right, top, bottom) = mb_edges(mb_col, mb_row, vis_w, vis_h); + let (left, right, top, bottom) = modes::mb_edges(mb_col, mb_row, (vis_w + 15) >> 4, (vis_h + 15) >> 4); if mv.1 < left - (19 << 3) { mv.1 = left - (16 << 3); } 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 /// (reconinter.c:336-339 — the 16x16 path clamps the chroma MV /// unconditionally for exactly this reason). fn clamp_uvmv_to_umv_border(mv: &mut (i32, i32), mb_col: usize, mb_row: usize, vis_w: usize, vis_h: usize) { - let (left, right, top, bottom) = mb_edges(mb_col, mb_row, vis_w, vis_h); + let (left, right, top, bottom) = modes::mb_edges(mb_col, mb_row, (vis_w + 15) >> 4, (vis_h + 15) >> 4); if 2 * mv.1 < left - (19 << 3) { mv.1 = (left - (16 << 3)) >> 1;