Unverified Commit a8dde02f authored by fbossen's avatar fbossen Committed by GitHub

Apply normative clamping to MV stack (#568)

See section 7.10.2.14 context and clamping process
parent e9ef8224
......@@ -2430,6 +2430,20 @@ impl ContextWriter {
/* TODO: Handle single reference frame extension */
// clamp mvs
for mv in mv_stack {
let blk_w = bsize.width();
let blk_h = bsize.height();
let border_w = 128 + blk_w as isize * 8;
let border_h = 128 + blk_h as isize * 8;
let x_min = -(bo.x as isize) * (8 * MI_SIZE) as isize - border_w;
let x_max = (self.bc.cols - bo.x - blk_w / MI_SIZE) as isize * (8 * MI_SIZE) as isize + border_w;
let y_min = -(bo.y as isize) * (8 * MI_SIZE) as isize - border_h;
let y_max = (self.bc.rows - bo.y - blk_h / MI_SIZE) as isize * (8 * MI_SIZE) as isize + border_h;
mv.this_mv.row = (mv.this_mv.row as isize).max(y_min).min(y_max) as i16;
mv.this_mv.col = (mv.this_mv.col as isize).max(x_min).min(x_max) as i16;
}
mode_context
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment