Commit 4d5b81a8 authored by Daniel Kang's avatar Daniel Kang

Refactor RD to take same codepath for single and comp pred

Change-Id: Id38baf1b89648ef534e28be72f583137871f920c
parent bd9e5ece
......@@ -266,7 +266,7 @@ typedef struct {
#endif
MV_REFERENCE_FRAME ref_frame, second_ref_frame;
TX_SIZE txfm_size;
int_mv mv, second_mv;
int_mv mv[2]; // for each reference frame used
#if CONFIG_NEWBESTREFMV
int_mv ref_mv, second_ref_mv;
#endif
......
......@@ -108,7 +108,8 @@ void vp8_print_modes_and_motion_vectors(MODE_INFO *mi, int rows, int cols, int f
for (mb_row = 0; mb_row < rows; mb_row++) {
for (mb_col = 0; mb_col < cols; mb_col++) {
fprintf(mvs, "%5d:%-5d", mi[mb_index].mbmi.mv.as_mv.row / 2, mi[mb_index].mbmi.mv.as_mv.col / 2);
fprintf(mvs, "%5d:%-5d", mi[mb_index].mbmi.mv[0].as_mv.row / 2,
mi[mb_index].mbmi.mv[0].as_mv.col / 2);
mb_index++;
}
......
......@@ -68,9 +68,9 @@ void vp8_find_near_mvs
/* Process above */
if (above->mbmi.ref_frame != INTRA_FRAME) {
if (above->mbmi.mv.as_int) {
if (above->mbmi.mv[0].as_int) {
++ mv;
mv->as_int = above->mbmi.mv.as_int;
mv->as_int = above->mbmi.mv[0].as_int;
mv_bias(ref_frame_sign_bias[above->mbmi.ref_frame],
refframe, mv, ref_frame_sign_bias);
#if CONFIG_NEWBESTREFMV
......@@ -83,9 +83,9 @@ void vp8_find_near_mvs
/* Process left */
if (left->mbmi.ref_frame != INTRA_FRAME) {
if (left->mbmi.mv.as_int) {
if (left->mbmi.mv[0].as_int) {
int_mv this_mv;
this_mv.as_int = left->mbmi.mv.as_int;
this_mv.as_int = left->mbmi.mv[0].as_int;
mv_bias(ref_frame_sign_bias[left->mbmi.ref_frame],
refframe, &this_mv, ref_frame_sign_bias);
#if CONFIG_NEWBESTREFMV
......@@ -103,14 +103,14 @@ void vp8_find_near_mvs
/* Process above left or the one from last frame */
if (aboveleft->mbmi.ref_frame != INTRA_FRAME ||
(lf_here->mbmi.ref_frame == LAST_FRAME && refframe == LAST_FRAME)) {
if (aboveleft->mbmi.mv.as_int) {
if (aboveleft->mbmi.mv[0].as_int) {
third = aboveleft;
#if CONFIG_NEWBESTREFMV
ref_mv[2].as_int = aboveleft->mbmi.mv.as_int;
mv_bias(ref_frame_sign_bias[aboveleft->mbmi.ref_frame],
refframe, (ref_mv+2), ref_frame_sign_bias);
#endif
} else if (lf_here->mbmi.mv.as_int) {
} else if (lf_here->mbmi.mv[0].as_int) {
third = lf_here;
}
#if CONFIG_NEWBESTREFMV
......@@ -122,7 +122,7 @@ void vp8_find_near_mvs
#endif
if (third) {
int_mv this_mv;
this_mv.as_int = third->mbmi.mv.as_int;
this_mv.as_int = third->mbmi.mv[0].as_int;
mv_bias(ref_frame_sign_bias[third->mbmi.ref_frame],
refframe, &this_mv, ref_frame_sign_bias);
......
......@@ -96,7 +96,7 @@ static int left_block_mv(const MODE_INFO *cur_mb, int b) {
--cur_mb;
if (cur_mb->mbmi.mode != SPLITMV)
return cur_mb->mbmi.mv.as_int;
return cur_mb->mbmi.mv[0].as_int;
b += 4;
}
......@@ -109,7 +109,7 @@ static int left_block_second_mv(const MODE_INFO *cur_mb, int b) {
--cur_mb;
if (cur_mb->mbmi.mode != SPLITMV)
return cur_mb->mbmi.second_ref_frame ? cur_mb->mbmi.second_mv.as_int : cur_mb->mbmi.mv.as_int;
return cur_mb->mbmi.second_ref_frame ? cur_mb->mbmi.mv[1].as_int : cur_mb->mbmi.mv[0].as_int;
b += 4;
}
......@@ -122,7 +122,7 @@ static int above_block_mv(const MODE_INFO *cur_mb, int b, int mi_stride) {
cur_mb -= mi_stride;
if (cur_mb->mbmi.mode != SPLITMV)
return cur_mb->mbmi.mv.as_int;
return cur_mb->mbmi.mv[0].as_int;
b += 16;
}
......@@ -135,7 +135,7 @@ static int above_block_second_mv(const MODE_INFO *cur_mb, int b, int mi_stride)
cur_mb -= mi_stride;
if (cur_mb->mbmi.mode != SPLITMV)
return cur_mb->mbmi.second_ref_frame ? cur_mb->mbmi.second_mv.as_int : cur_mb->mbmi.mv.as_int;
return cur_mb->mbmi.second_ref_frame ? cur_mb->mbmi.mv[1].as_int : cur_mb->mbmi.mv[0].as_int;
b += 16;
}
......
......@@ -139,7 +139,7 @@ void segment_via_mode_info(VP8_COMMON *oci, int how) {
n = mi[mb_index].mbmi.mode;
break;
case SEGMENT_MV:
n = mi[mb_index].mbmi.mv.as_int;
n = mi[mb_index].mbmi.mv[0].as_int;
if (mi[mb_index].mbmi.ref_frame == INTRA_FRAME)
n = -9999999;
break;
......@@ -243,7 +243,8 @@ void segment_via_mode_info(VP8_COMMON *oci, int how) {
printf(" ");
for (j = 0; j < oci->mb_cols; j++, mb_index++) {
// printf("%3d",mi[mb_index].mbmi.mode );
printf("%4d:%4d", mi[mb_index].mbmi.mv.as_mv.row, mi[mb_index].mbmi.mv.as_mv.col);
printf("%4d:%4d", mi[mb_index].mbmi.mv[0].as_mv.row,
mi[mb_index].mbmi.mv[0].as_mv.col);
}
printf("\n");
++mb_index;
......
......@@ -611,7 +611,7 @@ void vp8_build_1st_inter16x16_predictors_mby(MACROBLOCKD *xd,
int pre_stride = xd->block[0].pre_stride;
int_mv ymv;
ymv.as_int = xd->mode_info_context->mbmi.mv.as_int;
ymv.as_int = xd->mode_info_context->mbmi.mv[0].as_int;
if (xd->mode_info_context->mbmi.need_to_clamp_mvs)
clamp_mv_to_umv_border(&ymv.as_mv, xd);
......@@ -662,7 +662,7 @@ void vp8_build_1st_inter16x16_predictors_mbuv(MACROBLOCKD *x,
int_mv _o16x16mv;
int_mv _16x16mv;
_16x16mv.as_int = x->mode_info_context->mbmi.mv.as_int;
_16x16mv.as_int = x->mode_info_context->mbmi.mv[0].as_int;
if (x->mode_info_context->mbmi.need_to_clamp_mvs)
clamp_mv_to_umv_border(&_16x16mv.as_mv, x);
......@@ -767,7 +767,7 @@ void vp8_build_2nd_inter16x16_predictors_mby(MACROBLOCKD *x,
unsigned char *ptr_base = x->second_pre.y_buffer;
int pre_stride = x->block[0].pre_stride;
_16x16mv.as_int = x->mode_info_context->mbmi.second_mv.as_int;
_16x16mv.as_int = x->mode_info_context->mbmi.mv[1].as_int;
if (x->mode_info_context->mbmi.need_to_clamp_secondmv)
clamp_mv_to_umv_border(&_16x16mv.as_mv, x);
......@@ -825,7 +825,7 @@ void vp8_build_2nd_inter16x16_predictors_mbuv(MACROBLOCKD *x,
int pre_stride = x->block[0].pre_stride;
_16x16mv.as_int = x->mode_info_context->mbmi.second_mv.as_int;
_16x16mv.as_int = x->mode_info_context->mbmi.mv[1].as_int;
if (x->mode_info_context->mbmi.need_to_clamp_secondmv)
clamp_mv_to_umv_border(&_16x16mv.as_mv, x);
......
......@@ -30,6 +30,13 @@ extern void vp8_build_1st_inter16x16_predictors_mb(MACROBLOCKD *x,
int dst_ystride,
int dst_uvstride);
extern void vp8_build_2nd_inter16x16_predictors_mby(MACROBLOCKD *x,
unsigned char *dst_y,
int dst_ystride);
extern void vp8_build_2nd_inter16x16_predictors_mbuv(MACROBLOCKD *x,
unsigned char *dst_u,
unsigned char *dst_v,
int dst_uvstride);
extern void vp8_build_2nd_inter16x16_predictors_mb(MACROBLOCKD *x,
unsigned char *dst_y,
unsigned char *dst_u,
......
......@@ -867,7 +867,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
}
mv->as_int = mi->bmi[15].as_mv.first.as_int;
mbmi->second_mv.as_int = mi->bmi[15].as_mv.second.as_int;
mbmi->mv[1].as_int = mi->bmi[15].as_mv.second.as_int;
break; /* done with SPLITMV */
......@@ -877,8 +877,8 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
vp8_clamp_mv(mv, mb_to_left_edge, mb_to_right_edge,
mb_to_top_edge, mb_to_bottom_edge);
if (mbmi->second_ref_frame) {
mbmi->second_mv.as_int = nearby_second.as_int;
vp8_clamp_mv(&mbmi->second_mv, mb_to_left_edge, mb_to_right_edge,
mbmi->mv[1].as_int = nearby_second.as_int;
vp8_clamp_mv(&mbmi->mv[1], mb_to_left_edge, mb_to_right_edge,
mb_to_top_edge, mb_to_bottom_edge);
}
break;
......@@ -889,8 +889,8 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
vp8_clamp_mv(mv, mb_to_left_edge, mb_to_right_edge,
mb_to_top_edge, mb_to_bottom_edge);
if (mbmi->second_ref_frame) {
mbmi->second_mv.as_int = nearest_second.as_int;
vp8_clamp_mv(&mbmi->second_mv, mb_to_left_edge, mb_to_right_edge,
mbmi->mv[1].as_int = nearest_second.as_int;
vp8_clamp_mv(&mbmi->mv[1], mb_to_left_edge, mb_to_right_edge,
mb_to_top_edge, mb_to_bottom_edge);
}
break;
......@@ -898,7 +898,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
case ZEROMV:
mv->as_int = 0;
if (mbmi->second_ref_frame)
mbmi->second_mv.as_int = 0;
mbmi->mv[1].as_int = 0;
break;
case NEWMV:
......@@ -926,22 +926,20 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
mb_to_bottom_edge);
if (mbmi->second_ref_frame) {
if (xd->allow_high_precision_mv) {
read_mv_hp(bc, &mbmi->second_mv.as_mv,
(const MV_CONTEXT_HP *) mvc_hp);
cm->fc.MVcount_hp[0][mv_max_hp + (mbmi->second_mv.as_mv.row)]++;
cm->fc.MVcount_hp[1][mv_max_hp + (mbmi->second_mv.as_mv.col)]++;
read_mv_hp(bc, &mbmi->mv[1].as_mv, (const MV_CONTEXT_HP *) mvc_hp);
cm->fc.MVcount_hp[0][mv_max_hp + (mbmi->mv[1].as_mv.row)]++;
cm->fc.MVcount_hp[1][mv_max_hp + (mbmi->mv[1].as_mv.col)]++;
} else {
read_mv(bc, &mbmi->second_mv.as_mv, (const MV_CONTEXT *) mvc);
cm->fc.MVcount[0][mv_max + (mbmi->second_mv.as_mv.row >> 1)]++;
cm->fc.MVcount[1][mv_max + (mbmi->second_mv.as_mv.col >> 1)]++;
read_mv(bc, &mbmi->mv[1].as_mv, (const MV_CONTEXT *) mvc);
cm->fc.MVcount[0][mv_max + (mbmi->mv[1].as_mv.row >> 1)]++;
cm->fc.MVcount[1][mv_max + (mbmi->mv[1].as_mv.col >> 1)]++;
}
mbmi->second_mv.as_mv.row += best_mv_second.as_mv.row;
mbmi->second_mv.as_mv.col += best_mv_second.as_mv.col;
mbmi->need_to_clamp_secondmv |= vp8_check_mv_bounds(&mbmi->second_mv,
mb_to_left_edge,
mb_to_right_edge,
mb_to_top_edge,
mb_to_bottom_edge);
mbmi->mv[1].as_mv.row += best_mv_second.as_mv.row;
mbmi->mv[1].as_mv.col += best_mv_second.as_mv.col;
mbmi->need_to_clamp_secondmv |=
vp8_check_mv_bounds(&mbmi->mv[1],
mb_to_left_edge, mb_to_right_edge,
mb_to_top_edge, mb_to_bottom_edge);
}
break;
default:
......@@ -952,7 +950,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
}
} else {
/* required for left and above block mv */
mbmi->mv.as_int = 0;
mbmi->mv[0].as_int = 0;
if (segfeature_active(xd, mbmi->segment_id, SEG_LVL_MODE))
mbmi->mode = (MB_PREDICTION_MODE)
......
......@@ -1007,20 +1007,16 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
active_section = 5;
#endif
if (xd->allow_high_precision_mv) {
write_mv_hp(w, &mi->mv.as_mv, &best_mv, mvc_hp);
} else {
write_mv(w, &mi->mv.as_mv, &best_mv, mvc);
}
if (xd->allow_high_precision_mv)
write_mv_hp(w, &mi->mv[0].as_mv, &best_mv, mvc_hp);
else
write_mv(w, &mi->mv[0].as_mv, &best_mv, mvc);
if (mi->second_ref_frame) {
if (xd->allow_high_precision_mv) {
write_mv_hp(w, &mi->second_mv.as_mv,
&best_second_mv, mvc_hp);
} else {
write_mv(w, &mi->second_mv.as_mv,
&best_second_mv, mvc);
}
if (xd->allow_high_precision_mv)
write_mv_hp(w, &mi->mv[1].as_mv, &best_second_mv, mvc_hp);
else
write_mv(w, &mi->mv[1].as_mv, &best_second_mv, mvc);
}
break;
case SPLITMV: {
......
......@@ -392,8 +392,8 @@ static void update_state(VP8_COMP *cpi, MACROBLOCK *x, PICK_MODE_CONTEXT *ctx) {
vpx_memcpy(x->partition_info, &ctx->partition_info,
sizeof(PARTITION_INFO));
mbmi->mv.as_int = x->partition_info->bmi[15].mv.as_int;
mbmi->second_mv.as_int = x->partition_info->bmi[15].second_mv.as_int;
mbmi->mv[0].as_int = x->partition_info->bmi[15].mv.as_int;
mbmi->mv[1].as_int = x->partition_info->bmi[15].second_mv.as_int;
}
if (cpi->common.frame_type == KEY_FRAME) {
......
......@@ -3574,7 +3574,7 @@ static void encode_frame_to_data_rate
for (mb_row = 0; mb_row < cm->mb_rows + 1; mb_row ++) {
for (mb_col = 0; mb_col < cm->mb_cols + 1; mb_col ++) {
if (tmp->mbmi.ref_frame != INTRA_FRAME)
cpi->lfmv[mb_col + mb_row * (cm->mode_info_stride + 1)].as_int = tmp->mbmi.mv.as_int;
cpi->lfmv[mb_col + mb_row * (cm->mode_info_stride + 1)].as_int = tmp->mbmi.mv[0].as_int;
cpi->lf_ref_frame_sign_bias[mb_col + mb_row * (cm->mode_info_stride + 1)] = cm->ref_frame_sign_bias[tmp->mbmi.ref_frame];
cpi->lf_ref_frame[mb_col + mb_row * (cm->mode_info_stride + 1)] = tmp->mbmi.ref_frame;
......
This diff is collapsed.
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