ref: 587cca4505adeb512d8b331629148134b0e9e8fe
parent: e6058ea06119f86d45eafc5a517b74a865f198fe
author: Yunqing Wang <[email protected]>
date: Fri Mar 14 11:02:48 EDT 2014
Calculate rate_mv after sub-pixel search in non-rd mode Modified the non-rd rate_mv calculation and moved it after sub-pixel motion search is done. Change-Id: I6a5cbd3d67ff0a86b3693e25ecf1fd77b16d708c
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -29,7 +29,7 @@
static int 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, int *rate_mv) {
+ 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}};
@@ -139,13 +139,6 @@
xd->plane[0].pre[0].buf + buf_offset,
stride, 0x7fffffff);
- // scale to 1/8 pixel resolution
- tmp_mv->as_mv.row = tmp_mv->as_mv.row * 8;
- tmp_mv->as_mv.col = tmp_mv->as_mv.col * 8;
-
- // calculate the bit cost on motion vector
- *rate_mv = vp9_mv_bit_cost(&tmp_mv->as_mv, &ref_mv,
- x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
return bestsme;
}
@@ -152,7 +145,7 @@
static void sub_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
const TileInfo *const tile,
BLOCK_SIZE bsize, int mi_row, int mi_col,
- MV *tmp_mv) {
+ MV *tmp_mv, int *rate_mv) {
MACROBLOCKD *xd = &x->e_mbd;
MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi;
struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0}};
@@ -173,9 +166,6 @@
vp9_setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL);
}
- tmp_mv->col >>= 3;
- tmp_mv->row >>= 3;
-
cpi->find_fractional_mv_step(x, tmp_mv, &ref_mv,
cpi->common.allow_high_precision_mv,
x->errorperbit,
@@ -185,6 +175,10 @@
x->nmvjointcost, x->mvcost,
&dis, &x->pred_sse[ref]);
+ // calculate the bit cost on motion vector
+ *rate_mv = vp9_mv_bit_cost(tmp_mv, &ref_mv,
+ x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
+
if (scaled_ref_frame) {
int i;
for (i = 0; i < MAX_MB_PLANE; i++)
@@ -301,13 +295,13 @@
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);
+ &frame_mv[NEWMV][ref_frame]);
if (frame_mv[NEWMV][ref_frame].as_int == INVALID_MV)
continue;
sub_pixel_motion_search(cpi, x, tile, bsize, mi_row, mi_col,
- &frame_mv[NEWMV][ref_frame].as_mv);
+ &frame_mv[NEWMV][ref_frame].as_mv, &rate_mv);
}
if (this_mode != NEARESTMV)