Merge "Refactor rd loop for inter modes" into experimental

This commit is contained in:
Jingning Han
2013-05-29 10:55:23 -07:00
committed by Gerrit Code Review

View File

@@ -938,7 +938,7 @@ void vp9_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv) {
}
static int labels2mode(MACROBLOCK *x,
int const *labelings, int which_label,
int const *labelings, int i,
MB_PREDICTION_MODE this_mode,
int_mv *this_mv, int_mv *this_second_mv,
int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES],
@@ -949,7 +949,7 @@ static int labels2mode(MACROBLOCK *x,
MACROBLOCKD *const xd = &x->e_mbd;
MODE_INFO *const mic = xd->mode_info_context;
MB_MODE_INFO * mbmi = &mic->mbmi;
int i, cost = 0, thismvcost = 0;
int cost = 0, thismvcost = 0;
int idx, idy;
int bw = 1 << b_width_log2(mbmi->sb_type);
int bh = 1 << b_height_log2(mbmi->sb_type);
@@ -957,13 +957,8 @@ static int labels2mode(MACROBLOCK *x,
/* We have to be careful retrieving previously-encoded motion vectors.
Ones from this macroblock have to be pulled from the BLOCKD array
as they have not yet made it to the bmi array in our MB_MODE_INFO. */
for (i = 0; i < 4; ++i) {
MB_PREDICTION_MODE m;
if (labelings[i] != which_label)
continue;
{
// the only time we should do costing for new motion vector or mode
// is when we are on a new label (jbb May 08, 2007)
switch (m = this_mode) {
@@ -1005,7 +1000,6 @@ static int labels2mode(MACROBLOCK *x,
cost = vp9_cost_mv_ref(cpi, this_mode,
mbmi->mb_mode_context[mbmi->ref_frame]);
}
mic->bmi[i].as_mv[0].as_int = this_mv->as_int;
if (mbmi->second_ref_frame > 0)
@@ -1024,7 +1018,6 @@ static int labels2mode(MACROBLOCK *x,
sizeof(x->partition_info->bmi[i]));
}
}
}
cost += thismvcost;
return cost;
@@ -1881,50 +1874,19 @@ static INLINE int get_switchable_rate(VP9_COMMON *cm, MACROBLOCK *x) {
return SWITCHABLE_INTERP_RATE_FACTOR * x->switchable_interp_costs[c][m];
}
static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
static void iterative_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE_TYPE bsize,
int64_t txfm_cache[],
int *rate2, int *distortion, int *skippable,
int *compmode_cost,
int *rate_y, int *distortion_y,
int *rate_uv, int *distortion_uv,
int *mode_excluded, int *disable_skip,
INTERPOLATIONFILTERTYPE *best_filter,
int_mv *frame_mv,
YV12_BUFFER_CONFIG **scaled_ref_frame,
int mi_row, int mi_col,
int_mv single_newmv[MAX_REF_FRAMES]) {
const int bw = 1 << mi_width_log2(bsize), bh = 1 << mi_height_log2(bsize);
VP9_COMMON *cm = &cpi->common;
int pw = 4 << b_width_log2(bsize), ph = 4 << b_height_log2(bsize);
MACROBLOCKD *xd = &x->e_mbd;
const enum BlockSize block_size = get_plane_block_size(bsize, &xd->plane[0]);
const enum BlockSize uv_block_size = get_plane_block_size(bsize,
&xd->plane[1]);
MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
const int is_comp_pred = (mbmi->second_ref_frame > 0);
const int num_refs = is_comp_pred ? 2 : 1;
const int this_mode = mbmi->mode;
int i;
int refs[2] = { mbmi->ref_frame,
(mbmi->second_ref_frame < 0 ? 0 : mbmi->second_ref_frame) };
int_mv cur_mv[2];
int_mv ref_mv[2];
int64_t this_rd = 0;
unsigned char tmp_buf[MAX_MB_PLANE][64 * 64];
int pred_exists = 0;
int interpolating_intpel_seen = 0;
int intpel_mv;
int64_t rd, best_rd = INT64_MAX;
switch (this_mode) {
case NEWMV:
ref_mv[0] = mbmi->ref_mvs[refs[0]][0];
ref_mv[1] = mbmi->ref_mvs[refs[1]][0];
if (is_comp_pred) {
if (cpi->sf.comp_inter_joint_serach) {
int pw = 4 << b_width_log2(bsize), ph = 4 << b_height_log2(bsize);
const enum BlockSize block_size = get_plane_block_size(bsize, &xd->plane[0]);
int ite;
// Prediction buffer from second frame.
uint8_t *second_pred = vpx_memalign(16, pw * ph * sizeof(uint8_t));
@@ -1935,6 +1897,9 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
struct buf_2d scaled_first_yv12;
int last_besterr[2] = {INT_MAX, INT_MAX};
ref_mv[0] = mbmi->ref_mvs[refs[0]][0];
ref_mv[1] = mbmi->ref_mvs[refs[1]][0];
if (scaled_ref_frame[0]) {
int i;
@@ -2063,6 +2028,52 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
vpx_free(second_pred);
}
static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE_TYPE bsize,
int64_t txfm_cache[],
int *rate2, int *distortion, int *skippable,
int *compmode_cost,
int *rate_y, int *distortion_y,
int *rate_uv, int *distortion_uv,
int *mode_excluded, int *disable_skip,
INTERPOLATIONFILTERTYPE *best_filter,
int_mv *frame_mv,
YV12_BUFFER_CONFIG **scaled_ref_frame,
int mi_row, int mi_col,
int_mv single_newmv[MAX_REF_FRAMES]) {
const int bw = 1 << mi_width_log2(bsize), bh = 1 << mi_height_log2(bsize);
VP9_COMMON *cm = &cpi->common;
MACROBLOCKD *xd = &x->e_mbd;
const enum BlockSize block_size = get_plane_block_size(bsize, &xd->plane[0]);
const enum BlockSize uv_block_size = get_plane_block_size(bsize,
&xd->plane[1]);
MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
const int is_comp_pred = (mbmi->second_ref_frame > 0);
const int num_refs = is_comp_pred ? 2 : 1;
const int this_mode = mbmi->mode;
int i;
int refs[2] = { mbmi->ref_frame,
(mbmi->second_ref_frame < 0 ? 0 : mbmi->second_ref_frame) };
int_mv cur_mv[2];
int_mv ref_mv[2];
int64_t this_rd = 0;
unsigned char tmp_buf[MAX_MB_PLANE][64 * 64];
int pred_exists = 0;
int interpolating_intpel_seen = 0;
int intpel_mv;
int64_t rd, best_rd = INT64_MAX;
switch (this_mode) {
case NEWMV:
ref_mv[0] = mbmi->ref_mvs[refs[0]][0];
ref_mv[1] = mbmi->ref_mvs[refs[1]][0];
if (is_comp_pred) {
if (cpi->sf.comp_inter_joint_serach)
iterative_motion_search(cpi, x, bsize, frame_mv, scaled_ref_frame,
mi_row, mi_col, single_newmv);
if (frame_mv[refs[0]].as_int == INVALID_MV ||
frame_mv[refs[1]].as_int == INVALID_MV)
return INT64_MAX;