ref-mv: Don't stop scanning when ref-mv stack is full.
This would result in certain motion vectors getting
lower weights than they deserve, so putting them in
the wrong position in the stack.
BUG=aomedia:981
Change-Id: I8bd106e97f494f5d3debaf967efcabcd39846726
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index aac9f30..958ab13 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -133,7 +133,7 @@
if (index < *refmv_count) ref_mv_stack[index].weight += weight * len;
// Add a new item to the list.
- if (index == *refmv_count) {
+ if (index == *refmv_count && *refmv_count < MAX_REF_MV_STACK_SIZE) {
ref_mv_stack[index].this_mv = this_refmv;
ref_mv_stack[index].pred_diff[0] = av1_get_pred_diff_ctx(
get_sub_block_pred_mv(candidate_mi, ref, col, block), this_refmv);
@@ -171,7 +171,7 @@
if (index < *refmv_count) ref_mv_stack[index].weight += weight * len;
// Add a new item to the list.
- if (index == *refmv_count) {
+ if (index == *refmv_count && *refmv_count < MAX_REF_MV_STACK_SIZE) {
ref_mv_stack[index].this_mv = this_refmv[0];
ref_mv_stack[index].comp_mv = this_refmv[1];
ref_mv_stack[index].pred_diff[0] = av1_get_pred_diff_ctx(
@@ -211,7 +211,7 @@
const int use_step_16 = (xd->n8_w >= 16);
MODE_INFO **const candidate_mi0 = xd->mi + row_offset * xd->mi_stride;
- for (i = 0; i < end_mi && *refmv_count < MAX_REF_MV_STACK_SIZE;) {
+ for (i = 0; i < end_mi;) {
const MODE_INFO *const candidate_mi = candidate_mi0[col_offset + i];
const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
const int candidate_bsize = candidate->sb_type;
@@ -280,7 +280,7 @@
}
const int use_step_16 = (xd->n8_h >= 16);
- for (i = 0; i < end_mi && *refmv_count < MAX_REF_MV_STACK_SIZE;) {
+ for (i = 0; i < end_mi;) {
const MODE_INFO *const candidate_mi =
xd->mi[(row_offset + i) * xd->mi_stride + col_offset];
const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
@@ -343,8 +343,7 @@
mi_pos.row = row_offset;
mi_pos.col = col_offset;
- if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm, &mi_pos) &&
- *refmv_count < MAX_REF_MV_STACK_SIZE) {
+ if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm, &mi_pos)) {
const MODE_INFO *const candidate_mi =
xd->mi[mi_pos.row * xd->mi_stride + mi_pos.col];
const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;