return &buf->buf[mv->row * buf->stride + mv->col];
}
-void vp9_set_mv_search_range(MACROBLOCK *x, const MV *mv) {
+void vp9_set_mv_search_range(MvLimits *mv_limits, const MV *mv) {
int col_min = (mv->col >> 3) - MAX_FULL_PEL_VAL + (mv->col & 7 ? 1 : 0);
int row_min = (mv->row >> 3) - MAX_FULL_PEL_VAL + (mv->row & 7 ? 1 : 0);
int col_max = (mv->col >> 3) + MAX_FULL_PEL_VAL;
// Get intersection of UMV window and valid MV window to reduce # of checks
// in diamond search.
- if (x->mv_col_min < col_min) x->mv_col_min = col_min;
- if (x->mv_col_max > col_max) x->mv_col_max = col_max;
- if (x->mv_row_min < row_min) x->mv_row_min = row_min;
- if (x->mv_row_max > row_max) x->mv_row_max = row_max;
+ if (mv_limits->col_min < col_min) mv_limits->col_min = col_min;
+ if (mv_limits->col_max > col_max) mv_limits->col_max = col_max;
+ if (mv_limits->row_min < row_min) mv_limits->row_min = row_min;
+ if (mv_limits->row_max > row_max) mv_limits->row_max = row_max;
}
int vp9_init_search_range(int size) {
} \
}
-#define SETUP_SUBPEL_SEARCH \
- const uint8_t *const z = x->plane[0].src.buf; \
- const int src_stride = x->plane[0].src.stride; \
- const MACROBLOCKD *xd = &x->e_mbd; \
- unsigned int besterr = INT_MAX; \
- unsigned int sse; \
- unsigned int whichdir; \
- int thismse; \
- const unsigned int halfiters = iters_per_step; \
- const unsigned int quarteriters = iters_per_step; \
- const unsigned int eighthiters = iters_per_step; \
- const int y_stride = xd->plane[0].pre[0].stride; \
- const int offset = bestmv->row * y_stride + bestmv->col; \
- const uint8_t *const y = xd->plane[0].pre[0].buf; \
- \
- int rr = ref_mv->row; \
- int rc = ref_mv->col; \
- int br = bestmv->row * 8; \
- int bc = bestmv->col * 8; \
- int hstep = 4; \
- const int minc = VPXMAX(x->mv_col_min * 8, ref_mv->col - MV_MAX); \
- const int maxc = VPXMIN(x->mv_col_max * 8, ref_mv->col + MV_MAX); \
- const int minr = VPXMAX(x->mv_row_min * 8, ref_mv->row - MV_MAX); \
- const int maxr = VPXMIN(x->mv_row_max * 8, ref_mv->row + MV_MAX); \
- int tr = br; \
- int tc = bc; \
- \
- bestmv->row *= 8; \
+#define SETUP_SUBPEL_SEARCH \
+ const uint8_t *const z = x->plane[0].src.buf; \
+ const int src_stride = x->plane[0].src.stride; \
+ const MACROBLOCKD *xd = &x->e_mbd; \
+ unsigned int besterr = INT_MAX; \
+ unsigned int sse; \
+ unsigned int whichdir; \
+ int thismse; \
+ const unsigned int halfiters = iters_per_step; \
+ const unsigned int quarteriters = iters_per_step; \
+ const unsigned int eighthiters = iters_per_step; \
+ const int y_stride = xd->plane[0].pre[0].stride; \
+ const int offset = bestmv->row * y_stride + bestmv->col; \
+ const uint8_t *const y = xd->plane[0].pre[0].buf; \
+ \
+ int rr = ref_mv->row; \
+ int rc = ref_mv->col; \
+ int br = bestmv->row * 8; \
+ int bc = bestmv->col * 8; \
+ int hstep = 4; \
+ const int minc = VPXMAX(x->mv_limits.col_min * 8, ref_mv->col - MV_MAX); \
+ const int maxc = VPXMIN(x->mv_limits.col_max * 8, ref_mv->col + MV_MAX); \
+ const int minr = VPXMAX(x->mv_limits.row_min * 8, ref_mv->row - MV_MAX); \
+ const int maxr = VPXMIN(x->mv_limits.row_max * 8, ref_mv->row + MV_MAX); \
+ int tr = br; \
+ int tc = bc; \
+ \
+ bestmv->row *= 8; \
bestmv->col *= 8;
static unsigned int setup_center_error(
int bc = bestmv->col * 8;
int hstep = 4;
int iter, round = 3 - forced_stop;
- const int minc = VPXMAX(x->mv_col_min * 8, ref_mv->col - MV_MAX);
- const int maxc = VPXMIN(x->mv_col_max * 8, ref_mv->col + MV_MAX);
- const int minr = VPXMAX(x->mv_row_min * 8, ref_mv->row - MV_MAX);
- const int maxr = VPXMIN(x->mv_row_max * 8, ref_mv->row + MV_MAX);
+ const int minc = VPXMAX(x->mv_limits.col_min * 8, ref_mv->col - MV_MAX);
+ const int maxc = VPXMIN(x->mv_limits.col_max * 8, ref_mv->col + MV_MAX);
+ const int minr = VPXMAX(x->mv_limits.row_min * 8, ref_mv->row - MV_MAX);
+ const int maxr = VPXMIN(x->mv_limits.row_max * 8, ref_mv->row + MV_MAX);
int tr = br;
int tc = bc;
const MV *search_step = search_step_table;
#undef MVC
#undef CHECK_BETTER
-static INLINE int check_bounds(const MACROBLOCK *x, int row, int col,
+static INLINE int check_bounds(const MvLimits *mv_limits, int row, int col,
int range) {
- return ((row - range) >= x->mv_row_min) & ((row + range) <= x->mv_row_max) &
- ((col - range) >= x->mv_col_min) & ((col + range) <= x->mv_col_max);
+ return ((row - range) >= mv_limits->row_min) &
+ ((row + range) <= mv_limits->row_max) &
+ ((col - range) >= mv_limits->col_min) &
+ ((col + range) <= mv_limits->col_max);
}
-static INLINE int is_mv_in(const MACROBLOCK *x, const MV *mv) {
- return (mv->col >= x->mv_col_min) && (mv->col <= x->mv_col_max) &&
- (mv->row >= x->mv_row_min) && (mv->row <= x->mv_row_max);
+static INLINE int is_mv_in(const MvLimits *mv_limits, const MV *mv) {
+ return (mv->col >= mv_limits->col_min) && (mv->col <= mv_limits->col_max) &&
+ (mv->row >= mv_limits->row_min) && (mv->row <= mv_limits->row_max);
}
#define CHECK_BETTER \
fn_ptr->vf(what->buf, what->stride, get_buf_from_mv(in_what, &this_mv),
in_what->stride, &sse) +
mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb);
- if (check_bounds(x, br, bc, 1)) {
+ if (check_bounds(&x->mv_limits, br, bc, 1)) {
for (i = 0; i < 4; i++) {
const MV this_mv = { br + neighbors[i].row, bc + neighbors[i].col };
cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride,
} else {
for (i = 0; i < 4; i++) {
const MV this_mv = { br + neighbors[i].row, bc + neighbors[i].col };
- if (!is_mv_in(x, &this_mv))
+ if (!is_mv_in(&x->mv_limits, &this_mv))
cost_list[i + 1] = INT_MAX;
else
cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride,
const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 };
int best_init_s = search_param_to_steps[search_param];
// 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, x->mv_limits.col_min, x->mv_limits.col_max,
+ x->mv_limits.row_min, x->mv_limits.row_max);
br = ref_mv->row;
bc = ref_mv->col;
best_init_s = -1;
for (t = 0; t <= s; ++t) {
int best_site = -1;
- if (check_bounds(x, br, bc, 1 << t)) {
+ if (check_bounds(&x->mv_limits, br, bc, 1 << t)) {
for (i = 0; i < num_candidates[t]; i++) {
const MV this_mv = { br + candidates[t][i].row,
bc + candidates[t][i].col };
for (i = 0; i < num_candidates[t]; i++) {
const MV this_mv = { br + candidates[t][i].row,
bc + candidates[t][i].col };
- if (!is_mv_in(x, &this_mv)) continue;
+ if (!is_mv_in(&x->mv_limits, &this_mv)) continue;
thissad =
vfp->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &this_mv), in_what->stride);
do {
// No need to search all 6 points the 1st time if initial search was used
if (!do_init_search || s != best_init_s) {
- if (check_bounds(x, br, bc, 1 << s)) {
+ if (check_bounds(&x->mv_limits, br, bc, 1 << s)) {
for (i = 0; i < num_candidates[s]; i++) {
const MV this_mv = { br + candidates[s][i].row,
bc + candidates[s][i].col };
for (i = 0; i < num_candidates[s]; i++) {
const MV this_mv = { br + candidates[s][i].row,
bc + candidates[s][i].col };
- if (!is_mv_in(x, &this_mv)) continue;
+ if (!is_mv_in(&x->mv_limits, &this_mv)) continue;
thissad =
vfp->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &this_mv), in_what->stride);
next_chkpts_indices[1] = k;
next_chkpts_indices[2] = (k == num_candidates[s] - 1) ? 0 : k + 1;
- if (check_bounds(x, br, bc, 1 << s)) {
+ if (check_bounds(&x->mv_limits, br, bc, 1 << s)) {
for (i = 0; i < PATTERN_CANDIDATES_REF; i++) {
const MV this_mv = {
br + candidates[s][next_chkpts_indices[i]].row,
br + candidates[s][next_chkpts_indices[i]].row,
bc + candidates[s][next_chkpts_indices[i]].col
};
- if (!is_mv_in(x, &this_mv)) continue;
+ if (!is_mv_in(&x->mv_limits, &this_mv)) continue;
thissad =
vfp->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &this_mv), in_what->stride);
const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 };
int best_init_s = search_param_to_steps[search_param];
// 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, x->mv_limits.col_min, x->mv_limits.col_max,
+ x->mv_limits.row_min, x->mv_limits.row_max);
br = ref_mv->row;
bc = ref_mv->col;
if (cost_list != NULL) {
best_init_s = -1;
for (t = 0; t <= s; ++t) {
int best_site = -1;
- if (check_bounds(x, br, bc, 1 << t)) {
+ if (check_bounds(&x->mv_limits, br, bc, 1 << t)) {
for (i = 0; i < num_candidates[t]; i++) {
const MV this_mv = { br + candidates[t][i].row,
bc + candidates[t][i].col };
for (i = 0; i < num_candidates[t]; i++) {
const MV this_mv = { br + candidates[t][i].row,
bc + candidates[t][i].col };
- if (!is_mv_in(x, &this_mv)) continue;
+ if (!is_mv_in(&x->mv_limits, &this_mv)) continue;
thissad =
vfp->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &this_mv), in_what->stride);
for (; s >= do_sad; s--) {
if (!do_init_search || s != best_init_s) {
- if (check_bounds(x, br, bc, 1 << s)) {
+ if (check_bounds(&x->mv_limits, br, bc, 1 << s)) {
for (i = 0; i < num_candidates[s]; i++) {
const MV this_mv = { br + candidates[s][i].row,
bc + candidates[s][i].col };
for (i = 0; i < num_candidates[s]; i++) {
const MV this_mv = { br + candidates[s][i].row,
bc + candidates[s][i].col };
- if (!is_mv_in(x, &this_mv)) continue;
+ if (!is_mv_in(&x->mv_limits, &this_mv)) continue;
thissad =
vfp->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &this_mv), in_what->stride);
next_chkpts_indices[1] = k;
next_chkpts_indices[2] = (k == num_candidates[s] - 1) ? 0 : k + 1;
- if (check_bounds(x, br, bc, 1 << s)) {
+ if (check_bounds(&x->mv_limits, br, bc, 1 << s)) {
for (i = 0; i < PATTERN_CANDIDATES_REF; i++) {
const MV this_mv = {
br + candidates[s][next_chkpts_indices[i]].row,
br + candidates[s][next_chkpts_indices[i]].row,
bc + candidates[s][next_chkpts_indices[i]].col
};
- if (!is_mv_in(x, &this_mv)) continue;
+ if (!is_mv_in(&x->mv_limits, &this_mv)) continue;
thissad =
vfp->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &this_mv), in_what->stride);
if (s == 0) {
cost_list[0] = bestsad;
if (!do_init_search || s != best_init_s) {
- if (check_bounds(x, br, bc, 1 << s)) {
+ if (check_bounds(&x->mv_limits, br, bc, 1 << s)) {
for (i = 0; i < num_candidates[s]; i++) {
const MV this_mv = { br + candidates[s][i].row,
bc + candidates[s][i].col };
for (i = 0; i < num_candidates[s]; i++) {
const MV this_mv = { br + candidates[s][i].row,
bc + candidates[s][i].col };
- if (!is_mv_in(x, &this_mv)) continue;
+ if (!is_mv_in(&x->mv_limits, &this_mv)) continue;
cost_list[i + 1] = thissad =
vfp->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &this_mv), in_what->stride);
cost_list[((k + 2) % 4) + 1] = cost_list[0];
cost_list[0] = bestsad;
- if (check_bounds(x, br, bc, 1 << s)) {
+ if (check_bounds(&x->mv_limits, br, bc, 1 << s)) {
for (i = 0; i < PATTERN_CANDIDATES_REF; i++) {
const MV this_mv = {
br + candidates[s][next_chkpts_indices[i]].row,
br + candidates[s][next_chkpts_indices[i]].row,
bc + candidates[s][next_chkpts_indices[i]].col
};
- if (!is_mv_in(x, &this_mv)) {
+ if (!is_mv_in(&x->mv_limits, &this_mv)) {
cost_list[next_chkpts_indices[i] + 1] = INT_MAX;
continue;
}
static const MV neighbors[4] = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 } };
if (cost_list[0] == INT_MAX) {
cost_list[0] = bestsad;
- if (check_bounds(x, br, bc, 1)) {
+ if (check_bounds(&x->mv_limits, br, bc, 1)) {
for (i = 0; i < 4; i++) {
const MV this_mv = { br + neighbors[i].row, bc + neighbors[i].col };
cost_list[i + 1] =
} else {
for (i = 0; i < 4; i++) {
const MV this_mv = { br + neighbors[i].row, bc + neighbors[i].col };
- if (!is_mv_in(x, &this_mv))
+ if (!is_mv_in(&x->mv_limits, &this_mv))
cost_list[i + 1] = INT_MAX;
else
cost_list[i + 1] =
assert(step >= 1);
- clamp_mv(&fcenter_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min,
- x->mv_row_max);
+ clamp_mv(&fcenter_mv, x->mv_limits.col_min, x->mv_limits.col_max,
+ x->mv_limits.row_min, x->mv_limits.row_max);
*best_mv = fcenter_mv;
best_sad =
fn_ptr->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &fcenter_mv), in_what->stride) +
mvsad_err_cost(x, &fcenter_mv, ref_mv, sad_per_bit);
- start_row = VPXMAX(-range, x->mv_row_min - fcenter_mv.row);
- start_col = VPXMAX(-range, x->mv_col_min - fcenter_mv.col);
- end_row = VPXMIN(range, x->mv_row_max - fcenter_mv.row);
- end_col = VPXMIN(range, x->mv_col_max - fcenter_mv.col);
+ start_row = VPXMAX(-range, x->mv_limits.row_min - fcenter_mv.row);
+ start_col = VPXMAX(-range, x->mv_limits.col_min - fcenter_mv.col);
+ end_row = VPXMIN(range, x->mv_limits.row_max - fcenter_mv.row);
+ end_col = VPXMIN(range, x->mv_limits.col_max - fcenter_mv.col);
for (r = start_row; r <= end_row; r += step) {
for (c = start_col; c <= end_col; c += col_step) {
const int tot_steps = cfg->total_steps - search_param;
const MV fcenter_mv = { center_mv->row >> 3, center_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, x->mv_limits.col_min, x->mv_limits.col_max,
+ x->mv_limits.row_min, x->mv_limits.row_max);
ref_row = ref_mv->row;
ref_col = ref_mv->col;
*num00 = 0;
// All_in is true if every one of the points we are checking are within
// the bounds of the image.
- all_in &= ((best_mv->row + ss_mv[i].row) > x->mv_row_min);
- all_in &= ((best_mv->row + ss_mv[i + 1].row) < x->mv_row_max);
- all_in &= ((best_mv->col + ss_mv[i + 2].col) > x->mv_col_min);
- all_in &= ((best_mv->col + ss_mv[i + 3].col) < x->mv_col_max);
+ all_in &= ((best_mv->row + ss_mv[i].row) > x->mv_limits.row_min);
+ all_in &= ((best_mv->row + ss_mv[i + 1].row) < x->mv_limits.row_max);
+ all_in &= ((best_mv->col + ss_mv[i + 2].col) > x->mv_limits.col_min);
+ all_in &= ((best_mv->col + ss_mv[i + 3].col) < x->mv_limits.col_max);
// If all the pixels are within the bounds we don't check whether the
// search point is valid in this loop, otherwise we check each point
const MV this_mv = { best_mv->row + ss_mv[i].row,
best_mv->col + ss_mv[i].col };
- if (is_mv_in(x, &this_mv)) {
+ if (is_mv_in(&x->mv_limits, &this_mv)) {
const uint8_t *const check_here = ss_os[i] + best_address;
unsigned int thissad =
fn_ptr->sdf(what, what_stride, check_here, in_what_stride);
while (1) {
const MV this_mv = { best_mv->row + ss_mv[best_site].row,
best_mv->col + ss_mv[best_site].col };
- if (is_mv_in(x, &this_mv)) {
+ if (is_mv_in(&x->mv_limits, &this_mv)) {
const uint8_t *const check_here = ss_os[best_site] + best_address;
unsigned int thissad =
fn_ptr->sdf(what, what_stride, check_here, in_what_stride);
const MACROBLOCKD *const xd = &x->e_mbd;
const struct buf_2d *const what = &x->plane[0].src;
const struct buf_2d *const in_what = &xd->plane[0].pre[0];
- const int row_min = VPXMAX(ref_mv->row - distance, x->mv_row_min);
- const int row_max = VPXMIN(ref_mv->row + distance, x->mv_row_max);
- const int col_min = VPXMAX(ref_mv->col - distance, x->mv_col_min);
- const int col_max = VPXMIN(ref_mv->col + distance, x->mv_col_max);
+ const int row_min = VPXMAX(ref_mv->row - distance, x->mv_limits.row_min);
+ const int row_max = VPXMIN(ref_mv->row + distance, x->mv_limits.row_max);
+ const int col_min = VPXMAX(ref_mv->col - distance, x->mv_limits.col_min);
+ const int col_max = VPXMIN(ref_mv->col + distance, x->mv_limits.col_max);
const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 };
int best_sad =
fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, ref_mv),
const MACROBLOCKD *const xd = &x->e_mbd;
const struct buf_2d *const what = &x->plane[0].src;
const struct buf_2d *const in_what = &xd->plane[0].pre[0];
- const int row_min = VPXMAX(ref_mv->row - distance, x->mv_row_min);
- const int row_max = VPXMIN(ref_mv->row + distance, x->mv_row_max);
- const int col_min = VPXMAX(ref_mv->col - distance, x->mv_col_min);
- const int col_max = VPXMIN(ref_mv->col + distance, x->mv_col_max);
+ const int row_min = VPXMAX(ref_mv->row - distance, x->mv_limits.row_min);
+ const int row_max = VPXMIN(ref_mv->row + distance, x->mv_limits.row_max);
+ const int col_min = VPXMAX(ref_mv->col - distance, x->mv_limits.col_min);
+ const int col_max = VPXMIN(ref_mv->col + distance, x->mv_limits.col_max);
const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 };
unsigned int best_sad =
fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, ref_mv),
const MACROBLOCKD *const xd = &x->e_mbd;
const struct buf_2d *const what = &x->plane[0].src;
const struct buf_2d *const in_what = &xd->plane[0].pre[0];
- const int row_min = VPXMAX(ref_mv->row - distance, x->mv_row_min);
- const int row_max = VPXMIN(ref_mv->row + distance, x->mv_row_max);
- const int col_min = VPXMAX(ref_mv->col - distance, x->mv_col_min);
- const int col_max = VPXMIN(ref_mv->col + distance, x->mv_col_max);
+ const int row_min = VPXMAX(ref_mv->row - distance, x->mv_limits.row_min);
+ const int row_max = VPXMIN(ref_mv->row + distance, x->mv_limits.row_max);
+ const int col_min = VPXMAX(ref_mv->col - distance, x->mv_limits.col_min);
+ const int col_max = VPXMIN(ref_mv->col + distance, x->mv_limits.col_max);
const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 };
unsigned int best_sad =
fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, ref_mv),
for (i = 0; i < search_range; i++) {
int best_site = -1;
- const int all_in = ((ref_mv->row - 1) > x->mv_row_min) &
- ((ref_mv->row + 1) < x->mv_row_max) &
- ((ref_mv->col - 1) > x->mv_col_min) &
- ((ref_mv->col + 1) < x->mv_col_max);
+ const int all_in = ((ref_mv->row - 1) > x->mv_limits.row_min) &
+ ((ref_mv->row + 1) < x->mv_limits.row_max) &
+ ((ref_mv->col - 1) > x->mv_limits.col_min) &
+ ((ref_mv->col + 1) < x->mv_limits.col_max);
if (all_in) {
unsigned int sads[4];
const MV mv = { ref_mv->row + neighbors[j].row,
ref_mv->col + neighbors[j].col };
- if (is_mv_in(x, &mv)) {
+ if (is_mv_in(&x->mv_limits, &mv)) {
unsigned int sad =
fn_ptr->sdf(what->buf, what->stride,
get_buf_from_mv(in_what, &mv), in_what->stride);
const MV mv = { ref_mv->row + neighbors[j].row,
ref_mv->col + neighbors[j].col };
- if (is_mv_in(x, &mv)) {
+ if (is_mv_in(&x->mv_limits, &mv)) {
unsigned int sad =
fn_ptr->sdaf(what->buf, what->stride, get_buf_from_mv(in_what, &mv),
in_what->stride, second_pred);
int mvthresh;
} BEST_SEG_INFO;
-static INLINE int mv_check_bounds(const MACROBLOCK *x, const MV *mv) {
- return (mv->row >> 3) < x->mv_row_min || (mv->row >> 3) > x->mv_row_max ||
- (mv->col >> 3) < x->mv_col_min || (mv->col >> 3) > x->mv_col_max;
+static INLINE int mv_check_bounds(const MvLimits *mv_limits, const MV *mv) {
+ return (mv->row >> 3) < mv_limits->row_min ||
+ (mv->row >> 3) > mv_limits->row_max ||
+ (mv->col >> 3) < mv_limits->col_min ||
+ (mv->col >> 3) > mv_limits->col_max;
}
static INLINE void mi_buf_shift(MACROBLOCK *x, int i) {
MV tmp_mv;
int search_range = 3;
- int tmp_col_min = x->mv_col_min;
- int tmp_col_max = x->mv_col_max;
- int tmp_row_min = x->mv_row_min;
- int tmp_row_max = x->mv_row_max;
+ const MvLimits tmp_mv_limits = x->mv_limits;
int id = ite % 2; // Even iterations search in the first reference frame,
// odd iterations search in the second. The predictor
// found for the 'other' reference frame is factored in.
// Do compound motion search on the current reference frame.
if (id) xd->plane[0].pre[0] = ref_yv12[id];
- vp9_set_mv_search_range(x, &ref_mv[id].as_mv);
+ vp9_set_mv_search_range(&x->mv_limits, &ref_mv[id].as_mv);
// Use the mv result from the single mode as mv predictor.
tmp_mv = frame_mv[refs[id]].as_mv;
bestsme = vp9_get_mvpred_av_var(x, &tmp_mv, &ref_mv[id].as_mv,
second_pred, &cpi->fn_ptr[bsize], 1);
- x->mv_col_min = tmp_col_min;
- x->mv_col_max = tmp_col_max;
- x->mv_row_min = tmp_row_min;
- x->mv_row_max = tmp_row_max;
+ x->mv_limits = tmp_mv_limits;
if (bestsme < UINT_MAX) {
uint32_t dis; /* TODO: use dis in distortion calculation later. */
MV mvp_full;
int max_mv;
int cost_list[5];
- int tmp_col_min = x->mv_col_min;
- int tmp_col_max = x->mv_col_max;
- int tmp_row_min = x->mv_row_min;
- int tmp_row_max = x->mv_row_max;
+ const MvLimits tmp_mv_limits = x->mv_limits;
/* Is the best so far sufficiently good that we cant justify doing
* and new motion search. */
// adjust src pointer for this block
mi_buf_shift(x, i);
- vp9_set_mv_search_range(x, &bsi->ref_mv[0]->as_mv);
+ vp9_set_mv_search_range(&x->mv_limits, &bsi->ref_mv[0]->as_mv);
bestsme = vp9_full_pixel_search(
cpi, x, bsize, &mvp_full, step_param, sadpb,
sf->mv.subpel_search_method != SUBPEL_TREE ? cost_list : NULL,
&bsi->ref_mv[0]->as_mv, new_mv, INT_MAX, 1);
- x->mv_col_min = tmp_col_min;
- x->mv_col_max = tmp_col_max;
- x->mv_row_min = tmp_row_min;
- x->mv_row_max = tmp_row_max;
+ x->mv_limits = tmp_mv_limits;
if (bestsme < UINT_MAX) {
uint32_t distortion;
}
// Trap vectors that reach beyond the UMV borders
- if (mv_check_bounds(x, &mode_mv[this_mode][0].as_mv) ||
- (has_second_rf && mv_check_bounds(x, &mode_mv[this_mode][1].as_mv)))
+ if (mv_check_bounds(&x->mv_limits, &mode_mv[this_mode][0].as_mv) ||
+ (has_second_rf &&
+ mv_check_bounds(&x->mv_limits, &mode_mv[this_mode][1].as_mv)))
continue;
if (filter_idx > 0) {
MV mvp_full;
int ref = mi->ref_frame[0];
MV ref_mv = x->mbmi_ext->ref_mvs[ref][0].as_mv;
-
- int tmp_col_min = x->mv_col_min;
- int tmp_col_max = x->mv_col_max;
- int tmp_row_min = x->mv_row_min;
- int tmp_row_max = x->mv_row_max;
+ const MvLimits tmp_mv_limits = x->mv_limits;
int cost_list[5];
const YV12_BUFFER_CONFIG *scaled_ref_frame =
vp9_setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL);
}
- vp9_set_mv_search_range(x, &ref_mv);
+ vp9_set_mv_search_range(&x->mv_limits, &ref_mv);
// Work out the size of the first step in the mv step search.
// 0 here is maximum length first step. 1 is VPXMAX >> 1 etc.
cond_cost_list(cpi, cost_list), &ref_mv,
&tmp_mv->as_mv, INT_MAX, 1);
- x->mv_col_min = tmp_col_min;
- x->mv_col_max = tmp_col_max;
- x->mv_row_min = tmp_row_min;
- x->mv_row_max = tmp_row_max;
+ x->mv_limits = tmp_mv_limits;
if (bestsme < INT_MAX) {
uint32_t dis; /* TODO: use dis in distortion calculation later. */
// Clip "next_nearest" so that it does not extend to far out of image
if (this_mode != NEWMV) clamp_mv2(&cur_mv[i].as_mv, xd);
- if (mv_check_bounds(x, &cur_mv[i].as_mv)) return INT64_MAX;
+ if (mv_check_bounds(&x->mv_limits, &cur_mv[i].as_mv)) return INT64_MAX;
mi->mv[i].as_int = cur_mv[i].as_int;
}