From 01824d1848c1feeb727ea7dfd6522f8966133953 Mon Sep 17 00:00:00 2001 From: Scott LaVarnway Date: Mon, 5 Nov 2012 12:41:24 -0800 Subject: [PATCH] Moving MVcount to macroblock struct Change-Id: Ie22841d096f3c86694b95bd06fc3a8ce1f032a10 --- vp8/encoder/block.h | 1 + vp8/encoder/encodeframe.c | 10 +++++++++- vp8/encoder/encodemv.c | 6 ++++-- vp8/encoder/ethreading.c | 1 + vp8/encoder/onyx_int.h | 2 -- vp8/encoder/pickinter.c | 9 +++++---- vp8/encoder/rdopt.c | 8 ++++---- 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h index 1e475b83d..d5496a7e2 100644 --- a/vp8/encoder/block.h +++ b/vp8/encoder/block.h @@ -129,6 +129,7 @@ typedef struct macroblock int skip_true_count; unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; + unsigned int MVcount [2] [MVvals]; /* (row,col) MV cts this frame */ int ymode_count [VP8_YMODES]; /* intra MB type cts this frame */ int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */ diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index f99bdb3ee..6364f7d7e 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -762,7 +762,7 @@ void vp8_encode_frame(VP8_COMP *cpi) xd->mode_info_context = cm->mi; - vp8_zero(cpi->MVcount); + vp8_zero(cpi->mb.MVcount); vp8cx_frame_init_quantizer(cpi); @@ -868,6 +868,7 @@ void vp8_encode_frame(VP8_COMP *cpi) for (i = 0; i < cpi->encoding_thread_count; i++) { int mode_count; + int mv_vals; totalrate += cpi->mb_row_ei[i].totalrate; cpi->mb.skip_true_count += cpi->mb_row_ei[i].mb.skip_true_count; @@ -880,6 +881,13 @@ void vp8_encode_frame(VP8_COMP *cpi) cpi->mb.uv_mode_count[mode_count] += cpi->mb_row_ei[i].mb.uv_mode_count[mode_count]; + for(mv_vals = 0; mv_vals < MVvals; mv_vals++) + { + cpi->mb.MVcount[0][mv_vals] += + cpi->mb_row_ei[i].mb.MVcount[0][mv_vals]; + cpi->mb.MVcount[1][mv_vals] += + cpi->mb_row_ei[i].mb.MVcount[1][mv_vals]; + } /* add up counts for each thread */ sum_coef_counts(x, &cpi->mb_row_ei[i].mb); diff --git a/vp8/encoder/encodemv.c b/vp8/encoder/encodemv.c index 7d8c84dd3..0c43d0692 100644 --- a/vp8/encoder/encodemv.c +++ b/vp8/encoder/encodemv.c @@ -363,10 +363,12 @@ void vp8_write_mvprobs(VP8_COMP *cpi) active_section = 4; #endif write_component_probs( - w, &mvc[0], &vp8_default_mv_context[0], &vp8_mv_update_probs[0], cpi->MVcount[0], 0, &flags[0] + w, &mvc[0], &vp8_default_mv_context[0], &vp8_mv_update_probs[0], + cpi->mb.MVcount[0], 0, &flags[0] ); write_component_probs( - w, &mvc[1], &vp8_default_mv_context[1], &vp8_mv_update_probs[1], cpi->MVcount[1], 1, &flags[1] + w, &mvc[1], &vp8_default_mv_context[1], &vp8_mv_update_probs[1], + cpi->mb.MVcount[1], 1, &flags[1] ); if (flags[0] || flags[1]) diff --git a/vp8/encoder/ethreading.c b/vp8/encoder/ethreading.c index 1ad6dabf0..81fbe52c7 100644 --- a/vp8/encoder/ethreading.c +++ b/vp8/encoder/ethreading.c @@ -475,6 +475,7 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi, vp8_zero(mb->coef_counts); vp8_zero(x->ymode_count); mb->skip_true_count = 0; + vp8_zero(mb->MVcount); } } diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h index f38bf8942..395287dbf 100644 --- a/vp8/encoder/onyx_int.h +++ b/vp8/encoder/onyx_int.h @@ -452,8 +452,6 @@ typedef struct VP8_COMP int drop_frames_allowed; /* Are we permitted to drop frames? */ int drop_frame; /* Drop this frame? */ - unsigned int MVcount [2] [MVvals]; /* (row,col) MV cts this frame */ - vp8_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; char update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; diff --git a/vp8/encoder/pickinter.c b/vp8/encoder/pickinter.c index f894d395c..3f09a9f19 100644 --- a/vp8/encoder/pickinter.c +++ b/vp8/encoder/pickinter.c @@ -389,15 +389,16 @@ static void pick_intra_mbuv_mode(MACROBLOCK *mb) } -static void update_mvcount(VP8_COMP *cpi, MACROBLOCKD *xd, int_mv *best_ref_mv) +static void update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv) { + MACROBLOCKD *xd = &x->e_mbd; /* Split MV modes currently not supported when RD is nopt enabled, * therefore, only need to modify MVcount in NEWMV mode. */ if (xd->mode_info_context->mbmi.mode == NEWMV) { - cpi->MVcount[0][mv_max+((xd->mode_info_context->mbmi.mv.as_mv.row - + x->MVcount[0][mv_max+((xd->mode_info_context->mbmi.mv.as_mv.row - best_ref_mv->as_mv.row) >> 1)]++; - cpi->MVcount[1][mv_max+((xd->mode_info_context->mbmi.mv.as_mv.col - + x->MVcount[1][mv_max+((xd->mode_info_context->mbmi.mv.as_mv.col - best_ref_mv->as_mv.col) >> 1)]++; } } @@ -1240,7 +1241,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, != cpi->common.ref_frame_sign_bias[xd->mode_info_context->mbmi.ref_frame]) best_ref_mv.as_int = best_ref_mv_sb[!sign_bias].as_int; - update_mvcount(cpi, &x->e_mbd, &best_ref_mv); + update_mvcount(cpi, x, &best_ref_mv); } diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index 0dda2405a..7d806067f 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -1738,18 +1738,18 @@ static void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv) { if (x->partition_info->bmi[i].mode == NEW4X4) { - cpi->MVcount[0][mv_max+((x->partition_info->bmi[i].mv.as_mv.row + x->MVcount[0][mv_max+((x->partition_info->bmi[i].mv.as_mv.row - best_ref_mv->as_mv.row) >> 1)]++; - cpi->MVcount[1][mv_max+((x->partition_info->bmi[i].mv.as_mv.col + x->MVcount[1][mv_max+((x->partition_info->bmi[i].mv.as_mv.col - best_ref_mv->as_mv.col) >> 1)]++; } } } else if (x->e_mbd.mode_info_context->mbmi.mode == NEWMV) { - cpi->MVcount[0][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.row + x->MVcount[0][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.row - best_ref_mv->as_mv.row) >> 1)]++; - cpi->MVcount[1][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col + x->MVcount[1][mv_max+((x->e_mbd.mode_info_context->mbmi.mv.as_mv.col - best_ref_mv->as_mv.col) >> 1)]++; } }