diff options
Diffstat (limited to 'vp8/encoder/pickinter.c')
-rw-r--r-- | vp8/encoder/pickinter.c | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/vp8/encoder/pickinter.c b/vp8/encoder/pickinter.c index 0759e2d5b..ea4f01fad 100644 --- a/vp8/encoder/pickinter.c +++ b/vp8/encoder/pickinter.c @@ -50,7 +50,7 @@ extern int vp8_cost_mv_ref(MB_PREDICTION_MODE m, const int near_mv_ref_ct[4]); extern void vp8_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, MV *mv); -int vp8_skip_fractional_mv_step(MACROBLOCK *mb, BLOCK *b, BLOCKD *d, MV *bestmv, MV *ref_mv, int error_per_bit, const vp8_variance_fn_ptr_t *vfp, int *mvcost[2]) +int vp8_skip_fractional_mv_step(MACROBLOCK *mb, BLOCK *b, BLOCKD *d, MV *bestmv, MV *ref_mv, int error_per_bit, const vp8_variance_fn_ptr_t *vfp, int *mvcost[2], int *distortion, unsigned int *sse) { (void) b; (void) d; @@ -58,6 +58,8 @@ int vp8_skip_fractional_mv_step(MACROBLOCK *mb, BLOCK *b, BLOCKD *d, MV *bestmv, (void) error_per_bit; (void) vfp; (void) mvcost; + (void) distortion; + (void) sse; bestmv->row <<= 3; bestmv->col <<= 3; return 0; @@ -192,9 +194,10 @@ static int pick_intra4x4block( int this_rd; rate = mode_costs[mode]; - vp8_predict_intra4x4(b, mode, b->predictor); + RECON_INVOKE(&rtcd->common->recon, intra4x4_predict) + (b, mode, b->predictor); distortion = get_prediction_error(be, b, &rtcd->variance); - this_rd = RD_ESTIMATE(x->rdmult, x->rddiv, rate, distortion); + this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion); if (this_rd < best_rd) { @@ -212,7 +215,13 @@ static int pick_intra4x4block( } -int vp8_pick_intra4x4mby_modes(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb, int *Rate, int *best_dist) +int vp8_pick_intra4x4mby_modes +( + const VP8_ENCODER_RTCD *rtcd, + MACROBLOCK *mb, + int *Rate, + int *best_dist +) { MACROBLOCKD *const xd = &mb->e_mbd; int i; @@ -239,20 +248,18 @@ int vp8_pick_intra4x4mby_modes(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb, int mic->bmi[i].mode = xd->block[i].bmi.mode = best_mode; - // Break out case where we have already exceeded best so far value that was bassed in + // Break out case where we have already exceeded best so far value + // that was passed in if (distortion > *best_dist) break; } - for (i = 0; i < 16; i++) - xd->block[i].bmi.mv.as_int = 0; - *Rate = cost; if (i == 16) { *best_dist = distortion; - error = RD_ESTIMATE(mb->rdmult, mb->rddiv, cost, distortion); + error = RDCOST(mb->rdmult, mb->rddiv, cost, distortion); } else { @@ -260,6 +267,9 @@ int vp8_pick_intra4x4mby_modes(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb, int error = INT_MAX; } + for (i = 0; i < 16; i++) + xd->block[i].bmi.mv.as_int = 0; + return error; } @@ -435,7 +445,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re int bestsme; //int all_rds[MAX_MODES]; // Experimental debug code. int best_mode_index = 0; - int sse = INT_MAX; + unsigned int sse = INT_MAX; MV mvp; int near_sadidx[8] = {0, 1, 2, 3, 4, 5, 6, 7}; @@ -452,6 +462,8 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re int skip_mode[4] = {0, 0, 0, 0}; + int have_subp_search = cpi->sf.half_pixel_search; /* In real-time mode, when Speed >= 15, no sub-pixel search. */ + vpx_memset(mode_mv, 0, sizeof(mode_mv)); vpx_memset(nearest_mv, 0, sizeof(nearest_mv)); vpx_memset(near_mv, 0, sizeof(near_mv)); @@ -632,10 +644,10 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re switch (this_mode) { case B_PRED: - distortion2 = *returndistortion; // Best so far passed in as breakout value to vp8_pick_intra4x4mby_modes - vp8_pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, &rate, &distortion2); - rate2 += rate; - distortion2 = VARIANCE_INVOKE(&cpi->rtcd.variance, get16x16prederror)(x->src.y_buffer, x->src.y_stride, x->e_mbd.predictor, 16, 0x7fffffff); + // Pass best so far to vp8_pick_intra4x4mby_modes to use as breakout + distortion2 = *returndistortion; + vp8_pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, + &rate, &distortion2); if (distortion2 == INT_MAX) { @@ -643,7 +655,12 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re } else { - this_rd = RD_ESTIMATE(x->rdmult, x->rddiv, rate2, distortion2); + rate2 += rate; + distortion2 = VARIANCE_INVOKE + (&cpi->rtcd.variance, get16x16prederror)( + x->src.y_buffer, x->src.y_stride, + x->e_mbd.predictor, 16, 0x7fffffff); + this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2); if (this_rd < best_intra_rd) { @@ -667,7 +684,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re (&x->e_mbd); distortion2 = VARIANCE_INVOKE(&cpi->rtcd.variance, get16x16prederror)(x->src.y_buffer, x->src.y_stride, x->e_mbd.predictor, 16, 0x7fffffff); rate2 += x->mbmode_cost[x->e_mbd.frame_type][x->e_mbd.mode_info_context->mbmi.mode]; - this_rd = RD_ESTIMATE(x->rdmult, x->rddiv, rate2, distortion2); + this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2); if (this_rd < best_intra_rd) { @@ -781,7 +798,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re } if (bestsme < INT_MAX) - cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv.as_mv, &best_ref_mv, x->errorperbit, &cpi->fn_ptr[BLOCK_16X16], cpi->mb.mvcost); + cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv.as_mv, &best_ref_mv, x->errorperbit, &cpi->fn_ptr[BLOCK_16X16], cpi->mb.mvcost, &distortion2, &sse); mode_mv[NEWMV].row = d->bmi.mv.as_mv.row; mode_mv[NEWMV].col = d->bmi.mv.as_mv.col; @@ -811,9 +828,10 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re x->e_mbd.block[0].bmi.mode = this_mode; x->e_mbd.block[0].bmi.mv.as_int = x->e_mbd.mode_info_context->mbmi.mv.as_int; - distortion2 = get_inter_mbpred_error(x, &cpi->fn_ptr[BLOCK_16X16], (unsigned int *)(&sse)); + if((this_mode != NEWMV) || !(have_subp_search)) + distortion2 = get_inter_mbpred_error(x, &cpi->fn_ptr[BLOCK_16X16], &sse); - this_rd = RD_ESTIMATE(x->rdmult, x->rddiv, rate2, distortion2); + this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2); if (cpi->active_map_enabled && x->active_ptr[0] == 0) { @@ -921,7 +939,6 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re best_mbmode.uv_mode = 0; best_mbmode.mb_skip_coeff = (cpi->common.mb_no_coeff_skip) ? 1 : 0; best_mbmode.partitioning = 0; - best_mbmode.dc_diff = 0; vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO)); vpx_memcpy(x->partition_info, &best_partition, sizeof(PARTITION_INFO)); @@ -932,6 +949,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re } x->e_mbd.mode_info_context->mbmi.mv.as_int = 0; + return; } |