Commit e52e8b70 authored by Yaowu Xu's avatar Yaowu Xu
Browse files

Changed to use reference mv as nearest mv

The reference motion vector selected by surrounding pixels that has
the best matching score is used as nearest motion vector.

The change has shown consistent gain on all test sets, compression
gains range from .2% to .6%. The variation is largely dependent on
various other experiments on or off.

Change-Id: I5552e1c2f6fc57c3e8818a5ee41ffda89af05e75
parent b91219e2
...@@ -202,7 +202,9 @@ vp8_prob *vp8_mv_ref_probs(VP8_COMMON *pc, ...@@ -202,7 +202,9 @@ vp8_prob *vp8_mv_ref_probs(VP8_COMMON *pc,
void vp8_find_best_ref_mvs(MACROBLOCKD *xd, void vp8_find_best_ref_mvs(MACROBLOCKD *xd,
unsigned char *ref_y_buffer, unsigned char *ref_y_buffer,
int ref_y_stride, int ref_y_stride,
int_mv *best_mv){ int_mv *best_mv,
int_mv *nearest,
int_mv *near) {
int_mv *ref_mv = xd->ref_mv; int_mv *ref_mv = xd->ref_mv;
int bestsad = INT_MAX; int bestsad = INT_MAX;
int i; int i;
...@@ -259,6 +261,13 @@ void vp8_find_best_ref_mvs(MACROBLOCKD *xd, ...@@ -259,6 +261,13 @@ void vp8_find_best_ref_mvs(MACROBLOCKD *xd,
lower_mv_precision(best_mv); lower_mv_precision(best_mv);
vp8_clamp_mv2(best_mv, xd); vp8_clamp_mv2(best_mv, xd);
if (best_mv->as_int != 0 &&
(best_mv->as_mv.row >> 3) != (nearest->as_mv.row >>3 ) &&
(best_mv->as_mv.col >> 3) != (nearest->as_mv.col >>3 )) {
near->as_int = nearest->as_int;
nearest->as_int = best_mv->as_int;
}
} }
#endif #endif
...@@ -653,7 +653,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, ...@@ -653,7 +653,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
vp8_find_best_ref_mvs(xd, vp8_find_best_ref_mvs(xd,
xd->pre.y_buffer, xd->pre.y_buffer,
recon_y_stride, recon_y_stride,
&best_mv); &best_mv, &nearest, &nearby);
} }
#endif #endif
...@@ -732,7 +732,9 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, ...@@ -732,7 +732,9 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
vp8_find_best_ref_mvs(xd, vp8_find_best_ref_mvs(xd,
xd->second_pre.y_buffer, xd->second_pre.y_buffer,
recon_y_stride, recon_y_stride,
&best_mv_second); &best_mv_second,
&nearest_second,
&nearby_second);
} }
#else #else
vp8_find_near_mvs(xd, mi, prev_mi, vp8_find_near_mvs(xd, mi, prev_mi,
......
...@@ -2652,7 +2652,10 @@ void setup_buffer_inter(VP8_COMP *cpi, MACROBLOCK *x, int idx, int frame_type, ...@@ -2652,7 +2652,10 @@ void setup_buffer_inter(VP8_COMP *cpi, MACROBLOCK *x, int idx, int frame_type,
v_buffer[frame_type] = yv12->v_buffer + recon_uvoffset; v_buffer[frame_type] = yv12->v_buffer + recon_uvoffset;
#if CONFIG_NEWBESTREFMV #if CONFIG_NEWBESTREFMV
vp8_find_best_ref_mvs(&x->e_mbd, y_buffer[frame_type], vp8_find_best_ref_mvs(&x->e_mbd, y_buffer[frame_type],
yv12->y_stride, &frame_best_ref_mv[frame_type]); yv12->y_stride,
&frame_best_ref_mv[frame_type],
&frame_nearest_mv[frame_type],
&frame_near_mv[frame_type]);
ref_mv[frame_type].as_int = frame_best_ref_mv[frame_type].as_int; ref_mv[frame_type].as_int = frame_best_ref_mv[frame_type].as_int;
#endif #endif
} }
......
...@@ -1311,6 +1311,7 @@ void vp8_stuff_mb_8x8(VP8_COMP *cpi, ...@@ -1311,6 +1311,7 @@ void vp8_stuff_mb_8x8(VP8_COMP *cpi,
ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context; ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context;
int plane_type; int plane_type;
int b; int b;
TOKENEXTRA *t_backup = *t;
stuff2nd_order_b_8x8(x->block + 24, t, 1, x->frame_type, stuff2nd_order_b_8x8(x->block + 24, t, 1, x->frame_type,
A + vp8_block2above_8x8[24], A + vp8_block2above_8x8[24],
...@@ -1334,6 +1335,8 @@ void vp8_stuff_mb_8x8(VP8_COMP *cpi, ...@@ -1334,6 +1335,8 @@ void vp8_stuff_mb_8x8(VP8_COMP *cpi,
*(A + vp8_block2above_8x8[b] + 1) = *(A + vp8_block2above_8x8[b]); *(A + vp8_block2above_8x8[b] + 1) = *(A + vp8_block2above_8x8[b]);
*(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b]); *(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b]);
} }
if (dry_run)
*t = t_backup;
} }
...@@ -1370,6 +1373,7 @@ void vp8_stuff_mb_16x16(VP8_COMP *cpi, ...@@ -1370,6 +1373,7 @@ void vp8_stuff_mb_16x16(VP8_COMP *cpi,
ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)x->above_context; ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)x->above_context;
ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context; ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context;
int b, i; int b, i;
TOKENEXTRA *t_backup = *t;
stuff1st_order_b_16x16(x->block, t, x->frame_type, A, L, cpi, dry_run); stuff1st_order_b_16x16(x->block, t, x->frame_type, A, L, cpi, dry_run);
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
...@@ -1386,6 +1390,8 @@ void vp8_stuff_mb_16x16(VP8_COMP *cpi, ...@@ -1386,6 +1390,8 @@ void vp8_stuff_mb_16x16(VP8_COMP *cpi,
} }
vpx_memset(&A[8], 0, sizeof(A[8])); vpx_memset(&A[8], 0, sizeof(A[8]));
vpx_memset(&L[8], 0, sizeof(L[8])); vpx_memset(&L[8], 0, sizeof(L[8]));
if (dry_run)
*t = t_backup;
} }
#endif #endif
...@@ -1456,7 +1462,8 @@ void stuff1st_order_buv ...@@ -1456,7 +1462,8 @@ void stuff1st_order_buv
*a = *l = pt; *a = *l = pt;
} }
void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t, int dry_run) { void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x,
TOKENEXTRA **t, int dry_run) {
ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)x->above_context; ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)x->above_context;
ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context; ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context;
int plane_type; int plane_type;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment