diff options
Diffstat (limited to 'vp8/encoder/rdopt.c')
-rw-r--r-- | vp8/encoder/rdopt.c | 103 |
1 files changed, 87 insertions, 16 deletions
diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index 391254bf2..a2b234ebe 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -37,6 +37,7 @@ #include "vpx_mem/vpx_mem.h" #include "dct.h" #include "vp8/common/systemdependent.h" +#include "vp8/encoder/encodemv.h" #include "vp8/common/seg_common.h" #include "vp8/common/pred_common.h" @@ -58,8 +59,6 @@ extern void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x); extern void vp8_ht_quantize_b(BLOCK *b, BLOCKD *d); #endif -#define XMVCOST (x->e_mbd.allow_high_precision_mv?x->mvcost_hp:x->mvcost) - #define MAXF(a,b) (((a) > (b)) ? (a) : (b)) #define INVALID_MV 0x80008000 @@ -376,6 +375,17 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int QIndex) { cpi->common.kf_ymode_probs_index = cpi->common.base_qindex >> 4; vp8_init_mode_costs(cpi); + if (cpi->common.frame_type != KEY_FRAME) + { +#if CONFIG_NEWMVENTROPY + vp8_build_nmv_cost_table( + cpi->mb.nmvjointcost, + cpi->mb.e_mbd.allow_high_precision_mv ? + cpi->mb.nmvcost_hp : cpi->mb.nmvcost, + &cpi->common.fc.nmvc, + cpi->mb.e_mbd.allow_high_precision_mv, 1, 1); +#endif + } } void vp8_auto_select_speed(VP8_COMP *cpi) { @@ -404,7 +414,9 @@ void vp8_auto_select_speed(VP8_COMP *cpi) { cpi->oxcf.cpu_used = -16; */ - if (cpi->avg_pick_mode_time < milliseconds_for_compress && (cpi->avg_encode_time - cpi->avg_pick_mode_time) < milliseconds_for_compress) { + if (cpi->avg_pick_mode_time < milliseconds_for_compress && + (cpi->avg_encode_time - cpi->avg_pick_mode_time) < + milliseconds_for_compress) { if (cpi->avg_pick_mode_time == 0) { cpi->Speed = 4; } else { @@ -418,7 +430,8 @@ void vp8_auto_select_speed(VP8_COMP *cpi) { } } - if (milliseconds_for_compress * 100 > cpi->avg_encode_time * auto_speed_thresh[cpi->Speed]) { + if (milliseconds_for_compress * 100 > + cpi->avg_encode_time * auto_speed_thresh[cpi->Speed]) { cpi->Speed -= 1; cpi->avg_pick_mode_time = 0; cpi->avg_encode_time = 0; @@ -1883,11 +1896,15 @@ void vp8_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv) { x->e_mbd.mode_info_context->mbmi.mv[0].as_int = mv->as_int; } -static int labels2mode(MACROBLOCK *x, int const *labelings, int which_label, - B_PREDICTION_MODE this_mode, - int_mv *this_mv, int_mv *this_second_mv, - int_mv seg_mvs[MAX_REF_FRAMES - 1], int_mv *best_ref_mv, - int_mv *second_best_ref_mv, int *mvcost[2]) { +static int labels2mode( + MACROBLOCK *x, + int const *labelings, int which_label, + B_PREDICTION_MODE this_mode, + int_mv *this_mv, int_mv *this_second_mv, + int_mv seg_mvs[MAX_REF_FRAMES - 1], + int_mv *best_ref_mv, + int_mv *second_best_ref_mv, + DEC_MVCOSTS) { MACROBLOCKD *const xd = & x->e_mbd; MODE_INFO *const mic = xd->mode_info_context; MB_MODE_INFO * mbmi = &mic->mbmi; @@ -1922,11 +1939,11 @@ static int labels2mode(MACROBLOCK *x, int const *labelings, int which_label, seg_mvs[mbmi->second_ref_frame - 1].as_int; } - thismvcost = vp8_mv_bit_cost(this_mv, best_ref_mv, mvcost, + thismvcost = vp8_mv_bit_cost(this_mv, best_ref_mv, MVCOSTS, 102, xd->allow_high_precision_mv); if (mbmi->second_ref_frame) { thismvcost += vp8_mv_bit_cost(this_second_mv, second_best_ref_mv, - mvcost, 102, + MVCOSTS, 102, xd->allow_high_precision_mv); } break; @@ -2656,8 +2673,10 @@ void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffse void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv, int_mv *second_best_ref_mv) { - MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi; +#if CONFIG_NEWMVENTROPY + MV mv; +#endif if (mbmi->mode == SPLITMV) { int i; @@ -2665,6 +2684,21 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, for (i = 0; i < x->partition_info->count; i++) { if (x->partition_info->bmi[i].mode == NEW4X4) { if (x->e_mbd.allow_high_precision_mv) { +#if CONFIG_NEWMVENTROPY + mv.row = (x->partition_info->bmi[i].mv.as_mv.row + - best_ref_mv->as_mv.row); + mv.col = (x->partition_info->bmi[i].mv.as_mv.col + - best_ref_mv->as_mv.col); + vp8_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 1); + if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) { + mv.row = (x->partition_info->bmi[i].second_mv.as_mv.row + - second_best_ref_mv->as_mv.row); + mv.col = (x->partition_info->bmi[i].second_mv.as_mv.col + - second_best_ref_mv->as_mv.col); + vp8_increment_nmv(&mv, &second_best_ref_mv->as_mv, + &cpi->NMVcount, 1); + } +#else cpi->MVcount_hp[0][mv_max_hp + (x->partition_info->bmi[i].mv.as_mv.row - best_ref_mv->as_mv.row)]++; cpi->MVcount_hp[1][mv_max_hp + (x->partition_info->bmi[i].mv.as_mv.col @@ -2675,8 +2709,23 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, cpi->MVcount_hp[1][mv_max_hp + (x->partition_info->bmi[i].second_mv.as_mv.col - second_best_ref_mv->as_mv.col)]++; } - } else - { +#endif + } else { +#if CONFIG_NEWMVENTROPY + mv.row = (x->partition_info->bmi[i].mv.as_mv.row + - best_ref_mv->as_mv.row); + mv.col = (x->partition_info->bmi[i].mv.as_mv.col + - best_ref_mv->as_mv.col); + vp8_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 0); + if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) { + mv.row = (x->partition_info->bmi[i].second_mv.as_mv.row + - second_best_ref_mv->as_mv.row); + mv.col = (x->partition_info->bmi[i].second_mv.as_mv.col + - second_best_ref_mv->as_mv.col); + vp8_increment_nmv(&mv, &second_best_ref_mv->as_mv, + &cpi->NMVcount, 0); + } +#else cpi->MVcount[0][mv_max + ((x->partition_info->bmi[i].mv.as_mv.row - best_ref_mv->as_mv.row) >> 1)]++; cpi->MVcount[1][mv_max + ((x->partition_info->bmi[i].mv.as_mv.col @@ -2687,11 +2736,22 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, cpi->MVcount[1][mv_max + ((x->partition_info->bmi[i].second_mv.as_mv.col - second_best_ref_mv->as_mv.col) >> 1)]++; } +#endif } } } } else if (mbmi->mode == NEWMV) { if (x->e_mbd.allow_high_precision_mv) { +#if CONFIG_NEWMVENTROPY + mv.row = (mbmi->mv[0].as_mv.row - best_ref_mv->as_mv.row); + mv.col = (mbmi->mv[0].as_mv.col - best_ref_mv->as_mv.col); + vp8_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 1); + if (mbmi->second_ref_frame) { + mv.row = (mbmi->mv[1].as_mv.row - second_best_ref_mv->as_mv.row); + mv.col = (mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col); + vp8_increment_nmv(&mv, &second_best_ref_mv->as_mv, &cpi->NMVcount, 1); + } +#else cpi->MVcount_hp[0][mv_max_hp + (mbmi->mv[0].as_mv.row - best_ref_mv->as_mv.row)]++; cpi->MVcount_hp[1][mv_max_hp + (mbmi->mv[0].as_mv.col @@ -2702,8 +2762,18 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, cpi->MVcount_hp[1][mv_max_hp + (mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col)]++; } - } else - { +#endif + } else { +#if CONFIG_NEWMVENTROPY + mv.row = (mbmi->mv[0].as_mv.row - best_ref_mv->as_mv.row); + mv.col = (mbmi->mv[0].as_mv.col - best_ref_mv->as_mv.col); + vp8_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount, 0); + if (mbmi->second_ref_frame) { + mv.row = (mbmi->mv[1].as_mv.row - second_best_ref_mv->as_mv.row); + mv.col = (mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col); + vp8_increment_nmv(&mv, &second_best_ref_mv->as_mv, &cpi->NMVcount, 0); + } +#else cpi->MVcount[0][mv_max + ((mbmi->mv[0].as_mv.row - best_ref_mv->as_mv.row) >> 1)]++; cpi->MVcount[1][mv_max + ((mbmi->mv[0].as_mv.col @@ -2714,6 +2784,7 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, cpi->MVcount[1][mv_max + ((mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col) >> 1)]++; } +#endif } } } |