ref: ddf02e323a7134bf330f6b2dfb5814fb4fc60edf
parent: 19d42de3cac1fe488799a650dd3ea80a7898216a
parent: b621e2d72efe6e164264359e0e330123afeae835
author: Dmitry Kovalev <[email protected]>
date: Thu Aug 1 10:50:14 EDT 2013
Merge "Nice looking motion vector clamping functions."
--- a/vp9/common/vp9_findnearmv.c
+++ b/vp9/common/vp9_findnearmv.c
@@ -32,7 +32,7 @@
// Make sure all the candidates are properly clamped etc
for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
lower_mv_precision(&mvlist[i], xd->allow_high_precision_mv);
- clamp_mv2(&mvlist[i], xd);
+ clamp_mv2(&mvlist[i].as_mv, xd);
}
*nearest = mvlist[0];
*near = mvlist[1];
--- a/vp9/common/vp9_findnearmv.h
+++ b/vp9/common/vp9_findnearmv.h
@@ -29,24 +29,17 @@
int_mv *near);
// TODO(jingning): this mv clamping function should be block size dependent.
-static void clamp_mv(int_mv *mv,
- int mb_to_left_edge,
- int mb_to_right_edge,
- int mb_to_top_edge,
- int mb_to_bottom_edge) {
- mv->as_mv.col = clamp(mv->as_mv.col, mb_to_left_edge, mb_to_right_edge);
- mv->as_mv.row = clamp(mv->as_mv.row, mb_to_top_edge, mb_to_bottom_edge);
+static void clamp_mv(MV *mv, int min_col, int max_col,
+ int min_row, int max_row) {
+ mv->col = clamp(mv->col, min_col, max_col);
+ mv->row = clamp(mv->row, min_row, max_row);
}
-static int clamp_mv2(int_mv *mv, const MACROBLOCKD *xd) {
- int_mv tmp_mv;
- tmp_mv.as_int = mv->as_int;
- clamp_mv(mv,
- xd->mb_to_left_edge - LEFT_TOP_MARGIN,
- xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN,
- xd->mb_to_top_edge - LEFT_TOP_MARGIN,
- xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN);
- return tmp_mv.as_int != mv->as_int;
+static void clamp_mv2(MV *mv, const MACROBLOCKD *xd) {
+ clamp_mv(mv, xd->mb_to_left_edge - LEFT_TOP_MARGIN,
+ xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN,
+ xd->mb_to_top_edge - LEFT_TOP_MARGIN,
+ xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN);
}
void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *pc,
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -366,16 +366,6 @@
return mode;
}
-static INLINE void assign_and_clamp_mv(int_mv *dst, const int_mv *src,
- int mb_to_left_edge,
- int mb_to_right_edge,
- int mb_to_top_edge,
- int mb_to_bottom_edge) {
- dst->as_int = src->as_int;
- clamp_mv(dst, mb_to_left_edge, mb_to_right_edge, mb_to_top_edge,
- mb_to_bottom_edge);
-}
-
static INLINE INTERPOLATIONFILTERTYPE read_switchable_filter_type(
VP9D_COMP *pbi, vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
@@ -558,36 +548,25 @@
mv0->as_int = mi->bmi[3].as_mv[0].as_int;
mv1->as_int = mi->bmi[3].as_mv[1].as_int;
} else {
- const int mb_to_top_edge = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
- const int mb_to_bottom_edge = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
- const int mb_to_left_edge = xd->mb_to_left_edge - LEFT_TOP_MARGIN;
- const int mb_to_right_edge = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN;
-
switch (mbmi->mode) {
case NEARMV:
- // Clip "next_nearest" so that it does not extend to far out of image
- assign_and_clamp_mv(mv0, &nearby, mb_to_left_edge,
- mb_to_right_edge,
- mb_to_top_edge,
- mb_to_bottom_edge);
- if (ref1 > 0)
- assign_and_clamp_mv(mv1, &nearby_second, mb_to_left_edge,
- mb_to_right_edge,
- mb_to_top_edge,
- mb_to_bottom_edge);
+ mv0->as_int = nearby.as_int;
+ clamp_mv2(&mv0->as_mv, xd);
+
+ if (ref1 > 0) {
+ mv1->as_int = nearby_second.as_int;
+ clamp_mv2(&mv1->as_mv, xd);
+ }
break;
case NEARESTMV:
- // Clip "next_nearest" so that it does not extend to far out of image
- assign_and_clamp_mv(mv0, &nearest, mb_to_left_edge,
- mb_to_right_edge,
- mb_to_top_edge,
- mb_to_bottom_edge);
- if (ref1 > 0)
- assign_and_clamp_mv(mv1, &nearest_second, mb_to_left_edge,
- mb_to_right_edge,
- mb_to_top_edge,
- mb_to_bottom_edge);
+ mv0->as_int = nearest.as_int;
+ clamp_mv2(&mv0->as_mv, xd);
+
+ if (ref1 > 0) {
+ mv1->as_int = nearest_second.as_int;
+ clamp_mv2(&mv1->as_mv, xd);
+ }
break;
case ZEROMV:
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -1319,7 +1319,8 @@
fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
// adjust ref_mv to make sure it is within MV range
- clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
+ clamp_mv(&ref_mv->as_mv,
+ x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
br = ref_mv->as_mv.row;
bc = ref_mv->as_mv.col;
@@ -1475,7 +1476,8 @@
fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
- clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
+ clamp_mv(&ref_mv->as_mv,
+ x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
ref_row = ref_mv->as_mv.row;
ref_col = ref_mv->as_mv.col;
*num00 = 0;
@@ -1615,7 +1617,8 @@
fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
- clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
+ clamp_mv(&ref_mv->as_mv,
+ x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
ref_row = ref_mv->as_mv.row;
ref_col = ref_mv->as_mv.col;
*num00 = 0;
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1973,7 +1973,7 @@
// Should we do a full search (best quality only)
if (cpi->compressor_speed == 0) {
/* Check if mvp_full is within the range. */
- clamp_mv(&mvp_full, x->mv_col_min, x->mv_col_max,
+ clamp_mv(&mvp_full.as_mv, x->mv_col_min, x->mv_col_max,
x->mv_row_min, x->mv_row_max);
thissme = cpi->full_search_sad(x, &mvp_full,
@@ -2833,10 +2833,8 @@
for (i = 0; i < num_refs; ++i) {
cur_mv[i] = frame_mv[refs[i]];
// Clip "next_nearest" so that it does not extend to far out of image
- if (this_mode == NEWMV)
- assert(!clamp_mv2(&cur_mv[i], xd));
- else
- clamp_mv2(&cur_mv[i], xd);
+ if (this_mode != NEWMV)
+ clamp_mv2(&cur_mv[i].as_mv, xd);
if (mv_check_bounds(x, &cur_mv[i]))
return INT64_MAX;