From b18df82e1d40ac30f97e6ab22b63efe28bbfca2a Mon Sep 17 00:00:00 2001 From: Scott LaVarnway Date: Tue, 1 Feb 2011 11:26:04 -0500 Subject: [PATCH] Moved rd calculation into vp8_pick_intra4x4mby_modes Then removed unnecessary code. Change-Id: I142658815d843c9396b07881dbdd8d387c43c90e --- vp8/encoder/encodeframe.c | 7 +------ vp8/encoder/pickinter.c | 29 ++++++++++------------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index 4c23a5f..08fb6e5 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -1197,12 +1197,7 @@ int vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t) } x->e_mbd.mode_info_context->mbmi.mode = best_mode; - vp8_pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, &rate2, &best_distortion); - - if (best_distortion == INT_MAX) - Error4x4 = INT_MAX; - else - Error4x4 = RD_ESTIMATE(x->rdmult, x->rddiv, rate2, best_distortion); + Error4x4 = vp8_pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, &rate2, &best_distortion); } if (Error4x4 < Error16x16) diff --git a/vp8/encoder/pickinter.c b/vp8/encoder/pickinter.c index 2b0f575..cfaf497 100644 --- a/vp8/encoder/pickinter.c +++ b/vp8/encoder/pickinter.c @@ -168,8 +168,6 @@ static int pick_intra4x4block( B_PREDICTION_MODE *best_mode, B_PREDICTION_MODE above, B_PREDICTION_MODE left, - ENTROPY_CONTEXT *a, - ENTROPY_CONTEXT *l, int *bestrate, int *bestdistortion) @@ -179,8 +177,6 @@ static int pick_intra4x4block( int rate; int distortion; unsigned int *mode_costs; - (void) l; - (void) a; if (x->e_mbd.frame_type == KEY_FRAME) { @@ -211,6 +207,7 @@ static int pick_intra4x4block( b->bmi.mode = (B_PREDICTION_MODE)(*best_mode); vp8_encode_intra4x4block(rtcd, x, be, b, b->bmi.mode); + return best_rd; } @@ -220,17 +217,8 @@ int vp8_pick_intra4x4mby_modes(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb, int MACROBLOCKD *const xd = &mb->e_mbd; int i; int cost = mb->mbmode_cost [xd->frame_type] [B_PRED]; - int error = RD_ESTIMATE(mb->rdmult, mb->rddiv, cost, 0); // Rd estimate for the cost of the block prediction mode + int error; int distortion = 0; - ENTROPY_CONTEXT_PLANES t_above, t_left; - ENTROPY_CONTEXT *ta; - ENTROPY_CONTEXT *tl; - - vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES)); - vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES)); - - ta = (ENTROPY_CONTEXT *)&t_above; - tl = (ENTROPY_CONTEXT *)&t_left; vp8_intra_prediction_down_copy(xd); @@ -243,10 +231,8 @@ int vp8_pick_intra4x4mby_modes(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb, int B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode); int UNINITIALIZED_IS_SAFE(r), UNINITIALIZED_IS_SAFE(d); - error += pick_intra4x4block(rtcd, - mb, mb->block + i, xd->block + i, &best_mode, A, L, - ta + vp8_block2above[i], - tl + vp8_block2left[i], &r, &d); + pick_intra4x4block(rtcd, mb, mb->block + i, xd->block + i, + &best_mode, A, L, &r, &d); cost += r; distortion += d; @@ -264,10 +250,15 @@ int vp8_pick_intra4x4mby_modes(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb, int *Rate = cost; if (i == 16) + { *best_dist = distortion; + error = RD_ESTIMATE(mb->rdmult, mb->rddiv, cost, distortion); + } else + { *best_dist = INT_MAX; - + error = INT_MAX; + } return error; } -- 2.7.4