ref: e52e8b70250b0f897e6947b5c24db365e489ba07
parent: b91219e29eb52d429cc5051c7e7ab5aaac8e7d02
author: Yaowu Xu <yaowu@google.com>
date: Mon Aug 6 06:51:20 EDT 2012
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
--- a/vp8/common/findnearmv.c
+++ b/vp8/common/findnearmv.c
@@ -202,7 +202,9 @@
void vp8_find_best_ref_mvs(MACROBLOCKD *xd,
unsigned char *ref_y_buffer,
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 bestsad = INT_MAX;
int i;
@@ -259,6 +261,13 @@
lower_mv_precision(best_mv);
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
--- a/vp8/decoder/decodemv.c
+++ b/vp8/decoder/decodemv.c
@@ -653,7 +653,7 @@
vp8_find_best_ref_mvs(xd,
xd->pre.y_buffer,
recon_y_stride,
- &best_mv);
+ &best_mv, &nearest, &nearby);
}
#endif
@@ -732,7 +732,9 @@
vp8_find_best_ref_mvs(xd,
xd->second_pre.y_buffer,
recon_y_stride,
- &best_mv_second);
+ &best_mv_second,
+ &nearest_second,
+ &nearby_second);
}
#else
vp8_find_near_mvs(xd, mi, prev_mi,
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -2652,7 +2652,10 @@
v_buffer[frame_type] = yv12->v_buffer + recon_uvoffset;
#if CONFIG_NEWBESTREFMV
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;
#endif
}
--- a/vp8/encoder/tokenize.c
+++ b/vp8/encoder/tokenize.c
@@ -1311,6 +1311,7 @@
ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)x->left_context;
int plane_type;
int b;
+ TOKENEXTRA *t_backup = *t;
stuff2nd_order_b_8x8(x->block + 24, t, 1, x->frame_type,
A + vp8_block2above_8x8[24],
@@ -1334,6 +1335,8 @@
*(A + vp8_block2above_8x8[b] + 1) = *(A + vp8_block2above_8x8[b]);
*(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b]);
}
+ if (dry_run)
+ *t = t_backup;
}
@@ -1370,6 +1373,7 @@
ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)x->above_context;
ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context;
int b, i;
+ TOKENEXTRA *t_backup = *t;
stuff1st_order_b_16x16(x->block, t, x->frame_type, A, L, cpi, dry_run);
for (i = 1; i < 16; i++) {
@@ -1386,6 +1390,8 @@
}
vpx_memset(&A[8], 0, sizeof(A[8]));
vpx_memset(&L[8], 0, sizeof(L[8]));
+ if (dry_run)
+ *t = t_backup;
}
#endif
@@ -1456,7 +1462,8 @@
*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 *L = (ENTROPY_CONTEXT *)x->left_context;
int plane_type;
--
⑨