return old_b - new_b - update_b;
}
-static int independent_coef_context_savings(VP8_COMP *cpi)
-{
- int savings = 0;
- int i = 0;
- do
- {
- int j = 0;
- do
- {
- int k = 0;
- unsigned int prev_coef_count_sum[MAX_ENTROPY_TOKENS] = {0};
- int prev_coef_savings[MAX_ENTROPY_TOKENS] = {0};
- /* Calculate new probabilities given the constraint that
- * they must be equal over the prev coef contexts
- */
- if (cpi->common.frame_type == KEY_FRAME)
- {
- /* Reset to default probabilities at key frames */
- sum_probs_over_prev_coef_context(default_coef_counts[i][j],
- prev_coef_count_sum);
- }
- else
- {
- sum_probs_over_prev_coef_context(cpi->coef_counts[i][j],
- prev_coef_count_sum);
- }
- do
- {
- /* at every context */
-
- /* calc probs and branch cts for this frame only */
- //vp8_prob new_p [ENTROPY_NODES];
- //unsigned int branch_ct [ENTROPY_NODES] [2];
-
- int t = 0; /* token/prob index */
-
- vp8_tree_probs_from_distribution(
- MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
- cpi->frame_coef_probs[i][j][k],
- cpi->frame_branch_ct [i][j][k],
- prev_coef_count_sum,
- 256, 1);
-
- do
- {
- const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t];
- const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
- const vp8_prob oldp = cpi->common.fc.coef_probs [i][j][k][t];
- const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
- const int s = prob_update_savings(ct, oldp, newp, upd);
-
- if (cpi->common.frame_type != KEY_FRAME ||
- (cpi->common.frame_type == KEY_FRAME && newp != oldp))
- prev_coef_savings[t] += s;
- }
- while (++t < ENTROPY_NODES);
- }
- while (++k < PREV_COEF_CONTEXTS);
- k = 0;
- do
- {
- /* We only update probabilities if we can save bits, except
- * for key frames where we have to update all probabilities
- * to get the equal probabilities across the prev coef
- * contexts.
- */
- if (prev_coef_savings[k] > 0 ||
- cpi->common.frame_type == KEY_FRAME)
- savings += prev_coef_savings[k];
- }
- while (++k < ENTROPY_NODES);
- }
- while (++j < COEF_BANDS);
- }
- while (++i < BLOCK_TYPES);
- return savings;
-}
-
static int default_coef_context_savings(VP8_COMP *cpi)
{
int savings = 0;
cm->prob_gf_coded = new_gf_alt;
}
- if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
- savings += independent_coef_context_savings(cpi);
- else
- savings += default_coef_context_savings(cpi);
-
+ savings += default_coef_context_savings(cpi);
#if CONFIG_T8X8
/* do not do this if not evena allowed */
{
int k = 0;
int prev_coef_savings[ENTROPY_NODES] = {0};
- if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
- {
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
- {
- int t; /* token/prob index */
- for (t = 0; t < ENTROPY_NODES; ++t)
- {
- const unsigned int *ct = cpi->frame_branch_ct [i][j]
- [k][t];
- const vp8_prob newp = cpi->frame_coef_probs[i][j][k][t];
- const vp8_prob oldp = cpi->common.fc.coef_probs[i][j]
- [k][t];
- const vp8_prob upd = vp8_coef_update_probs[i][j][k][t];
- prev_coef_savings[t] +=
- prob_update_savings(ct, oldp, newp, upd);
- }
- }
- k = 0;
- }
do
{
//note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here.
const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
int s = prev_coef_savings[t];
int u = 0;
- if (!(cpi->oxcf.error_resilient_mode &
- VPX_ERROR_RESILIENT_PARTITIONS))
- {
- s = prob_update_savings(
- cpi->frame_branch_ct [i][j][k][t],
- *Pold, newp, upd);
- }
+
+ s = prob_update_savings(
+ cpi->frame_branch_ct [i][j][k][t],
+ *Pold, newp, upd);
+
if (s > 0)
u = 1;
- /* Force updates on key frames if the new is different,
- * so that we can be sure we end up with equal probabilities
- * over the prev coef contexts.
- */
- if ((cpi->oxcf.error_resilient_mode &
- VPX_ERROR_RESILIENT_PARTITIONS) &&
- cpi->common.frame_type == KEY_FRAME && newp != *Pold)
- u = 1;
+
update += u;
}
while (++t < ENTROPY_NODES);
{
int k = 0;
int prev_coef_savings[ENTROPY_NODES] = {0};
- if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
- {
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
- {
- int t; /* token/prob index */
- for (t = 0; t < ENTROPY_NODES; ++t)
- {
- const unsigned int *ct = cpi->frame_branch_ct [i][j]
- [k][t];
- const vp8_prob newp = cpi->frame_coef_probs[i][j][k][t];
- const vp8_prob oldp = cpi->common.fc.coef_probs[i][j]
- [k][t];
- const vp8_prob upd = vp8_coef_update_probs[i][j][k][t];
- prev_coef_savings[t] +=
- prob_update_savings(ct, oldp, newp, upd);
- }
- }
- k = 0;
- }
+
do
{
//note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here.
const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
int s = prev_coef_savings[t];
int u = 0;
- if (!(cpi->oxcf.error_resilient_mode &
- VPX_ERROR_RESILIENT_PARTITIONS))
- {
- s = prob_update_savings(
- cpi->frame_branch_ct [i][j][k][t],
- *Pold, newp, upd);
- }
+
+ s = prob_update_savings(
+ cpi->frame_branch_ct [i][j][k][t],
+ *Pold, newp, upd);
+
if (s > 0)
u = 1;
- /* Force updates on key frames if the new is different,
- * so that we can be sure we end up with equal probabilities
- * over the prev coef contexts.
- */
- if ((cpi->oxcf.error_resilient_mode &
- VPX_ERROR_RESILIENT_PARTITIONS) &&
- cpi->common.frame_type == KEY_FRAME && newp != *Pold)
- u = 1;
+
vp8_write(w, u, upd);
#ifdef ENTROPY_STATS
++ tree_update_hist [i][j][k][t] [u];
if (xd->mode_ref_lf_delta_enabled)
{
// Do the deltas need to be updated
- int send_update = xd->mode_ref_lf_delta_update
- || cpi->oxcf.error_resilient_mode;
+ int send_update = xd->mode_ref_lf_delta_update;
vp8_write_bit(bc, send_update);
if (send_update)
Data = xd->ref_lf_deltas[i];
// Frame level data
- if (xd->ref_lf_deltas[i] != xd->last_ref_lf_deltas[i]
- || cpi->oxcf.error_resilient_mode)
+ if (xd->ref_lf_deltas[i] != xd->last_ref_lf_deltas[i])
{
xd->last_ref_lf_deltas[i] = xd->ref_lf_deltas[i];
vp8_write_bit(bc, 1);
{
Data = xd->mode_lf_deltas[i];
- if (xd->mode_lf_deltas[i] != xd->last_mode_lf_deltas[i]
- || cpi->oxcf.error_resilient_mode)
+ if (xd->mode_lf_deltas[i] != xd->last_mode_lf_deltas[i])
{
xd->last_mode_lf_deltas[i] = xd->mode_lf_deltas[i];
vp8_write_bit(bc, 1);
#endif
}
- if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
- {
- if (pc->frame_type == KEY_FRAME)
- pc->refresh_entropy_probs = 1;
- else
- pc->refresh_entropy_probs = 0;
- }
-
vp8_write_bit(bc, pc->refresh_entropy_probs);
if (pc->frame_type != KEY_FRAME)
// Define next KF group and assign bits to it
vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
find_next_key_frame(cpi, &this_frame_copy);
-
- // Special case: Error error_resilient_mode mode does not make much sense for two pass but with its current meaning but this code is designed to stop
- // outlandish behaviour if someone does set it when using two pass. It effectively disables GF groups.
- // This is temporary code till we decide what should really happen in this case.
- if (cpi->oxcf.error_resilient_mode)
- {
- cpi->twopass.gf_group_bits = cpi->twopass.kf_group_bits;
- cpi->twopass.gf_group_error_left = cpi->twopass.kf_group_error_left;
- cpi->baseline_gf_interval = cpi->twopass.frames_to_key;
- cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
- cpi->source_alt_ref_pending = FALSE;
- }
-
}
// Is this a GF / ARF (Note that a KF is always also a GF)
// Otherwise this is an ordinary frame
else
{
- // Special case: Error error_resilient_mode mode does not make much sense for two pass but with its current meaning but this code is designed to stop
- // outlandish behaviour if someone does set it when using two pass. It effectively disables GF groups.
- // This is temporary code till we decide what should really happen in this case.
- if (cpi->oxcf.error_resilient_mode)
- {
- cpi->frames_till_gf_update_due = cpi->twopass.frames_to_key;
-
- if (cpi->common.frame_type != KEY_FRAME)
- {
- // Assign bits from those allocated to the GF group
- vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
- assign_std_frame_bits(cpi, &this_frame_copy);
- }
- }
- else
- {
- // Assign bits from those allocated to the GF group
- vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
- assign_std_frame_bits(cpi, &this_frame_copy);
- }
+ // Assign bits from those allocated to the GF group
+ vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame));
+ assign_std_frame_bits(cpi, &this_frame_copy);
}
// Keep a globally available copy of this and the next frame's iiratio.
// For inter frames the current default behavior is that when
// cm->refresh_golden_frame is set we copy the old GF over to the ARF buffer
// This is purely an encoder decision at present.
- if (!cpi->oxcf.error_resilient_mode && cm->refresh_golden_frame)
+ if (cm->refresh_golden_frame)
cm->copy_buffer_to_arf = 2;
- else
- cm->copy_buffer_to_arf = 0;
cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
update_reference_frames(cm);
- if (cpi->oxcf.error_resilient_mode)
- {
- cm->refresh_entropy_probs = 0;
- }
-
// Work out the segment probabilites if segmentation is enabled and
// the map is due to be updated
if (xd->segmentation_enabled && xd->update_mb_segmentation_map)
if (cpi->gold_is_alt)
cpi->ref_frame_flags &= ~VP8_ALT_FLAG;
-
- if (!cpi->oxcf.error_resilient_mode)
- {
- if (cpi->oxcf.play_alternate && cm->refresh_alt_ref_frame && (cm->frame_type != KEY_FRAME))
- // Update the alternate reference frame stats as appropriate.
- update_alt_ref_frame_stats(cpi);
- else
- // Update the Golden frame stats as appropriate.
- update_golden_frame_stats(cpi);
- }
+ if (cpi->oxcf.play_alternate && cm->refresh_alt_ref_frame && (cm->frame_type != KEY_FRAME))
+ // Update the alternate reference frame stats as appropriate.
+ update_alt_ref_frame_stats(cpi);
+ else
+ // Update the Golden frame stats as appropriate.
+ update_golden_frame_stats(cpi);
if (cm->frame_type == KEY_FRAME)
{
cpi->source = NULL;
// Should we code an alternate reference frame
- if (cpi->oxcf.error_resilient_mode == 0 &&
- cpi->oxcf.play_alternate &&
+ if (cpi->oxcf.play_alternate &&
cpi->source_alt_ref_pending)
{
if ((cpi->source = vp8_lookahead_peek(cpi->lookahead,