diff options
author | Paul Wilkins <paulwilkins@google.com> | 2012-08-24 15:44:01 +0100 |
---|---|---|
committer | Paul Wilkins <paulwilkins@google.com> | 2012-08-24 18:08:21 +0100 |
commit | 2d60bee1fbfb7e5b6862e4e636151effabae98e3 (patch) | |
tree | 3f0760847eaba681c8c708f6e4f029129cd81137 /vp8/encoder/rdopt.c | |
parent | 3777125ba66d15fef1436ea8871b3901a86c6991 (diff) | |
download | libvpx-2d60bee1fbfb7e5b6862e4e636151effabae98e3.tar libvpx-2d60bee1fbfb7e5b6862e4e636151effabae98e3.tar.gz libvpx-2d60bee1fbfb7e5b6862e4e636151effabae98e3.tar.bz2 libvpx-2d60bee1fbfb7e5b6862e4e636151effabae98e3.zip |
New Motion Reference Search
Alternative strategy for finding a list of candidate motion
vectors to use as reference values in mv coding and as
nearest and near.
Sort by sad in vp8_find_best_ref_mvs() rather than just
pick the best. Allow 0,0 as a best ref option but not a
nearest or near unless there are no alternatives.
Encode/Decode verified on at least some clips.
Some commented out experimental and stats code still in place.
Gain over existing code averages about 1% on derf (alll metrics)
with improvement on all clips. Other test results pending.
The entropy coding of the mode (nearest/near etc) still
depends upon and requires the old "findnear" code so
this needs looking at and may provide room for further gains.
Change-Id: I871d7cba1d1c379c4bad9bcccce1fb19c46b8247
Diffstat (limited to 'vp8/encoder/rdopt.c')
-rw-r--r-- | vp8/encoder/rdopt.c | 67 |
1 files changed, 64 insertions, 3 deletions
diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index d217f2ffc..d07c2383e 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -41,6 +41,10 @@ #include "vp8/common/seg_common.h" #include "vp8/common/pred_common.h" +#if CONFIG_NEW_MVREF +#include "vp8/common/mvref_common.h" +#endif + #if CONFIG_RUNTIME_CPU_DETECT #define IF_RTCD(x) (x) #else @@ -2892,9 +2896,10 @@ void setup_buffer_inter(VP8_COMP *cpi, MACROBLOCK *x, int idx, int frame_type, unsigned char *y_buffer[4], unsigned char *u_buffer[4], unsigned char *v_buffer[4]) { YV12_BUFFER_CONFIG *yv12 = &cpi->common.yv12_fb[idx]; + MACROBLOCKD *xd = &x->e_mbd; - vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, - x->e_mbd.prev_mode_info_context, + vp8_find_near_mvs(xd, xd->mode_info_context, + xd->prev_mode_info_context, &frame_nearest_mv[frame_type], &frame_near_mv[frame_type], &frame_best_ref_mv[frame_type], frame_mdcounts[frame_type], frame_type, cpi->common.ref_frame_sign_bias); @@ -2902,8 +2907,27 @@ void setup_buffer_inter(VP8_COMP *cpi, MACROBLOCK *x, int idx, int frame_type, y_buffer[frame_type] = yv12->y_buffer + recon_yoffset; u_buffer[frame_type] = yv12->u_buffer + recon_uvoffset; v_buffer[frame_type] = yv12->v_buffer + recon_uvoffset; + #if CONFIG_NEWBESTREFMV - vp8_find_best_ref_mvs(&x->e_mbd, y_buffer[frame_type], +#if CONFIG_NEW_MVREF + // 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, &frame_best_ref_mv[frame_type], &frame_nearest_mv[frame_type], @@ -3407,6 +3431,43 @@ 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 + // Update stats on relative distance of chosen vector to the + // possible best reference vectors. + { + unsigned int distance; + MV_REFERENCE_FRAME ref = mbmi->ref_frame; + int_mv selected_best_ref; + unsigned int best_index = 0; + + find_mv_refs(xd, xd->mode_info_context, + xd->prev_mode_info_context, + ref, + mbmi->ref_mvs[ref], + cpi->common.ref_frame_sign_bias ); + + distance = mv_distance(&tmp_mv, &best_ref_mv); + cpi->mv_ref_sum_distance[ref][CUR_BEST] += distance; + + distance = + mv_distance(&tmp_mv, + &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], + &selected_best_ref); + + distance = mv_distance(&tmp_mv, &selected_best_ref); + mbmi->mv_ref_index[ref] = best_index; + cpi->mv_ref_sum_distance[ref][BEST_SELECTED] += distance; + cpi->best_ref_index_counts[best_index]++; + + // Temp + //mbmi->mv_ref_index[ref] = 0; + //mbmi->ref_mvs[ref][0].as_int = best_ref_mv.as_int; + } +#endif + // Add the new motion vector cost to our rolling cost variable rate2 += vp8_mv_bit_cost(&tmp_mv, &best_ref_mv, XMVCOST, 96, |