Merge "Combined non-rd motion searchs into a single function"
This commit is contained in:
Коммит
0e99f3a387
|
@ -106,24 +106,25 @@ static int mv_refs_rt(const VP9_COMMON *cm, const MACROBLOCKD *xd,
|
||||||
return const_motion;
|
return const_motion;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
|
static int combined_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
|
||||||
BLOCK_SIZE bsize, int mi_row, int mi_col,
|
BLOCK_SIZE bsize, int mi_row, int mi_col,
|
||||||
int_mv *tmp_mv, int *rate_mv) {
|
int_mv *tmp_mv, int *rate_mv,
|
||||||
|
int64_t best_rd_sofar) {
|
||||||
MACROBLOCKD *xd = &x->e_mbd;
|
MACROBLOCKD *xd = &x->e_mbd;
|
||||||
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
|
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
|
||||||
struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}};
|
struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}};
|
||||||
int step_param;
|
const int step_param = cpi->sf.mv.fullpel_search_step_param;
|
||||||
int sadpb = x->sadperbit16;
|
const int sadpb = x->sadperbit16;
|
||||||
MV mvp_full;
|
MV mvp_full;
|
||||||
int ref = mbmi->ref_frame[0];
|
const int ref = mbmi->ref_frame[0];
|
||||||
const MV ref_mv = mbmi->ref_mvs[ref][0].as_mv;
|
const MV ref_mv = mbmi->ref_mvs[ref][0].as_mv;
|
||||||
int i;
|
int dis;
|
||||||
|
int rate_mode;
|
||||||
int tmp_col_min = x->mv_col_min;
|
const int tmp_col_min = x->mv_col_min;
|
||||||
int tmp_col_max = x->mv_col_max;
|
const int tmp_col_max = x->mv_col_max;
|
||||||
int tmp_row_min = x->mv_row_min;
|
const int tmp_row_min = x->mv_row_min;
|
||||||
int tmp_row_max = x->mv_row_max;
|
const int tmp_row_max = x->mv_row_max;
|
||||||
|
int rv = 0;
|
||||||
const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi,
|
const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi,
|
||||||
ref);
|
ref);
|
||||||
if (scaled_ref_frame) {
|
if (scaled_ref_frame) {
|
||||||
|
@ -133,27 +134,19 @@ static void full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
|
||||||
// motion search code to be used without additional modifications.
|
// motion search code to be used without additional modifications.
|
||||||
for (i = 0; i < MAX_MB_PLANE; i++)
|
for (i = 0; i < MAX_MB_PLANE; i++)
|
||||||
backup_yv12[i] = xd->plane[i].pre[0];
|
backup_yv12[i] = xd->plane[i].pre[0];
|
||||||
|
|
||||||
vp9_setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL);
|
vp9_setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
vp9_set_mv_search_range(x, &ref_mv);
|
vp9_set_mv_search_range(x, &ref_mv);
|
||||||
|
|
||||||
// TODO(jingning) exploiting adaptive motion search control in non-RD
|
if (cpi->common.show_frame &&
|
||||||
// mode decision too.
|
(x->pred_mv_sad[ref] >> 3) > x->pred_mv_sad[LAST_FRAME]) {
|
||||||
step_param = cpi->sf.mv.fullpel_search_step_param;
|
tmp_mv->as_int = INVALID_MV;
|
||||||
|
if (scaled_ref_frame) {
|
||||||
for (i = LAST_FRAME; i <= LAST_FRAME && cpi->common.show_frame; ++i) {
|
int i;
|
||||||
if ((x->pred_mv_sad[ref] >> 3) > x->pred_mv_sad[i]) {
|
for (i = 0; i < MAX_MB_PLANE; i++)
|
||||||
tmp_mv->as_int = INVALID_MV;
|
xd->plane[i].pre[0] = backup_yv12[i];
|
||||||
|
|
||||||
if (scaled_ref_frame) {
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < MAX_MB_PLANE; i++)
|
|
||||||
xd->plane[i].pre[0] = backup_yv12[i];
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
assert(x->mv_best_ref_index[ref] <= 2);
|
assert(x->mv_best_ref_index[ref] <= 2);
|
||||||
if (x->mv_best_ref_index[ref] < 2)
|
if (x->mv_best_ref_index[ref] < 2)
|
||||||
|
@ -172,60 +165,39 @@ static void full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
|
||||||
x->mv_row_min = tmp_row_min;
|
x->mv_row_min = tmp_row_min;
|
||||||
x->mv_row_max = tmp_row_max;
|
x->mv_row_max = tmp_row_max;
|
||||||
|
|
||||||
if (scaled_ref_frame) {
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < MAX_MB_PLANE; i++)
|
|
||||||
xd->plane[i].pre[0] = backup_yv12[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate the bit cost on motion vector
|
// calculate the bit cost on motion vector
|
||||||
mvp_full.row = tmp_mv->as_mv.row * 8;
|
mvp_full.row = tmp_mv->as_mv.row * 8;
|
||||||
mvp_full.col = tmp_mv->as_mv.col * 8;
|
mvp_full.col = tmp_mv->as_mv.col * 8;
|
||||||
|
|
||||||
*rate_mv = vp9_mv_bit_cost(&mvp_full, &ref_mv,
|
*rate_mv = vp9_mv_bit_cost(&mvp_full, &ref_mv,
|
||||||
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
|
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
|
||||||
}
|
|
||||||
|
|
||||||
static void sub_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
|
rate_mode = cpi->inter_mode_cost[mbmi->mode_context[ref]]
|
||||||
BLOCK_SIZE bsize, int mi_row, int mi_col,
|
[INTER_OFFSET(NEWMV)];
|
||||||
MV *tmp_mv) {
|
rv = !(RDCOST(x->rdmult, x->rddiv, (*rate_mv + rate_mode), 0) >
|
||||||
MACROBLOCKD *xd = &x->e_mbd;
|
best_rd_sofar);
|
||||||
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
|
|
||||||
struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}};
|
|
||||||
int ref = mbmi->ref_frame[0];
|
|
||||||
MV ref_mv = mbmi->ref_mvs[ref][0].as_mv;
|
|
||||||
int dis;
|
|
||||||
|
|
||||||
const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi,
|
if (rv) {
|
||||||
ref);
|
cpi->find_fractional_mv_step(x, &tmp_mv->as_mv, &ref_mv,
|
||||||
if (scaled_ref_frame) {
|
cpi->common.allow_high_precision_mv,
|
||||||
int i;
|
x->errorperbit,
|
||||||
// Swap out the reference frame for a version that's been scaled to
|
&cpi->fn_ptr[bsize],
|
||||||
// match the resolution of the current frame, allowing the existing
|
cpi->sf.mv.subpel_force_stop,
|
||||||
// motion search code to be used without additional modifications.
|
cpi->sf.mv.subpel_iters_per_step,
|
||||||
for (i = 0; i < MAX_MB_PLANE; i++)
|
x->nmvjointcost, x->mvcost,
|
||||||
backup_yv12[i] = xd->plane[i].pre[0];
|
&dis, &x->pred_sse[ref]);
|
||||||
|
x->pred_mv[ref] = tmp_mv->as_mv;
|
||||||
vp9_setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cpi->find_fractional_mv_step(x, tmp_mv, &ref_mv,
|
|
||||||
cpi->common.allow_high_precision_mv,
|
|
||||||
x->errorperbit,
|
|
||||||
&cpi->fn_ptr[bsize],
|
|
||||||
cpi->sf.mv.subpel_force_stop,
|
|
||||||
cpi->sf.mv.subpel_iters_per_step,
|
|
||||||
x->nmvjointcost, x->mvcost,
|
|
||||||
&dis, &x->pred_sse[ref]);
|
|
||||||
|
|
||||||
if (scaled_ref_frame) {
|
if (scaled_ref_frame) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < MAX_MB_PLANE; i++)
|
for (i = 0; i < MAX_MB_PLANE; i++)
|
||||||
xd->plane[i].pre[0] = backup_yv12[i];
|
xd->plane[i].pre[0] = backup_yv12[i];
|
||||||
}
|
}
|
||||||
|
return rv;
|
||||||
x->pred_mv[ref] = *tmp_mv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize,
|
static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize,
|
||||||
MACROBLOCK *x, MACROBLOCKD *xd,
|
MACROBLOCK *x, MACROBLOCKD *xd,
|
||||||
int *out_rate_sum, int64_t *out_dist_sum,
|
int *out_rate_sum, int64_t *out_dist_sum,
|
||||||
|
@ -544,28 +516,17 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (this_mode == NEWMV) {
|
if (this_mode == NEWMV) {
|
||||||
int rate_mode = 0;
|
|
||||||
if (this_rd < (int64_t)(1 << num_pels_log2_lookup[bsize]))
|
if (this_rd < (int64_t)(1 << num_pels_log2_lookup[bsize]))
|
||||||
continue;
|
continue;
|
||||||
|
if (!combined_motion_search(cpi, x, bsize, mi_row, mi_col,
|
||||||
full_pixel_motion_search(cpi, x, bsize, mi_row, mi_col,
|
&frame_mv[NEWMV][ref_frame],
|
||||||
&frame_mv[NEWMV][ref_frame], &rate_mv);
|
&rate_mv, best_rd))
|
||||||
|
|
||||||
if (frame_mv[NEWMV][ref_frame].as_int == INVALID_MV)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rate_mode = cpi->inter_mode_cost[mbmi->mode_context[ref_frame]]
|
|
||||||
[INTER_OFFSET(this_mode)];
|
|
||||||
if (RDCOST(x->rdmult, x->rddiv, rate_mv + rate_mode, 0) > best_rd)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sub_pixel_motion_search(cpi, x, bsize, mi_row, mi_col,
|
|
||||||
&frame_mv[NEWMV][ref_frame].as_mv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this_mode != NEARESTMV)
|
if (this_mode != NEARESTMV &&
|
||||||
if (frame_mv[this_mode][ref_frame].as_int ==
|
frame_mv[this_mode][ref_frame].as_int ==
|
||||||
frame_mv[NEARESTMV][ref_frame].as_int)
|
frame_mv[NEARESTMV][ref_frame].as_int)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mbmi->mode = this_mode;
|
mbmi->mode = this_mode;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче