Commit 6d009773 authored by Daniel Kang's avatar Daniel Kang
Browse files

Refactor SPLITMV in RD to a special case.

SPLITMV shares very little code with the other inter modes.

Change-Id: I0beee95de1fbedeea1f71650951ffc7db3a118eb
parent b0a46b6b
...@@ -3036,11 +3036,12 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int ...@@ -3036,11 +3036,12 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
break; break;
} }
} }
// Single prediction inter // Split MV. The code is very different from the other inter modes so
else if (!x->e_mbd.mode_info_context->mbmi.second_ref_frame) { // special case it.
switch (this_mode) { else if (this_mode == SPLITMV) {
case SPLITMV: {
int64_t tmp_rd, this_rd_thresh; int64_t tmp_rd, this_rd_thresh;
int is_comp_pred = x->e_mbd.mode_info_context->mbmi.second_ref_frame != 0;
int_mv *second_ref = is_comp_pred ? &second_best_ref_mv : NULL;
this_rd_thresh = this_rd_thresh =
(x->e_mbd.mode_info_context->mbmi.ref_frame == LAST_FRAME) ? (x->e_mbd.mode_info_context->mbmi.ref_frame == LAST_FRAME) ?
...@@ -3049,11 +3050,10 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int ...@@ -3049,11 +3050,10 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
(x->e_mbd.mode_info_context->mbmi.ref_frame == GOLDEN_FRAME) ? (x->e_mbd.mode_info_context->mbmi.ref_frame == GOLDEN_FRAME) ?
cpi->rd_threshes[THR_NEWG] : this_rd_thresh; cpi->rd_threshes[THR_NEWG] : this_rd_thresh;
tmp_rd = vp8_rd_pick_best_mbsegmentation(cpi, x, &best_ref_mv, NULL, tmp_rd = vp8_rd_pick_best_mbsegmentation(cpi, x, &best_ref_mv,
best_yrd, mdcounts, second_ref, best_yrd, mdcounts,
&rate, &rate_y, &distortion, &rate, &rate_y, &distortion,
this_rd_thresh, seg_mvs); this_rd_thresh, seg_mvs);
rate2 += rate; rate2 += rate;
distortion2 += distortion; distortion2 += distortion;
...@@ -3074,12 +3074,19 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int ...@@ -3074,12 +3074,19 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
this_rd = INT64_MAX; this_rd = INT64_MAX;
disable_skip = 1; disable_skip = 1;
} }
if (is_comp_pred)
mode_excluded = cpi->common.comp_pred_mode == SINGLE_PREDICTION_ONLY;
else
mode_excluded = cpi->common.comp_pred_mode == COMP_PREDICTION_ONLY; mode_excluded = cpi->common.comp_pred_mode == COMP_PREDICTION_ONLY;
compmode_cost = compmode_cost =
vp8_cost_bit(get_pred_prob(cm, xd, PRED_COMP), 0); vp8_cost_bit(get_pred_prob(cm, xd, PRED_COMP), is_comp_pred);
x->e_mbd.mode_info_context->mbmi.mode = this_mode;
} }
break; // Single prediction inter
else if (!x->e_mbd.mode_info_context->mbmi.second_ref_frame) {
switch (this_mode) {
case NEWMV: { case NEWMV: {
int thissme, bestsme = INT_MAX; int thissme, bestsme = INT_MAX;
int step_param = cpi->sf.first_step; int step_param = cpi->sf.first_step;
...@@ -3290,37 +3297,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int ...@@ -3290,37 +3297,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
x->e_mbd.mode_info_context->mbmi.mv.as_int = frame_nearest_mv[ref1].as_int; x->e_mbd.mode_info_context->mbmi.mv.as_int = frame_nearest_mv[ref1].as_int;
x->e_mbd.mode_info_context->mbmi.second_mv.as_int = frame_nearest_mv[ref2].as_int; x->e_mbd.mode_info_context->mbmi.second_mv.as_int = frame_nearest_mv[ref2].as_int;
break; break;
case SPLITMV: {
int64_t tmp_rd, this_rd_thresh;
this_rd_thresh =
(x->e_mbd.mode_info_context->mbmi.ref_frame == LAST_FRAME) ?
cpi->rd_threshes[THR_NEWMV] : cpi->rd_threshes[THR_NEWA];
this_rd_thresh =
(x->e_mbd.mode_info_context->mbmi.ref_frame == GOLDEN_FRAME) ?
cpi->rd_threshes[THR_NEWG] : this_rd_thresh;
tmp_rd = vp8_rd_pick_best_mbsegmentation(cpi, x, &best_ref_mv,
&second_best_ref_mv,
best_yrd, mdcounts,
&rate, &rate_y, &distortion,
this_rd_thresh, seg_mvs);
rate2 += rate;
distortion2 += distortion;
// If even the 'Y' rd value of split is higher than best so far then dont bother looking at UV
if (tmp_rd < best_yrd) {
// Now work out UV cost and add it in
rd_inter4x4_uv(cpi, x, &rate_uv, &distortion_uv, cpi->common.full_pixel);
rate2 += rate_uv;
distortion2 += distortion_uv;
} else {
this_rd = INT64_MAX;
disable_skip = 1;
}
}
break;
default: default:
break; break;
} }
...@@ -3331,7 +3307,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int ...@@ -3331,7 +3307,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
compmode_cost = compmode_cost =
vp8_cost_bit(get_pred_prob(cm, xd, PRED_COMP), 1); vp8_cost_bit(get_pred_prob(cm, xd, PRED_COMP), 1);
if (this_mode != SPLITMV) {
/* Add in the Mv/mode cost */ /* Add in the Mv/mode cost */
rate2 += vp8_cost_mv_ref(cpi, this_mode, mdcounts); rate2 += vp8_cost_mv_ref(cpi, this_mode, mdcounts);
...@@ -3352,7 +3327,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int ...@@ -3352,7 +3327,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
inter_mode_cost(cpi, x, this_mode, &rate2, &distortion2, inter_mode_cost(cpi, x, this_mode, &rate2, &distortion2,
&rate_y, &distortion, &rate_uv, &distortion_uv); &rate_y, &distortion, &rate_uv, &distortion_uv);
}
/* don't bother w/ skip, we would never have come here if skip were enabled */ /* don't bother w/ skip, we would never have come here if skip were enabled */
x->e_mbd.mode_info_context->mbmi.mode = this_mode; x->e_mbd.mode_info_context->mbmi.mode = this_mode;
......
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