diff options
Diffstat (limited to 'vp9/encoder/vp9_pickmode.c')
-rw-r--r-- | vp9/encoder/vp9_pickmode.c | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index 0a396fff0..c500a0163 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -26,14 +26,13 @@ #include "vp9/encoder/vp9_ratectrl.h" #include "vp9/encoder/vp9_rdopt.h" -static int full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x, +static void full_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 bestsme = INT_MAX; int step_param; int sadpb = x->sadperbit16; MV mvp_full; @@ -46,9 +45,6 @@ static int full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x, int tmp_row_min = x->mv_row_min; int tmp_row_max = x->mv_row_max; - int buf_offset; - int stride = xd->plane[0].pre[0].stride; - const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi, ref); if (scaled_ref_frame) { @@ -77,11 +73,14 @@ static int full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x, for (i = 0; i < MAX_MB_PLANE; i++) xd->plane[i].pre[0] = backup_yv12[i]; } - return INT_MAX; + return; } } - - mvp_full = mbmi->ref_mvs[ref][x->mv_best_ref_index[ref]].as_mv; + assert(x->mv_best_ref_index[ref] <= 2); + if (x->mv_best_ref_index[ref] < 2) + mvp_full = mbmi->ref_mvs[ref][x->mv_best_ref_index[ref]].as_mv; + else + mvp_full = x->pred_mv[ref].as_mv; mvp_full.col >>= 3; mvp_full.row >>= 3; @@ -129,17 +128,6 @@ static int full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x, for (i = 0; i < MAX_MB_PLANE; i++) xd->plane[i].pre[0] = backup_yv12[i]; } - - // TODO(jingning) This step can be merged into full pixel search step in the - // re-designed log-diamond search - buf_offset = tmp_mv->as_mv.row * stride + tmp_mv->as_mv.col; - - // Find sad for current vector. - bestsme = cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf, x->plane[0].src.stride, - xd->plane[0].pre[0].buf + buf_offset, - stride, 0x7fffffff); - - return bestsme; } static void sub_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x, @@ -184,6 +172,8 @@ static void sub_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x, for (i = 0; i < MAX_MB_PLANE; i++) xd->plane[i].pre[0] = backup_yv12[i]; } + + x->pred_mv[ref].as_mv = *tmp_mv; } static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize, @@ -196,7 +186,6 @@ static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize, int rate; int64_t dist; - struct macroblock_plane *const p = &x->plane[0]; struct macroblockd_plane *const pd = &xd->plane[0]; const BLOCK_SIZE bs = get_plane_block_size(bsize, pd); @@ -233,12 +222,22 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, int64_t best_rd = INT64_MAX; int64_t this_rd = INT64_MAX; - const int64_t inter_mode_thresh = 300; - const int64_t intra_mode_cost = 50; - int rate = INT_MAX; int64_t dist = INT64_MAX; + VP9_COMMON *cm = &cpi->common; + int intra_cost_penalty = 20 * vp9_dc_quant(cm->base_qindex, cm->y_dc_delta_q); + + const int64_t inter_mode_thresh = RDCOST(x->rdmult, x->rddiv, + intra_cost_penalty, 0); + const int64_t intra_mode_cost = 50; + + unsigned char segment_id = mbmi->segment_id; + const int *const rd_threshes = cpi->rd_threshes[segment_id][bsize]; + const int *const rd_thresh_freq_fact = cpi->rd_thresh_freq_fact[bsize]; + // Mode index conversion form THR_MODES to MB_PREDICTION_MODE for a ref frame. + int mode_idx[MB_MODE_COUNT] = {0}; + x->skip_encode = cpi->sf.skip_encode_frame && x->q_index < QIDX_SKIP_THRESH; x->skip = 0; @@ -256,7 +255,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, mbmi->interp_filter = cpi->common.interp_filter == SWITCHABLE ? EIGHTTAP : cpi->common.interp_filter; mbmi->skip = 0; - mbmi->segment_id = 0; + mbmi->segment_id = segment_id; xd->interp_kernel = vp9_get_interp_kernel(mbmi->interp_filter); for (ref_frame = LAST_FRAME; ref_frame <= LAST_FRAME ; ++ref_frame) { @@ -282,6 +281,14 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, mbmi->ref_frame[0] = ref_frame; + // Set conversion index for LAST_FRAME. + if (ref_frame == LAST_FRAME) { + mode_idx[NEARESTMV] = THR_NEARESTMV; // LAST_FRAME, NEARESTMV + mode_idx[NEARMV] = THR_NEARMV; // LAST_FRAME, NEARMV + mode_idx[ZEROMV] = THR_ZEROMV; // LAST_FRAME, ZEROMV + mode_idx[NEWMV] = THR_NEWMV; // LAST_FRAME, NEWMV + } + for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) { int rate_mv = 0; @@ -289,13 +296,17 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, (1 << INTER_OFFSET(this_mode))) continue; + if (best_rd < ((int64_t)rd_threshes[mode_idx[this_mode]] * + rd_thresh_freq_fact[this_mode] >> 5) || + rd_threshes[mode_idx[this_mode]] == INT_MAX) + continue; + if (this_mode == NEWMV) { if (this_rd < (int64_t)(1 << num_pels_log2_lookup[bsize])) 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]); + full_pixel_motion_search(cpi, x, tile, bsize, mi_row, mi_col, + &frame_mv[NEWMV][ref_frame]); if (frame_mv[NEWMV][ref_frame].as_int == INVALID_MV) continue; @@ -345,6 +356,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, model_rd_for_sb_y(cpi, bsize, x, xd, &rate, &dist); rate += x->mbmode_cost[this_mode]; + rate += intra_cost_penalty; this_rd = RDCOST(x->rdmult, x->rddiv, rate, dist); if (this_rd + intra_mode_cost < best_rd) { |