From ca9132d0eb73ccddaf4c983bceb2d9a8e3478887 Mon Sep 17 00:00:00 2001 From: Jonathan Matthews Date: Tue, 31 Oct 2017 10:32:38 +0000 Subject: [PATCH] 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 --- av1/common/mvref_common.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c index aac9f30e6..958ab1331 100644 --- a/av1/common/mvref_common.c +++ b/av1/common/mvref_common.c @@ -133,7 +133,7 @@ static uint8_t add_ref_mv_candidate( 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 @@ static uint8_t add_ref_mv_candidate( 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 @@ static uint8_t scan_row_mbmi(const AV1_COMMON *cm, const MACROBLOCKD *xd, 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 @@ static uint8_t scan_col_mbmi(const AV1_COMMON *cm, const MACROBLOCKD *xd, } 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 @@ static uint8_t scan_blk_mbmi(const AV1_COMMON *cm, const MACROBLOCKD *xd, 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; -- GitLab