MV reference changes

Extend experiment to use both vectors from MBs
coded using compound prediction as candidates.

In final sort only consider best 4 candidates
for now but make sure 0,0 is always one of them.

Other minor changes to new MV reference code.
Pass in Mv list to vp8_find_best_ref_mvs().

Change-Id: Ib96220c33c6b80bd1d5e0fbe8b68121be7997095
This commit is contained in:
Paul Wilkins 2012-09-07 12:46:41 +01:00
parent 00f9eb6590
commit 38e1c79185
9 changed files with 217 additions and 117 deletions

View File

@ -45,7 +45,7 @@ void vpx_log(const char *format, ...);
#define SEGMENT_DELTADATA 0
#define SEGMENT_ABSDATA 1
#if CONFIG_NEW_MVREF
#define MAX_MV_REFS 10
#define MAX_MV_REFS 19
#endif
typedef struct {

View File

@ -206,10 +206,10 @@ vp8_prob *vp8_mv_ref_probs(VP8_COMMON *pc,
void vp8_find_best_ref_mvs(MACROBLOCKD *xd,
unsigned char *ref_y_buffer,
int ref_y_stride,
int_mv *mvlist,
int_mv *best_mv,
int_mv *nearest,
int_mv *near) {
int_mv *ref_mv = xd->ref_mv;
int i, j;
unsigned char *above_src;
unsigned char *left_src;
@ -229,12 +229,14 @@ void vp8_find_best_ref_mvs(MACROBLOCKD *xd,
above_ref = ref_y_buffer - ref_y_stride * 2;
left_ref = ref_y_buffer - 2;
for(i = 0; i < MAX_MV_REFS; ++i) {
//for(i = 0; i < MAX_MV_REFS; ++i) {
// Limit search to the predicted best 4
for(i = 0; i < 4; ++i) {
int_mv this_mv;
int offset=0;
int row_offset, col_offset;
this_mv.as_int = ref_mv[i].as_int;
this_mv.as_int = mvlist[i].as_int;
// If we see a 0,0 vector for a second time we have reached the end of
// the list of valid candidate vectors.
@ -278,32 +280,6 @@ void vp8_find_best_ref_mvs(MACROBLOCKD *xd,
}
}
// If not see add 0,0 as a possibility
/*if ( (i < MAX_MV_REFS) && !zero_seen ) {
sad = vp8_sad16x2_c(above_src, xd->dst.y_stride,
above_ref, ref_y_stride,
INT_MAX);
sad += vp8_sad2x16_c(left_src, xd->dst.y_stride,
left_ref, ref_y_stride,
INT_MAX);
this_mv.as_int = 0;
// Add the entry to our list and then resort the list on score.
sad_scores[i] = sad;
sorted_mvs[i].as_int = this_mv.as_int;
j = i;
while (j > 0) {
if (sad_scores[j] < sad_scores[j-1]) {
sad_scores[j] = sad_scores[j-1];
sorted_mvs[j].as_int = sorted_mvs[j-1].as_int;
sad_scores[j-1] = sad;
sorted_mvs[j-1].as_int = this_mv.as_int;
j--;
} else
break;
}
}*/
// Set the best mv to the first entry in the sorted list
best_mv->as_int = sorted_mvs[0].as_int;
@ -325,6 +301,9 @@ void vp8_find_best_ref_mvs(MACROBLOCKD *xd,
near->as_int = sorted_mvs[2].as_int;
}
// Copy back the re-ordered mv list
vpx_memcpy(mvlist, sorted_mvs, sizeof(sorted_mvs));
if (!xd->allow_high_precision_mv)
lower_mv_precision(best_mv);
@ -336,10 +315,10 @@ void vp8_find_best_ref_mvs(MACROBLOCKD *xd,
void vp8_find_best_ref_mvs(MACROBLOCKD *xd,
unsigned char *ref_y_buffer,
int ref_y_stride,
int_mv *mvlist,
int_mv *best_mv,
int_mv *nearest,
int_mv *near) {
int_mv *ref_mv = xd->ref_mv;
int bestsad = INT_MAX;
int i;
unsigned char *above_src;
@ -362,11 +341,11 @@ void vp8_find_best_ref_mvs(MACROBLOCKD *xd,
best_mv->as_int = 0;
for(i = 0; i < 4; ++i) {
if (ref_mv[i].as_int) {
if (mvlist[i].as_int) {
int_mv this_mv;
int offset=0;
int row_offset, col_offset;
this_mv.as_int = ref_mv[i].as_int;
this_mv.as_int = mvlist[i].as_int;
vp8_clamp_mv(&this_mv,
xd->mb_to_left_edge - LEFT_TOP_MARGIN + 16,
xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN,

View File

@ -26,6 +26,7 @@
void vp8_find_best_ref_mvs(MACROBLOCKD *xd,
unsigned char *ref_y_buffer,
int ref_y_stride,
int_mv *mvlist,
int_mv *best_mv,
int_mv *nearest,
int_mv *near);

View File

@ -47,30 +47,63 @@ unsigned int mv_distance(int_mv *mv1, int_mv *mv2) {
int get_candidate_mvref(
const MODE_INFO *candidate_mi,
MV_REFERENCE_FRAME ref_frame,
MV_REFERENCE_FRAME *candidate_ref_frame,
int_mv *candidate_mv
MV_REFERENCE_FRAME *c_ref_frame,
int_mv *c_mv,
MV_REFERENCE_FRAME *c2_ref_frame,
int_mv *c2_mv
) {
int ret_val = FALSE;
c2_mv->as_int = 0;
*c2_ref_frame = INTRA_FRAME;
// Target ref frame matches candidate first ref frame
if (ref_frame == candidate_mi->mbmi.ref_frame) {
candidate_mv->as_int = candidate_mi->mbmi.mv[FIRST_REF].as_int;
*candidate_ref_frame = ref_frame;
c_mv->as_int = candidate_mi->mbmi.mv[FIRST_REF].as_int;
*c_ref_frame = ref_frame;
ret_val = TRUE;
// Is there a second non zero vector we can use.
if ((candidate_mi->mbmi.second_ref_frame != INTRA_FRAME) &&
(candidate_mi->mbmi.mv[SECOND_REF].as_int != 0) &&
(candidate_mi->mbmi.mv[SECOND_REF].as_int != c_mv->as_int)) {
c2_mv->as_int = candidate_mi->mbmi.mv[SECOND_REF].as_int;
*c2_ref_frame = candidate_mi->mbmi.second_ref_frame;
}
// Target ref frame matches candidate second ref frame
} else if (ref_frame == candidate_mi->mbmi.second_ref_frame) {
candidate_mv->as_int = candidate_mi->mbmi.mv[SECOND_REF].as_int;
*candidate_ref_frame = ref_frame;
c_mv->as_int = candidate_mi->mbmi.mv[SECOND_REF].as_int;
*c_ref_frame = ref_frame;
ret_val = TRUE;
// Is there a second non zero vector we can use.
if ((candidate_mi->mbmi.ref_frame != INTRA_FRAME) &&
(candidate_mi->mbmi.mv[FIRST_REF].as_int != 0) &&
(candidate_mi->mbmi.mv[FIRST_REF].as_int != c_mv->as_int)) {
c2_mv->as_int = candidate_mi->mbmi.mv[FIRST_REF].as_int;
*c2_ref_frame = candidate_mi->mbmi.ref_frame;
}
// No ref frame matches so use first ref mv as first choice
} else if (candidate_mi->mbmi.ref_frame != INTRA_FRAME) {
candidate_mv->as_int = candidate_mi->mbmi.mv[FIRST_REF].as_int;
*candidate_ref_frame = candidate_mi->mbmi.ref_frame;
c_mv->as_int = candidate_mi->mbmi.mv[FIRST_REF].as_int;
*c_ref_frame = candidate_mi->mbmi.ref_frame;
ret_val = TRUE;
// Is there a second non zero vector we can use.
if ((candidate_mi->mbmi.second_ref_frame != INTRA_FRAME) &&
(candidate_mi->mbmi.mv[SECOND_REF].as_int != 0) &&
(candidate_mi->mbmi.mv[SECOND_REF].as_int != c_mv->as_int)) {
c2_mv->as_int = candidate_mi->mbmi.mv[SECOND_REF].as_int;
*c2_ref_frame = candidate_mi->mbmi.second_ref_frame;
}
// If only the second ref mv is valid:- (Should not trigger in current code
// base given current possible compound prediction options).
} else if (candidate_mi->mbmi.second_ref_frame != INTRA_FRAME) {
candidate_mv->as_int = candidate_mi->mbmi.mv[SECOND_REF].as_int;
*candidate_ref_frame = candidate_mi->mbmi.second_ref_frame;
c_mv->as_int = candidate_mi->mbmi.mv[SECOND_REF].as_int;
*c_ref_frame = candidate_mi->mbmi.second_ref_frame;
ret_val = TRUE;
}
@ -142,8 +175,10 @@ void addmv_and_shuffle(
int duplicate_found = FALSE;
// Check for duplicates. If there is one increment its score.
// Duplicate defined as being the same full pel vector with rounding.
while (i > 0) {
i--;
if (candidate_mv.as_int == mv_list[i].as_int) {
duplicate_found = TRUE;
mv_scores[i] += weight;
@ -175,33 +210,6 @@ void addmv_and_shuffle(
}
}
// Measure the distance of each reference candidate from the actual
// residual vector and return the nearest
unsigned int pick_best_mv_ref( int_mv target_mv,
int_mv * mv_ref_list,
int_mv * best_ref ) {
int i;
int best_index = 0;
unsigned int distance, distance2;
distance = mv_distance(&target_mv, &mv_ref_list[0]);
for (i = 1; i < MAX_MV_REFS; ++i ) {
distance2 =
mv_distance(&target_mv, &mv_ref_list[i]);
if (distance2 < distance) {
distance = distance2;
best_index = i;
}
}
(*best_ref).as_int = mv_ref_list[best_index].as_int;
return best_index;
}
// This function searches the neighbourhood of a given MB/SB and populates a
// list of candidate reference vectors.
//
@ -219,6 +227,8 @@ void find_mv_refs(
int_mv candidate_mvs[MAX_MV_REFS];
int_mv c_refmv;
MV_REFERENCE_FRAME c_ref_frame;
int_mv c2_refmv;
MV_REFERENCE_FRAME c2_ref_frame;
int candidate_scores[MAX_MV_REFS];
int index = 0;
int ref_weight = 0;
@ -239,15 +249,27 @@ void find_mv_refs(
(mv_ref_search[i][1] * xd->mode_info_stride);
valid_mv_ref = get_candidate_mvref(candidate_mi, ref_frame,
&c_ref_frame, &c_refmv);
&c_ref_frame, &c_refmv,
&c2_ref_frame, &c2_refmv);
// If there is a valid MV candidate then add it to the list
if (valid_mv_ref) {
scale_mv(xd, ref_frame, c_ref_frame, &c_refmv, ref_sign_bias );
scale_mv(xd, ref_frame, c_ref_frame, &c_refmv, ref_sign_bias );
ref_weight = ref_distance_weight[i] +
((c_ref_frame == ref_frame) << 4);
addmv_and_shuffle(candidate_mvs, candidate_scores,
&index, c_refmv, ref_weight);
// If there is a second valid mv then add it as well.
if (c2_ref_frame != INTRA_FRAME) {
scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias );
ref_weight = ref_distance_weight[i] +
((c_ref_frame == ref_frame) << 3);
((c2_ref_frame == ref_frame) << 4);
addmv_and_shuffle(candidate_mvs, candidate_scores,
&index, c_refmv, ref_weight);
&index, c2_refmv, ref_weight);
}
}
}
}
@ -255,12 +277,25 @@ void find_mv_refs(
// Look at the corresponding vector in the last frame
candidate_mi = lf_here;
valid_mv_ref = get_candidate_mvref(candidate_mi, ref_frame,
&c_ref_frame, &c_refmv);
&c_ref_frame, &c_refmv,
&c2_ref_frame, &c2_refmv);
// If there is a valid MV candidate then add it to the list
if (valid_mv_ref) {
scale_mv(xd, ref_frame, c_ref_frame, &c_refmv, ref_sign_bias );
ref_weight = 2 + ((c_ref_frame == ref_frame) << 3);
ref_weight = 2 + ((c_ref_frame == ref_frame) << 4);
addmv_and_shuffle(candidate_mvs, candidate_scores,
&index, c_refmv, ref_weight);
// If there is a second valid mv then add it as well.
if (c2_ref_frame != INTRA_FRAME) {
scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias );
ref_weight = ref_distance_weight[i] +
((c2_ref_frame == ref_frame) << 4);
addmv_and_shuffle(candidate_mvs, candidate_scores,
&index, c2_refmv, ref_weight);
}
}
// Populate a list with candidate reference vectors from the
@ -273,15 +308,27 @@ void find_mv_refs(
(mv_ref_search[i][1] * xd->mode_info_stride);
valid_mv_ref = get_candidate_mvref(candidate_mi, ref_frame,
&c_ref_frame, &c_refmv);
&c_ref_frame, &c_refmv,
&c2_ref_frame, &c2_refmv);
// If there is a valid MV candidate then add it to the list
if (valid_mv_ref) {
scale_mv(xd, ref_frame, c_ref_frame, &c_refmv, ref_sign_bias );
scale_mv(xd, ref_frame, c_ref_frame, &c_refmv, ref_sign_bias );
ref_weight = ref_distance_weight[i] +
((c_ref_frame == ref_frame) << 4);
addmv_and_shuffle(candidate_mvs, candidate_scores,
&index, c_refmv, ref_weight);
// If there is a second valid mv then add it as well.
if (c2_ref_frame != INTRA_FRAME) {
scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias );
ref_weight = ref_distance_weight[i] +
((c_ref_frame == ref_frame) << 3);
((c2_ref_frame == ref_frame) << 4);
addmv_and_shuffle(candidate_mvs, candidate_scores,
&index, c_refmv, ref_weight);
&index, c2_refmv, ref_weight);
}
}
}
}
@ -293,7 +340,7 @@ void find_mv_refs(
if (i == index) {
c_refmv.as_int = 0;
addmv_and_shuffle(candidate_mvs, candidate_scores,
&index, c_refmv, 1);
&index, c_refmv, candidate_scores[3]+1 );
}
// Copy over the candidate list.

View File

@ -19,10 +19,6 @@
unsigned int mv_distance(int_mv *mv1, int_mv *mv2);
unsigned int pick_best_mv_ref( int_mv target_mv,
int_mv * mv_ref_list,
int_mv * best_ref );
void find_mv_refs(
MACROBLOCKD *xd,
MODE_INFO *here,

View File

@ -818,11 +818,12 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
#if CONFIG_NEWBESTREFMV
{
int ref_fb_idx;
MV_REFERENCE_FRAME ref_frame = mbmi->ref_frame;
/* Select the appropriate reference frame for this MB */
if (mbmi->ref_frame == LAST_FRAME)
if (ref_frame == LAST_FRAME)
ref_fb_idx = cm->lst_fb_idx;
else if (mbmi->ref_frame == GOLDEN_FRAME)
else if (ref_frame == GOLDEN_FRAME)
ref_fb_idx = cm->gld_fb_idx;
else
ref_fb_idx = cm->alt_fb_idx;
@ -841,21 +842,20 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
// Update stats on relative distance of chosen vector to the
// possible best reference vectors.
{
MV_REFERENCE_FRAME ref_frame = mbmi->ref_frame;
find_mv_refs(xd, mi, prev_mi,
ref_frame, mbmi->ref_mvs[ref_frame],
cm->ref_frame_sign_bias );
// Copy over the candidates.
vpx_memcpy(xd->ref_mv, mbmi->ref_mvs[ref_frame],
(MAX_MV_REFS * sizeof(int_mv)) );
}
#endif
vp8_find_best_ref_mvs(xd,
xd->pre.y_buffer,
recon_y_stride,
#if CONFIG_NEW_MVREF
mbmi->ref_mvs[ref_frame],
#else
xd->ref_mv,
#endif
&best_mv, &nearest, &nearby);
}
#endif
@ -947,16 +947,17 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
find_mv_refs(xd, mi, prev_mi,
ref_frame, mbmi->ref_mvs[ref_frame],
cm->ref_frame_sign_bias );
// Copy over the mv candidates
vpx_memcpy(xd->ref_mv, mbmi->ref_mvs[ref_frame],
(MAX_MV_REFS * sizeof(int_mv)) );
}
#endif
vp8_find_best_ref_mvs(xd,
xd->second_pre.y_buffer,
recon_y_stride,
#if CONFIG_NEW_MVREF
mbmi->ref_mvs[mbmi->second_ref_frame],
#else
xd->ref_mv,
#endif
&best_mv_second,
&nearest_second,
&nearby_second);

View File

@ -106,6 +106,69 @@ static int prob_diff_update_cost(vp8_prob newp, vp8_prob oldp) {
return update_bits[delp] * 256;
}
#if CONFIG_NEW_MVREF
// Estimate the cost of each coding the vector using each reference candidate
unsigned int pick_best_mv_ref( MACROBLOCK *x,
int_mv target_mv,
int_mv * mv_ref_list,
int_mv * best_ref ) {
int i;
int best_index = 0;
int cost, cost2;
int index_cost[MAX_MV_REFS];
MACROBLOCKD *xd = &x->e_mbd;
/*unsigned int distance, distance2;
distance = mv_distance(&target_mv, &mv_ref_list[0]);
for (i = 1; i < MAX_MV_REFS; ++i ) {
distance2 =
mv_distance(&target_mv, &mv_ref_list[i]);
if (distance2 < distance) {
distance = distance2;
best_index = i;
}
}*/
// For now estimate the cost of selecting a given ref index
// as index * 1 bits (but here 1 bit is scaled to 256)
for (i = 0; i < MAX_MV_REFS; ++i ) {
index_cost[i] = i << 8;
}
index_cost[0] = vp8_cost_zero(205);
index_cost[1] = vp8_cost_zero(40);
index_cost[2] = vp8_cost_zero(8);
index_cost[3] = vp8_cost_zero(2);
cost = index_cost[0] +
vp8_mv_bit_cost(&target_mv,
&mv_ref_list[0],
XMVCOST, 96,
xd->allow_high_precision_mv);
//for (i = 1; i < MAX_MV_REFS; ++i ) {
for (i = 1; i < 4; ++i ) {
cost2 = index_cost[i] +
vp8_mv_bit_cost(&target_mv,
&mv_ref_list[i],
XMVCOST, 96,
xd->allow_high_precision_mv);
if (cost2 < cost) {
cost = cost2;
best_index = i;
}
}
(*best_ref).as_int = mv_ref_list[best_index].as_int;
return best_index;
}
#endif
static void update_mode(
vp8_writer *const w,
int n,
@ -760,6 +823,7 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
const MV_CONTEXT *mvc = pc->fc.mvc;
const MV_CONTEXT_HP *mvc_hp = pc->fc.mvc_hp;
#endif
MACROBLOCK *x = &cpi->mb;
MACROBLOCKD *xd = &cpi->mb.e_mbd;
MODE_INFO *m;
MODE_INFO *prev_m;
@ -1075,12 +1139,18 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
#endif
#if 0 //CONFIG_NEW_MVREF
find_mv_refs(xd, m, prev_m,
m->mbmi.ref_frame,
mi->ref_mvs[rf],
cpi->common.ref_frame_sign_bias );
{
unsigned int best_index;
/*find_mv_refs(xd, m, prev_m,
m->mbmi.ref_frame,
mi->ref_mvs[rf],
cpi->common.ref_frame_sign_bias );*/
pick_best_mv_ref( mi->mv[0], mi->ref_mvs[rf], &best_mv);
best_index = pick_best_mv_ref(x, mi->mv[0],
mi->ref_mvs[rf], &best_mv);
cpi->best_ref_index_counts[best_index]++;
}
#endif
#if CONFIG_NEWMVENTROPY
write_nmv(w, &mi->mv[0].as_mv, &best_mv,
@ -1096,14 +1166,18 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
if (mi->second_ref_frame) {
#if 0 //CONFIG_NEW_MVREF
find_mv_refs(xd, m, prev_m,
unsigned int best_index;
/*find_mv_refs(xd, m, prev_m,
m->mbmi.second_ref_frame,
mi->ref_mvs[mi->second_ref_frame],
cpi->common.ref_frame_sign_bias );
cpi->common.ref_frame_sign_bias );*/
pick_best_mv_ref( mi->mv[1],
mi->ref_mvs[mi->second_ref_frame],
&best_second_mv);
best_index =
pick_best_mv_ref(x, mi->mv[1],
mi->ref_mvs[mi->second_ref_frame],
&best_second_mv);
cpi->best_ref_index_counts[best_index]++;
#endif
#if CONFIG_NEWMVENTROPY
write_nmv(w, &mi->mv[1].as_mv, &best_second_mv,

View File

@ -3881,7 +3881,7 @@ static void encode_frame_to_data_rate
FILE *f = fopen("mv_ref_dist.stt", "a");
unsigned int i;
//fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %10d %10d\n",
fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %10d %10d",
/*fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %10d %10d",
cpi->common.current_video_frame,
cpi->mv_ref_sum_distance[1][0],
cpi->mv_ref_sum_distance[1][1],
@ -3891,7 +3891,7 @@ static void encode_frame_to_data_rate
cpi->mv_ref_sum_distance[2][2],
cpi->mv_ref_sum_distance[3][0],
cpi->mv_ref_sum_distance[3][1],
cpi->mv_ref_sum_distance[3][2] );
cpi->mv_ref_sum_distance[3][2] );*/
for (i = 0; i < MAX_MV_REFS; ++i) {
fprintf(f, "%10d", cpi->best_ref_index_counts[i] );

View File

@ -3031,6 +3031,8 @@ void setup_buffer_inter(VP8_COMP *cpi, MACROBLOCK *x, int idx, int frame_type,
unsigned char *v_buffer[4]) {
YV12_BUFFER_CONFIG *yv12 = &cpi->common.yv12_fb[idx];
MACROBLOCKD *xd = &x->e_mbd;
MB_MODE_INFO * mbmi = &xd->mode_info_context->mbmi;
vp8_find_near_mvs(xd, xd->mode_info_context,
xd->prev_mode_info_context,
@ -3047,22 +3049,21 @@ void setup_buffer_inter(VP8_COMP *cpi, MACROBLOCK *x, int idx, int frame_type,
// Update stats on relative distance of chosen vector to the
// possible best reference vectors.
{
MB_MODE_INFO * mbmi = &xd->mode_info_context->mbmi;
find_mv_refs(xd, xd->mode_info_context,
xd->prev_mode_info_context,
frame_type,
mbmi->ref_mvs[frame_type],
cpi->common.ref_frame_sign_bias );
// Copy over the mv candidates
vpx_memcpy(xd->ref_mv, mbmi->ref_mvs[frame_type],
(MAX_MV_REFS * sizeof(int_mv)) );
}
#endif
vp8_find_best_ref_mvs(xd, y_buffer[frame_type],
yv12->y_stride,
#if CONFIG_NEW_MVREF
mbmi->ref_mvs[frame_type],
#else
xd->ref_mv,
#endif
&frame_best_ref_mv[frame_type],
&frame_nearest_mv[frame_type],
&frame_near_mv[frame_type]);
@ -3573,7 +3574,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
d->bmi.as_mv.first.as_int = tmp_mv.as_int;
frame_mv[NEWMV][refs[0]].as_int = d->bmi.as_mv.first.as_int;
#if CONFIG_NEW_MVREF
#if 0 //CONFIG_NEW_MVREF
// Update stats on relative distance of chosen vector to the
// possible best reference vectors.
{
@ -3596,7 +3597,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
&mbmi->ref_mvs[ref][0]);
cpi->mv_ref_sum_distance[ref][NEW_BEST] += distance;
best_index = pick_best_mv_ref(tmp_mv, mbmi->ref_mvs[ref],
best_index = pick_best_mv_ref(x, tmp_mv, mbmi->ref_mvs[ref],
&selected_best_ref);
distance = mv_distance(&tmp_mv, &selected_best_ref);
@ -3626,6 +3627,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
flag = 1;
if (flag)
continue;
case ZEROMV:
default: