From f62b33f140a150470d784b6ff37ef1c5c227212b Mon Sep 17 00:00:00 2001 From: Yunqing Wang Date: Fri, 13 May 2011 10:56:45 -0400 Subject: [PATCH] Modify MVcount in pick_inter_mode to eliminate calling of vp8_find_near_mvs Moved MVcount modification in pick_inter_mode, and eliminated calling of vp8_find_near_mvs. Change-Id: Icd47448a1dfc8fdf526f86757d0e5a7f218cb5e8 --- vp8/encoder/encodeframe.c | 25 ------------------------- vp8/encoder/pickinter.c | 12 ++++++++++++ vp8/encoder/rdopt.c | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index c8805a4..c9c52cb 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -1342,14 +1342,8 @@ int vp8cx_encode_inter_macroblock } else { - int_mv best_ref_mv; - int_mv nearest, nearby; - int mdcounts[4]; int ref_fb_idx; - vp8_find_near_mvs(xd, xd->mode_info_context, - &nearest, &nearby, &best_ref_mv, mdcounts, xd->mode_info_context->mbmi.ref_frame, cpi->common.ref_frame_sign_bias); - vp8_build_uvmvs(xd, cpi->common.full_pixel); if (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME) @@ -1363,25 +1357,6 @@ int vp8cx_encode_inter_macroblock xd->pre.u_buffer = cpi->common.yv12_fb[ref_fb_idx].u_buffer + recon_uvoffset; xd->pre.v_buffer = cpi->common.yv12_fb[ref_fb_idx].v_buffer + recon_uvoffset; - if (xd->mode_info_context->mbmi.mode == SPLITMV) - { - int i; - - for (i = 0; i < 16; i++) - { - if (xd->block[i].bmi.mode == NEW4X4) - { - cpi->MVcount[0][mv_max+((xd->block[i].bmi.mv.as_mv.row - best_ref_mv.as_mv.row) >> 1)]++; - cpi->MVcount[1][mv_max+((xd->block[i].bmi.mv.as_mv.col - best_ref_mv.as_mv.col) >> 1)]++; - } - } - } - else if (xd->mode_info_context->mbmi.mode == NEWMV) - { - cpi->MVcount[0][mv_max+((xd->block[0].bmi.mv.as_mv.row - best_ref_mv.as_mv.row) >> 1)]++; - cpi->MVcount[1][mv_max+((xd->block[0].bmi.mv.as_mv.col - best_ref_mv.as_mv.col) >> 1)]++; - } - if (!x->skip) { vp8_encode_inter16x16(IF_RTCD(&cpi->rtcd), x); diff --git a/vp8/encoder/pickinter.c b/vp8/encoder/pickinter.c index 61d6612..94f63ef 100644 --- a/vp8/encoder/pickinter.c +++ b/vp8/encoder/pickinter.c @@ -426,6 +426,16 @@ void vp8_pick_intra_mbuv_mode(MACROBLOCK *mb) } +static void vp8_update_mvcount(VP8_COMP *cpi, MACROBLOCKD *xd, int_mv *best_ref_mv) +{ + /* Split MV modes currently not supported when RD is nopt enabled, therefore, only need to modify MVcount in NEWMV mode. */ + if (xd->mode_info_context->mbmi.mode == NEWMV) + { + cpi->MVcount[0][mv_max+((xd->block[0].bmi.mv.as_mv.row - best_ref_mv->as_mv.row) >> 1)]++; + cpi->MVcount[1][mv_max+((xd->block[0].bmi.mv.as_mv.col - best_ref_mv->as_mv.col) >> 1)]++; + } +} + void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset, int *returnrate, int *returndistortion, int *returnintra) { BLOCK *b = &x->block[0]; @@ -970,4 +980,6 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re } x->e_mbd.mode_info_context->mbmi.mv.as_mv = x->e_mbd.block[15].bmi.mv.as_mv; + + vp8_update_mvcount(cpi, &x->e_mbd, &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame]); } diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index 85d617d..7ce7378 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -1686,6 +1686,28 @@ void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffse } } +static void vp8_rd_update_mvcount(VP8_COMP *cpi, MACROBLOCKD *xd, int_mv *best_ref_mv) +{ + int i; + + if (xd->mode_info_context->mbmi.mode == SPLITMV) + { + for (i = 0; i < 16; i++) + { + if (xd->block[i].bmi.mode == NEW4X4) + { + cpi->MVcount[0][mv_max+((xd->block[i].bmi.mv.as_mv.row - best_ref_mv->as_mv.row) >> 1)]++; + cpi->MVcount[1][mv_max+((xd->block[i].bmi.mv.as_mv.col - best_ref_mv->as_mv.col) >> 1)]++; + } + } + } + else if (xd->mode_info_context->mbmi.mode == NEWMV) + { + cpi->MVcount[0][mv_max+((xd->block[0].bmi.mv.as_mv.row - best_ref_mv->as_mv.row) >> 1)]++; + cpi->MVcount[1][mv_max+((xd->block[0].bmi.mv.as_mv.col - best_ref_mv->as_mv.col) >> 1)]++; + } +} + void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset, int *returnrate, int *returndistortion, int *returnintra) { BLOCK *b = &x->block[0]; @@ -2400,4 +2422,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int } x->e_mbd.mode_info_context->mbmi.mv.as_mv = x->e_mbd.block[15].bmi.mv.as_mv; + + vp8_rd_update_mvcount(cpi, &x->e_mbd, &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame]); } -- 2.7.4