Enable sub-pixel motion search for rtc mode
Run sub-pixel motion search when NEWMV gives lower rate-distortion cost. This improves coding performance of derf set by 8%, std-hd by 2.2%. Change-Id: Ife50f7fda8463927784fe59a41cc439c833e941a
This commit is contained in:
Родитель
cc10ee0add
Коммит
6478673933
|
@ -1111,8 +1111,8 @@ static void encode_b_rt(VP9_COMP *cpi, const TileInfo *const tile,
|
|||
}
|
||||
|
||||
static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
TOKENEXTRA **tp, int mi_row, int mi_col,
|
||||
int output_enabled, BLOCK_SIZE bsize) {
|
||||
TOKENEXTRA **tp, int mi_row, int mi_col,
|
||||
int output_enabled, BLOCK_SIZE bsize) {
|
||||
VP9_COMMON *const cm = &cpi->common;
|
||||
MACROBLOCK *const x = &cpi->mb;
|
||||
const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4;
|
||||
|
@ -2254,11 +2254,11 @@ static INLINE int get_block_col(int b32i, int b16i, int b8i) {
|
|||
}
|
||||
|
||||
static void rtc_use_partition(VP9_COMP *cpi,
|
||||
const TileInfo *const tile,
|
||||
MODE_INFO **mi_8x8,
|
||||
TOKENEXTRA **tp, int mi_row, int mi_col,
|
||||
BLOCK_SIZE bsize, int *rate, int64_t *dist,
|
||||
int do_recon) {
|
||||
const TileInfo *const tile,
|
||||
MODE_INFO **mi_8x8,
|
||||
TOKENEXTRA **tp, int mi_row, int mi_col,
|
||||
BLOCK_SIZE bsize, int *rate, int64_t *dist,
|
||||
int do_recon) {
|
||||
VP9_COMMON *const cm = &cpi->common;
|
||||
MACROBLOCK *const x = &cpi->mb;
|
||||
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
|
||||
|
@ -2316,6 +2316,7 @@ static void rtc_use_partition(VP9_COMP *cpi,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
encode_sb_rt(cpi, tile, tp, mi_row, mi_col, 1, BLOCK_64X64);
|
||||
|
||||
*rate = chosen_rate;
|
||||
|
@ -2698,6 +2699,7 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
|
|||
const int mis = cm->mode_info_stride;
|
||||
const int mi_width = num_8x8_blocks_wide_lookup[bsize];
|
||||
const int mi_height = num_8x8_blocks_high_lookup[bsize];
|
||||
|
||||
x->skip_recode = !x->select_txfm_size && mbmi->sb_type >= BLOCK_8X8 &&
|
||||
(cpi->oxcf.aq_mode != COMPLEXITY_AQ) &&
|
||||
!cpi->sf.use_pick_mode;
|
||||
|
|
|
@ -128,11 +128,52 @@ static int full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
|
|||
// calculate the bit cost on motion vector
|
||||
*rate_mv = vp9_mv_bit_cost(&tmp_mv->as_mv, &ref_mv.as_mv,
|
||||
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
|
||||
|
||||
|
||||
return bestsme;
|
||||
}
|
||||
|
||||
static void sub_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
const TileInfo *const tile,
|
||||
BLOCK_SIZE bsize, int mi_row, int mi_col,
|
||||
int_mv *tmp_mv) {
|
||||
MACROBLOCKD *xd = &x->e_mbd;
|
||||
MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi;
|
||||
struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0}};
|
||||
int ref = mbmi->ref_frame[0];
|
||||
int_mv ref_mv = mbmi->ref_mvs[ref][0];
|
||||
int dis;
|
||||
|
||||
const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi,
|
||||
ref);
|
||||
if (scaled_ref_frame) {
|
||||
int i;
|
||||
// Swap out the reference frame for a version that's been scaled to
|
||||
// match the resolution of the current frame, allowing the existing
|
||||
// motion search code to be used without additional modifications.
|
||||
for (i = 0; i < MAX_MB_PLANE; i++)
|
||||
backup_yv12[i] = xd->plane[i].pre[0];
|
||||
|
||||
setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL);
|
||||
}
|
||||
|
||||
tmp_mv->as_mv.col >>= 3;
|
||||
tmp_mv->as_mv.row >>= 3;
|
||||
|
||||
cpi->find_fractional_mv_step(x, &tmp_mv->as_mv, &ref_mv.as_mv,
|
||||
cpi->common.allow_high_precision_mv,
|
||||
x->errorperbit,
|
||||
&cpi->fn_ptr[bsize],
|
||||
cpi->sf.subpel_force_stop,
|
||||
cpi->sf.subpel_iters_per_step,
|
||||
x->nmvjointcost, x->mvcost,
|
||||
&dis, &x->pred_sse[ref]);
|
||||
|
||||
if (scaled_ref_frame) {
|
||||
int i;
|
||||
for (i = 0; i < MAX_MB_PLANE; i++)
|
||||
xd->plane[i].pre[0] = backup_yv12[i];
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(jingning) placeholder for inter-frame non-RD mode decision.
|
||||
// this needs various further optimizations. to be continued..
|
||||
int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
|
@ -162,6 +203,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
|||
|
||||
// initialize mode decisions
|
||||
*returnrate = INT_MAX;
|
||||
*returndistortion = INT64_MAX;
|
||||
vpx_memset(mbmi, 0, sizeof(MB_MODE_INFO));
|
||||
mbmi->sb_type = bsize;
|
||||
mbmi->ref_frame[0] = NONE;
|
||||
|
@ -201,9 +243,6 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
|||
int64_t dist;
|
||||
|
||||
if (this_mode == NEWMV) {
|
||||
if (this_rd < 300)
|
||||
continue;
|
||||
|
||||
x->mode_sad[ref_frame][INTER_OFFSET(NEWMV)] =
|
||||
full_pixel_motion_search(cpi, x, tile, bsize, mi_row, mi_col,
|
||||
&frame_mv[NEWMV][ref_frame], &rate_mv);
|
||||
|
@ -227,6 +266,13 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
|||
}
|
||||
|
||||
// TODO(jingning) sub-pixel motion search, if NEWMV is chosen
|
||||
if (mbmi->mode == NEWMV) {
|
||||
ref_frame = mbmi->ref_frame[0];
|
||||
sub_pixel_motion_search(cpi, x, tile, bsize, mi_row, mi_col,
|
||||
&frame_mv[NEWMV][ref_frame]);
|
||||
mbmi->mv[0].as_int = frame_mv[NEWMV][ref_frame].as_int;
|
||||
xd->mi_8x8[0]->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int;
|
||||
}
|
||||
|
||||
// TODO(jingning) intra prediction search, if the best SAD is above a certain
|
||||
// threshold.
|
||||
|
|
Загрузка…
Ссылка в новой задаче