diff options
author | Deb Mukherjee <debargha@google.com> | 2012-06-20 05:07:24 -0700 |
---|---|---|
committer | Yaowu Xu <yaowu@google.com> | 2012-06-25 18:09:54 -0700 |
commit | f3dff402556cb1b1dd3c7dbc1877104a792f329c (patch) | |
tree | 8969a12f67f323c51a03994861a42ec055a7200d /vp8/encoder | |
parent | 9c9d6743d460da1bfb88af66bf43597ae6927af3 (diff) | |
download | libvpx-f3dff402556cb1b1dd3c7dbc1877104a792f329c.tar libvpx-f3dff402556cb1b1dd3c7dbc1877104a792f329c.tar.gz libvpx-f3dff402556cb1b1dd3c7dbc1877104a792f329c.tar.bz2 libvpx-f3dff402556cb1b1dd3c7dbc1877104a792f329c.zip |
Continued adaptive entropy coding
Incorporates mv_ref, mbsplit and second_mv into the adaptive
entropy framework. The mv_ref framework has been modified from
before.
Adds some clean-ups and fixes.
Results with the adaptive entropy experiment are currently up by
+1.93% on derf; +2.33% std-hd and +1.87% yt-hd.
Fixed a nasty intermittent bug.
Change-Id: I4b1ac9f9483b48432597595195bfec05f31d1e39
Diffstat (limited to 'vp8/encoder')
-rw-r--r-- | vp8/encoder/bitstream.c | 54 | ||||
-rw-r--r-- | vp8/encoder/block.h | 1 | ||||
-rw-r--r-- | vp8/encoder/encodeframe.c | 8 | ||||
-rw-r--r-- | vp8/encoder/modecosts.c | 11 | ||||
-rw-r--r-- | vp8/encoder/onyx_if.c | 5 | ||||
-rw-r--r-- | vp8/encoder/onyx_int.h | 7 | ||||
-rw-r--r-- | vp8/encoder/ratectrl.c | 44 | ||||
-rw-r--r-- | vp8/encoder/rdopt.c | 49 | ||||
-rw-r--r-- | vp8/encoder/rdopt.h | 5 |
9 files changed, 141 insertions, 43 deletions
diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c index ee805110b..e0cb2d48c 100644 --- a/vp8/encoder/bitstream.c +++ b/vp8/encoder/bitstream.c @@ -300,10 +300,10 @@ static void write_bmode(vp8_writer *bc, int m, const vp8_prob *p) vp8_write_token(bc, vp8_bmode_tree, p, vp8_bmode_encodings + m); } -static void write_split(vp8_writer *bc, int x) +static void write_split(vp8_writer *bc, int x, const vp8_prob *p) { vp8_write_token( - bc, vp8_mbsplit_tree, vp8_mbsplit_probs, vp8_mbsplit_encodings + x + bc, vp8_mbsplit_tree, p, vp8_mbsplit_encodings + x ); } @@ -856,7 +856,7 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) vp8_write_mvprobs_hp(cpi); else #endif - vp8_write_mvprobs(cpi); + vp8_write_mvprobs(cpi); mb_row = 0; for (row=0; row < pc->mb_rows; row += 2) @@ -1061,21 +1061,29 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) #if CONFIG_HIGH_PRECISION_MV if (xd->allow_high_precision_mv) + { write_mv_hp(w, &mi->mv.as_mv, &best_mv, mvc_hp); + } else #endif - write_mv(w, &mi->mv.as_mv, &best_mv, mvc); + { + write_mv(w, &mi->mv.as_mv, &best_mv, mvc); + } if (mi->second_ref_frame) { #if CONFIG_HIGH_PRECISION_MV if (xd->allow_high_precision_mv) + { write_mv_hp(w, &mi->second_mv.as_mv, &best_second_mv, mvc_hp); + } else #endif - write_mv(w, &mi->second_mv.as_mv, + { + write_mv(w, &mi->second_mv.as_mv, &best_second_mv, mvc); + } } break; case SPLITMV: @@ -1086,7 +1094,10 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) ++count_mb_seg [mi->partitioning]; #endif - write_split(w, mi->partitioning); + write_split(w, mi->partitioning, cpi->common.fc.mbsplit_prob); +#if CONFIG_ADAPTIVE_ENTROPY + cpi->mbsplit_count[mi->partitioning]++; +#endif do { @@ -1112,8 +1123,10 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) mv_contz = vp8_mv_cont(&leftmv, &abovemv); write_sub_mv_ref(w, blockmode, - vp8_sub_mv_ref_prob2 [mv_contz]); - + cpi->common.fc.sub_mv_ref_prob [mv_contz]); +#if CONFIG_ADAPTIVE_ENTROPY + cpi->sub_mv_ref_count[mv_contz][blockmode-LEFT4X4]++; +#endif if (blockmode == NEW4X4) { #ifdef ENTROPY_STATS @@ -1121,23 +1134,31 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) #endif #if CONFIG_HIGH_PRECISION_MV if (xd->allow_high_precision_mv) + { write_mv_hp(w, &blockmv.as_mv, &best_mv, (const MV_CONTEXT_HP *) mvc_hp); + } else #endif - write_mv(w, &blockmv.as_mv, &best_mv, + { + write_mv(w, &blockmv.as_mv, &best_mv, (const MV_CONTEXT *) mvc); + } if (mi->second_ref_frame) { #if CONFIG_HIGH_PRECISION_MV if (xd->allow_high_precision_mv) + { write_mv_hp(w, &cpi->mb.partition_info->bmi[j].second_mv.as_mv, &best_second_mv, (const MV_CONTEXT_HP *) mvc_hp); + } else #endif + { write_mv(w, &cpi->mb.partition_info->bmi[j].second_mv.as_mv, &best_second_mv, (const MV_CONTEXT *) mvc); + } } } } @@ -2229,8 +2250,6 @@ static void segment_reference_frames(VP8_COMP *cpi) enable_segfeature(xd,i,SEG_LVL_REF_FRAME); set_segdata( xd,i, SEG_LVL_REF_FRAME, ref[i]); } - - } void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size) @@ -2628,15 +2647,21 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size) vp8_copy(cpi->common.fc.pre_ymode_prob, cpi->common.fc.ymode_prob); vp8_copy(cpi->common.fc.pre_uv_mode_prob, cpi->common.fc.uv_mode_prob); vp8_copy(cpi->common.fc.pre_bmode_prob, cpi->common.fc.bmode_prob); + vp8_copy(cpi->common.fc.pre_sub_mv_ref_prob, cpi->common.fc.sub_mv_ref_prob); + vp8_copy(cpi->common.fc.pre_mbsplit_prob, cpi->common.fc.mbsplit_prob); vp8_copy(cpi->common.fc.pre_i8x8_mode_prob, cpi->common.fc.i8x8_mode_prob); vp8_copy(cpi->common.fc.pre_mvc, cpi->common.fc.mvc); #if CONFIG_HIGH_PRECISION_MV vp8_copy(cpi->common.fc.pre_mvc_hp, cpi->common.fc.mvc_hp); #endif + vp8_zero(cpi->sub_mv_ref_count); + vp8_zero(cpi->mbsplit_count); + vp8_zero(cpi->common.fc.mv_ref_ct) + vp8_zero(cpi->common.fc.mv_ref_ct_a) #endif -#if COEFUPDATETYPE == 2 +#if CONFIG_NEWUPDATE && COEFUPDATETYPE == 2 update_coef_probs2(cpi); -#elif COEFUPDATETYPE == 3 +#elif CONFIG_NEWUPDATE && COEFUPDATETYPE == 3 update_coef_probs3(cpi); #else update_coef_probs(cpi); @@ -2661,8 +2686,9 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size) else { pack_inter_mode_mvs(cpi); - +#if CONFIG_ADAPTIVE_ENTROPY == 0 vp8_update_mode_context(&cpi->common); +#endif #ifdef ENTROPY_STATS active_section = 1; diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h index 98bc13277..fb309f461 100644 --- a/vp8/encoder/block.h +++ b/vp8/encoder/block.h @@ -72,6 +72,7 @@ typedef struct MODE_INFO mic; PARTITION_INFO partition_info; int_mv best_ref_mv; + int_mv second_best_ref_mv; int rate; int distortion; int intra_error; diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index a92bdbcda..55041c5a6 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -458,7 +458,7 @@ static void update_state (VP8_COMP *cpi, MACROBLOCK *x, PICK_MODE_CONTEXT *ctx) // Note how often each mode chosen as best cpi->mode_chosen_counts[mb_mode_index]++; - rd_update_mvcount(cpi, x, &ctx->best_ref_mv); + rd_update_mvcount(cpi, x, &ctx->best_ref_mv, &ctx->second_best_ref_mv); cpi->prediction_error += ctx->distortion; cpi->intra_error += ctx->intra_error; @@ -1068,6 +1068,12 @@ void init_encode_frame_mb_context(VP8_COMP *cpi) vp8_zero(cpi->ymode_count) vp8_zero(cpi->i8x8_mode_count) vp8_zero(cpi->y_uv_mode_count) + vp8_zero(cpi->sub_mv_ref_count) + vp8_zero(cpi->mbsplit_count) +#if CONFIG_ADAPTIVE_ENTROPY + vp8_zero(cpi->common.fc.mv_ref_ct) + vp8_zero(cpi->common.fc.mv_ref_ct_a) +#endif //vp8_zero(cpi->uv_mode_count) x->mvc = cm->fc.mvc; diff --git a/vp8/encoder/modecosts.c b/vp8/encoder/modecosts.c index e7d071124..6cd0da56a 100644 --- a/vp8/encoder/modecosts.c +++ b/vp8/encoder/modecosts.c @@ -37,8 +37,14 @@ void vp8_init_mode_costs(VP8_COMP *c) vp8_cost_tokens((int *)c->mb.inter_bmode_costs, x->fc.bmode_prob, T); } +#if CONFIG_ADAPTIVE_ENTROPY vp8_cost_tokens((int *)c->mb.inter_bmode_costs, - x->fc.sub_mv_ref_prob, vp8_sub_mv_ref_tree); + vp8_sub_mv_ref_prob, vp8_sub_mv_ref_tree); + //x->fc.sub_mv_ref_prob[1], vp8_sub_mv_ref_tree); +#else + vp8_cost_tokens((int *)c->mb.inter_bmode_costs, + vp8_sub_mv_ref_prob, vp8_sub_mv_ref_tree); +#endif vp8_cost_tokens(c->mb.mbmode_cost[1], x->fc.ymode_prob, vp8_ymode_tree); vp8_cost_tokens(c->mb.mbmode_cost[0], @@ -48,6 +54,7 @@ void vp8_init_mode_costs(VP8_COMP *c) x->fc.uv_mode_prob[VP8_YMODES-1], vp8_uv_mode_tree); vp8_cost_tokens(c->mb.intra_uv_mode_cost[0], x->kf_uv_mode_prob[VP8_YMODES-1], vp8_uv_mode_tree); - vp8_cost_tokens((int *)c->mb.i8x8_mode_costs, + vp8_cost_tokens(c->mb.i8x8_mode_costs, x->fc.i8x8_mode_prob,vp8_i8x8_mode_tree); + } diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index aa46fb073..decb31b4b 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -3702,6 +3702,8 @@ static void encode_frame_to_data_rate vp8_copy(cpi->common.fc.uv_mode_counts, cpi->y_uv_mode_count); vp8_copy(cpi->common.fc.bmode_counts, cpi->bmode_count); vp8_copy(cpi->common.fc.i8x8_mode_counts, cpi->i8x8_mode_count); + vp8_copy(cpi->common.fc.sub_mv_ref_counts, cpi->sub_mv_ref_count); + vp8_copy(cpi->common.fc.mbsplit_counts, cpi->mbsplit_count); vp8_adapt_mode_probs(&cpi->common); vp8_copy(cpi->common.fc.MVcount, cpi->MVcount); @@ -3709,6 +3711,7 @@ static void encode_frame_to_data_rate vp8_copy(cpi->common.fc.MVcount_hp, cpi->MVcount_hp); #endif vp8_adapt_mv_probs(&cpi->common); + vp8_update_mode_context(&cpi->common); } #endif /* CONFIG_ADAPTIVE_ENTROPY */ @@ -3809,7 +3812,7 @@ static void encode_frame_to_data_rate // in this frame. update_base_skip_probs( cpi ); -#if 1 && CONFIG_INTERNAL_STATS +#if 0//1 && CONFIG_INTERNAL_STATS { FILE *f = fopen("tmp.stt", "a"); int recon_err; diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h index f4e6f9490..54ed23340 100644 --- a/vp8/encoder/onyx_int.h +++ b/vp8/encoder/onyx_int.h @@ -23,6 +23,7 @@ #include "encodemb.h" #include "quantize.h" #include "vp8/common/entropy.h" +#include "vp8/common/entropymode.h" #include "vpx_ports/mem.h" #include "vpx/internal/vpx_codec_internal.h" #include "mcomp.h" @@ -99,6 +100,8 @@ typedef struct vp8_prob uv_mode_prob [VP8_YMODES][VP8_UV_MODES-1]; vp8_prob bmode_prob [VP8_BINTRAMODES-1]; vp8_prob i8x8_mode_prob [VP8_I8X8_MODES-1]; + vp8_prob sub_mv_ref_prob [SUBMVREF_COUNT][VP8_SUBMVREFS-1]; + vp8_prob mbsplit_prob [VP8_NUMMBSPLITS-1]; int mv_ref_ct[6][4][2]; int mode_context[6][4]; @@ -458,7 +461,10 @@ typedef struct VP8_COMP int ymode_count [VP8_YMODES]; /* intra MB type cts this frame */ int bmode_count [VP8_BINTRAMODES]; int i8x8_mode_count [VP8_I8X8_MODES]; + int sub_mv_ref_count [SUBMVREF_COUNT][VP8_SUBMVREFS]; + int mbsplit_count [VP8_NUMMBSPLITS]; //int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */ + int y_uv_mode_count[VP8_YMODES][VP8_UV_MODES]; unsigned int MVcount [2] [MVvals]; /* (row,col) MV cts this frame */ #if CONFIG_HIGH_PRECISION_MV @@ -542,7 +548,6 @@ typedef struct VP8_COMP int t4x4_count; int t8x8_count; - int y_uv_mode_count[VP8_YMODES][VP8_UV_MODES]; unsigned char *segmentation_map; // segment threashold for encode breakout diff --git a/vp8/encoder/ratectrl.c b/vp8/encoder/ratectrl.c index 6d510e9d9..75246fca2 100644 --- a/vp8/encoder/ratectrl.c +++ b/vp8/encoder/ratectrl.c @@ -150,15 +150,17 @@ void vp8_save_coding_context(VP8_COMP *cpi) vp8_copy(cc->mvcosts_hp, cpi->mb.mvcosts_hp); #endif - vp8_copy( cc->mv_ref_ct, cm->mv_ref_ct ); - vp8_copy( cc->mode_context, cm->mode_context ); - vp8_copy( cc->mv_ref_ct_a, cm->mv_ref_ct_a ); - vp8_copy( cc->mode_context_a, cm->mode_context_a ); + vp8_copy( cc->mv_ref_ct, cm->fc.mv_ref_ct ); + vp8_copy( cc->mode_context, cm->fc.mode_context ); + vp8_copy( cc->mv_ref_ct_a, cm->fc.mv_ref_ct_a ); + vp8_copy( cc->mode_context_a, cm->fc.mode_context_a ); vp8_copy( cc->ymode_prob, cm->fc.ymode_prob ); vp8_copy( cc->bmode_prob, cm->fc.bmode_prob ); vp8_copy( cc->uv_mode_prob, cm->fc.uv_mode_prob ); vp8_copy( cc->i8x8_mode_prob, cm->fc.i8x8_mode_prob ); + vp8_copy( cc->sub_mv_ref_prob, cm->fc.sub_mv_ref_prob ); + vp8_copy( cc->mbsplit_prob, cm->fc.mbsplit_prob ); // Stats #ifdef MODE_STATS @@ -201,15 +203,17 @@ void vp8_restore_coding_context(VP8_COMP *cpi) vp8_copy(cpi->mb.mvcosts_hp, cc->mvcosts_hp); #endif - vp8_copy( cm->mv_ref_ct, cc->mv_ref_ct ); - vp8_copy( cm->mode_context, cc->mode_context ); - vp8_copy( cm->mv_ref_ct_a, cc->mv_ref_ct_a ); - vp8_copy( cm->mode_context_a, cc->mode_context_a ); + vp8_copy( cm->fc.mv_ref_ct, cc->mv_ref_ct ); + vp8_copy( cm->fc.mode_context, cc->mode_context ); + vp8_copy( cm->fc.mv_ref_ct_a, cc->mv_ref_ct_a ); + vp8_copy( cm->fc.mode_context_a, cc->mode_context_a ); vp8_copy( cm->fc.ymode_prob, cc->ymode_prob); vp8_copy( cm->fc.bmode_prob, cc->bmode_prob); vp8_copy( cm->fc.i8x8_mode_prob, cc->i8x8_mode_prob); vp8_copy( cm->fc.uv_mode_prob, cc->uv_mode_prob); + vp8_copy( cm->fc.sub_mv_ref_prob, cc->sub_mv_ref_prob); + vp8_copy( cm->fc.mbsplit_prob, cc->mbsplit_prob ); // Stats #ifdef MODE_STATS @@ -271,14 +275,16 @@ void vp8_setup_key_frame(VP8_COMP *cpi) cpi->common.refresh_golden_frame = TRUE; cpi->common.refresh_alt_ref_frame = TRUE; + vp8_init_mode_contexts(&cpi->common); vpx_memcpy(&cpi->common.lfc, &cpi->common.fc, sizeof(cpi->common.fc)); vpx_memcpy(&cpi->common.lfc_a, &cpi->common.fc, sizeof(cpi->common.fc)); - vp8_init_mode_contexts(&cpi->common); - vpx_memcpy( cpi->common.vp8_mode_contexts, - cpi->common.mode_context, - sizeof(cpi->common.mode_context)); - vpx_memcpy( cpi->common.vp8_mode_contexts, + /* + vpx_memcpy( cpi->common.fc.vp8_mode_contexts, + cpi->common.fc.mode_context, + sizeof(cpi->common.fc.mode_context)); + */ + vpx_memcpy( cpi->common.fc.vp8_mode_contexts, default_vp8_mode_contexts, sizeof(default_vp8_mode_contexts)); @@ -293,18 +299,18 @@ void vp8_setup_inter_frame(VP8_COMP *cpi) vpx_memcpy( &cpi->common.fc, &cpi->common.lfc_a, sizeof(cpi->common.fc)); - vpx_memcpy( cpi->common.vp8_mode_contexts, - cpi->common.mode_context_a, - sizeof(cpi->common.vp8_mode_contexts)); + vpx_memcpy( cpi->common.fc.vp8_mode_contexts, + cpi->common.fc.mode_context_a, + sizeof(cpi->common.fc.vp8_mode_contexts)); } else { vpx_memcpy( &cpi->common.fc, &cpi->common.lfc, sizeof(cpi->common.fc)); - vpx_memcpy( cpi->common.vp8_mode_contexts, - cpi->common.mode_context, - sizeof(cpi->common.vp8_mode_contexts)); + vpx_memcpy( cpi->common.fc.vp8_mode_contexts, + cpi->common.fc.mode_context, + sizeof(cpi->common.fc.vp8_mode_contexts)); } } diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index e8ddd66d5..18b62bf59 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -2502,7 +2502,8 @@ void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffse } } -void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv) +void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, + int_mv *best_ref_mv, int_mv *second_best_ref_mv) { if (x->e_mbd.mode_info_context->mbmi.mode == SPLITMV) { @@ -2519,6 +2520,15 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv) - best_ref_mv->as_mv.row)]++; cpi->MVcount_hp[1][mv_max_hp+(x->partition_info->bmi[i].mv.as_mv.col - best_ref_mv->as_mv.col)]++; +#if CONFIG_ADAPTIVE_ENTROPY + if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) + { + cpi->MVcount_hp[0][mv_max_hp+(x->partition_info->bmi[i].second_mv.as_mv.row + - second_best_ref_mv->as_mv.row)]++; + cpi->MVcount_hp[1][mv_max_hp+(x->partition_info->bmi[i].second_mv.as_mv.col + - second_best_ref_mv->as_mv.col)]++; + } +#endif } else #endif @@ -2527,6 +2537,15 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv) - best_ref_mv->as_mv.row) >> 1)]++; cpi->MVcount[1][mv_max+((x->partition_info->bmi[i].mv.as_mv.col - best_ref_mv->as_mv.col) >> 1)]++; +#if CONFIG_ADAPTIVE_ENTROPY + if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) + { + cpi->MVcount[0][mv_max+((x->partition_info->bmi[i].second_mv.as_mv.row + - second_best_ref_mv->as_mv.row) >> 1)]++; + cpi->MVcount[1][mv_max+((x->partition_info->bmi[i].second_mv.as_mv.col + - second_best_ref_mv->as_mv.col) >> 1)]++; + } +#endif } } } @@ -2540,6 +2559,15 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv) - best_ref_mv->as_mv.row)]++; cpi->MVcount_hp[1][mv_max_hp+(x->e_mbd.mode_info_context->mbmi.mv.as_mv.col - best_ref_mv->as_mv.col)]++; +#if CONFIG_ADAPTIVE_ENTROPY + if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) + { + cpi->MVcount_hp[0][mv_max_hp+(x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row + - second_best_ref_mv->as_mv.row)]++; + cpi->MVcount_hp[1][mv_max_hp+(x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col + - second_best_ref_mv->as_mv.col)]++; + } +#endif } else #endif @@ -2548,6 +2576,15 @@ void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv) - best_ref_mv->as_mv.row) >> 1)]++; cpi->MVcount[1][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col - best_ref_mv->as_mv.col) >> 1)]++; +#if CONFIG_ADAPTIVE_ENTROPY + if (x->e_mbd.mode_info_context->mbmi.second_ref_frame) + { + cpi->MVcount[0][mv_max+((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.row + - second_best_ref_mv->as_mv.row) >> 1)]++; + cpi->MVcount[1][mv_max+((x->e_mbd.mode_info_context->mbmi.second_mv.as_mv.col + - second_best_ref_mv->as_mv.col) >> 1)]++; + } +#endif } } } @@ -2740,7 +2777,8 @@ static void vp8_estimate_ref_frame_costs(VP8_COMP *cpi, int segment_id, unsigned static void store_coding_context (MACROBLOCK *x, int mb_index, int mode_index, PARTITION_INFO *partition, - int_mv *ref_mv) + int_mv *ref_mv, + int_mv *second_ref_mv) { MACROBLOCKD *xd = &x->e_mbd; @@ -2752,6 +2790,7 @@ static void store_coding_context (MACROBLOCK *x, int mb_index, vpx_memcpy(&x->mb_context[mb_index].partition_info, partition, sizeof(PARTITION_INFO)); x->mb_context[mb_index].best_ref_mv.as_int = ref_mv->as_int; + x->mb_context[mb_index].second_best_ref_mv.as_int = second_ref_mv->as_int; //x->mb_context[mb_index].rddiv = x->rddiv; //x->mb_context[mb_index].rdmult = x->rdmult; @@ -3847,7 +3886,8 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int *best_single_rd_diff = *best_comp_rd_diff = *best_hybrid_rd_diff = 0; store_coding_context (x, mb_index, best_mode_index, &best_partition, - &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame] ); + &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame], + &frame_best_ref_mv[xd->mode_info_context->mbmi.second_ref_frame]); return; } @@ -3898,7 +3938,8 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int *best_hybrid_rd_diff = best_rd - best_hybrid_rd; store_coding_context (x, mb_index, best_mode_index, &best_partition, - &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame] ); + &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame], + &frame_best_ref_mv[xd->mode_info_context->mbmi.second_ref_frame]); } int vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x) diff --git a/vp8/encoder/rdopt.h b/vp8/encoder/rdopt.h index 0a1920a1a..5e11c8d49 100644 --- a/vp8/encoder/rdopt.h +++ b/vp8/encoder/rdopt.h @@ -35,6 +35,9 @@ extern void vp8_mv_pred extern void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffset, int near_sadidx[]); extern void vp8_init_me_luts(); extern void vp8_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv); -void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv); +extern void rd_update_mvcount(VP8_COMP *cpi, + MACROBLOCK *x, + int_mv *best_ref_mv, + int_mv *second_best_ref_mv); #endif |