diff options
author | Paul Wilkins <paulwilkins@google.com> | 2012-09-07 12:46:41 +0100 |
---|---|---|
committer | Paul Wilkins <paulwilkins@google.com> | 2012-09-07 12:46:41 +0100 |
commit | 38e1c7918518ac231b2787fabeb45990c8a7995a (patch) | |
tree | ec0ba1bbc0300564c1b6d8f7ddc6af0ff0235490 /vp8/encoder | |
parent | 00f9eb659034cb5cef0bf063c1b72c72c6333f36 (diff) | |
download | libvpx-38e1c7918518ac231b2787fabeb45990c8a7995a.tar libvpx-38e1c7918518ac231b2787fabeb45990c8a7995a.tar.gz libvpx-38e1c7918518ac231b2787fabeb45990c8a7995a.tar.bz2 libvpx-38e1c7918518ac231b2787fabeb45990c8a7995a.zip |
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
Diffstat (limited to 'vp8/encoder')
-rw-r--r-- | vp8/encoder/bitstream.c | 94 | ||||
-rw-r--r-- | vp8/encoder/onyx_if.c | 4 | ||||
-rw-r--r-- | vp8/encoder/rdopt.c | 18 |
3 files changed, 96 insertions, 20 deletions
diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c index 712019602..7875cf93b 100644 --- a/vp8/encoder/bitstream.c +++ b/vp8/encoder/bitstream.c @@ -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 );*/ + + best_index = pick_best_mv_ref(x, mi->mv[0], + mi->ref_mvs[rf], &best_mv); + cpi->best_ref_index_counts[best_index]++; - pick_best_mv_ref( mi->mv[0], mi->ref_mvs[rf], &best_mv); + } #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, diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index fdb3fa196..ea6e45d83 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -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] ); diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index a2b234ebe..673d631b1 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -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: |