Commit 3e225434 authored by Yunqing Wang's avatar Yunqing Wang

[NORMATIVE] Consolidate reference mv clamping

Clamp_mv_ref happens in multiple places in ref_mv search, which can be
convoluted as reported in issue 1124. This change is to consolidate
the clamping into one place.

Borg test result on lowres set:
avg_psnr:    ovr_psnr:   ssim:
  0.000       0.000      0.001

BUG=aomedia:1377
BUG=aomedia:1124
BUG=aomedia:857

Change-Id: I1649d5b5f37683c9c30e493c6eed13a808ab543a
parent 73190512
......@@ -1207,12 +1207,16 @@ static void setup_ref_mv_list(
for (int idx = refmv_count[ref_frame]; idx < MAX_MV_REF_CANDIDATES; ++idx)
mv_ref_list[rf[0]][idx].as_int = gm_mv_candidates[0].as_int;
#endif
for (int idx = 0; idx < refmv_count[ref_frame]; ++idx) {
clamp_mv_ref(&ref_mv_stack[ref_frame][idx].this_mv.as_mv,
xd->n8_w << MI_SIZE_LOG2, xd->n8_h << MI_SIZE_LOG2, xd);
}
for (int idx = 0;
idx < AOMMIN(MAX_MV_REF_CANDIDATES, refmv_count[ref_frame]); ++idx) {
mv_ref_list[rf[0]][idx].as_int =
ref_mv_stack[ref_frame][idx].this_mv.as_int;
clamp_mv_ref(&mv_ref_list[rf[0]][idx].as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
}
}
(void)nearest_match;
......
......@@ -1867,8 +1867,6 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
if (xd->ref_mv_count[ref_frame_type] > 1) {
ref_mv[0] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
clamp_mv_ref(&ref_mv[0].as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
}
nearestmv[0] = ref_mv[0];
}
......@@ -1876,8 +1874,6 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
if (xd->ref_mv_count[ref_frame_type] > 1) {
ref_mv[1] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
clamp_mv_ref(&ref_mv[1].as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
}
nearestmv[1] = ref_mv[1];
}
......@@ -1886,8 +1882,6 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
if (xd->ref_mv_count[ref_frame_type] > 1) {
ref_mv[0] = xd->ref_mv_stack[ref_frame_type][mbmi->ref_mv_idx].this_mv;
clamp_mv_ref(&ref_mv[0].as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
}
nearestmv[0] = ref_mv[0];
}
......
......@@ -400,8 +400,6 @@ static void set_ref_and_pred_mvs(MACROBLOCK *const x, int_mv *const mi_pred_mv,
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const int bw = xd->n8_w << MI_SIZE_LOG2;
const int bh = xd->n8_h << MI_SIZE_LOG2;
int ref_mv_idx = mbmi->ref_mv_idx;
MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
CANDIDATE_MV *const curr_ref_mv_stack = mbmi_ext->ref_mv_stack[rf_type];
......@@ -413,14 +411,12 @@ static void set_ref_and_pred_mvs(MACROBLOCK *const x, int_mv *const mi_pred_mv,
if (compound_ref0_mode(mbmi->mode) == NEWMV) {
int_mv this_mv = curr_ref_mv_stack[ref_mv_idx].this_mv;
clamp_mv_ref(&this_mv.as_mv, bw, bh, xd);
mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0] = this_mv;
mbmi->pred_mv[0] = this_mv;
mi_pred_mv[0] = this_mv;
}
if (compound_ref1_mode(mbmi->mode) == NEWMV) {
int_mv this_mv = curr_ref_mv_stack[ref_mv_idx].comp_mv;
clamp_mv_ref(&this_mv.as_mv, bw, bh, xd);
mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0] = this_mv;
mbmi->pred_mv[1] = this_mv;
mi_pred_mv[1] = this_mv;
......@@ -431,7 +427,6 @@ static void set_ref_and_pred_mvs(MACROBLOCK *const x, int_mv *const mi_pred_mv,
for (i = 0; i < 1 + has_second_ref(mbmi); ++i) {
int_mv this_mv = (i == 0) ? curr_ref_mv_stack[ref_mv_idx].this_mv
: curr_ref_mv_stack[ref_mv_idx].comp_mv;
clamp_mv_ref(&this_mv.as_mv, bw, bh, xd);
mbmi_ext->ref_mvs[mbmi->ref_frame[i]][0] = this_mv;
mbmi->pred_mv[i] = this_mv;
mi_pred_mv[i] = this_mv;
......
......@@ -10042,15 +10042,11 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
if (compound_ref0_mode(mbmi->mode) == NEWMV) {
int_mv this_mv =
mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0] = this_mv;
}
if (compound_ref1_mode(mbmi->mode) == NEWMV) {
int_mv this_mv =
mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0] = this_mv;
}
}
......@@ -10061,8 +10057,6 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
int_mv this_mv =
(ref == 0) ? mbmi_ext->ref_mv_stack[ref_frame_type][0].this_mv
: mbmi_ext->ref_mv_stack[ref_frame_type][0].comp_mv;
clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
mbmi_ext->ref_mvs[mbmi->ref_frame[ref]][0] = this_mv;
}
}
......@@ -10171,28 +10165,20 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
if (compound_ref0_mode(mbmi->mode) == NEWMV) {
int_mv this_mv =
mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0] = this_mv;
} else if (compound_ref0_mode(mbmi->mode) == NEARESTMV) {
int_mv this_mv =
mbmi_ext->ref_mv_stack[ref_frame_type][0].this_mv;
clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0] = this_mv;
}
if (compound_ref1_mode(mbmi->mode) == NEWMV) {
int_mv this_mv =
mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0] = this_mv;
} else if (compound_ref1_mode(mbmi->mode) == NEARESTMV) {
int_mv this_mv =
mbmi_ext->ref_mv_stack[ref_frame_type][0].comp_mv;
clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0] = this_mv;
}
} else {
......@@ -10200,8 +10186,6 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
->ref_mv_stack[ref_frame_type]
[mbmi->ref_mv_idx + idx_offset]
.this_mv;
clamp_mv_ref(&this_mv.as_mv, xd->n8_w << MI_SIZE_LOG2,
xd->n8_h << MI_SIZE_LOG2, xd);
mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0] = this_mv;
}
......
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