Commit a2ebd0f3 authored by John Koleszar's avatar John Koleszar
Browse files

Merge remote branch 'origin/master' into experimental

parents 3a778de7 9a6740af
......@@ -804,7 +804,8 @@ void vp8_set_speed_features(VP8_COMP *cpi)
sf->thresh_mult[THR_SPLITA ] = 50000;
}
// Only do recode loop on key frames and golden frames
// Only do recode loop on key frames, golden frames and
// alt ref frames
sf->recode_loop = 2;
sf->full_freq[0] = 31;
......@@ -3435,6 +3436,37 @@ void write_cx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame)
#endif
// return of 0 means drop frame
// Function to test for conditions that indeicate we should loop
// back and recode a frame.
static BOOL recode_loop_test( VP8_COMP *cpi,
int high_limit, int low_limit,
int q, int maxq, int minq )
{
BOOL force_recode = FALSE;
VP8_COMMON *cm = &cpi->common;
// Is frame recode allowed at all
// Yes if either recode mode 1 is selected or mode two is selcted
// and the frame is a key frame. golden frame or alt_ref_frame
if ( (cpi->sf.recode_loop == 1) ||
( (cpi->sf.recode_loop == 2) &&
( (cm->frame_type == KEY_FRAME) ||
cm->refresh_golden_frame ||
cm->refresh_alt_ref_frame ) ) )
{
// General over and under shoot tests
if ( ((cpi->projected_frame_size > high_limit) && (q < maxq)) ||
((cpi->projected_frame_size < low_limit) && (q > minq)) )
{
force_recode = TRUE;
}
// Specific rate control mode related tests
// TBD
}
return force_recode;
}
static void encode_frame_to_data_rate
(
VP8_COMP *cpi,
......@@ -4029,19 +4061,18 @@ static void encode_frame_to_data_rate
#if !(CONFIG_REALTIME_ONLY)
// Is the projected frame size out of range and are we allowed to attempt to recode.
if (((cpi->sf.recode_loop == 1) ||
((cpi->sf.recode_loop == 2) && (cm->refresh_golden_frame || (cm->frame_type == KEY_FRAME)))) &&
(((cpi->projected_frame_size > frame_over_shoot_limit) && (Q < top_index)) ||
//((cpi->projected_frame_size > frame_over_shoot_limit ) && (Q == top_index) && (cpi->zbin_over_quant < ZBIN_OQ_MAX)) ||
((cpi->projected_frame_size < frame_under_shoot_limit) && (Q > bottom_index)))
)
if ( recode_loop_test( cpi,
frame_over_shoot_limit, frame_under_shoot_limit,
Q, top_index, bottom_index ) )
{
int last_q = Q;
int Retries = 0;
// Frame size out of permitted range:
// Update correction factor & compute new Q to try...
if (cpi->projected_frame_size > frame_over_shoot_limit)
// Frame is too large
if (cpi->projected_frame_size > cpi->this_frame_target)
{
//if ( cpi->zbin_over_quant == 0 )
q_low = (Q < q_high) ? (Q + 1) : q_high; // Raise Qlow as to at least the current value
......@@ -4085,6 +4116,7 @@ static void encode_frame_to_data_rate
overshoot_seen = TRUE;
}
// Frame is too small
else
{
if (cpi->zbin_over_quant == 0)
......
......@@ -477,67 +477,6 @@ int vp8_mbuverror_c(MACROBLOCK *mb)
return error;
}
#if !(CONFIG_REALTIME_ONLY)
static int macro_block_max_error(MACROBLOCK *mb)
{
int error = 0;
int dc = 0;
BLOCK *be;
int i, j;
int berror;
dc = !(mb->e_mbd.mode_info_context->mbmi.mode == B_PRED || mb->e_mbd.mode_info_context->mbmi.mode == SPLITMV);
for (i = 0; i < 16; i++)
{
be = &mb->block[i];
berror = 0;
for (j = dc; j < 16; j++)
{
int this_diff = be->coeff[j];
berror += this_diff * this_diff;
}
error += berror;
}
for (i = 16; i < 24; i++)
{
be = &mb->block[i];
berror = 0;
for (j = 0; j < 16; j++)
{
int this_diff = be->coeff[j];
berror += this_diff * this_diff;
}
error += berror;
}
error <<= 2;
if (dc)
{
be = &mb->block[24];
berror = 0;
for (j = 0; j < 16; j++)
{
int this_diff = be->coeff[j];
berror += this_diff * this_diff;
}
error += berror;
}
error >>= 4;
return error;
}
#endif
int VP8_UVSSE(MACROBLOCK *x, const vp8_variance_rtcd_vtable_t *rtcd)
{
unsigned char *uptr, *vptr;
......@@ -610,11 +549,10 @@ static int cost_coeffs(MACROBLOCK *mb, BLOCKD *b, int type, ENTROPY_CONTEXT *a,
return cost;
}
int vp8_rdcost_mby(MACROBLOCK *mb)
static int vp8_rdcost_mby(MACROBLOCK *mb)
{
int cost = 0;
int b;
int type = 0;
MACROBLOCKD *x = &mb->e_mbd;
ENTROPY_CONTEXT_PLANES t_above, t_left;
ENTROPY_CONTEXT *ta;
......@@ -626,16 +564,12 @@ int vp8_rdcost_mby(MACROBLOCK *mb)
ta = (ENTROPY_CONTEXT *)&t_above;
tl = (ENTROPY_CONTEXT *)&t_left;
if (x->mode_info_context->mbmi.mode == SPLITMV)
type = 3;
for (b = 0; b < 16; b++)
cost += cost_coeffs(mb, x->block + b, type,
cost += cost_coeffs(mb, x->block + b, 0,
ta + vp8_block2above[b], tl + vp8_block2left[b]);
if (x->mode_info_context->mbmi.mode != SPLITMV)
cost += cost_coeffs(mb, x->block + 24, 1,
ta + vp8_block2above[24], tl + vp8_block2left[24]);
cost += cost_coeffs(mb, x->block + 24, 1,
ta + vp8_block2above[24], tl + vp8_block2left[24]);
return cost;
}
......@@ -1062,10 +996,7 @@ static void macro_block_yrd(MACROBLOCK *mb, int *Rate, int *Distortion, const vp
}
// 2nd order fdct
if (x->mode_info_context->mbmi.mode != SPLITMV)
{
mb->short_walsh4x4(mb_y2->src_diff, mb_y2->coeff, 8);
}
mb->short_walsh4x4(mb_y2->src_diff, mb_y2->coeff, 8);
// Quantization
for (b = 0; b < 16; b++)
......@@ -1074,22 +1005,11 @@ static void macro_block_yrd(MACROBLOCK *mb, int *Rate, int *Distortion, const vp
}
// DC predication and Quantization of 2nd Order block
if (x->mode_info_context->mbmi.mode != SPLITMV)
{
{
mb->quantize_b(mb_y2, x_y2);
}
}
mb->quantize_b(mb_y2, x_y2);
// Distortion
if (x->mode_info_context->mbmi.mode == SPLITMV)
d = ENCODEMB_INVOKE(rtcd, mberr)(mb, 0) << 2;
else
{
d = ENCODEMB_INVOKE(rtcd, mberr)(mb, 1) << 2;
d += ENCODEMB_INVOKE(rtcd, berr)(mb_y2->coeff, x_y2->dqcoeff);
}
d = ENCODEMB_INVOKE(rtcd, mberr)(mb, 1) << 2;
d += ENCODEMB_INVOKE(rtcd, berr)(mb_y2->coeff, x_y2->dqcoeff);
*Distortion = (d >> 4);
......@@ -2016,40 +1936,6 @@ int vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
#endif
}
#if 0
else
{
int rateuseskip;
int ratenotuseskip;
int maxdistortion;
int minrate;
int skip_rd;
// distortion when no coeff is encoded
maxdistortion = macro_block_max_error(x);
ratenotuseskip = rate_y + rate_uv + vp8_cost_bit(cpi->prob_skip_false, 0);
rateuseskip = vp8_cost_bit(cpi->prob_skip_false, 1);
minrate = rateuseskip - ratenotuseskip;
skip_rd = RDFUNC(x->rdmult, x->rddiv, minrate, maxdistortion - distortion2, cpi->target_bits_per_mb);
if (skip_rd + 50 < 0 && x->e_mbd.mbmi.ref_frame != INTRA_FRAME && rate_y + rate_uv < 4000)
{
force_no_skip = 1;
rate2 = rate2 + rateuseskip - ratenotuseskip;
distortion2 = maxdistortion;
}
else
{
force_no_skip = 0;
}
}
#endif
}
// Calculate the final RD estimate for this mode
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment