Merge remote branch 'internal/upstream' into HEAD

This commit is contained in:
John Koleszar 2011-02-02 00:05:14 -05:00
commit 2d9a394503
5 changed files with 36 additions and 97 deletions

View File

@ -1283,77 +1283,41 @@ static void sum_intra_stats(VP8_COMP *cpi, MACROBLOCK *x)
int vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
{
int Error4x4, Error16x16, error_uv;
B_PREDICTION_MODE intra_bmodes[16];
int rate4x4, rate16x16, rateuv;
int dist4x4, dist16x16, distuv;
int rate = 0;
int rate4x4_tokenonly = 0;
int rate16x16_tokenonly = 0;
int rateuv_tokenonly = 0;
int i;
x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
#if !(CONFIG_REALTIME_ONLY)
if (cpi->sf.RD && cpi->compressor_speed != 2)
{
Error4x4 = vp8_rd_pick_intra4x4mby_modes(cpi, x, &rate4x4, &rate4x4_tokenonly, &dist4x4);
//save the b modes for possible later use
for (i = 0; i < 16; i++)
intra_bmodes[i] = x->e_mbd.block[i].bmi.mode;
error_uv = vp8_rd_pick_intra_mbuv_mode(cpi, x, &rateuv, &rateuv_tokenonly, &distuv);
rate += rateuv;
Error16x16 = vp8_rd_pick_intra16x16mby_mode(cpi, x, &rate16x16, &rate16x16_tokenonly, &dist16x16);
error_uv = vp8_rd_pick_intra_mbuv_mode(cpi, x, &rateuv, &rateuv_tokenonly, &distuv);
Error4x4 = vp8_rd_pick_intra4x4mby_modes(cpi, x, &rate4x4, &rate4x4_tokenonly, &dist4x4);
vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
rate += rateuv;
if (Error4x4 < Error16x16)
{
rate += rate4x4;
x->e_mbd.mode_info_context->mbmi.mode = B_PRED;
// get back the intra block modes
for (i = 0; i < 16; i++)
x->e_mbd.block[i].bmi.mode = intra_bmodes[i];
vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x);
cpi->prediction_error += Error4x4 ;
#if 0
// Experimental RD code
cpi->frame_distortion += dist4x4;
#endif
}
else
{
vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
rate += rate16x16;
#if 0
// Experimental RD code
cpi->prediction_error += Error16x16;
cpi->frame_distortion += dist16x16;
#endif
}
sum_intra_stats(cpi, x);
vp8_tokenize_mb(cpi, &x->e_mbd, t);
rate += (Error4x4 < Error16x16) ? rate4x4 : rate16x16;
}
else
#endif
{
int rate2, distortion2;
int rate2, best_distortion;
MB_PREDICTION_MODE mode, best_mode = DC_PRED;
int this_rd;
Error16x16 = INT_MAX;
vp8_pick_intra_mbuv_mode(x);
for (mode = DC_PRED; mode <= TM_PRED; mode ++)
{
int distortion2;
x->e_mbd.mode_info_context->mbmi.mode = mode;
vp8_build_intra_predictors_mby_ptr(&x->e_mbd);
distortion2 = VARIANCE_INVOKE(&cpi->rtcd.variance, get16x16prederror)(x->src.y_buffer, x->src.y_stride, x->e_mbd.predictor, 16, 0x7fffffff);
@ -1364,35 +1328,28 @@ int vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
{
Error16x16 = this_rd;
best_mode = mode;
best_distortion = distortion2;
}
}
x->e_mbd.mode_info_context->mbmi.mode = best_mode;
vp8_pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, &rate2, &distortion2);
if (distortion2 == INT_MAX)
Error4x4 = INT_MAX;
else
Error4x4 = RD_ESTIMATE(x->rdmult, x->rddiv, rate2, distortion2);
if (Error4x4 < Error16x16)
{
x->e_mbd.mode_info_context->mbmi.mode = B_PRED;
vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x);
cpi->prediction_error += Error4x4;
}
else
{
x->e_mbd.mode_info_context->mbmi.mode = best_mode;
vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
cpi->prediction_error += Error16x16;
}
vp8_pick_intra_mbuv_mode(x);
vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
sum_intra_stats(cpi, x);
vp8_tokenize_mb(cpi, &x->e_mbd, t);
Error4x4 = vp8_pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, &rate2, &best_distortion);
}
if (Error4x4 < Error16x16)
{
x->e_mbd.mode_info_context->mbmi.mode = B_PRED;
vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x);
}
else
{
vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
}
vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
sum_intra_stats(cpi, x);
vp8_tokenize_mb(cpi, &x->e_mbd, t);
return rate;
}
#ifdef SPEEDSTATS

View File

@ -347,7 +347,6 @@ typedef struct
long long last_prediction_error;
long long intra_error;
long long last_intra_error;
long long last_auto_filter_prediction_error;
#if 0
// Experimental RD code

View File

@ -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;
}

View File

@ -296,7 +296,6 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
int filt_err = 0;
int min_filter_level;
int max_filter_level;
int prediction_difference = (int)(100 * abs((int)(cpi->last_auto_filter_prediction_error - cpi->prediction_error)) / (1 + cpi->prediction_error));
int filter_step;
int filt_high = 0;
@ -478,6 +477,5 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
cpi->last_auto_filt_val = filt_best;
cpi->last_auto_filt_q = cm->base_qindex;
cpi->last_auto_filter_prediction_error = cpi->prediction_error;
cpi->frames_since_auto_filter = 0;
}

View File

@ -772,16 +772,10 @@ int vp8_rd_pick_intra16x16mby_mode(VP8_COMP *cpi,
int distortion;
int best_rd = INT_MAX;
int this_rd;
int i;
//Y Search for 16x16 intra prediction mode
for (mode = DC_PRED; mode <= TM_PRED; mode++)
{
for (i = 0; i < 16; i++)
{
vpx_memset(&x->e_mbd.block[i].bmi, 0, sizeof(B_MODE_INFO));
}
x->e_mbd.mode_info_context->mbmi.mode = mode;
vp8_build_intra_predictors_mby_ptr(&x->e_mbd);